diff --git a/examples/connect.py b/examples/connect.py index d5cce1c09..fe6ebd026 100644 --- a/examples/connect.py +++ b/examples/connect.py @@ -45,6 +45,7 @@ class Opts(object): def _get_resource_value(resource_key, default): return config.get_extra_config('example').get(resource_key, default) + SERVER_NAME = 'openstacksdk-example' IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk') FLAVOR_NAME = _get_resource_value('flavor_name', 'm1.small') diff --git a/openstack/_adapter.py b/openstack/_adapter.py index 7f5da392b..18b4e7dd9 100644 --- a/openstack/_adapter.py +++ b/openstack/_adapter.py @@ -22,7 +22,6 @@ except ImportError: JSONDecodeError = ValueError from six.moves import urllib - from keystoneauth1 import adapter from openstack import exceptions diff --git a/openstack/baremetal/v1/node.py b/openstack/baremetal/v1/node.py index d8a5bc18a..4b6a655ae 100644 --- a/openstack/baremetal/v1/node.py +++ b/openstack/baremetal/v1/node.py @@ -239,16 +239,16 @@ class Node(resource.Resource): self._body.clean(only={'provision_state'}) super(Node, self).create(session, *args, **kwargs) - if (self.provision_state == 'enroll' and - expected_provision_state != 'enroll'): + if (self.provision_state == 'enroll' + and expected_provision_state != 'enroll'): self.set_provision_state(session, 'manage', wait=True) - if (self.provision_state == 'manageable' and - expected_provision_state == 'available'): + if (self.provision_state == 'manageable' + and expected_provision_state == 'available'): self.set_provision_state(session, 'provide', wait=True) - if (self.provision_state == 'available' and - expected_provision_state == 'manageable'): + if (self.provision_state == 'available' + and expected_provision_state == 'manageable'): self.set_provision_state(session, 'manage', wait=True) return self @@ -422,9 +422,9 @@ class Node(resource.Resource): a failure state is reached. """ # NOTE(dtantsur): microversion 1.2 changed None to available - if (self.provision_state == expected_state or - (expected_state == 'available' and - self.provision_state is None)): + if (self.provision_state == expected_state + or (expected_state == 'available' + and self.provision_state is None)): return True elif not abort_on_failed_state: return False @@ -437,8 +437,8 @@ class Node(resource.Resource): 'error': self.last_error}) # Special case: a failure state for "manage" transition can be # "enroll" - elif (expected_state == 'manageable' and - self.provision_state == 'enroll' and self.last_error): + elif (expected_state == 'manageable' + and self.provision_state == 'enroll' and self.last_error): raise exceptions.SDKException( "Node %(node)s could not reach state manageable: " "failed to verify management credentials; " diff --git a/openstack/block_storage/v2/_proxy.py b/openstack/block_storage/v2/_proxy.py index ece8b2609..3a5dc461f 100644 --- a/openstack/block_storage/v2/_proxy.py +++ b/openstack/block_storage/v2/_proxy.py @@ -41,7 +41,7 @@ class Proxy(proxy.Proxy): objects will be returned. The default, ``True``, will cause :class:`~openstack.block_storage.v2.snapshot.SnapshotDetail` objects to be returned. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the snapshots being returned. Available parameters include: * name: Name of the snapshot as a string. @@ -150,7 +150,7 @@ class Proxy(proxy.Proxy): will be returned. The default, ``True``, will cause :class:`~openstack.block_storage.v2.volume.VolumeDetail` objects to be returned. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the volumes being returned. Available parameters include: * name: Name of the volume as a string. diff --git a/openstack/cloud/_heat/template_format.py b/openstack/cloud/_heat/template_format.py index cf37ee528..9b95ef24e 100644 --- a/openstack/cloud/_heat/template_format.py +++ b/openstack/cloud/_heat/template_format.py @@ -27,6 +27,8 @@ def _construct_yaml_str(self, node): # Override the default string handling function # to always return unicode objects return self.construct_scalar(node) + + HeatYamlLoader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str) # Unquoted dates like 2013-05-23 in yaml files get loaded as objects of type # datetime.data which causes problems in API layer when being processed by diff --git a/openstack/cloud/_heat/template_utils.py b/openstack/cloud/_heat/template_utils.py index c56b76ea5..1e1d3fa18 100644 --- a/openstack/cloud/_heat/template_utils.py +++ b/openstack/cloud/_heat/template_utils.py @@ -79,8 +79,8 @@ def resolve_template_get_files(template, files, template_base_url, return True if not isinstance(value, six.string_types): return True - if (key == 'type' and - not value.endswith(('.yaml', '.template'))): + if (key == 'type' + and not value.endswith(('.yaml', '.template'))): return True return False diff --git a/openstack/cloud/_utils.py b/openstack/cloud/_utils.py index 1f139f48a..10a8f1ac7 100644 --- a/openstack/cloud/_utils.py +++ b/openstack/cloud/_utils.py @@ -113,8 +113,8 @@ def _filter_list(data, name_or_id, filters): e_id = _make_unicode(e.get('id', None)) e_name = _make_unicode(e.get('name', None)) - if ((e_id and e_id == name_or_id) or - (e_name and e_name == name_or_id)): + if ((e_id and e_id == name_or_id) + or (e_name and e_name == name_or_id)): identifier_matches.append(e) else: # Only try fnmatch if we don't match exactly @@ -123,8 +123,8 @@ def _filter_list(data, name_or_id, filters): # so that we log the bad pattern bad_pattern = True continue - if ((e_id and fn_reg.match(e_id)) or - (e_name and fn_reg.match(e_name))): + if ((e_id and fn_reg.match(e_id)) + or (e_name and fn_reg.match(e_name))): identifier_matches.append(e) if not identifier_matches and bad_pattern: log.debug("Bad pattern passed to fnmatch", exc_info=True) @@ -187,8 +187,8 @@ def _get_entity(cloud, resource, name_or_id, filters, **kwargs): # an additional call, it's simple enough to test to see if we got an # object and just short-circuit return it. - if (hasattr(name_or_id, 'id') or - (isinstance(name_or_id, dict) and 'id' in name_or_id)): + if (hasattr(name_or_id, 'id') + or (isinstance(name_or_id, dict) and 'id' in name_or_id)): return name_or_id # If a uuid is passed short-circuit it calling the @@ -528,8 +528,8 @@ def _call_client_and_retry(client, url, retry_on=None, try: ret_val = client(url, **kwargs) except exc.OpenStackCloudHTTPError as e: - if (retry_on is not None and - e.response.status_code in retry_on): + if (retry_on is not None + and e.response.status_code in retry_on): log.debug('Received retryable error {err}, waiting ' '{wait} seconds to retry', { 'err': e.response.status_code, @@ -570,7 +570,7 @@ def parse_range(value): if value is None: return None - range_exp = re.match('(<|>|<=|>=){0,1}(\d+)$', value) + range_exp = re.match(r'(<|>|<=|>=){0,1}(\d+)$', value) if range_exp is None: return None diff --git a/openstack/cloud/meta.py b/openstack/cloud/meta.py index 8c13d0ec7..1312d00d9 100644 --- a/openstack/cloud/meta.py +++ b/openstack/cloud/meta.py @@ -404,8 +404,9 @@ def _get_supplemental_addresses(cloud, server): try: # Don't bother doing this before the server is active, it's a waste # of an API call while polling for a server to come up - if (cloud.has_service('network') and cloud._has_floating_ips() and - server['status'] == 'ACTIVE'): + if (cloud.has_service('network') + and cloud._has_floating_ips() + and server['status'] == 'ACTIVE'): for port in cloud.search_ports( filters=dict(device_id=server['id'])): # This SHOULD return one and only one FIP - but doing it as a diff --git a/openstack/cloud/openstackcloud.py b/openstack/cloud/openstackcloud.py index f267b99ab..12bf74f55 100755 --- a/openstack/cloud/openstackcloud.py +++ b/openstack/cloud/openstackcloud.py @@ -1377,8 +1377,8 @@ class _OpenStackCloudMixin(_normalize.Normalizer): """ flavors = self.list_flavors(get_extra=get_extra) for flavor in sorted(flavors, key=operator.itemgetter('ram')): - if (flavor['ram'] >= ram and - (not include or include in flavor['name'])): + if (flavor['ram'] >= ram + and (not include or include in flavor['name'])): return flavor raise exc.OpenStackCloudException( "Could not find a flavor with {ram} and '{include}'".format( @@ -2402,38 +2402,38 @@ class _OpenStackCloudMixin(_normalize.Normalizer): or network['id'] in self._external_ipv4_names): external_ipv4_networks.append(network) elif ((('router:external' in network - and network['router:external']) or - network.get('provider:physical_network')) and - network['name'] not in self._internal_ipv4_names and - network['id'] not in self._internal_ipv4_names): + and network['router:external']) + or network.get('provider:physical_network')) + and network['name'] not in self._internal_ipv4_names + and network['id'] not in self._internal_ipv4_names): external_ipv4_networks.append(network) # Internal networks if (network['name'] in self._internal_ipv4_names or network['id'] in self._internal_ipv4_names): internal_ipv4_networks.append(network) - elif (not network.get('router:external', False) and - not network.get('provider:physical_network') and - network['name'] not in self._external_ipv4_names and - network['id'] not in self._external_ipv4_names): + elif (not network.get('router:external', False) + and not network.get('provider:physical_network') + and network['name'] not in self._external_ipv4_names + and network['id'] not in self._external_ipv4_names): internal_ipv4_networks.append(network) # External networks if (network['name'] in self._external_ipv6_names or network['id'] in self._external_ipv6_names): external_ipv6_networks.append(network) - elif (network.get('router:external') and - network['name'] not in self._internal_ipv6_names and - network['id'] not in self._internal_ipv6_names): + elif (network.get('router:external') + and network['name'] not in self._internal_ipv6_names + and network['id'] not in self._internal_ipv6_names): external_ipv6_networks.append(network) # Internal networks if (network['name'] in self._internal_ipv6_names or network['id'] in self._internal_ipv6_names): internal_ipv6_networks.append(network) - elif (not network.get('router:external', False) and - network['name'] not in self._external_ipv6_names and - network['id'] not in self._external_ipv6_names): + elif (not network.get('router:external', False) + and network['name'] not in self._external_ipv6_names + and network['id'] not in self._external_ipv6_names): internal_ipv6_networks.append(network) # External Floating IPv4 networks @@ -2612,8 +2612,8 @@ class _OpenStackCloudMixin(_normalize.Normalizer): """ self._find_interesting_networks() return list( - set(self._external_ipv4_networks) | - set(self._external_ipv6_networks)) + set(self._external_ipv4_networks) + | set(self._external_ipv6_networks)) def get_internal_networks(self): """Return the networks that are configured to not route northbound. @@ -2625,8 +2625,8 @@ class _OpenStackCloudMixin(_normalize.Normalizer): """ self._find_interesting_networks() return list( - set(self._internal_ipv4_networks) | - set(self._internal_ipv6_networks)) + set(self._internal_ipv4_networks) + | set(self._internal_ipv6_networks)) def get_external_ipv4_networks(self): """Return the networks that are configured to route northbound. @@ -9744,8 +9744,8 @@ class _OpenStackCloudMixin(_normalize.Normalizer): "Timeout waiting for reservation to clear " "before setting provide state"): machine = self.get_machine(machine['uuid']) - if (machine['reservation'] is None and - machine['provision_state'] is not 'enroll'): + if (machine['reservation'] is None + and machine['provision_state'] != 'enroll'): # NOTE(TheJulia): In this case, the node has # has moved on from the previous state and is # likely not being verified, as no lock is diff --git a/openstack/clustering/v1/_proxy.py b/openstack/clustering/v1/_proxy.py index e78d68bdf..c6cc8db5f 100644 --- a/openstack/clustering/v1/_proxy.py +++ b/openstack/clustering/v1/_proxy.py @@ -134,7 +134,7 @@ class Proxy(proxy.Proxy): def profiles(self, **query): """Retrieve a generator of profiles. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the profiles to be returned. Available parameters include: * name: The name of a profile. @@ -247,7 +247,7 @@ class Proxy(proxy.Proxy): def clusters(self, **query): """Retrieve a generator of clusters. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the clusters to be returned. Available parameters include: * name: The name of a cluster. @@ -302,7 +302,7 @@ class Proxy(proxy.Proxy): :param cluster: Either the name or the ID of the cluster, or an instance of :class:`~openstack.clustering.v1.cluster.Cluster`. :param nodes: List of nodes to be removed from the cluster. - :param kwargs \*\*params: Optional query parameters to be sent to + :param kwargs params: Optional query parameters to be sent to restrict the nodes to be returned. Available parameters include: * destroy_after_deletion: A boolean value indicating whether the @@ -364,7 +364,7 @@ class Proxy(proxy.Proxy): :param cluster: Either the name or the ID of the cluster, or an instance of :class:`~openstack.clustering.v1.cluster.Cluster`. - :param dict \*\*params: A dictionary providing the parameters for the + :param dict params: A dictionary providing the parameters for the resize action. :returns: A dict containing the action initiated by this operation. """ @@ -380,7 +380,7 @@ class Proxy(proxy.Proxy): :param cluster: Either the name or the ID of the cluster, or an instance of :class:`~openstack.clustering.v1.cluster.Cluster`. :param policy: Either the name or the ID of a policy. - :param dict \*\*params: A dictionary containing the properties for the + :param dict params: A dictionary containing the properties for the policy to be attached. :returns: A dict containing the action initiated by this operation. """ @@ -410,7 +410,7 @@ class Proxy(proxy.Proxy): :param cluster: Either the name or the ID of the cluster, or an instance of :class:`~openstack.clustering.v1.cluster.Cluster`. :param policy: Either the name or the ID of a policy. - :param dict \*\*params: A dictionary containing the new properties for + :param dict params: A dictionary containing the new properties for the policy. :returns: A dict containing the action initiated by this operation. """ @@ -544,7 +544,7 @@ class Proxy(proxy.Proxy): def nodes(self, **query): """Retrieve a generator of nodes. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the nodes to be returned. Available parameters include: * cluster_id: A string including the name or ID of a cluster to @@ -708,7 +708,7 @@ class Proxy(proxy.Proxy): def policies(self, **query): """Retrieve a generator of policies. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the policies to be returned. Available parameters include: * name: The name of a policy. @@ -760,7 +760,7 @@ class Proxy(proxy.Proxy): :param cluster: The value can be the name or ID of a cluster or a :class:`~openstack.clustering.v1.cluster.Cluster` instance. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the policies to be returned. Available parameters include: * enabled: A boolean value indicating whether the policy is @@ -858,7 +858,7 @@ class Proxy(proxy.Proxy): def receivers(self, **query): """Retrieve a generator of receivers. - :param kwargs \*\*query: Optional query parameters for restricting the + :param kwargs query: Optional query parameters for restricting the receivers to be returned. Available parameters include: * name: The name of a receiver object. @@ -891,7 +891,7 @@ class Proxy(proxy.Proxy): def actions(self, **query): """Retrieve a generator of actions. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the actions to be returned. Available parameters include: * name: name of action for query. @@ -929,7 +929,7 @@ class Proxy(proxy.Proxy): def events(self, **query): """Retrieve a generator of events. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the events to be returned. Available parameters include: * obj_name: name string of the object associated with an event. diff --git a/openstack/compute/v2/_proxy.py b/openstack/compute/v2/_proxy.py index b0a14ede8..ce57489fa 100644 --- a/openstack/compute/v2/_proxy.py +++ b/openstack/compute/v2/_proxy.py @@ -112,7 +112,7 @@ class Proxy(proxy.Proxy): :class:`~openstack.compute.v2.flavor.FlavorDetail` objects, otherwise :class:`~openstack.compute.v2.flavor.Flavor`. *Default: ``True``* - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the flavors being returned. :returns: A generator of flavor objects @@ -168,7 +168,7 @@ class Proxy(proxy.Proxy): :class:`~openstack.compute.v2.image.ImageDetail` objects, otherwise :class:`~openstack.compute.v2.image.Image`. *Default: ``True``* - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of image objects @@ -379,7 +379,7 @@ class Proxy(proxy.Proxy): will be returned. The default, ``True``, will cause :class:`~openstack.compute.v2.server.ServerDetail` instances to be returned. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the servers being returned. Available parameters include: * changes_since: A time/date stamp for when the server last changed @@ -1077,7 +1077,7 @@ class Proxy(proxy.Proxy): def server_groups(self, **query): """Return a generator of server groups - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of ServerGroup objects diff --git a/openstack/config/loader.py b/openstack/config/loader.py index d38cc4bf6..030fc029b 100644 --- a/openstack/config/loader.py +++ b/openstack/config/loader.py @@ -919,9 +919,9 @@ class OpenStackConfig(object): def option_prompt(self, config, p_opt): """Prompt user for option that requires a value""" if ( - getattr(p_opt, 'prompt', None) is not None and - p_opt.dest not in config['auth'] and - self._pw_callback is not None + getattr(p_opt, 'prompt', None) is not None + and p_opt.dest not in config['auth'] + and self._pw_callback is not None ): config['auth'][p_opt.dest] = self._pw_callback(p_opt.prompt) return config @@ -948,9 +948,9 @@ class OpenStackConfig(object): """Perform the set of magic argument fixups""" # Infer token plugin if a token was given - if (('auth' in config and 'token' in config['auth']) or - ('auth_token' in config and config['auth_token']) or - ('token' in config and config['token'])): + if (('auth' in config and 'token' in config['auth']) + or ('auth_token' in config and config['auth_token']) + or ('token' in config and config['token'])): config.setdefault('token', config.pop('auth_token', None)) # These backwards compat values are only set via argparse. If it's diff --git a/openstack/database/v1/_proxy.py b/openstack/database/v1/_proxy.py index 826e19297..a21804da6 100644 --- a/openstack/database/v1/_proxy.py +++ b/openstack/database/v1/_proxy.py @@ -81,7 +81,7 @@ class Proxy(proxy.Proxy): :param instance: This can be either the ID of an instance or a :class:`~openstack.database.v1.instance.Instance` instance that the interface belongs to. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of database objects @@ -137,7 +137,7 @@ class Proxy(proxy.Proxy): def flavors(self, **query): """Return a generator of flavors - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of flavor objects @@ -203,7 +203,7 @@ class Proxy(proxy.Proxy): def instances(self, **query): """Return a generator of instances - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of instance objects @@ -283,7 +283,7 @@ class Proxy(proxy.Proxy): :param instance: This can be either the ID of an instance or a :class:`~openstack.database.v1.instance.Instance` - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of user objects diff --git a/openstack/exceptions.py b/openstack/exceptions.py index 8dbe70e85..fdbe11d2d 100644 --- a/openstack/exceptions.py +++ b/openstack/exceptions.py @@ -29,6 +29,8 @@ class SDKException(Exception): self.message = self.__class__.__name__ if message is None else message self.extra_data = extra_data super(SDKException, self).__init__(self.message) + + OpenStackCloudException = SDKException diff --git a/openstack/identity/v2/_proxy.py b/openstack/identity/v2/_proxy.py index 5c2175355..97560c12e 100644 --- a/openstack/identity/v2/_proxy.py +++ b/openstack/identity/v2/_proxy.py @@ -96,7 +96,7 @@ class Proxy(proxy.Proxy): def roles(self, **query): """Retrieve a generator of roles - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of role instances. @@ -173,7 +173,7 @@ class Proxy(proxy.Proxy): def tenants(self, **query): """Retrieve a generator of tenants - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of tenant instances. @@ -250,7 +250,7 @@ class Proxy(proxy.Proxy): def users(self, **query): """Retrieve a generator of users - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of user instances. diff --git a/openstack/identity/v3/_proxy.py b/openstack/identity/v3/_proxy.py index ae0e3012d..50472fd8b 100644 --- a/openstack/identity/v3/_proxy.py +++ b/openstack/identity/v3/_proxy.py @@ -96,7 +96,7 @@ class Proxy(proxy.Proxy): def credentials(self, **query): """Retrieve a generator of credentials - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of credentials instances. @@ -174,7 +174,7 @@ class Proxy(proxy.Proxy): def domains(self, **query): """Retrieve a generator of domains - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of domain instances. @@ -254,7 +254,7 @@ class Proxy(proxy.Proxy): def endpoints(self, **query): """Retrieve a generator of endpoints - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of endpoint instances. @@ -334,7 +334,7 @@ class Proxy(proxy.Proxy): def groups(self, **query): """Retrieve a generator of groups - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of group instances. @@ -412,7 +412,7 @@ class Proxy(proxy.Proxy): def policies(self, **query): """Retrieve a generator of policies - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of policy instances. @@ -490,7 +490,7 @@ class Proxy(proxy.Proxy): def projects(self, **query): """Retrieve a generator of projects - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of project instances. @@ -505,7 +505,7 @@ class Proxy(proxy.Proxy): :param user: Either the user id or an instance of :class:`~openstack.identity.v3.user.User` - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of project instances. @@ -584,7 +584,7 @@ class Proxy(proxy.Proxy): def services(self, **query): """Retrieve a generator of services - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of service instances. @@ -662,7 +662,7 @@ class Proxy(proxy.Proxy): def users(self, **query): """Retrieve a generator of users - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of user instances. @@ -740,7 +740,7 @@ class Proxy(proxy.Proxy): def trusts(self, **query): """Retrieve a generator of trusts - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of trust instances. @@ -805,7 +805,7 @@ class Proxy(proxy.Proxy): def regions(self, **query): """Retrieve a generator of regions - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the regions being returned. :returns: A generator of region instances. @@ -883,7 +883,7 @@ class Proxy(proxy.Proxy): def roles(self, **query): """Retrieve a generator of roles - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. The options are: domain_id, name. :return: A generator of role instances. @@ -964,7 +964,7 @@ class Proxy(proxy.Proxy): def role_assignments(self, **query): """Retrieve a generator of role assignments - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. The options are: group_id, role_id, scope_domain_id, scope_project_id, user_id, include_names, @@ -978,7 +978,7 @@ class Proxy(proxy.Proxy): def registered_limits(self, **query): """Retrieve a generator of registered_limits - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the registered_limits being returned. :returns: A generator of registered_limits instances. @@ -1052,7 +1052,7 @@ class Proxy(proxy.Proxy): def limits(self, **query): """Retrieve a generator of limits - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the limits being returned. :returns: A generator of limits instances. diff --git a/openstack/image/v1/_proxy.py b/openstack/image/v1/_proxy.py index 472107b16..8e00ea851 100644 --- a/openstack/image/v1/_proxy.py +++ b/openstack/image/v1/_proxy.py @@ -72,8 +72,8 @@ class Proxy(proxy.Proxy): def images(self, **query): """Return a generator of images - :param kwargs \*\*query: Optional query parameters to be sent to limit - the resources being returned. + :param kwargs query: Optional query parameters to be sent to limit + the resources being returned. :returns: A generator of image objects :rtype: :class:`~openstack.image.v1.image.Image` diff --git a/openstack/image/v2/_proxy.py b/openstack/image/v2/_proxy.py index 3b2d65f3c..9968367c1 100644 --- a/openstack/image/v2/_proxy.py +++ b/openstack/image/v2/_proxy.py @@ -138,7 +138,7 @@ class Proxy(proxy.Proxy): def images(self, **query): """Return a generator of images - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of image objects diff --git a/openstack/instance_ha/v1/_proxy.py b/openstack/instance_ha/v1/_proxy.py index e283e33ec..2022ea980 100644 --- a/openstack/instance_ha/v1/_proxy.py +++ b/openstack/instance_ha/v1/_proxy.py @@ -29,7 +29,7 @@ class Proxy(proxy.Proxy): def notifications(self, **query): """Return a generator of notifications. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to limit the notifications being returned. :returns: A generator of notifications """ @@ -67,7 +67,7 @@ class Proxy(proxy.Proxy): def segments(self, **query): """Return a generator of segments. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to limit the segments being returned. :returns: A generator of segments """ @@ -132,7 +132,7 @@ class Proxy(proxy.Proxy): """Return a generator of hosts. :param segment_id: The ID of a failover segment. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to limit the hosts being returned. :returns: A generator of hosts diff --git a/openstack/key_manager/v1/_proxy.py b/openstack/key_manager/v1/_proxy.py index c54bafeae..3945f4caa 100644 --- a/openstack/key_manager/v1/_proxy.py +++ b/openstack/key_manager/v1/_proxy.py @@ -78,7 +78,7 @@ class Proxy(proxy.Proxy): def containers(self, **query): """Return a generator of containers - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of container objects @@ -158,7 +158,7 @@ class Proxy(proxy.Proxy): def orders(self, **query): """Return a generator of orders - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of order objects @@ -239,7 +239,7 @@ class Proxy(proxy.Proxy): def secrets(self, **query): """Return a generator of secrets - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of secret objects diff --git a/openstack/message/v2/_proxy.py b/openstack/message/v2/_proxy.py index 2d8dae961..1606235ce 100644 --- a/openstack/message/v2/_proxy.py +++ b/openstack/message/v2/_proxy.py @@ -47,7 +47,7 @@ class Proxy(proxy.Proxy): def queues(self, **query): """Retrieve a generator of queues - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the queues to be returned. Available parameters include: * limit: Requests at most the specified number of items be @@ -93,7 +93,7 @@ class Proxy(proxy.Proxy): """Retrieve a generator of messages :param queue_name: The name of target queue to query messages from. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the messages to be returned. Available parameters include: * limit: Requests at most the specified number of items be @@ -170,7 +170,7 @@ class Proxy(proxy.Proxy): """Retrieve a generator of subscriptions :param queue_name: The name of target queue to subscribe on. - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the subscriptions to be returned. Available parameters include: diff --git a/openstack/network/v2/_proxy.py b/openstack/network/v2/_proxy.py index 77cc26dde..d7d2af176 100644 --- a/openstack/network/v2/_proxy.py +++ b/openstack/network/v2/_proxy.py @@ -214,7 +214,7 @@ class Proxy(proxy.Proxy): :param agent: Either the agent id of an instance of :class:`~openstack.network.v2.network_agent.Agent` - :param query: kwargs \*\*query: Optional query parameters to be sent + :param query: kwargs query: Optional query parameters to be sent to limit the resources being returned. :return: A generator of networks """ @@ -1136,7 +1136,7 @@ class Proxy(proxy.Proxy): def networks(self, **query): """Return a generator of networks - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. Available parameters include: * ``description``: The network description. @@ -1210,7 +1210,7 @@ class Proxy(proxy.Proxy): def network_ip_availabilities(self, **query): """Return a generator of network ip availabilities - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. Available parameters include: * ``ip_version``: IP version of the network @@ -1504,7 +1504,7 @@ class Proxy(proxy.Proxy): def ports(self, **query): """Return a generator of ports - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. Available parameters include: * ``description``: The port description. @@ -1647,7 +1647,7 @@ class Proxy(proxy.Proxy): :param qos_policy: The value can be the ID of the QoS policy that the rule belongs or a :class:`~openstack.network.v2. qos_policy.QoSPolicy` instance. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of bandwidth limit rule objects :rtype: :class:`~openstack.network.v2.qos_bandwidth_limit_rule. @@ -1770,7 +1770,7 @@ class Proxy(proxy.Proxy): :param qos_policy: The value can be the ID of the QoS policy that the rule belongs or a :class:`~openstack.network.v2. qos_policy.QoSPolicy` instance. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of QoS DSCP marking rule objects :rtype: :class:`~openstack.network.v2.qos_dscp_marking_rule. @@ -1893,7 +1893,7 @@ class Proxy(proxy.Proxy): :param qos_policy: The value can be the ID of the QoS policy that the rule belongs or a :class:`~openstack.network.v2. qos_policy.QoSPolicy` instance. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of minimum bandwidth rule objects :rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. @@ -2385,7 +2385,7 @@ class Proxy(proxy.Proxy): :param router: Either the router id or an instance of :class:`~openstack.network.v2.router.Router` - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources returned :returns: A generator of Router L3 Agents @@ -2400,7 +2400,7 @@ class Proxy(proxy.Proxy): :param agent: Either the agent id of an instance of :class:`~openstack.network.v2.network_agent.Agent` - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources returned :returns: A generator of routers @@ -2939,7 +2939,7 @@ class Proxy(proxy.Proxy): def security_group_rules(self, **query): """Return a generator of security group rules - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. Available parameters include: * ``description``: The security group rule description @@ -3019,7 +3019,7 @@ class Proxy(proxy.Proxy): def segments(self, **query): """Return a generator of segments - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. Available parameters include: * ``description``: The segment description @@ -3051,7 +3051,7 @@ class Proxy(proxy.Proxy): def service_providers(self, **query): """Return a generator of service providers - :param kwargs \*\* query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of service provider objects @@ -3308,7 +3308,7 @@ class Proxy(proxy.Proxy): def subnet_pools(self, **query): """Return a generator of subnet pools - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. Available parameters include: * ``address_scope_id``: Subnet pool address scope ID diff --git a/openstack/object_store/v1/_proxy.py b/openstack/object_store/v1/_proxy.py index fef003eb5..629a5f733 100644 --- a/openstack/object_store/v1/_proxy.py +++ b/openstack/object_store/v1/_proxy.py @@ -150,7 +150,7 @@ class Proxy(proxy.Proxy): that you want to retrieve objects from. :type container: :class:`~openstack.object_store.v1.container.Container` - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :rtype: A generator of diff --git a/openstack/orchestration/v1/_proxy.py b/openstack/orchestration/v1/_proxy.py index ccf9790fc..4378353e1 100644 --- a/openstack/orchestration/v1/_proxy.py +++ b/openstack/orchestration/v1/_proxy.py @@ -59,7 +59,7 @@ class Proxy(proxy.Proxy): def stacks(self, **query): """Return a generator of stacks - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of stack objects @@ -84,7 +84,7 @@ class Proxy(proxy.Proxy): :param stack: The value can be the ID of a stack or a :class:`~openstack.orchestration.v1.stack.Stack` instance. - :param kwargs \*\*attrs: The attributes to update on the stack + :param kwargs attrs: The attributes to update on the stack represented by ``value``. :returns: The updated stack @@ -191,7 +191,7 @@ class Proxy(proxy.Proxy): :param stack: This can be a stack object, or the name of a stack for which the resources are to be listed. - :param kwargs \*\*query: Optional query parameters to be sent to limit + :param kwargs query: Optional query parameters to be sent to limit the resources being returned. :returns: A generator of resource objects if the stack exists and diff --git a/openstack/task_manager.py b/openstack/task_manager.py index 37c5ed1ee..8d2bec8a5 100644 --- a/openstack/task_manager.py +++ b/openstack/task_manager.py @@ -90,7 +90,7 @@ class Task(object): # Retry one time if we get a retriable connection failure try: self.done(self.main()) - except keystoneauth1.exceptions.RetriableConnectionFailure as e: + except keystoneauth1.exceptions.RetriableConnectionFailure: self.done(self.main()) except Exception as e: self.exception(e, sys.exc_info()[2]) diff --git a/openstack/tests/fakes.py b/openstack/tests/fakes.py index a8e8f7f1d..08d07568a 100644 --- a/openstack/tests/fakes.py +++ b/openstack/tests/fakes.py @@ -64,6 +64,8 @@ def make_fake_flavor(flavor_id, name, ram=100, disk=1600, vcpus=24): u'swap': u'', u'vcpus': vcpus } + + FAKE_FLAVOR = make_fake_flavor(FLAVOR_ID, 'vanilla') FAKE_CHOCOLATE_FLAVOR = make_fake_flavor( CHOCOLATE_FLAVOR_ID, 'chocolate', ram=200) diff --git a/openstack/tests/functional/base.py b/openstack/tests/functional/base.py index b6f38c3f5..215673499 100644 --- a/openstack/tests/functional/base.py +++ b/openstack/tests/functional/base.py @@ -38,6 +38,7 @@ def _disable_keep_alive(conn): sess = conn.config.get_session() sess.keep_alive = False + IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk') FLAVOR_NAME = _get_resource_value('flavor_name', 'm1.small') @@ -129,10 +130,12 @@ class BaseFunctionalTest(base.TestCase): if not min_microversion: return - if not (data.min_microversion and data.max_microversion and - discover.version_between(data.min_microversion, - data.max_microversion, - min_microversion)): + if not (data.min_microversion + and data.max_microversion + and discover.version_between( + data.min_microversion, + data.max_microversion, + min_microversion)): self.skipTest('Service {service_type} does not provide ' 'microversion {ver}'.format( service_type=service_type, diff --git a/openstack/tests/unit/cloud/test_meta.py b/openstack/tests/unit/cloud/test_meta.py index f7e82894f..f6100d939 100644 --- a/openstack/tests/unit/cloud/test_meta.py +++ b/openstack/tests/unit/cloud/test_meta.py @@ -79,6 +79,7 @@ class FakeCloud(object): def get_default_network(self): return None + standard_fake_server = fakes.make_fake_server( server_id='test-id-0', name='test-id-0', diff --git a/openstack/tests/unit/test_exceptions.py b/openstack/tests/unit/test_exceptions.py index 63b15b91e..fad45d145 100644 --- a/openstack/tests/unit/test_exceptions.py +++ b/openstack/tests/unit/test_exceptions.py @@ -22,8 +22,8 @@ from openstack import exceptions class Test_Exception(base.TestCase): def test_method_not_supported(self): exc = exceptions.MethodNotSupported(self.__class__, 'list') - expected = ('The list method is not supported for ' + - 'openstack.tests.unit.test_exceptions.Test_Exception') + expected = ('The list method is not supported for ' + + 'openstack.tests.unit.test_exceptions.Test_Exception') self.assertEqual(expected, str(exc)) diff --git a/openstack/workflow/v2/_proxy.py b/openstack/workflow/v2/_proxy.py index 0e4a51333..f2b9f0c53 100644 --- a/openstack/workflow/v2/_proxy.py +++ b/openstack/workflow/v2/_proxy.py @@ -44,7 +44,7 @@ class Proxy(proxy.Proxy): def workflows(self, **query): """Retrieve a generator of workflows - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the workflows to be returned. Available parameters include: @@ -120,7 +120,7 @@ class Proxy(proxy.Proxy): def executions(self, **query): """Retrieve a generator of executions - :param kwargs \*\*query: Optional query parameters to be sent to + :param kwargs query: Optional query parameters to be sent to restrict the executions to be returned. Available parameters include: diff --git a/tox.ini b/tox.ini index 676f6f34d..6670d2938 100644 --- a/tox.ini +++ b/tox.ini @@ -40,6 +40,7 @@ skip_install = True deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} doc8 + flake8 hacking pygments readme