How to use openstack method in tempest

Best Python code snippet using tempest_python

os_image_info.py

Source:os_image_info.py Github

copy

Full Screen

1#!/usr/bin/python2# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.3# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)4from __future__ import absolute_import, division, print_function5__metaclass__ = type6ANSIBLE_METADATA = {'metadata_version': '1.1',7 'status': ['preview'],8 'supported_by': 'community'}9DOCUMENTATION = '''10module: os_image_info11short_description: Retrieve information about an image within OpenStack.12version_added: "2.0"13author: "Davide Agnello (@dagnello)"14description:15 - Retrieve information about a image image from OpenStack.16 - This module was called C(os_image_facts) before Ansible 2.9, returning C(ansible_facts).17 Note that the M(os_image_info) module no longer returns C(ansible_facts)!18requirements:19 - "python >= 2.7"20 - "openstacksdk"21options:22 image:23 description:24 - Name or ID of the image25 required: false26 properties:27 description:28 - Dict of properties of the images used for query29 type: dict30 required: false31 version_added: '2.9'32 availability_zone:33 description:34 - Ignored. Present for backwards compatibility35 required: false36extends_documentation_fragment: openstack37'''38EXAMPLES = '''39- name: Gather information about a previously created image named image140 os_image_info:41 auth:42 auth_url: https://identity.example.com43 username: user44 password: password45 project_name: someproject46 image: image147 register: result48- name: Show openstack information49 debug:50 msg: "{{ result.openstack_image }}"51# Show all available Openstack images52- name: Retrieve all available Openstack images53 os_image_info:54 register: result55- name: Show images56 debug:57 msg: "{{ result.openstack_image }}"58# Show images matching requested properties59- name: Retrieve images having properties with desired values60 os_image_facts:61 properties:62 some_property: some_value63 OtherProp: OtherVal64- name: Show images65 debug:66 msg: "{{ result.openstack_image }}"67'''68RETURN = '''69openstack_image:70 description: has all the openstack information about the image71 returned: always, but can be null72 type: complex73 contains:74 id:75 description: Unique UUID.76 returned: success77 type: str78 name:79 description: Name given to the image.80 returned: success81 type: str82 status:83 description: Image status.84 returned: success85 type: str86 created_at:87 description: Image created at timestamp.88 returned: success89 type: str90 deleted:91 description: Image deleted flag.92 returned: success93 type: bool94 container_format:95 description: Container format of the image.96 returned: success97 type: str98 min_ram:99 description: Min amount of RAM required for this image.100 returned: success101 type: int102 disk_format:103 description: Disk format of the image.104 returned: success105 type: str106 updated_at:107 description: Image updated at timestamp.108 returned: success109 type: str110 properties:111 description: Additional properties associated with the image.112 returned: success113 type: dict114 min_disk:115 description: Min amount of disk space required for this image.116 returned: success117 type: int118 protected:119 description: Image protected flag.120 returned: success121 type: bool122 checksum:123 description: Checksum for the image.124 returned: success125 type: str126 owner:127 description: Owner for the image.128 returned: success129 type: str130 is_public:131 description: Is public flag of the image.132 returned: success133 type: bool134 deleted_at:135 description: Image deleted at timestamp.136 returned: success137 type: str138 size:139 description: Size of the image.140 returned: success141 type: int142'''143from ansible.module_utils.basic import AnsibleModule144from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module145def main():146 argument_spec = openstack_full_argument_spec(147 image=dict(required=False),148 properties=dict(default=None, type='dict'),149 )150 module_kwargs = openstack_module_kwargs()151 module = AnsibleModule(argument_spec, **module_kwargs)152 is_old_facts = module._name == 'os_image_facts'153 if is_old_facts:154 module.deprecate("The 'os_image_facts' module has been renamed to 'os_image_info', "155 "and the renamed one no longer returns ansible_facts", version='2.13')156 sdk, cloud = openstack_cloud_from_module(module)157 try:158 if module.params['image']:159 image = cloud.get_image(module.params['image'])160 if is_old_facts:161 module.exit_json(changed=False, ansible_facts=dict(162 openstack_image=image))163 else:164 module.exit_json(changed=False, openstack_image=image)165 else:166 images = cloud.search_images(filters=module.params['properties'])167 if is_old_facts:168 module.exit_json(changed=False, ansible_facts=dict(169 openstack_image=images))170 else:171 module.exit_json(changed=False, openstack_image=images)172 except sdk.exceptions.OpenStackCloudException as e:173 module.fail_json(msg=str(e))174if __name__ == '__main__':...

Full Screen

Full Screen

BUILD

Source:BUILD Github

copy

Full Screen

1package(default_visibility = ["//visibility:public"])2load(3 "@io_bazel_rules_go//go:def.bzl",4 "go_library",5 "go_test",6)7go_library(8 name = "go_default_library",9 srcs = [10 "metadata.go",11 "openstack.go",12 "openstack_client.go",13 "openstack_instances.go",14 "openstack_loadbalancer.go",15 "openstack_metrics.go",16 "openstack_routes.go",17 "openstack_volumes.go",18 ],19 importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/openstack",20 deps = [21 "//pkg/api/v1/service:go_default_library",22 "//pkg/apis/core/v1/helper:go_default_library",23 "//pkg/cloudprovider:go_default_library",24 "//pkg/controller:go_default_library",25 "//pkg/kubelet/apis:go_default_library",26 "//pkg/util/mount:go_default_library",27 "//pkg/volume:go_default_library",28 "//pkg/volume/util:go_default_library",29 "//vendor/github.com/golang/glog:go_default_library",30 "//vendor/github.com/gophercloud/gophercloud:go_default_library",31 "//vendor/github.com/gophercloud/gophercloud/openstack:go_default_library",32 "//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions:go_default_library",33 "//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes:go_default_library",34 "//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes:go_default_library",35 "//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes:go_default_library",36 "//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces:go_default_library",37 "//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach:go_default_library",38 "//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers:go_default_library",39 "//vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts:go_default_library",40 "//vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens:go_default_library",41 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions:go_default_library",42 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external:go_default_library",43 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips:go_default_library",44 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers:go_default_library",45 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners:go_default_library",46 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers:go_default_library",47 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/monitors:go_default_library",48 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/pools:go_default_library",49 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups:go_default_library",50 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules:go_default_library",51 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks:go_default_library",52 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports:go_default_library",53 "//vendor/github.com/gophercloud/gophercloud/pagination:go_default_library",54 "//vendor/github.com/mitchellh/mapstructure:go_default_library",55 "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",56 "//vendor/gopkg.in/gcfg.v1:go_default_library",57 "//vendor/k8s.io/api/core/v1:go_default_library",58 "//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",59 "//vendor/k8s.io/apimachinery/pkg/types:go_default_library",60 "//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",61 "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",62 "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",63 "//vendor/k8s.io/client-go/util/cert:go_default_library",64 "//vendor/k8s.io/utils/exec:go_default_library",65 ],66)67go_test(68 name = "go_default_test",69 srcs = [70 "metadata_test.go",71 "openstack_routes_test.go",72 "openstack_test.go",73 ],74 embed = [":go_default_library"],75 deps = [76 "//pkg/cloudprovider:go_default_library",77 "//vendor/github.com/gophercloud/gophercloud:go_default_library",78 "//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers:go_default_library",79 "//vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers:go_default_library",80 "//vendor/k8s.io/api/core/v1:go_default_library",81 "//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",82 "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",83 "//vendor/k8s.io/apimachinery/pkg/types:go_default_library",84 "//vendor/k8s.io/apimachinery/pkg/util/rand:go_default_library",85 "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",86 ],87)88filegroup(89 name = "package-srcs",90 srcs = glob(["**"]),91 tags = ["automanaged"],92 visibility = ["//visibility:private"],93)94filegroup(95 name = "all-srcs",96 srcs = [":package-srcs"],97 tags = ["automanaged"],...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful