diff --git a/.zuul.yaml b/.zuul.yaml index cc2f0ed6e..3e85fb999 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -11,7 +11,9 @@ required-projects: - openstack/shade - openstack/keystoneauth - - openstack/openstacksdk + # stable/train is needed for py27 support + - name: openstack/openstacksdk + override-checkout: stable/train - openstack/os-client-config - job: @@ -31,14 +33,21 @@ - openstack/os-client-config - project-template: - name: shade-tox-tips + name: shade-tox-tips-py27 check: jobs: - shade-tox-py27-tips - - shade-tox-py35-tips gate: jobs: - shade-tox-py27-tips + +- project-template: + name: shade-tox-tips + check: + jobs: + - shade-tox-py35-tips + gate: + jobs: - shade-tox-py35-tips - job: @@ -113,6 +122,7 @@ description: | Run shade functional tests against a master devstack vars: + python_version: 2.7 devstack_localrc: Q_SERVICE_PLUGIN_CLASSES: qos Q_ML2_PLUGIN_EXT_DRIVERS: qos,port_security @@ -137,15 +147,21 @@ - name: openstack/openstacksdk - name: openstack/os-client-config vars: + python_version: 2.7 tox_install_siblings: true - job: name: shade-functional-devstack-tips-python3 - parent: shade-functional-devstack-tips + parent: shade-functional-devstack description: | Run shade functional tests with tips of library dependencies using python3 against a master devstack. + required-projects: + - name: openstack/keystoneauth + - name: openstack/openstacksdk + - name: openstack/os-client-config vars: + tox_install_siblings: true tox_environment: SHADE_TOX_PYTHON: python3 @@ -204,14 +220,21 @@ tox_install_siblings: true - project-template: - name: shade-functional-tips + name: shade-functional-tips-py27 check: jobs: - shade-functional-devstack-tips - - shade-functional-devstack-tips-python3 gate: jobs: - shade-functional-devstack-tips + +- project-template: + name: shade-functional-tips + check: + jobs: + - shade-functional-devstack-tips-python3 + gate: + jobs: - shade-functional-devstack-tips-python3 - project: @@ -224,7 +247,9 @@ - publish-to-pypi - release-notes-jobs-python3 - shade-functional-tips + - shade-functional-tips-py27 - shade-tox-tips + - shade-tox-tips-py27 check: jobs: - bifrost-integration-tinyipa: diff --git a/shade/_heat/template_format.py b/shade/_heat/template_format.py index 4bb6098dc..4286fcfb0 100644 --- a/shade/_heat/template_format.py +++ b/shade/_heat/template_format.py @@ -28,6 +28,8 @@ def _construct_yaml_str(self, node): # Override the default string handling function # to always return unicode objects return self.construct_scalar(node) + + yaml_loader.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/shade/_utils.py b/shade/_utils.py index 9cf566d67..dc229268c 100644 --- a/shade/_utils.py +++ b/shade/_utils.py @@ -619,7 +619,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/shade/exc.py b/shade/exc.py index 0091f838c..5d0917b96 100644 --- a/shade/exc.py +++ b/shade/exc.py @@ -84,6 +84,7 @@ class OpenStackCloudBadRequest(OpenStackCloudHTTPError): class OpenStackCloudURINotFound(OpenStackCloudHTTPError): pass + # Backwards compat OpenStackCloudResourceNotFound = OpenStackCloudURINotFound diff --git a/shade/meta.py b/shade/meta.py index 3c531ab11..9dfd56480 100644 --- a/shade/meta.py +++ b/shade/meta.py @@ -395,10 +395,10 @@ def _get_supplemental_addresses(cloud, server): 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 search/list lets the logic work regardless for fip in cloud.search_floating_ips( filters=dict(port_id=port['id'])): - # This SHOULD return one and only one FIP - but doing - # it as a search/list lets the logic work regardless if fip['fixed_ip_address'] not in fixed_ip_mapping: log = _log.setup_logging('shade') log.debug( diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 591b40af6..0c98e0bd2 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -3152,10 +3152,10 @@ class OpenStackCloud( return "" def _get_server_console_output(self, server_id, length=None): - data = self._compute_client.post( - '/servers/{server_id}/action'.format(server_id=server_id), - json={'os-getConsoleOutput': {'length': length}}) - return self._get_and_munchify('output', data) + data = self._compute_client.post( + '/servers/{server_id}/action'.format(server_id=server_id), + json={'os-getConsoleOutput': {'length': length}}) + return self._get_and_munchify('output', data) def get_server( self, name_or_id=None, filters=None, detailed=False, bare=False, @@ -9305,7 +9305,7 @@ class OpenStackCloud( "before setting provide state"): machine = self.get_machine(machine['uuid']) if (machine['reservation'] is None and - machine['provision_state'] is not 'enroll'): + 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/shade/tests/fakes.py b/shade/tests/fakes.py index 76abc6281..82a9e0ab9 100644 --- a/shade/tests/fakes.py +++ b/shade/tests/fakes.py @@ -33,7 +33,7 @@ ORCHESTRATION_ENDPOINT = 'https://orchestration.example.com/v1/{p}'.format( p=PROJECT_ID) NO_MD5 = '93b885adfe0da089cdf634904fd59f71' NO_SHA256 = '6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d' -FAKE_PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkF3MX59OrlBs3dH5CU7lNmvpbrgZxSpyGjlnE8Flkirnc/Up22lpjznoxqeoTAwTW034k7Dz6aYIrZGmQwe2TkE084yqvlj45Dkyoj95fW/sZacm0cZNuL69EObEGHdprfGJQajrpz22NQoCD8TFB8Wv+8om9NH9Le6s+WPe98WC77KLw8qgfQsbIey+JawPWl4O67ZdL5xrypuRjfIPWjgy/VH85IXg/Z/GONZ2nxHgSShMkwqSFECAC5L3PHB+0+/12M/iikdatFSVGjpuHvkLOs3oe7m6HlOfluSJ85BzLWBbvva93qkGmLg4ZAc8rPh2O+YIsBUHNLLMM/oQp Generated-by-Nova\n" # flake8: noqa +FAKE_PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkF3MX59OrlBs3dH5CU7lNmvpbrgZxSpyGjlnE8Flkirnc/Up22lpjznoxqeoTAwTW034k7Dz6aYIrZGmQwe2TkE084yqvlj45Dkyoj95fW/sZacm0cZNuL69EObEGHdprfGJQajrpz22NQoCD8TFB8Wv+8om9NH9Le6s+WPe98WC77KLw8qgfQsbIey+JawPWl4O67ZdL5xrypuRjfIPWjgy/VH85IXg/Z/GONZ2nxHgSShMkwqSFECAC5L3PHB+0+/12M/iikdatFSVGjpuHvkLOs3oe7m6HlOfluSJ85BzLWBbvva93qkGmLg4ZAc8rPh2O+YIsBUHNLLMM/oQp Generated-by-Nova\n" # noqa def make_fake_flavor(flavor_id, name, ram=100, disk=1600, vcpus=24): @@ -58,6 +58,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) @@ -248,11 +250,12 @@ def make_fake_machine(machine_name, machine_id=None): id=machine_id, name=machine_name)) + def make_fake_port(address, node_id=None, port_id=None): if not node_id: - node_id = uuid.uuid4().hex + node_id = uuid.uuid4().hex if not port_id: - port_id = uuid.uuid4().hex + port_id = uuid.uuid4().hex return meta.obj_to_munch(FakeMachinePort( id=port_id, address=address, @@ -377,6 +380,7 @@ class FakeMachinePort(object): self.address = address self.node_uuid = node_id + def make_fake_neutron_security_group( id, name, description, rules, project_id=None): if not rules: diff --git a/shade/tests/unit/test_meta.py b/shade/tests/unit/test_meta.py index 16ea63215..707a96d74 100644 --- a/shade/tests/unit/test_meta.py +++ b/shade/tests/unit/test_meta.py @@ -75,6 +75,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/tox.ini b/tox.ini index 9d32cd75f..e0b310f52 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ skip_install = True deps = -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt} doc8 - hacking + hacking>=2.0,<3 pygments commands = doc8 doc/source @@ -97,7 +97,7 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen # H4 Are about docstrings - and there's just too many of them to fix # W503 Is supposed to be off by default but a bug has it on by default. It's # also a categorially terrible idea and Donald Knuth agrees with me. -ignore = H103,H306,H4,W503 +ignore = H103,H306,H4,W503,W504 show-source = True builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build