Enable check for E127

E127 continuation line over-indented for visual indent

Change-Id: I9dfd489565ee2d1469b2048a930c3a8384dd245d
This commit is contained in:
Andrey Kurilin 2014-09-24 23:45:27 +03:00
parent 8de2237cc4
commit ae6c39397e
20 changed files with 120 additions and 144 deletions

View File

@ -32,8 +32,8 @@ class ServiceCatalog(object):
return self.catalog['access']['token']['tenant']['id'] return self.catalog['access']['token']['tenant']['id']
def url_for(self, attr=None, filter_value=None, def url_for(self, attr=None, filter_value=None,
service_type=None, endpoint_type='publicURL', service_type=None, endpoint_type='publicURL',
service_name=None, volume_service_name=None): service_name=None, volume_service_name=None):
"""Fetch the public URL from the Compute service for """Fetch the public URL from the Compute service for
a particular endpoint attribute. If none given, return a particular endpoint attribute. If none given, return
the first. See tests for sample service catalog. the first. See tests for sample service catalog.

View File

@ -765,8 +765,11 @@ class OpenStackComputeShell(object):
commands.remove('bash_completion') commands.remove('bash_completion')
print(' '.join(commands | options)) print(' '.join(commands | options))
@utils.arg('command', metavar='<subcommand>', nargs='?', @utils.arg(
help='Display help for <subcommand>') 'command',
metavar='<subcommand>',
nargs='?',
help='Display help for <subcommand>')
def do_help(self, args): def do_help(self, args):
""" """
Display help about this program or one of its subcommands. Display help about this program or one of its subcommands.

View File

@ -43,10 +43,10 @@ class FakeClient(object):
called = self.client.callstack[pos][0:2] called = self.client.callstack[pos][0:2]
assert self.client.callstack, \ assert self.client.callstack, \
"Expected %s %s but no calls were made." % expected "Expected %s %s but no calls were made." % expected
assert expected == called, 'Expected %s %s; got %s %s' % \ assert expected == called, \
(expected + called) 'Expected %s %s; got %s %s' % (expected + called)
if body is not None: if body is not None:
if self.client.callstack[pos][2] != body: if self.client.callstack[pos][2] != body:
@ -60,7 +60,7 @@ class FakeClient(object):
expected = (method, url) expected = (method, url)
assert self.client.callstack, \ assert self.client.callstack, \
"Expected %s %s but no calls were made." % expected "Expected %s %s but no calls were made." % expected
found = False found = False
for entry in self.client.callstack: for entry in self.client.callstack:
@ -68,8 +68,7 @@ class FakeClient(object):
found = True found = True
break break
assert found, 'Expected %s; got %s' % \ assert found, 'Expected %s; got %s' % (expected, self.client.callstack)
(expected, self.client.callstack)
if body is not None: if body is not None:
try: try:
assert entry[2] == body assert entry[2] == body

View File

@ -614,8 +614,8 @@ class V3(Base):
context.headers['location'] = "http://blah/images/456" context.headers['location'] = "http://blah/images/456"
if action not in set.union(set(body_is_none_list), if action not in set.union(set(body_is_none_list),
set(body_params_check_exact.keys()), set(body_params_check_exact.keys()),
set(body_param_check_exists.keys())): set(body_param_check_exists.keys())):
raise AssertionError("Unexpected server action: %s" % action) raise AssertionError("Unexpected server action: %s" % action)
return _body return _body

View File

@ -57,10 +57,9 @@ class ClientTest(utils.TestCase):
} }
with mock.patch('requests.request', mock_request): with mock.patch('requests.request', mock_request):
instance.authenticate() instance.authenticate()
requests.request.assert_called_with(mock.ANY, mock.ANY, requests.request.assert_called_with(
timeout=2, mock.ANY, mock.ANY, timeout=2, headers=mock.ANY,
headers=mock.ANY, verify=mock.ANY)
verify=mock.ANY)
def test_client_reauth(self): def test_client_reauth(self):
instance = novaclient.client.HTTPClient(user='user', instance = novaclient.client.HTTPClient(user='user',
@ -208,7 +207,7 @@ class ClientTest(utils.TestCase):
def test_client_get_reset_timings_v3(self): def test_client_get_reset_timings_v3(self):
cs = novaclient.v3.client.Client("user", "password", "project_id", cs = novaclient.v3.client.Client("user", "password", "project_id",
auth_url="foo/v2") auth_url="foo/v2")
self.assertEqual(0, len(cs.get_timings())) self.assertEqual(0, len(cs.get_timings()))
cs.client.times.append("somevalue") cs.client.times.append("somevalue")
self.assertEqual(["somevalue"], cs.get_timings()) self.assertEqual(["somevalue"], cs.get_timings())
@ -220,15 +219,13 @@ class ClientTest(utils.TestCase):
fake_attribute_name1 = "FakeAttribute1" fake_attribute_name1 = "FakeAttribute1"
fake_attribute_name2 = "FakeAttribute2" fake_attribute_name2 = "FakeAttribute2"
extensions = [ extensions = [
novaclient.extension.Extension(fake_attribute_name1, novaclient.extension.Extension(fake_attribute_name1, fakes),
fakes), novaclient.extension.Extension(fake_attribute_name2, utils),
novaclient.extension.Extension(fake_attribute_name2,
utils),
] ]
cs = novaclient.v3.client.Client("user", "password", "project_id", cs = novaclient.v3.client.Client("user", "password", "project_id",
auth_url="foo/v2", auth_url="foo/v2",
extensions=extensions) extensions=extensions)
self.assertIsInstance(getattr(cs, fake_attribute_name1, None), self.assertIsInstance(getattr(cs, fake_attribute_name1, None),
fakes.FakeManager) fakes.FakeManager)
self.assertFalse(hasattr(cs, fake_attribute_name2)) self.assertFalse(hasattr(cs, fake_attribute_name2))
@ -236,7 +233,7 @@ class ClientTest(utils.TestCase):
@mock.patch.object(novaclient.client.HTTPClient, 'authenticate') @mock.patch.object(novaclient.client.HTTPClient, 'authenticate')
def test_authenticate_call_v3(self, mock_authenticate): def test_authenticate_call_v3(self, mock_authenticate):
cs = novaclient.v3.client.Client("user", "password", "project_id", cs = novaclient.v3.client.Client("user", "password", "project_id",
auth_url="foo/v2") auth_url="foo/v2")
cs.authenticate() cs.authenticate()
self.assertTrue(mock_authenticate.called) self.assertTrue(mock_authenticate.called)
@ -245,7 +242,7 @@ class ClientTest(utils.TestCase):
fake_client = mock.Mock() fake_client = mock.Mock()
mock_http_client.return_value = fake_client mock_http_client.return_value = fake_client
with novaclient.v1_1.client.Client("user", "password", "project_id", with novaclient.v1_1.client.Client("user", "password", "project_id",
auth_url="foo/v2"): auth_url="foo/v2"):
pass pass
self.assertTrue(fake_client.open_session.called) self.assertTrue(fake_client.open_session.called)
self.assertTrue(fake_client.close_session.called) self.assertTrue(fake_client.close_session.called)
@ -255,7 +252,7 @@ class ClientTest(utils.TestCase):
fake_client = mock.Mock() fake_client = mock.Mock()
mock_http_client.return_value = fake_client mock_http_client.return_value = fake_client
with novaclient.v3.client.Client("user", "password", "project_id", with novaclient.v3.client.Client("user", "password", "project_id",
auth_url="foo/v2"): auth_url="foo/v2"):
pass pass
self.assertTrue(fake_client.open_session.called) self.assertTrue(fake_client.open_session.called)
self.assertTrue(fake_client.close_session.called) self.assertTrue(fake_client.close_session.called)

View File

@ -879,11 +879,11 @@ class FakeHTTPClient(base_client.HTTPClient):
if body.get('pool'): if body.get('pool'):
return (200, {}, {'floating_ip': return (200, {}, {'floating_ip':
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1', {'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1',
'pool': 'nova'}}) 'pool': 'nova'}})
else: else:
return (200, {}, {'floating_ip': return (200, {}, {'floating_ip':
{'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1', {'id': 1, 'fixed_ip': '10.0.0.1', 'ip': '11.0.0.1',
'pool': None}}) 'pool': None}})
def delete_os_floating_ips_1(self, **kw): def delete_os_floating_ips_1(self, **kw):
return (204, {}, None) return (204, {}, None)
@ -895,43 +895,42 @@ class FakeHTTPClient(base_client.HTTPClient):
def get_os_floating_ip_dns_testdomain_entries(self, **kw): def get_os_floating_ip_dns_testdomain_entries(self, **kw):
if kw.get('ip'): if kw.get('ip'):
return (205, {}, {'dns_entries': return (205, {}, {
[{'dns_entry': 'dns_entries': [
{'ip': kw.get('ip'), {'dns_entry': {'ip': kw.get('ip'),
'name': "host1", 'name': "host1",
'type': "A", 'type': "A",
'domain': 'testdomain'}}, 'domain': 'testdomain'}},
{'dns_entry': {'dns_entry': {'ip': kw.get('ip'),
{'ip': kw.get('ip'), 'name': "host2",
'name': "host2", 'type': "A",
'type': "A", 'domain': 'testdomain'}}]})
'domain': 'testdomain'}}]})
else: else:
return (404, {}, None) return (404, {}, None)
def get_os_floating_ip_dns_testdomain_entries_testname(self, **kw): def get_os_floating_ip_dns_testdomain_entries_testname(self, **kw):
return (205, {}, {'dns_entry': return (205, {}, {
{'ip': "10.10.10.10", 'dns_entry': {'ip': "10.10.10.10",
'name': 'testname', 'name': 'testname',
'type': "A", 'type': "A",
'domain': 'testdomain'}}) 'domain': 'testdomain'}})
def put_os_floating_ip_dns_testdomain(self, body, **kw): def put_os_floating_ip_dns_testdomain(self, body, **kw):
if body['domain_entry']['scope'] == 'private': if body['domain_entry']['scope'] == 'private':
fakes.assert_has_keys(body['domain_entry'], fakes.assert_has_keys(body['domain_entry'],
required=['availability_zone', 'scope']) required=['availability_zone', 'scope'])
elif body['domain_entry']['scope'] == 'public': elif body['domain_entry']['scope'] == 'public':
fakes.assert_has_keys(body['domain_entry'], fakes.assert_has_keys(body['domain_entry'],
required=['project', 'scope']) required=['project', 'scope'])
else: else:
fakes.assert_has_keys(body['domain_entry'], fakes.assert_has_keys(body['domain_entry'],
required=['project', 'scope']) required=['project', 'scope'])
return (205, {}, body) return (205, {}, body)
def put_os_floating_ip_dns_testdomain_entries_testname(self, body, **kw): def put_os_floating_ip_dns_testdomain_entries_testname(self, body, **kw):
fakes.assert_has_keys(body['dns_entry'], fakes.assert_has_keys(body['dns_entry'],
required=['ip', 'dns_type']) required=['ip', 'dns_type'])
return (205, {}, body) return (205, {}, body)
def delete_os_floating_ip_dns_testdomain(self, **kw): def delete_os_floating_ip_dns_testdomain(self, **kw):
@ -1271,8 +1270,7 @@ class FakeHTTPClient(base_client.HTTPClient):
return (200, {}, {"security_groups": [ return (200, {}, {"security_groups": [
{"name": "test", {"name": "test",
"description": "FAKE_SECURITY_GROUP", "description": "FAKE_SECURITY_GROUP",
"tenant_id": "tenant_id": "4ffc664c198e435e9853f2538fbcd7a7",
"4ffc664c198e435e9853f2538fbcd7a7",
"id": 1, "id": 1,
"rules": [ "rules": [
{"id": 11, {"id": 11,
@ -1330,7 +1328,7 @@ class FakeHTTPClient(base_client.HTTPClient):
fakes.assert_has_keys(body['security_group'], fakes.assert_has_keys(body['security_group'],
required=['name', 'description']) required=['name', 'description'])
r = {'security_group': r = {'security_group':
self.get_os_security_groups()[2]['security_groups'][0]} self.get_os_security_groups()[2]['security_groups'][0]}
return (202, {}, r) return (202, {}, r)
def put_os_security_groups_1(self, body, **kw): def put_os_security_groups_1(self, body, **kw):
@ -1363,12 +1361,13 @@ class FakeHTTPClient(base_client.HTTPClient):
def post_os_security_group_rules(self, body, **kw): def post_os_security_group_rules(self, body, **kw):
assert list(body) == ['security_group_rule'] assert list(body) == ['security_group_rule']
fakes.assert_has_keys(body['security_group_rule'], fakes.assert_has_keys(
body['security_group_rule'],
required=['parent_group_id'], required=['parent_group_id'],
optional=['group_id', 'ip_protocol', 'from_port', optional=['group_id', 'ip_protocol', 'from_port',
'to_port', 'cidr']) 'to_port', 'cidr'])
r = {'security_group_rule': r = {'security_group_rule':
self.get_os_security_group_rules()[2]['security_group_rules'][0]} self.get_os_security_group_rules()[2]['security_group_rules'][0]}
return (202, {}, r) return (202, {}, r)
# #
@ -2160,12 +2159,10 @@ class FakeHTTPClient(base_client.HTTPClient):
def post_os_server_groups(self, body, **kw): def post_os_server_groups(self, body, **kw):
return self._return_server_group() return self._return_server_group()
def get_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, def get_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, **kw):
**kw):
return self._return_server_group() return self._return_server_group()
def put_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, def put_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b(self, **kw):
**kw):
return self._return_server_group() return self._return_server_group()
def post_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b_action( def post_os_server_groups_2cbd51f4_fafe_4cdb_801b_cf913a6f288b_action(

View File

@ -28,5 +28,5 @@ class TestFloatingIPPools(utils.FixturedTestCase):
def test_list_floating_ips(self): def test_list_floating_ips(self):
fl = self.cs.floating_ip_pools.list() fl = self.cs.floating_ip_pools.list()
self.assert_called('GET', '/os-floating-ip-pools') self.assert_called('GET', '/os-floating-ip-pools')
[self.assertIsInstance(f, floating_ip_pools.FloatingIPPool) for f in fl:
for f in fl] self.assertIsInstance(f, floating_ip_pools.FloatingIPPool)

View File

@ -46,9 +46,9 @@ class FloatingIPsBulkTest(utils.FixturedTestCase):
def test_create_floating_ips_bulk_with_pool_and_host(self): def test_create_floating_ips_bulk_with_pool_and_host(self):
fl = self.cs.floating_ips_bulk.create('192.168.1.0/30', 'poolTest', fl = self.cs.floating_ips_bulk.create('192.168.1.0/30', 'poolTest',
'interfaceTest') 'interfaceTest')
body = {'floating_ips_bulk_create': body = {'floating_ips_bulk_create': {
{'ip_range': '192.168.1.0/30', 'pool': 'poolTest', 'ip_range': '192.168.1.0/30', 'pool': 'poolTest',
'interface': 'interfaceTest'}} 'interface': 'interfaceTest'}}
self.assert_called('POST', '/os-floating-ips-bulk', body) self.assert_called('POST', '/os-floating-ips-bulk', body)
self.assertEqual(fl.ip_range, self.assertEqual(fl.ip_range,
body['floating_ips_bulk_create']['ip_range']) body['floating_ips_bulk_create']['ip_range'])

View File

@ -800,8 +800,8 @@ class ShellTest(utils.TestCase):
) )
def test_create_image_show(self): def test_create_image_show(self):
output = self.run_command('image-create ' output = self.run_command(
'sample-server mysnapshot --show') 'image-create sample-server mysnapshot --show')
self.assert_called_anytime( self.assert_called_anytime(
'POST', '/servers/1234/action', 'POST', '/servers/1234/action',
{'createImage': {'name': 'mysnapshot', 'metadata': {}}}, {'createImage': {'name': 'mysnapshot', 'metadata': {}}},
@ -2243,10 +2243,8 @@ class ShellTest(utils.TestCase):
mock.mock_open(read_data='FAKE_PUBLIC_KEY')) mock.mock_open(read_data='FAKE_PUBLIC_KEY'))
def test_keypair_import(self): def test_keypair_import(self):
self.run_command('keypair-add --pub-key test.pub test') self.run_command('keypair-add --pub-key test.pub test')
self.assert_called('POST', '/os-keypairs', self.assert_called('POST', '/os-keypairs', {
{'keypair': 'keypair': {'public_key': 'FAKE_PUBLIC_KEY', 'name': 'test'}})
{'public_key': 'FAKE_PUBLIC_KEY',
'name': 'test'}})
def test_keypair_list(self): def test_keypair_list(self):
self.run_command('keypair-list') self.run_command('keypair-list')
@ -2263,9 +2261,8 @@ class ShellTest(utils.TestCase):
def test_create_server_group(self): def test_create_server_group(self):
self.run_command('server-group-create wjsg affinity') self.run_command('server-group-create wjsg affinity')
self.assert_called('POST', '/os-server-groups', self.assert_called('POST', '/os-server-groups',
{'server_group': {'server_group': {'name': 'wjsg',
{'name': 'wjsg', 'policies': ['affinity']}})
'policies': ['affinity']}})
def test_delete_multi_server_groups(self): def test_delete_multi_server_groups(self):
self.run_command('server-group-delete 12345 56789') self.run_command('server-group-delete 12345 56789')

View File

@ -243,9 +243,9 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient):
_headers = dict(location="http://blah/images/456") _headers = dict(location="http://blah/images/456")
if action not in set.union(set(body_is_none_list), if action not in set.union(set(body_is_none_list),
set(body_params_check_exact.keys()), set(body_params_check_exact.keys()),
set(body_param_check_exists.keys()), set(body_param_check_exists.keys()),
set(body_params_check_superset.keys())): set(body_params_check_superset.keys())):
raise AssertionError("Unexpected server action: %s" % action) raise AssertionError("Unexpected server action: %s" % action)
return (resp, _headers, _body) return (resp, _headers, _body)

View File

@ -67,4 +67,4 @@ class FlavorAccessManager(base.ManagerWithFind):
_resp, body = self.api.client.post(url, body=body) _resp, body = self.api.client.post(url, body=body)
return [self.resource_class(self, res) return [self.resource_class(self, res)
for res in body['flavor_access']] for res in body['flavor_access']]

View File

@ -56,22 +56,18 @@ class FloatingIPDNSDomainManager(base.Manager):
def create_private(self, fqdomain, availability_zone): def create_private(self, fqdomain, availability_zone):
"""Add or modify a private DNS domain.""" """Add or modify a private DNS domain."""
body = {'domain_entry': body = {'domain_entry': {'scope': 'private',
{'scope': 'private', 'availability_zone': availability_zone}}
'availability_zone': availability_zone}}
return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain), return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain),
body, body,
'domain_entry') 'domain_entry')
def create_public(self, fqdomain, project): def create_public(self, fqdomain, project):
"""Add or modify a public DNS domain.""" """Add or modify a public DNS domain."""
body = {'domain_entry': body = {'domain_entry': {'scope': 'public', 'project': project}}
{'scope': 'public',
'project': project}}
return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain), return self._update('/os-floating-ip-dns/%s' % _quote_domain(fqdomain),
body, body, 'domain_entry')
'domain_entry')
def delete(self, fqdomain): def delete(self, fqdomain):
"""Delete the specified domain.""" """Delete the specified domain."""
@ -83,8 +79,7 @@ class FloatingIPDNSEntry(base.Resource):
self.manager.delete(self.name, self.domain) self.manager.delete(self.name, self.domain)
def create(self): def create(self):
self.manager.create(self.domain, self.name, self.manager.create(self.domain, self.name, self.ip, self.dns_type)
self.ip, self.dns_type)
def get(self): def get(self):
return self.manager.get(self.domain, self.name) return self.manager.get(self.domain, self.name)
@ -96,8 +91,7 @@ class FloatingIPDNSEntryManager(base.Manager):
def get(self, domain, name): def get(self, domain, name):
"""Return a list of entries for the given domain and ip or name.""" """Return a list of entries for the given domain and ip or name."""
return self._get("/os-floating-ip-dns/%s/entries/%s" % return self._get("/os-floating-ip-dns/%s/entries/%s" %
(_quote_domain(domain), name), (_quote_domain(domain), name), "dns_entry")
"dns_entry")
def get_for_ip(self, domain, ip): def get_for_ip(self, domain, ip):
"""Return a list of entries for the given domain and ip or name.""" """Return a list of entries for the given domain and ip or name."""
@ -105,32 +99,23 @@ class FloatingIPDNSEntryManager(base.Manager):
params = "?%s" % parse.urlencode(qparams) params = "?%s" % parse.urlencode(qparams)
return self._list("/os-floating-ip-dns/%s/entries%s" % return self._list("/os-floating-ip-dns/%s/entries%s" %
(_quote_domain(domain), params), (_quote_domain(domain), params), "dns_entries")
"dns_entries")
def create(self, domain, name, ip, dns_type): def create(self, domain, name, ip, dns_type):
"""Add a new DNS entry.""" """Add a new DNS entry."""
body = {'dns_entry': body = {'dns_entry': {'ip': ip, 'dns_type': dns_type}}
{'ip': ip,
'dns_type': dns_type}}
return self._update("/os-floating-ip-dns/%s/entries/%s" % return self._update("/os-floating-ip-dns/%s/entries/%s" %
(_quote_domain(domain), name), (_quote_domain(domain), name), body, "dns_entry")
body,
"dns_entry")
def modify_ip(self, domain, name, ip): def modify_ip(self, domain, name, ip):
"""Add a new DNS entry.""" """Add a new DNS entry."""
body = {'dns_entry': body = {'dns_entry': {'ip': ip, 'dns_type': 'A'}}
{'ip': ip,
'dns_type': 'A'}}
return self._update("/os-floating-ip-dns/%s/entries/%s" % return self._update("/os-floating-ip-dns/%s/entries/%s" %
(_quote_domain(domain), name), (_quote_domain(domain), name), body, "dns_entry")
body,
"dns_entry")
def delete(self, domain, name): def delete(self, domain, name):
"""Delete entry specified by name and domain.""" """Delete entry specified by name and domain."""
self._delete("/os-floating-ip-dns/%s/entries/%s" % self._delete("/os-floating-ip-dns/%s/entries/%s" %
(_quote_domain(domain), name)) (_quote_domain(domain), name))

View File

@ -87,8 +87,8 @@ class ImageManager(base.ManagerWithFind):
:param metadata: A dict of metadata to add to the image :param metadata: A dict of metadata to add to the image
""" """
body = {'metadata': metadata} body = {'metadata': metadata}
return self._create("/images/%s/metadata" % base.getid(image), body, return self._create("/images/%s/metadata" % base.getid(image),
"metadata") body, "metadata")
def delete_meta(self, image, keys): def delete_meta(self, image, keys):
""" """

View File

@ -1086,7 +1086,7 @@ class ServerManager(base.BootingManagerWithFind):
""" """
body = {'metadata': metadata} body = {'metadata': metadata}
return self._create("/servers/%s/metadata" % base.getid(server), return self._create("/servers/%s/metadata" % base.getid(server),
body, "metadata") body, "metadata")
def set_meta_item(self, server, key, value): def set_meta_item(self, server, key, value):
""" """

View File

@ -2367,8 +2367,8 @@ def _print_secgroups(secgroups):
def _get_secgroup(cs, secgroup): def _get_secgroup(cs, secgroup):
# Check secgroup is an ID (nova-network) or UUID (neutron) # Check secgroup is an ID (nova-network) or UUID (neutron)
if (utils.is_integer_like(encodeutils.safe_encode(secgroup)) if (utils.is_integer_like(encodeutils.safe_encode(secgroup)) or
or uuidutils.is_uuid_like(secgroup)): uuidutils.is_uuid_like(secgroup)):
try: try:
return cs.security_groups.get(secgroup) return cs.security_groups.get(secgroup)
except exceptions.NotFound: except exceptions.NotFound:
@ -2377,9 +2377,8 @@ def _get_secgroup(cs, secgroup):
# Check secgroup as a name # Check secgroup as a name
match_found = False match_found = False
for s in cs.security_groups.list(): for s in cs.security_groups.list():
encoding = (locale.getpreferredencoding() or encoding = (
sys.stdin.encoding or locale.getpreferredencoding() or sys.stdin.encoding or 'UTF-8')
'UTF-8')
if not six.PY3: if not six.PY3:
s.name = s.name.encode(encoding) s.name = s.name.encode(encoding)
if secgroup == s.name: if secgroup == s.name:
@ -3379,8 +3378,8 @@ def do_ssh(cs, args):
match = lambda addr: all(( match = lambda addr: all((
addr.get('version') == version, addr.get('version') == version,
addr.get('OS-EXT-IPS:type', 'floating') == address_type)) addr.get('OS-EXT-IPS:type', 'floating') == address_type))
matching_addresses = [address.get('addr') for address in network_addresses matching_addresses = [address.get('addr')
if match(address)] for address in network_addresses if match(address)]
if not any(matching_addresses): if not any(matching_addresses):
msg = _("No address that would match network '%(network)s'" msg = _("No address that would match network '%(network)s'"
" and type '%(address_type)s' of version %(pretty_version)s " " and type '%(address_type)s' of version %(pretty_version)s "
@ -3568,8 +3567,8 @@ def do_quota_defaults(cs, args):
dest='force', dest='force',
action="store_true", action="store_true",
default=None, default=None,
help=_('Whether force update the quota even if the already used' help=_('Whether force update the quota even if the already used and '
' and reserved exceeds the new quota')) 'reserved exceeds the new quota'))
def do_quota_update(cs, args): def do_quota_update(cs, args):
"""Update the quotas for a tenant/user.""" """Update the quotas for a tenant/user."""
@ -3902,7 +3901,7 @@ def do_secgroup_delete_default_rule(cs, args):
default=argparse.SUPPRESS, default=argparse.SUPPRESS,
nargs='*', nargs='*',
help='Policies for the server groups ' help='Policies for the server groups '
'("affinity" or "anti-affinity")') '("affinity" or "anti-affinity")')
@utils.arg('--policy', @utils.arg('--policy',
default=[], default=[],
action='append', action='append',

View File

@ -42,8 +42,8 @@ class SnapshotManager(base.ManagerWithFind):
""" """
resource_class = Snapshot resource_class = Snapshot
def create(self, volume_id, force=False, def create(self, volume_id, force=False, display_name=None,
display_name=None, display_description=None): display_description=None):
""" """
Create a snapshot of the given volume. Create a snapshot of the given volume.

View File

@ -45,10 +45,9 @@ class VolumeManager(base.ManagerWithFind):
""" """
resource_class = Volume resource_class = Volume
def create(self, size, snapshot_id=None, def create(self, size, snapshot_id=None, display_name=None,
display_name=None, display_description=None, display_description=None, volume_type=None,
volume_type=None, availability_zone=None, availability_zone=None, imageRef=None):
imageRef=None):
""" """
Create a volume. Create a volume.
@ -62,12 +61,12 @@ class VolumeManager(base.ManagerWithFind):
:param imageRef: reference to an image stored in glance :param imageRef: reference to an image stored in glance
""" """
body = {'volume': {'size': size, body = {'volume': {'size': size,
'snapshot_id': snapshot_id, 'snapshot_id': snapshot_id,
'display_name': display_name, 'display_name': display_name,
'display_description': display_description, 'display_description': display_description,
'volume_type': volume_type, 'volume_type': volume_type,
'availability_zone': availability_zone, 'availability_zone': availability_zone,
'imageRef': imageRef}} 'imageRef': imageRef}}
return self._create('/volumes', body, 'volume') return self._create('/volumes', body, 'volume')
def get(self, volume_id): def get(self, volume_id):
@ -162,4 +161,4 @@ class VolumeManager(base.ManagerWithFind):
:param attachment_id: The ID of the attachment :param attachment_id: The ID of the attachment
""" """
self._delete("/servers/%s/os-volume_attachments/%s" % self._delete("/servers/%s/os-volume_attachments/%s" %
(server_id, attachment_id,)) (server_id, attachment_id,))

View File

@ -440,7 +440,7 @@ class ServerManager(base.BootingManagerWithFind):
if block_device_mapping: if block_device_mapping:
bdm_param = 'block_device_mapping' bdm_param = 'block_device_mapping'
body['server'][bdm_param] = \ body['server'][bdm_param] = \
self._parse_block_device_mapping(block_device_mapping) self._parse_block_device_mapping(block_device_mapping)
elif block_device_mapping_v2: elif block_device_mapping_v2:
# Append the image to the list only if we have new style BDMs # Append the image to the list only if we have new style BDMs
bdm_param = 'block_device_mapping_v2' bdm_param = 'block_device_mapping_v2'
@ -893,8 +893,8 @@ class ServerManager(base.BootingManagerWithFind):
:param metadata: A dict of metadata to add to the server :param metadata: A dict of metadata to add to the server
""" """
body = {'metadata': metadata} body = {'metadata': metadata}
return self._create("/servers/%s/metadata" % base.getid(server), return self._create(
body, "metadata") "/servers/%s/metadata" % base.getid(server), body, "metadata")
def get_console_output(self, server, length=None): def get_console_output(self, server, length=None):
""" """

View File

@ -94,8 +94,8 @@ def _boot(cs, args):
max_count = args.num_instances max_count = args.num_instances
elif (args.num_instances is not None and elif (args.num_instances is not None and
(args.min_count is not None or args.max_count is not None)): (args.min_count is not None or args.max_count is not None)):
raise exceptions.CommandError("Don't mix num-instances and " raise exceptions.CommandError(
"max/min-count") "Don't mix num-instances and max/min-count")
if args.min_count is not None: if args.min_count is not None:
if args.min_count < 1: if args.min_count < 1:
raise exceptions.CommandError("min_count should be >= 1") raise exceptions.CommandError("min_count should be >= 1")
@ -1945,8 +1945,8 @@ def do_secgroup_add_group_rule(cs, args):
if args.ip_proto or args.from_port or args.to_port: if args.ip_proto or args.from_port or args.to_port:
if not (args.ip_proto and args.from_port and args.to_port): if not (args.ip_proto and args.from_port and args.to_port):
raise exceptions.CommandError("ip_proto, from_port, and to_port" raise exceptions.CommandError(
" must be specified together") "ip_proto, from_port, and to_port must be specified together")
params['ip_protocol'] = args.ip_proto.upper() params['ip_protocol'] = args.ip_proto.upper()
params['from_port'] = args.from_port params['from_port'] = args.from_port
params['to_port'] = args.to_port params['to_port'] = args.to_port
@ -1979,8 +1979,8 @@ def do_secgroup_delete_group_rule(cs, args):
if args.ip_proto or args.from_port or args.to_port: if args.ip_proto or args.from_port or args.to_port:
if not (args.ip_proto and args.from_port and args.to_port): if not (args.ip_proto and args.from_port and args.to_port):
raise exceptions.CommandError("ip_proto, from_port, and to_port" raise exceptions.CommandError(
" must be specified together") "ip_proto, from_port, and to_port must be specified together")
params['ip_protocol'] = args.ip_proto.upper() params['ip_protocol'] = args.ip_proto.upper()
params['from_port'] = int(args.from_port) params['from_port'] = int(args.from_port)
params['to_port'] = int(args.to_port) params['to_port'] = int(args.to_port)
@ -2013,8 +2013,8 @@ def do_keypair_add(cs, args):
with open(os.path.expanduser(pub_key)) as f: with open(os.path.expanduser(pub_key)) as f:
pub_key = f.read() pub_key = f.read()
except IOError as e: except IOError as e:
raise exceptions.CommandError("Can't open or read '%s': %s" % raise exceptions.CommandError(
(pub_key, e)) "Can't open or read '%s': %s" % (pub_key, e))
keypair = cs.keypairs.create(name, pub_key) keypair = cs.keypairs.create(name, pub_key)
@ -2822,8 +2822,8 @@ def do_ssh(cs, args):
match = lambda addr: all(( match = lambda addr: all((
addr.get('version') == version, addr.get('version') == version,
addr.get('OS-EXT-IPS:type', 'floating') == address_type)) addr.get('OS-EXT-IPS:type', 'floating') == address_type))
matching_addresses = [address.get('addr') for address in network_addresses matching_addresses = [address.get('addr')
if match(address)] for address in network_addresses if match(address)]
if not any(matching_addresses): if not any(matching_addresses):
msg = _("No address that would match network '%(network)s'" msg = _("No address that would match network '%(network)s'"
" and type '%(address_type)s' of version %(pretty_version)s " " and type '%(address_type)s' of version %(pretty_version)s "
@ -2980,8 +2980,8 @@ def do_quota_defaults(cs, args):
dest='force', dest='force',
action="store_true", action="store_true",
default=None, default=None,
help='Whether force update the quota even if the already used' help='Whether force update the quota even if the already used and '
' and reserved exceeds the new quota') 'reserved exceeds the new quota')
def do_quota_update(cs, args): def do_quota_update(cs, args):
"""Update the quotas for a tenant.""" """Update the quotas for a tenant."""

View File

@ -42,7 +42,7 @@ downloadcache = ~/cache/pip
# reason: removed in hacking (https://review.openstack.org/#/c/101701/) # reason: removed in hacking (https://review.openstack.org/#/c/101701/)
# #
# Additional checks are also ignored on purpose: F811, F821 # Additional checks are also ignored on purpose: F811, F821
ignore = E124,E127,E128,E129,F811,F821,H402,H404,H405,H904 ignore = E124,E128,E129,F811,F821,H402,H404,H405,H904
show-source = True show-source = True
exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,doc/source/conf.py exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,doc/source/conf.py