Fix and enable E12 pep8 rule (indentation issues)
Change-Id: I500d2cacba09f2a4337ff325ae658f61b64e4b7a Related-Bug: #1333290
This commit is contained in:
parent
02fb7a62d1
commit
900b660618
|
@ -148,7 +148,7 @@ class SecretsHelper(object):
|
|||
tenant_id.
|
||||
"""
|
||||
if (auth_token == self.auth_token and
|
||||
management_url == self.management_url):
|
||||
management_url == self.management_url):
|
||||
# Nothing changed....
|
||||
return
|
||||
if not all([management_url, auth_token, tenant_id]):
|
||||
|
@ -166,8 +166,8 @@ class SecretsHelper(object):
|
|||
self.keyring.delete_password(args)
|
||||
|
||||
def save_password(self):
|
||||
self.keyring.set_password('openstack',
|
||||
self.args.os_username, self.password)
|
||||
self.keyring.set_password('openstack', self.args.os_username,
|
||||
self.password)
|
||||
|
||||
def check_cached_password(self):
|
||||
"""Check if os_password is equal to cached password."""
|
||||
|
@ -214,7 +214,7 @@ class SecretsHelper(object):
|
|||
return None
|
||||
management_url = None
|
||||
block = self.keyring.get_password('manilaclient_auth',
|
||||
self._make_key())
|
||||
self._make_key())
|
||||
if block:
|
||||
_token, management_url, _tenant_id = block.split('|', 2)
|
||||
return management_url
|
||||
|
@ -230,7 +230,7 @@ class SecretsHelper(object):
|
|||
return None
|
||||
token = None
|
||||
block = self.keyring.get_password('manilaclient_auth',
|
||||
self._make_key())
|
||||
self._make_key())
|
||||
if block:
|
||||
token, _management_url, _tenant_id = block.split('|', 2)
|
||||
return token
|
||||
|
@ -246,7 +246,7 @@ class SecretsHelper(object):
|
|||
return None
|
||||
tenant_id = None
|
||||
block = self.keyring.get_password('manilaclient_auth',
|
||||
self._make_key())
|
||||
self._make_key())
|
||||
if block:
|
||||
_token, _management_url, tenant_id = block.split('|', 2)
|
||||
return tenant_id
|
||||
|
@ -536,11 +536,11 @@ class OpenStackManilaShell(object):
|
|||
os_region_name, os_tenant_id, endpoint_type, insecure,
|
||||
service_type, service_name, share_service_name,
|
||||
cacert, os_cache, os_reset_cache) = (
|
||||
args.os_username, args.os_password, args.os_tenant_name,
|
||||
args.os_auth_url, args.os_region_name, args.os_tenant_id,
|
||||
args.endpoint_type, args.insecure, args.service_type,
|
||||
args.service_name, args.share_service_name,
|
||||
args.os_cacert, args.os_cache, args.os_reset_cache)
|
||||
args.os_username, args.os_password, args.os_tenant_name,
|
||||
args.os_auth_url, args.os_region_name, args.os_tenant_id,
|
||||
args.endpoint_type, args.insecure, args.service_type,
|
||||
args.service_name, args.share_service_name,
|
||||
args.os_cacert, args.os_cache, args.os_reset_cache)
|
||||
|
||||
if not endpoint_type:
|
||||
endpoint_type = DEFAULT_MANILA_ENDPOINT_TYPE
|
||||
|
|
|
@ -73,11 +73,8 @@ def get_resource_manager_extra_kwargs(f, args, allow_conflicts=False):
|
|||
|
||||
conflicting_keys = set(list(hook_kwargs)) & set(list(extra_kwargs))
|
||||
if conflicting_keys and not allow_conflicts:
|
||||
msg = ("Hook '%(hook_name)s' is attempting to redefine attributes "
|
||||
"'%(conflicting_keys)s'" % {
|
||||
'hook_name': hook_name,
|
||||
'conflicting_keys': conflicting_keys,
|
||||
})
|
||||
msg = ("Hook '%s' is attempting to redefine "
|
||||
"attributes '%s'" % (hook_name, conflicting_keys))
|
||||
raise Exception(msg)
|
||||
|
||||
extra_kwargs.update(hook_kwargs)
|
||||
|
|
|
@ -106,9 +106,9 @@ class ServiceCatalogTest(utils.TestCase):
|
|||
self.assertRaises(exceptions.AmbiguousEndpoints, sc.url_for,
|
||||
service_type='compute')
|
||||
self.assertEqual(sc.url_for('tenantId', '1', service_type='compute'),
|
||||
"https://compute1.host/v1/1234")
|
||||
"https://compute1.host/v1/1234")
|
||||
self.assertEqual(sc.url_for('tenantId', '2', service_type='compute'),
|
||||
"https://compute1.host/v1/3456")
|
||||
"https://compute1.host/v1/3456")
|
||||
|
||||
self.assertRaises(exceptions.EndpointNotFound, sc.url_for,
|
||||
"region", "South", service_type='compute')
|
||||
|
|
|
@ -50,7 +50,7 @@ class ShellTest(utils.TestCase):
|
|||
'.*?^usage: ',
|
||||
'.*?^\s+create\s+Creates new NAS storage \(NFS or CIFS\).',
|
||||
'.*?(?m)^See "manila help COMMAND" for help '
|
||||
'on a specific command.',
|
||||
'on a specific command.',
|
||||
]
|
||||
help_text = self.shell('help')
|
||||
for r in required:
|
||||
|
|
|
@ -123,12 +123,13 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
|
|||
return (200, {}, share_nw)
|
||||
|
||||
def get_share_networks_detail(self, **kw):
|
||||
share_nw = {'share_networks': [{'id': 1234,
|
||||
'name': 'fake_share_nw'},
|
||||
{'id': 4321,
|
||||
'name': 'duplicated_name'},
|
||||
{'id': 4322,
|
||||
'name': 'duplicated_name'}]}
|
||||
share_nw = {
|
||||
'share_networks': [
|
||||
{'id': 1234, 'name': 'fake_share_nw'},
|
||||
{'id': 4321, 'name': 'duplicated_name'},
|
||||
{'id': 4322, 'name': 'duplicated_name'},
|
||||
]
|
||||
}
|
||||
return (200, {}, share_nw)
|
||||
|
||||
def get_security_services(self, **kw):
|
||||
|
|
|
@ -35,7 +35,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||
"id": "FAKE_ID",
|
||||
"tenant": {
|
||||
"id": "FAKE_TENANT_ID"
|
||||
},
|
||||
},
|
||||
},
|
||||
"serviceCatalog": [
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||
"id": "FAKE_ID",
|
||||
"tenant": {
|
||||
"id": "FAKE_TENANT_ID"
|
||||
},
|
||||
},
|
||||
},
|
||||
"serviceCatalog": [
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||
"id": "FAKE_ID",
|
||||
"tenant": {
|
||||
"id": "FAKE_TENANT_ID"
|
||||
},
|
||||
},
|
||||
},
|
||||
"serviceCatalog": [
|
||||
{
|
||||
|
|
|
@ -114,12 +114,13 @@ class SecurityServiceTest(utils.TestCase):
|
|||
|
||||
def test_update(self):
|
||||
security_service = 'fake service'
|
||||
values = {'dns_ip': 'new dns ip',
|
||||
'server': 'new.ldap.server',
|
||||
'domain': 'new.ldap.domain',
|
||||
'sid': 'new sid',
|
||||
'password': 'fake password',
|
||||
}
|
||||
values = {
|
||||
'dns_ip': 'new dns ip',
|
||||
'server': 'new.ldap.server',
|
||||
'domain': 'new.ldap.domain',
|
||||
'sid': 'new sid',
|
||||
'password': 'fake password',
|
||||
}
|
||||
|
||||
with mock.patch.object(self.manager, '_update', fakes.fake_update):
|
||||
result = self.manager.update(security_service, **values)
|
||||
|
|
|
@ -91,7 +91,7 @@ class ShareNetworkTest(utils.TestCase):
|
|||
def test_list_with_filters(self):
|
||||
filters = OrderedDict([('all_tenants', 1), ('status', 'ERROR')])
|
||||
expected_path = share_networks.RESOURCES_PATH + '/detail' + \
|
||||
'?all_tenants=1&status=ERROR'
|
||||
'?all_tenants=1&status=ERROR'
|
||||
|
||||
with mock.patch.object(self.manager, '_list',
|
||||
mock.Mock(return_value=None)):
|
||||
|
|
|
@ -214,12 +214,18 @@ class ShellTest(utils.TestCase):
|
|||
self.assert_called('GET', '/security-services?share_network_id=1234')
|
||||
|
||||
def test_share_network_security_service_list_by_name_not_found(self):
|
||||
self.assertRaises(exceptions.CommandError, self.run_command,
|
||||
'share-network-security-service-list inexistent_share_nw')
|
||||
self.assertRaises(
|
||||
exceptions.CommandError,
|
||||
self.run_command,
|
||||
'share-network-security-service-list inexistent_share_nw',
|
||||
)
|
||||
|
||||
def test_share_network_security_service_list_by_name_multiple(self):
|
||||
self.assertRaises(exceptions.CommandError, self.run_command,
|
||||
'share-network-security-service-list duplicated_name')
|
||||
self.assertRaises(
|
||||
exceptions.CommandError,
|
||||
self.run_command,
|
||||
'share-network-security-service-list duplicated_name',
|
||||
)
|
||||
|
||||
def test_share_network_security_service_list_by_id(self):
|
||||
self.run_command('share-network-security-service-list 1111')
|
||||
|
@ -371,17 +377,17 @@ class ShellTest(utils.TestCase):
|
|||
return utils.TestResponse({
|
||||
"status_code": 200,
|
||||
"text": jsonutils.dumps(resp_text),
|
||||
})
|
||||
})
|
||||
elif url == 'fake/shares/detail':
|
||||
resp_text = {"unauthorized": {"message": "Unauthorized",
|
||||
"code": "401"}}
|
||||
return utils.TestResponse({
|
||||
"status_code": 401,
|
||||
"text": jsonutils.dumps(resp_text),
|
||||
})
|
||||
})
|
||||
else:
|
||||
headers = {
|
||||
'x-server-management-url': 'new_url',
|
||||
'x-server-management-url': 'new_url',
|
||||
'x-auth-token': 'new_token',
|
||||
}
|
||||
resp_text = 'some_text'
|
||||
|
@ -389,7 +395,7 @@ class ShellTest(utils.TestCase):
|
|||
"status_code": 200,
|
||||
"text": jsonutils.dumps(resp_text),
|
||||
"headers": headers
|
||||
})
|
||||
})
|
||||
|
||||
client.get_client_class = lambda *_: client_v1.Client
|
||||
shell.SecretsHelper.tenant_id = \
|
||||
|
@ -405,8 +411,12 @@ class ShellTest(utils.TestCase):
|
|||
'User-Agent': 'python-manilaclient',
|
||||
'Accept': 'application/json',
|
||||
'X-Auth-Token': 'new_token'}
|
||||
requests.request.assert_called_with('GET', 'new_url/shares/detail',
|
||||
headers=expected_headers, verify=True)
|
||||
requests.request.assert_called_with(
|
||||
'GET',
|
||||
'new_url/shares/detail',
|
||||
headers=expected_headers,
|
||||
verify=True,
|
||||
)
|
||||
|
||||
|
||||
class SecretsHelperTestCase(utils.TestCase):
|
||||
|
@ -455,9 +465,11 @@ class SecretsHelperTestCase(utils.TestCase):
|
|||
expected_key = 'http://111.11.11.11:5000/user/project/region/' \
|
||||
'publicURL/share/fake/fake'
|
||||
self.helper.save('fake_token', 'fake_url', 'fake_tenant_id')
|
||||
shell.ManilaKeyring.set_password. \
|
||||
assert_called_once_with('manilaclient_auth',
|
||||
expected_key, 'fake_token|fake_url|fake_tenant_id')
|
||||
shell.ManilaKeyring.set_password.assert_called_once_with(
|
||||
'manilaclient_auth',
|
||||
expected_key,
|
||||
'fake_token|fake_url|fake_tenant_id',
|
||||
)
|
||||
|
||||
def test_save_params_already_cached(self):
|
||||
self.helper.save('fake_token', 'fake_url', 'fake_tenant_id')
|
||||
|
@ -490,8 +502,8 @@ class SecretsHelperTestCase(utils.TestCase):
|
|||
self.assertEqual(self.helper.management_url, 'fake_url')
|
||||
expected_key = 'http://111.11.11.11:5000/user/project/region/' \
|
||||
'publicURL/share/fake/fake'
|
||||
shell.ManilaKeyring.get_password. \
|
||||
assert_called_once_with('manilaclient_auth', expected_key)
|
||||
shell.ManilaKeyring.get_password.assert_called_once_with(
|
||||
'manilaclient_auth', expected_key)
|
||||
|
||||
def test_auth_token_os_cache_false(self):
|
||||
self.args.os_cache = False
|
||||
|
|
|
@ -195,8 +195,8 @@ def install_dependencies(venv=VENV):
|
|||
pip_install('-r', PIP_REQUIRES)
|
||||
pip_install('-r', TEST_REQUIRES)
|
||||
# Tell the virtual env how to "import manila"
|
||||
pthfile = os.path.join(venv, "lib", PY_VERSION, "site-packages",
|
||||
"manilaclient.pth")
|
||||
pthfile = os.path.join(
|
||||
venv, "lib", PY_VERSION, "site-packages", "manilaclient.pth")
|
||||
f = open(pthfile, 'w')
|
||||
f.write("%s\n" % ROOT)
|
||||
|
||||
|
@ -230,9 +230,11 @@ def print_help():
|
|||
def parse_args():
|
||||
"""Parse command-line arguments."""
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-n", "--no-site-packages", dest="no_site_packages",
|
||||
parser.add_option(
|
||||
"-n", "--no-site-packages", dest="no_site_packages",
|
||||
default=False, action="store_true",
|
||||
help="Do not inherit packages from global Python install")
|
||||
help="Do not inherit packages from global Python install",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue