diff options
| -rw-r--r-- | cloudinit/net/network_state.py | 2 | ||||
| -rwxr-xr-x | cloudinit/reporting/handlers.py | 12 | ||||
| -rwxr-xr-x | cloudinit/sources/helpers/azure.py | 6 | ||||
| -rw-r--r-- | tests/unittests/test_datasource/test_aliyun.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_datasource/test_azure.py | 8 | ||||
| -rw-r--r-- | tests/unittests/test_datasource/test_ec2.py | 15 | ||||
| -rw-r--r-- | tests/unittests/test_datasource/test_scaleway.py | 39 | ||||
| -rw-r--r-- | tests/unittests/test_distros/test_netconfig.py | 4 | ||||
| -rw-r--r-- | tests/unittests/test_ds_identify.py | 4 | ||||
| -rw-r--r-- | tests/unittests/test_handler/test_handler_puppet.py | 23 | ||||
| -rw-r--r-- | tests/unittests/test_net.py | 18 | ||||
| -rw-r--r-- | tox.ini | 4 | 
12 files changed, 75 insertions, 62 deletions
| diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py index 35c279f9..f28973dc 100644 --- a/cloudinit/net/network_state.py +++ b/cloudinit/net/network_state.py @@ -215,7 +215,7 @@ class NetworkState(object):          return (              route.get('prefix') == 0              and route.get('network') in default_nets -            ) +        )  class NetworkStateInterpreter(metaclass=CommandHandlerMeta): diff --git a/cloudinit/reporting/handlers.py b/cloudinit/reporting/handlers.py index 946df7e0..00e8d2e5 100755 --- a/cloudinit/reporting/handlers.py +++ b/cloudinit/reporting/handlers.py @@ -219,7 +219,7 @@ class HyperVKvpReportingHandler(ReportingHandler):          v = (              record_data[                  self.HV_KVP_EXCHANGE_MAX_KEY_SIZE:self.HV_KVP_RECORD_SIZE -                ].decode('utf-8').strip('\x00')) +            ].decode('utf-8').strip('\x00'))          return {'key': k, 'value': v} @@ -265,11 +265,11 @@ class HyperVKvpReportingHandler(ReportingHandler):          """          key = self._event_key(event)          meta_data = { -                "name": event.name, -                "type": event.event_type, -                "ts": (datetime.utcfromtimestamp(event.timestamp) -                       .isoformat() + 'Z'), -                } +            "name": event.name, +            "type": event.event_type, +            "ts": (datetime.utcfromtimestamp(event.timestamp) +                   .isoformat() + 'Z'), +        }          if hasattr(event, self.RESULT_KEY):              meta_data[self.RESULT_KEY] = event.result          meta_data[self.MSG_KEY] = event.description diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py index fc760581..82b6730c 100755 --- a/cloudinit/sources/helpers/azure.py +++ b/cloudinit/sources/helpers/azure.py @@ -64,13 +64,15 @@ def is_byte_swapped(previous_id, current_id):          return ''.join(dd)      parts = current_id.split('-') -    swapped_id = '-'.join([ +    swapped_id = '-'.join( +        [              swap_bytestring(parts[0]),              swap_bytestring(parts[1]),              swap_bytestring(parts[2]),              parts[3],              parts[4] -        ]) +        ] +    )      return previous_id == swapped_id diff --git a/tests/unittests/test_datasource/test_aliyun.py b/tests/unittests/test_datasource/test_aliyun.py index 1e66fcdb..b626229e 100644 --- a/tests/unittests/test_datasource/test_aliyun.py +++ b/tests/unittests/test_datasource/test_aliyun.py @@ -143,7 +143,7 @@ class TestAliYunDatasource(test_helpers.HttprettyTestCase):          self.assertEqual('aliyun', self.ds.cloud_name)          self.assertEqual('ec2', self.ds.platform)          self.assertEqual( -           'metadata (http://100.100.100.200)', self.ds.subplatform) +            'metadata (http://100.100.100.200)', self.ds.subplatform)      @mock.patch("cloudinit.sources.DataSourceAliYun._is_aliyun")      def test_returns_false_when_not_on_aliyun(self, m_is_aliyun): diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py index 2f8561cb..d8d812e3 100644 --- a/tests/unittests/test_datasource/test_azure.py +++ b/tests/unittests/test_datasource/test_azure.py @@ -114,14 +114,14 @@ NETWORK_METADATA = {                  "ipv4": {                      "subnet": [                          { -                           "prefix": "24", -                           "address": "10.0.0.0" +                            "prefix": "24", +                            "address": "10.0.0.0"                          }                      ],                      "ipAddress": [                          { -                           "privateIpAddress": "10.0.0.4", -                           "publicIpAddress": "104.46.124.81" +                            "privateIpAddress": "10.0.0.4", +                            "publicIpAddress": "104.46.124.81"                          }                      ]                  } diff --git a/tests/unittests/test_datasource/test_ec2.py b/tests/unittests/test_datasource/test_ec2.py index ad1ea595..80e69c03 100644 --- a/tests/unittests/test_datasource/test_ec2.py +++ b/tests/unittests/test_datasource/test_ec2.py @@ -576,7 +576,8 @@ class TestEc2(test_helpers.HttprettyTestCase):              md=None)          conn_error = requests.exceptions.ConnectionError( -           '[Errno 113] no route to host') +            '[Errno 113] no route to host' +        )          mock_success = mock.MagicMock(contents=b'fakesuccess')          mock_success.ok.return_value = True @@ -777,12 +778,12 @@ class TestGetSecondaryAddresses(test_helpers.CiTestCase):               '2600:1f16:292:100:f153:12a3:c37c:11f9/128'],              ec2.get_secondary_addresses(invalid_cidr_md, self.mac))          expected_logs = [ -           "WARNING: Could not parse subnet-ipv4-cidr-block" -           " something-unexpected for mac 06:17:04:d7:26:ff." -           " ipv4 network config prefix defaults to /24", -           "WARNING: Could not parse subnet-ipv6-cidr-block" -           " not/sure/what/this/is for mac 06:17:04:d7:26:ff." -           " ipv6 network config prefix defaults to /128" +            "WARNING: Could not parse subnet-ipv4-cidr-block" +            " something-unexpected for mac 06:17:04:d7:26:ff." +            " ipv4 network config prefix defaults to /24", +            "WARNING: Could not parse subnet-ipv6-cidr-block" +            " not/sure/what/this/is for mac 06:17:04:d7:26:ff." +            " ipv6 network config prefix defaults to /128"          ]          logs = self.logs.getvalue()          for log in expected_logs: diff --git a/tests/unittests/test_datasource/test_scaleway.py b/tests/unittests/test_datasource/test_scaleway.py index 1b4dd0ad..15441454 100644 --- a/tests/unittests/test_datasource/test_scaleway.py +++ b/tests/unittests/test_datasource/test_scaleway.py @@ -371,25 +371,32 @@ class TestDataSourceScaleway(HttprettyTestCase):          m_get_cmdline.return_value = 'scaleway'          fallback_nic.return_value = 'ens2'          self.datasource.metadata['ipv6'] = { -                'address': '2000:abc:4444:9876::42:999', -                'gateway': '2000:abc:4444:9876::42:000', -                'netmask': '127', -                } +            'address': '2000:abc:4444:9876::42:999', +            'gateway': '2000:abc:4444:9876::42:000', +            'netmask': '127', +        }          netcfg = self.datasource.network_config -        resp = {'version': 1, -                'config': [{ -                     'type': 'physical', -                     'name': 'ens2', -                     'subnets': [{'type': 'dhcp4'}, -                                 {'type': 'static', -                                  'address': '2000:abc:4444:9876::42:999', -                                  'gateway': '2000:abc:4444:9876::42:000', -                                  'netmask': '127', } -                                 ] - -                     }] +        resp = { +            'version': 1, +            'config': [ +                { +                    'type': 'physical', +                    'name': 'ens2', +                    'subnets': [ +                        { +                            'type': 'dhcp4' +                        }, +                        { +                            'type': 'static', +                            'address': '2000:abc:4444:9876::42:999', +                            'gateway': '2000:abc:4444:9876::42:000', +                            'netmask': '127', +                        } +                    ]                  } +            ] +        }          self.assertEqual(netcfg, resp)      @mock.patch('cloudinit.sources.DataSourceScaleway.net.find_fallback_nic') diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py index ccf66161..910207ca 100644 --- a/tests/unittests/test_distros/test_netconfig.py +++ b/tests/unittests/test_distros/test_netconfig.py @@ -532,7 +532,7 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase):                  NETWORKING_IPV6=yes                  IPV6_AUTOCONF=no                  """), -            } +        }          # rh_distro.apply_network_config(V1_NET_CFG_IPV6, False)          self._apply_and_verify(self.distro.apply_network_config,                                 V1_NET_CFG_IPV6, @@ -656,7 +656,7 @@ class TestNetCfgDistroArch(TestNetCfgDistroBase):                  IP=dhcp                  Interface=eth1                  """), -            } +        }          # ub_distro.apply_network_config(V1_NET_CFG, False)          self._apply_and_verify(self.distro.apply_network_config, diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py index c2318570..65a96090 100644 --- a/tests/unittests/test_ds_identify.py +++ b/tests/unittests/test_ds_identify.py @@ -1040,11 +1040,11 @@ VALID_CFG = {      'Ec2-E24Cloud': {          'ds': 'Ec2',          'files': {P_SYS_VENDOR: 'e24cloud\n'}, -     }, +    },      'Ec2-E24Cloud-negative': {          'ds': 'Ec2',          'files': {P_SYS_VENDOR: 'e24cloudyday\n'}, -     } +    }  }  # vi: ts=4 expandtab diff --git a/tests/unittests/test_handler/test_handler_puppet.py b/tests/unittests/test_handler/test_handler_puppet.py index 04aa7d03..2506d18a 100644 --- a/tests/unittests/test_handler/test_handler_puppet.py +++ b/tests/unittests/test_handler/test_handler_puppet.py @@ -149,15 +149,20 @@ class TestPuppetHandle(CiTestCase):          mycloud.distro = mock.MagicMock()          cfg = {              'puppet': { -              'csr_attributes': { -                'custom_attributes': { -                  '1.2.840.113549.1.9.7': '342thbjkt82094y0ut' -                                          'hhor289jnqthpc2290'}, -                'extension_requests': { -                  'pp_uuid': 'ED803750-E3C7-44F5-BB08-41A04433FE2E', -                  'pp_image_name': 'my_ami_image', -                  'pp_preshared_key': '342thbjkt82094y0uthhor289jnqthpc2290'} -                }}} +                'csr_attributes': { +                    'custom_attributes': { +                        '1.2.840.113549.1.9.7': +                            '342thbjkt82094y0uthhor289jnqthpc2290' +                    }, +                    'extension_requests': { +                        'pp_uuid': 'ED803750-E3C7-44F5-BB08-41A04433FE2E', +                        'pp_image_name': 'my_ami_image', +                        'pp_preshared_key': +                            '342thbjkt82094y0uthhor289jnqthpc2290' +                    } +                } +            } +        }          csr_attributes = 'cloudinit.config.cc_puppet.' \                           'PUPPET_CSR_ATTRIBUTES_PATH'          with mock.patch(csr_attributes, self.csr_attributes_path): diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index 84d3a5f0..23626395 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -3332,7 +3332,7 @@ USERCTL=no                  USERCTL=no                  VLAN=yes                  """) -            } +        }          self._compare_files_to_expected(              expected, self._render_and_read(network_config=v2data)) @@ -3406,7 +3406,7 @@ USERCTL=no                  TYPE=Ethernet                  USERCTL=no                  """), -            } +        }          for dhcp_ver in ('dhcp4', 'dhcp6'):              v2data = copy.deepcopy(v2base)              if dhcp_ver == 'dhcp6': @@ -4765,13 +4765,13 @@ class TestNetRenderers(CiTestCase):      def test_sysconfig_available_uses_variant_mapping(self, m_distro, m_avail):          m_avail.return_value = True          distro_values = [ -           ('opensuse', '', ''), -           ('opensuse-leap', '', ''), -           ('opensuse-tumbleweed', '', ''), -           ('sles', '', ''), -           ('centos', '', ''), -           ('fedora', '', ''), -           ('redhat', '', ''), +            ('opensuse', '', ''), +            ('opensuse-leap', '', ''), +            ('opensuse-tumbleweed', '', ''), +            ('sles', '', ''), +            ('centos', '', ''), +            ('fedora', '', ''), +            ('redhat', '', ''),          ]          for (distro_name, distro_version, flavor) in distro_values:              m_distro.return_value = (distro_name, distro_version, flavor) @@ -43,13 +43,11 @@ basepython = python2.7  deps = -r{toxinidir}/test-requirements.txt  [flake8] -# E121: continuation line under-indented for hanging indent -# E123: closing bracket does not match indentation of opening bracket’s line  # E126: continuation line over-indented for hanging indent  # E226: missing whitespace around arithmetic operator  # W503: line break before binary operator  # W504: line break after binary operator -ignore=E121,E123,E126,E226,W503,W504 +ignore=E126,E226,W503,W504  exclude = .venv,.tox,dist,doc,*egg,.git,build,tools  per-file-ignores =      cloudinit/cmd/main.py:E402 | 
