Fix W503 warnings
W503 line break before binary operator Looking at the code base, it sounds okay to follow this check. Change-Id: Id511e0104dc6de5b204021661d4a8776ca6d3658
This commit is contained in:
parent
f545272f12
commit
11eb4e9d3e
|
@ -143,8 +143,8 @@ def process_message_notification(request, messages_path):
|
||||||
# NOTE (lhcheng): Cache the processed messages to avoid parsing
|
# NOTE (lhcheng): Cache the processed messages to avoid parsing
|
||||||
# the files every time. Check directory modification time if
|
# the files every time. Check directory modification time if
|
||||||
# reload is necessary.
|
# reload is necessary.
|
||||||
if (_MESSAGES_CACHE is None
|
if (_MESSAGES_CACHE is None or
|
||||||
or _MESSAGES_MTIME != os.path.getmtime(messages_path)):
|
_MESSAGES_MTIME != os.path.getmtime(messages_path)):
|
||||||
_MESSAGES_CACHE = _get_processed_messages(messages_path)
|
_MESSAGES_CACHE = _get_processed_messages(messages_path)
|
||||||
_MESSAGES_MTIME = os.path.getmtime(messages_path)
|
_MESSAGES_MTIME = os.path.getmtime(messages_path)
|
||||||
|
|
||||||
|
|
|
@ -1072,8 +1072,8 @@ class DataTableOptions(object):
|
||||||
"""
|
"""
|
||||||
def __init__(self, options):
|
def __init__(self, options):
|
||||||
self.name = getattr(options, 'name', self.__class__.__name__)
|
self.name = getattr(options, 'name', self.__class__.__name__)
|
||||||
verbose_name = (getattr(options, 'verbose_name', None)
|
verbose_name = (getattr(options, 'verbose_name', None) or
|
||||||
or self.name.title())
|
self.name.title())
|
||||||
self.verbose_name = verbose_name
|
self.verbose_name = verbose_name
|
||||||
self.columns = getattr(options, 'columns', None)
|
self.columns = getattr(options, 'columns', None)
|
||||||
self.status_columns = getattr(options, 'status_columns', [])
|
self.status_columns = getattr(options, 'status_columns', [])
|
||||||
|
@ -1330,12 +1330,12 @@ class DataTable(object):
|
||||||
filter_string = self.get_filter_string()
|
filter_string = self.get_filter_string()
|
||||||
filter_field = self.get_filter_field()
|
filter_field = self.get_filter_field()
|
||||||
request_method = self.request.method
|
request_method = self.request.method
|
||||||
needs_preloading = (not filter_string
|
needs_preloading = (not filter_string and
|
||||||
and request_method == 'GET'
|
request_method == 'GET' and
|
||||||
and action.needs_preloading)
|
action.needs_preloading)
|
||||||
valid_method = (request_method == action.method)
|
valid_method = (request_method == action.method)
|
||||||
not_api_filter = (filter_string
|
not_api_filter = (filter_string and
|
||||||
and not action.is_api_filter(filter_field))
|
not action.is_api_filter(filter_field))
|
||||||
|
|
||||||
if valid_method or needs_preloading or not_api_filter:
|
if valid_method or needs_preloading or not_api_filter:
|
||||||
if self._meta.mixed_data_type:
|
if self._meta.mixed_data_type:
|
||||||
|
|
|
@ -138,8 +138,8 @@ class MultiTableMixin(object):
|
||||||
param_name = filter_action.get_param_name()
|
param_name = filter_action.get_param_name()
|
||||||
filter_string = request.POST.get(param_name)
|
filter_string = request.POST.get(param_name)
|
||||||
filter_string_session = request.session.get(param_name, "")
|
filter_string_session = request.session.get(param_name, "")
|
||||||
changed = (filter_string is not None
|
changed = (filter_string is not None and
|
||||||
and filter_string != filter_string_session)
|
filter_string != filter_string_session)
|
||||||
if filter_string is None:
|
if filter_string is None:
|
||||||
filter_string = filter_string_session
|
filter_string = filter_string_session
|
||||||
filter_field_param = param_name + '_field'
|
filter_field_param = param_name + '_field'
|
||||||
|
|
|
@ -91,8 +91,8 @@ class WebDriver(firefox.webdriver.WebDriver):
|
||||||
'connection refused.' % i)
|
'connection refused.' % i)
|
||||||
break
|
break
|
||||||
except socket.error as socket_error:
|
except socket.error as socket_error:
|
||||||
if (socket_error.errno == errno.ECONNREFUSED
|
if (socket_error.errno == errno.ECONNREFUSED and
|
||||||
and i < self.CONNREFUSED_RETRY_COUNT):
|
i < self.CONNREFUSED_RETRY_COUNT):
|
||||||
time.sleep(self.CONNREFUSED_RETRY_INTERVAL)
|
time.sleep(self.CONNREFUSED_RETRY_INTERVAL)
|
||||||
continue
|
continue
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -63,10 +63,10 @@ def sort_js_files(js_files):
|
||||||
mocks = [f for f in js_files if f.endswith(MOCK_EXT)]
|
mocks = [f for f in js_files if f.endswith(MOCK_EXT)]
|
||||||
specs = [f for f in js_files if f.endswith(SPEC_EXT)]
|
specs = [f for f in js_files if f.endswith(SPEC_EXT)]
|
||||||
|
|
||||||
other_sources = [f for f in js_files if
|
other_sources = [f for f in js_files
|
||||||
not f.endswith(MODULE_EXT)
|
if (not f.endswith(MODULE_EXT) and
|
||||||
and not f.endswith(MOCK_EXT)
|
not f.endswith(MOCK_EXT) and
|
||||||
and not f.endswith(SPEC_EXT)]
|
not f.endswith(SPEC_EXT))]
|
||||||
|
|
||||||
sources = modules + other_sources
|
sources = modules + other_sources
|
||||||
return sources, mocks, specs
|
return sources, mocks, specs
|
||||||
|
|
|
@ -128,8 +128,8 @@ class Token(object):
|
||||||
"""Determines if this is a pki-based token (pki or pkiz)"""
|
"""Determines if this is a pki-based token (pki or pkiz)"""
|
||||||
if token is None:
|
if token is None:
|
||||||
return False
|
return False
|
||||||
return (keystone_cms.is_ans1_token(token)
|
return (keystone_cms.is_ans1_token(token) or
|
||||||
or keystone_cms.is_pkiz(token))
|
keystone_cms.is_pkiz(token))
|
||||||
|
|
||||||
|
|
||||||
class User(models.AbstractBaseUser, models.AnonymousUser):
|
class User(models.AbstractBaseUser, models.AnonymousUser):
|
||||||
|
@ -229,8 +229,8 @@ class User(models.AbstractBaseUser, models.AnonymousUser):
|
||||||
self.project_name = project_name or tenant_name
|
self.project_name = project_name or tenant_name
|
||||||
self.service_catalog = service_catalog
|
self.service_catalog = service_catalog
|
||||||
self._services_region = (
|
self._services_region = (
|
||||||
services_region
|
services_region or
|
||||||
or utils.default_services_region(service_catalog)
|
utils.default_services_region(service_catalog)
|
||||||
)
|
)
|
||||||
self.roles = roles or []
|
self.roles = roles or []
|
||||||
self.endpoint = endpoint
|
self.endpoint = endpoint
|
||||||
|
|
|
@ -352,8 +352,8 @@ def default_services_region(service_catalog, request=None,
|
||||||
available_regions = [get_endpoint_region(endpoint) for service
|
available_regions = [get_endpoint_region(endpoint) for service
|
||||||
in service_catalog for endpoint
|
in service_catalog for endpoint
|
||||||
in service.get('endpoints', [])
|
in service.get('endpoints', [])
|
||||||
if (service.get('type') is not None
|
if (service.get('type') is not None and
|
||||||
and service.get('type') != 'identity')]
|
service.get('type') != 'identity')]
|
||||||
if not available_regions:
|
if not available_regions:
|
||||||
# this is very likely an incomplete keystone setup
|
# this is very likely an incomplete keystone setup
|
||||||
LOG.warning('No regions could be found excluding identity.')
|
LOG.warning('No regions could be found excluding identity.')
|
||||||
|
|
|
@ -98,8 +98,8 @@ class EvacuateHostViewTest(test.BaseAdminViewTests):
|
||||||
class MigrateHostViewTest(test.BaseAdminViewTests):
|
class MigrateHostViewTest(test.BaseAdminViewTests):
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
disabled_services = [service for service in self.services.list()
|
disabled_services = [service for service in self.services.list()
|
||||||
if service.binary == 'nova-compute'
|
if (service.binary == 'nova-compute' and
|
||||||
and service.status == 'disabled']
|
service.status == 'disabled')]
|
||||||
disabled_service = disabled_services[0]
|
disabled_service = disabled_services[0]
|
||||||
|
|
||||||
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
|
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
|
||||||
|
@ -112,8 +112,8 @@ class MigrateHostViewTest(test.BaseAdminViewTests):
|
||||||
@test.create_mocks({api.nova: ['migrate_host']})
|
@test.create_mocks({api.nova: ['migrate_host']})
|
||||||
def test_maintenance_host_cold_migration_succeed(self):
|
def test_maintenance_host_cold_migration_succeed(self):
|
||||||
disabled_services = [service for service in self.services.list()
|
disabled_services = [service for service in self.services.list()
|
||||||
if service.binary == 'nova-compute'
|
if (service.binary == 'nova-compute' and
|
||||||
and service.status == 'disabled']
|
service.status == 'disabled')]
|
||||||
disabled_service = disabled_services[0]
|
disabled_service = disabled_services[0]
|
||||||
self.mock_migrate_host.return_value = True
|
self.mock_migrate_host.return_value = True
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ class MigrateHostViewTest(test.BaseAdminViewTests):
|
||||||
@test.create_mocks({api.nova: ['migrate_host']})
|
@test.create_mocks({api.nova: ['migrate_host']})
|
||||||
def test_maintenance_host_live_migration_succeed(self):
|
def test_maintenance_host_live_migration_succeed(self):
|
||||||
disabled_services = [service for service in self.services.list()
|
disabled_services = [service for service in self.services.list()
|
||||||
if service.binary == 'nova-compute'
|
if (service.binary == 'nova-compute' and
|
||||||
and service.status == 'disabled']
|
service.status == 'disabled')]
|
||||||
disabled_service = disabled_services[0]
|
disabled_service = disabled_services[0]
|
||||||
self.mock_migrate_host.return_value = True
|
self.mock_migrate_host.return_value = True
|
||||||
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
|
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
|
||||||
|
@ -165,8 +165,8 @@ class MigrateHostViewTest(test.BaseAdminViewTests):
|
||||||
@test.create_mocks({api.nova: ['migrate_host']})
|
@test.create_mocks({api.nova: ['migrate_host']})
|
||||||
def test_maintenance_host_migration_fails(self):
|
def test_maintenance_host_migration_fails(self):
|
||||||
disabled_services = [service for service in self.services.list()
|
disabled_services = [service for service in self.services.list()
|
||||||
if service.binary == 'nova-compute'
|
if (service.binary == 'nova-compute' and
|
||||||
and service.status == 'disabled']
|
service.status == 'disabled')]
|
||||||
disabled_service = disabled_services[0]
|
disabled_service = disabled_services[0]
|
||||||
|
|
||||||
self.mock_migrate_host.side_effect = self.exceptions.nova
|
self.mock_migrate_host.side_effect = self.exceptions.nova
|
||||||
|
|
|
@ -124,8 +124,8 @@ class IndexView(tables.DataTableView):
|
||||||
invalid_msg = ('API query is not valid and is ignored: '
|
invalid_msg = ('API query is not valid and is ignored: '
|
||||||
'%(field)s=%(string)s')
|
'%(field)s=%(string)s')
|
||||||
try:
|
try:
|
||||||
filter_string = builtins.int(float(filter_string)
|
filter_string = builtins.int(float(filter_string) *
|
||||||
* (units.Mi))
|
(units.Mi))
|
||||||
if filter_string >= 0:
|
if filter_string >= 0:
|
||||||
filters[filter_field] = filter_string
|
filters[filter_field] = filter_string
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -66,9 +66,9 @@ class MigrateInstance(policy.PolicyTargetMixin, tables.BatchAction):
|
||||||
)
|
)
|
||||||
|
|
||||||
def allowed(self, request, instance):
|
def allowed(self, request, instance):
|
||||||
return ((instance.status in project_tables.ACTIVE_STATES
|
return ((instance.status in project_tables.ACTIVE_STATES or
|
||||||
or instance.status == 'SHUTOFF')
|
instance.status == 'SHUTOFF') and
|
||||||
and not project_tables.is_deleting(instance))
|
not project_tables.is_deleting(instance))
|
||||||
|
|
||||||
def action(self, request, obj_id):
|
def action(self, request, obj_id):
|
||||||
api.nova.server_migrate(request, obj_id)
|
api.nova.server_migrate(request, obj_id)
|
||||||
|
@ -84,8 +84,8 @@ class LiveMigrateInstance(policy.PolicyTargetMixin,
|
||||||
("compute", "os_compute_api:os-migrate-server:migrate_live"),)
|
("compute", "os_compute_api:os-migrate-server:migrate_live"),)
|
||||||
|
|
||||||
def allowed(self, request, instance):
|
def allowed(self, request, instance):
|
||||||
return ((instance.status in project_tables.ACTIVE_STATES)
|
return (instance.status in project_tables.ACTIVE_STATES and
|
||||||
and not project_tables.is_deleting(instance))
|
not project_tables.is_deleting(instance))
|
||||||
|
|
||||||
|
|
||||||
class AdminUpdateRow(project_tables.UpdateRow):
|
class AdminUpdateRow(project_tables.UpdateRow):
|
||||||
|
|
|
@ -44,8 +44,8 @@ class CreatePortInfoAction(project_workflow.CreatePortInfoAction):
|
||||||
class CreatePortInfo(project_workflow.CreatePortInfo):
|
class CreatePortInfo(project_workflow.CreatePortInfo):
|
||||||
action_class = CreatePortInfoAction
|
action_class = CreatePortInfoAction
|
||||||
depends_on = ("network_id", "target_tenant_id")
|
depends_on = ("network_id", "target_tenant_id")
|
||||||
contributes = (project_workflow.CreatePortInfo.contributes
|
contributes = (project_workflow.CreatePortInfo.contributes +
|
||||||
+ ['binding__host_id'])
|
['binding__host_id'])
|
||||||
|
|
||||||
|
|
||||||
class CreatePort(project_workflow.CreatePort):
|
class CreatePort(project_workflow.CreatePort):
|
||||||
|
|
|
@ -33,10 +33,10 @@ class Trunks(horizon.Panel):
|
||||||
request = context['request']
|
request = context['request']
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
super(Trunks, self).allowed(context)
|
super(Trunks, self).allowed(context) and
|
||||||
and request.user.has_perms(self.permissions)
|
request.user.has_perms(self.permissions) and
|
||||||
and neutron.is_extension_supported(request,
|
neutron.is_extension_supported(request,
|
||||||
extension_alias='trunk')
|
extension_alias='trunk')
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error("Call to list enabled services failed. This is likely "
|
LOG.error("Call to list enabled services failed. This is likely "
|
||||||
|
|
|
@ -123,8 +123,8 @@ class UserFilterAction(tables.FilterAction):
|
||||||
"""Naive case-insensitive search."""
|
"""Naive case-insensitive search."""
|
||||||
q = filter_string.lower()
|
q = filter_string.lower()
|
||||||
return [user for user in users
|
return [user for user in users
|
||||||
if q in user.name.lower()
|
if (q in user.name.lower() or
|
||||||
or q in (getattr(user, 'email', None) or '').lower()]
|
q in (getattr(user, 'email', None) or '').lower())]
|
||||||
|
|
||||||
|
|
||||||
class RemoveMembers(tables.DeleteAction):
|
class RemoveMembers(tables.DeleteAction):
|
||||||
|
|
|
@ -157,8 +157,9 @@ class CreateVolumeFromImage(tables.LinkAction):
|
||||||
return "?".join([base_url, params])
|
return "?".join([base_url, params])
|
||||||
|
|
||||||
def allowed(self, request, image=None):
|
def allowed(self, request, image=None):
|
||||||
if (image and image.container_format not in NOT_LAUNCHABLE_FORMATS
|
if (image and
|
||||||
and api.cinder.is_volume_service_enabled(request)):
|
image.container_format not in NOT_LAUNCHABLE_FORMATS and
|
||||||
|
api.cinder.is_volume_service_enabled(request)):
|
||||||
return image.status == "active"
|
return image.status == "active"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -137,9 +137,9 @@ class RebootInstance(policy.PolicyTargetMixin, tables.BatchAction):
|
||||||
|
|
||||||
def allowed(self, request, instance=None):
|
def allowed(self, request, instance=None):
|
||||||
if instance is not None:
|
if instance is not None:
|
||||||
return ((instance.status in ACTIVE_STATES
|
return ((instance.status in ACTIVE_STATES or
|
||||||
or instance.status == 'SHUTOFF')
|
instance.status == 'SHUTOFF') and
|
||||||
and not is_deleting(instance))
|
not is_deleting(instance))
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -230,9 +230,9 @@ class TogglePause(tables.BatchAction):
|
||||||
policy_rules, request,
|
policy_rules, request,
|
||||||
target={'project_id': getattr(instance, 'tenant_id', None)})
|
target={'project_id': getattr(instance, 'tenant_id', None)})
|
||||||
|
|
||||||
return (has_permission
|
return (has_permission and
|
||||||
and (instance.status in ACTIVE_STATES or self.paused)
|
(instance.status in ACTIVE_STATES or self.paused) and
|
||||||
and not is_deleting(instance))
|
not is_deleting(instance))
|
||||||
|
|
||||||
def action(self, request, obj_id):
|
def action(self, request, obj_id):
|
||||||
if self.paused:
|
if self.paused:
|
||||||
|
@ -297,9 +297,9 @@ class ToggleSuspend(tables.BatchAction):
|
||||||
policy_rules, request,
|
policy_rules, request,
|
||||||
target={'project_id': getattr(instance, 'tenant_id', None)})
|
target={'project_id': getattr(instance, 'tenant_id', None)})
|
||||||
|
|
||||||
return (has_permission
|
return (has_permission and
|
||||||
and (instance.status in ACTIVE_STATES or self.suspended)
|
(instance.status in ACTIVE_STATES or self.suspended) and
|
||||||
and not is_deleting(instance))
|
not is_deleting(instance))
|
||||||
|
|
||||||
def action(self, request, obj_id):
|
def action(self, request, obj_id):
|
||||||
if self.suspended:
|
if self.suspended:
|
||||||
|
@ -365,9 +365,9 @@ class ToggleShelve(tables.BatchAction):
|
||||||
policy_rules, request,
|
policy_rules, request,
|
||||||
target={'project_id': getattr(instance, 'tenant_id', None)})
|
target={'project_id': getattr(instance, 'tenant_id', None)})
|
||||||
|
|
||||||
return (has_permission
|
return (has_permission and
|
||||||
and (instance.status in SHELVE_READY_STATES or self.shelved)
|
(instance.status in SHELVE_READY_STATES or self.shelved) and
|
||||||
and not is_deleting(instance))
|
not is_deleting(instance))
|
||||||
|
|
||||||
def action(self, request, obj_id):
|
def action(self, request, obj_id):
|
||||||
if self.shelved:
|
if self.shelved:
|
||||||
|
@ -550,9 +550,9 @@ class ResizeLink(policy.PolicyTargetMixin, tables.LinkAction):
|
||||||
return "?".join([base_url, param])
|
return "?".join([base_url, param])
|
||||||
|
|
||||||
def allowed(self, request, instance):
|
def allowed(self, request, instance):
|
||||||
return ((instance.status in ACTIVE_STATES
|
return ((instance.status in ACTIVE_STATES or
|
||||||
or instance.status == 'SHUTOFF')
|
instance.status == 'SHUTOFF') and
|
||||||
and not is_deleting(instance))
|
not is_deleting(instance))
|
||||||
|
|
||||||
|
|
||||||
class ConfirmResize(policy.PolicyTargetMixin, tables.Action):
|
class ConfirmResize(policy.PolicyTargetMixin, tables.Action):
|
||||||
|
@ -590,9 +590,9 @@ class RebuildInstance(policy.PolicyTargetMixin, tables.LinkAction):
|
||||||
action_type = "danger"
|
action_type = "danger"
|
||||||
|
|
||||||
def allowed(self, request, instance):
|
def allowed(self, request, instance):
|
||||||
return ((instance.status in ACTIVE_STATES
|
return ((instance.status in ACTIVE_STATES or
|
||||||
or instance.status == 'SHUTOFF')
|
instance.status == 'SHUTOFF') and
|
||||||
and not is_deleting(instance))
|
not is_deleting(instance))
|
||||||
|
|
||||||
def get_link_url(self, datum):
|
def get_link_url(self, datum):
|
||||||
instance_id = self.table.get_object_id(datum)
|
instance_id = self.table.get_object_id(datum)
|
||||||
|
@ -609,11 +609,11 @@ class DecryptInstancePassword(tables.LinkAction):
|
||||||
enable = getattr(settings,
|
enable = getattr(settings,
|
||||||
'OPENSTACK_ENABLE_PASSWORD_RETRIEVE',
|
'OPENSTACK_ENABLE_PASSWORD_RETRIEVE',
|
||||||
False)
|
False)
|
||||||
return (enable
|
return (enable and
|
||||||
and (instance.status in ACTIVE_STATES
|
(instance.status in ACTIVE_STATES or
|
||||||
or instance.status == 'SHUTOFF')
|
instance.status == 'SHUTOFF') and
|
||||||
and not is_deleting(instance)
|
not is_deleting(instance) and
|
||||||
and get_keyname(instance) is not None)
|
get_keyname(instance) is not None)
|
||||||
|
|
||||||
def get_link_url(self, datum):
|
def get_link_url(self, datum):
|
||||||
instance_id = self.table.get_object_id(datum)
|
instance_id = self.table.get_object_id(datum)
|
||||||
|
@ -831,9 +831,9 @@ class StopInstance(policy.PolicyTargetMixin, tables.BatchAction):
|
||||||
)
|
)
|
||||||
|
|
||||||
def allowed(self, request, instance):
|
def allowed(self, request, instance):
|
||||||
return ((instance is None)
|
return (instance is None or
|
||||||
or ((get_power_state(instance) in ("RUNNING", "SUSPENDED"))
|
(get_power_state(instance) in ("RUNNING", "SUSPENDED") and
|
||||||
and not is_deleting(instance)))
|
not is_deleting(instance)))
|
||||||
|
|
||||||
def action(self, request, obj_id):
|
def action(self, request, obj_id):
|
||||||
api.nova.server_stop(request, obj_id)
|
api.nova.server_stop(request, obj_id)
|
||||||
|
@ -918,9 +918,9 @@ class AttachVolume(tables.LinkAction):
|
||||||
# is not active, or the instance is being deleted
|
# is not active, or the instance is being deleted
|
||||||
# or cinder is not enabled
|
# or cinder is not enabled
|
||||||
def allowed(self, request, instance=None):
|
def allowed(self, request, instance=None):
|
||||||
return instance.status in ("ACTIVE") \
|
return (instance.status in ("ACTIVE") and
|
||||||
and not is_deleting(instance) \
|
not is_deleting(instance) and
|
||||||
and api.cinder.is_volume_service_enabled(request)
|
api.cinder.is_volume_service_enabled(request))
|
||||||
|
|
||||||
|
|
||||||
class DetachVolume(AttachVolume):
|
class DetachVolume(AttachVolume):
|
||||||
|
@ -933,9 +933,9 @@ class DetachVolume(AttachVolume):
|
||||||
# is not active, or the instance is being deleted
|
# is not active, or the instance is being deleted
|
||||||
# or cinder is not enabled
|
# or cinder is not enabled
|
||||||
def allowed(self, request, instance=None):
|
def allowed(self, request, instance=None):
|
||||||
return instance.status in ("ACTIVE") \
|
return (instance.status in ("ACTIVE") and
|
||||||
and not is_deleting(instance) \
|
not is_deleting(instance) and
|
||||||
and api.cinder.is_volume_service_enabled(request)
|
api.cinder.is_volume_service_enabled(request))
|
||||||
|
|
||||||
|
|
||||||
class AttachInterface(policy.PolicyTargetMixin, tables.LinkAction):
|
class AttachInterface(policy.PolicyTargetMixin, tables.LinkAction):
|
||||||
|
@ -946,10 +946,10 @@ class AttachInterface(policy.PolicyTargetMixin, tables.LinkAction):
|
||||||
policy_rules = (("compute", "os_compute_api:os-attach-interfaces"),)
|
policy_rules = (("compute", "os_compute_api:os-attach-interfaces"),)
|
||||||
|
|
||||||
def allowed(self, request, instance):
|
def allowed(self, request, instance):
|
||||||
return ((instance.status in ACTIVE_STATES
|
return ((instance.status in ACTIVE_STATES or
|
||||||
or instance.status == 'SHUTOFF')
|
instance.status == 'SHUTOFF') and
|
||||||
and not is_deleting(instance)
|
not is_deleting(instance) and
|
||||||
and api.base.is_service_enabled(request, 'network'))
|
api.base.is_service_enabled(request, 'network'))
|
||||||
|
|
||||||
def get_link_url(self, datum):
|
def get_link_url(self, datum):
|
||||||
instance_id = self.table.get_object_id(datum)
|
instance_id = self.table.get_object_id(datum)
|
||||||
|
|
|
@ -519,8 +519,9 @@ class SetInstanceDetails(workflows.Step):
|
||||||
def contribute(self, data, context):
|
def contribute(self, data, context):
|
||||||
context = super(SetInstanceDetails, self).contribute(data, context)
|
context = super(SetInstanceDetails, self).contribute(data, context)
|
||||||
# Allow setting the source dynamically.
|
# Allow setting the source dynamically.
|
||||||
if ("source_type" in context and "source_id" in context
|
if ("source_type" in context and
|
||||||
and context["source_type"] not in context):
|
"source_id" in context and
|
||||||
|
context["source_type"] not in context):
|
||||||
context[context["source_type"]] = context["source_id"]
|
context[context["source_type"]] = context["source_id"]
|
||||||
|
|
||||||
# Translate form input to context for source values.
|
# Translate form input to context for source values.
|
||||||
|
|
|
@ -30,10 +30,9 @@ class NetworkQoS(horizon.Panel):
|
||||||
request = context['request']
|
request = context['request']
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
super(NetworkQoS, self).allowed(context)
|
super(NetworkQoS, self).allowed(context) and
|
||||||
and request.user.has_perms(self.permissions)
|
request.user.has_perms(self.permissions) and
|
||||||
and neutron.is_extension_supported(request,
|
neutron.is_extension_supported(request, extension_alias='qos')
|
||||||
extension_alias='qos')
|
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error("Call to list enabled services failed. This is likely "
|
LOG.error("Call to list enabled services failed. This is likely "
|
||||||
|
|
|
@ -220,15 +220,15 @@ class JSONView(View):
|
||||||
def add_resource_url(self, view, resources):
|
def add_resource_url(self, view, resources):
|
||||||
tenant_id = self.request.user.tenant_id
|
tenant_id = self.request.user.tenant_id
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
if (resource.get('tenant_id')
|
if (resource.get('tenant_id') and
|
||||||
and tenant_id != resource.get('tenant_id')):
|
tenant_id != resource.get('tenant_id')):
|
||||||
continue
|
continue
|
||||||
resource['url'] = reverse(view, None, [str(resource['id'])])
|
resource['url'] = reverse(view, None, [str(resource['id'])])
|
||||||
|
|
||||||
def _check_router_external_port(self, ports, router_id, network_id):
|
def _check_router_external_port(self, ports, router_id, network_id):
|
||||||
for port in ports:
|
for port in ports:
|
||||||
if (port['network_id'] == network_id
|
if (port['network_id'] == network_id and
|
||||||
and port['device_id'] == router_id):
|
port['device_id'] == router_id):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -361,8 +361,8 @@ class JSONView(View):
|
||||||
'status': self.trans.port[port.status],
|
'status': self.trans.port[port.status],
|
||||||
'original_status': port.status}
|
'original_status': port.status}
|
||||||
for port in neutron_ports
|
for port in neutron_ports
|
||||||
if port.device_owner != 'network:router_ha_interface'
|
if (port.device_owner != 'network:router_ha_interface' and
|
||||||
and port.network_id in tenant_network_ids]
|
port.network_id in tenant_network_ids)]
|
||||||
self.add_resource_url('horizon:project:networks:ports:detail',
|
self.add_resource_url('horizon:project:networks:ports:detail',
|
||||||
ports)
|
ports)
|
||||||
return ports
|
return ports
|
||||||
|
|
|
@ -82,8 +82,9 @@ class DetailView(tabs.TabbedTableView):
|
||||||
msg = _('Unable to retrieve port details.')
|
msg = _('Unable to retrieve port details.')
|
||||||
exceptions.handle(self.request, msg, redirect=redirect)
|
exceptions.handle(self.request, msg, redirect=redirect)
|
||||||
|
|
||||||
if (api.neutron.is_extension_supported(self.request, 'mac-learning')
|
if (api.neutron.is_extension_supported(self.request,
|
||||||
and not hasattr(port, 'mac_state')):
|
'mac-learning') and
|
||||||
|
not hasattr(port, 'mac_state')):
|
||||||
port.mac_state = api.neutron.OFF_STATE
|
port.mac_state = api.neutron.OFF_STATE
|
||||||
|
|
||||||
return port
|
return port
|
||||||
|
|
|
@ -272,8 +272,8 @@ class CreatePort(workflows.Workflow):
|
||||||
# If port_security_enabled is set to False, security groups on the port
|
# If port_security_enabled is set to False, security groups on the port
|
||||||
# must be cleared. We will clear the current security groups
|
# must be cleared. We will clear the current security groups
|
||||||
# in this case.
|
# in this case.
|
||||||
if ('port_security_enabled' in params
|
if ('port_security_enabled' in params and
|
||||||
and not params['port_security_enabled']):
|
not params['port_security_enabled']):
|
||||||
params['security_groups'] = []
|
params['security_groups'] = []
|
||||||
# In case of CreatePortSecurityGroup registered, 'wanted_groups'
|
# In case of CreatePortSecurityGroup registered, 'wanted_groups'
|
||||||
# exists in context.
|
# exists in context.
|
||||||
|
@ -421,8 +421,8 @@ class UpdatePort(workflows.Workflow):
|
||||||
# If port_security_enabled is set to False, security groups on the port
|
# If port_security_enabled is set to False, security groups on the port
|
||||||
# must be cleared. We will clear the current security groups
|
# must be cleared. We will clear the current security groups
|
||||||
# in this case.
|
# in this case.
|
||||||
if ('port_security_enabled' in params
|
if ('port_security_enabled' in params and
|
||||||
and not params['port_security_enabled']):
|
not params['port_security_enabled']):
|
||||||
params['security_groups'] = []
|
params['security_groups'] = []
|
||||||
# In case of UpdatePortSecurityGroup registered, 'wanted_groups'
|
# In case of UpdatePortSecurityGroup registered, 'wanted_groups'
|
||||||
# exists in data.
|
# exists in data.
|
||||||
|
|
|
@ -67,8 +67,8 @@ class ExtraRoutesTable(tables.DataTable):
|
||||||
|
|
||||||
def get_object_display(self, datum):
|
def get_object_display(self, datum):
|
||||||
"""Display ExtraRoutes when deleted."""
|
"""Display ExtraRoutes when deleted."""
|
||||||
return (super(ExtraRoutesTable, self).get_object_display(datum)
|
return (super(ExtraRoutesTable, self).get_object_display(datum) or
|
||||||
or datum.destination + " -> " + datum.nexthop)
|
datum.destination + " -> " + datum.nexthop)
|
||||||
|
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
name = "extra_routes"
|
name = "extra_routes"
|
||||||
|
|
|
@ -69,8 +69,8 @@ class AddInterface(forms.SelfHandlingForm):
|
||||||
'%s%s (%s)' % (net_name, subnet.cidr,
|
'%s%s (%s)' % (net_name, subnet.cidr,
|
||||||
subnet.name or subnet.id))
|
subnet.name or subnet.id))
|
||||||
for subnet in n['subnets']
|
for subnet in n['subnets']
|
||||||
if subnet.id not in router_subnet_ids
|
if (subnet.id not in router_subnet_ids and
|
||||||
and subnet.gateway_ip]
|
subnet.gateway_ip)]
|
||||||
if choices:
|
if choices:
|
||||||
choices.insert(0, ("", _("Select Subnet")))
|
choices.insert(0, ("", _("Select Subnet")))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -204,9 +204,9 @@ def check_rule_template(port, ip_proto):
|
||||||
if not rules_dict:
|
if not rules_dict:
|
||||||
return port
|
return port
|
||||||
templ_rule = [rule for rule in rules_dict.values()
|
templ_rule = [rule for rule in rules_dict.values()
|
||||||
if (str(port) == rule['from_port']
|
if (str(port) == rule['from_port'] and
|
||||||
and str(port) == rule['to_port']
|
str(port) == rule['to_port'] and
|
||||||
and ip_proto == rule['ip_protocol'])]
|
ip_proto == rule['ip_protocol'])]
|
||||||
if templ_rule:
|
if templ_rule:
|
||||||
return u"%(from_port)s (%(name)s)" % templ_rule[0]
|
return u"%(from_port)s (%(name)s)" % templ_rule[0]
|
||||||
return port
|
return port
|
||||||
|
|
|
@ -30,8 +30,8 @@ class ServerGroups(horizon.Panel):
|
||||||
request = context['request']
|
request = context['request']
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
super(ServerGroups, self).allowed(context)
|
super(ServerGroups, self).allowed(context) and
|
||||||
and request.user.has_perms(self.permissions)
|
request.user.has_perms(self.permissions)
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("Call to list enabled services failed. This is "
|
LOG.exception("Call to list enabled services failed. This is "
|
||||||
|
|
|
@ -32,10 +32,10 @@ class Trunks(horizon.Panel):
|
||||||
request = context['request']
|
request = context['request']
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
super(Trunks, self).allowed(context)
|
super(Trunks, self).allowed(context) and
|
||||||
and request.user.has_perms(self.permissions)
|
request.user.has_perms(self.permissions) and
|
||||||
and neutron.is_extension_supported(request,
|
neutron.is_extension_supported(request,
|
||||||
extension_alias='trunk')
|
extension_alias='trunk')
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error("Call to list enabled services failed. This is likely "
|
LOG.error("Call to list enabled services failed. This is likely "
|
||||||
|
|
|
@ -141,10 +141,10 @@ class CreateVolume(tables.LinkAction):
|
||||||
def allowed(self, request, volume=None):
|
def allowed(self, request, volume=None):
|
||||||
limits = api.cinder.tenant_absolute_limits(request)
|
limits = api.cinder.tenant_absolute_limits(request)
|
||||||
|
|
||||||
gb_available = (limits.get('maxTotalVolumeGigabytes', float("inf"))
|
gb_available = (limits.get('maxTotalVolumeGigabytes', float("inf")) -
|
||||||
- limits.get('totalGigabytesUsed', 0))
|
limits.get('totalGigabytesUsed', 0))
|
||||||
volumes_available = (limits.get('maxTotalVolumes', float("inf"))
|
volumes_available = (limits.get('maxTotalVolumes', float("inf")) -
|
||||||
- limits.get('totalVolumesUsed', 0))
|
limits.get('totalVolumesUsed', 0))
|
||||||
|
|
||||||
if gb_available <= 0 or volumes_available <= 0:
|
if gb_available <= 0 or volumes_available <= 0:
|
||||||
if "disabled" not in self.classes:
|
if "disabled" not in self.classes:
|
||||||
|
@ -217,8 +217,8 @@ class CreateSnapshot(VolumePolicyTargetMixin, tables.LinkAction):
|
||||||
exceptions.handle(request, _('Unable to retrieve tenant limits.'))
|
exceptions.handle(request, _('Unable to retrieve tenant limits.'))
|
||||||
limits = {}
|
limits = {}
|
||||||
|
|
||||||
snapshots_available = (limits.get('maxTotalSnapshots', float("inf"))
|
snapshots_available = (limits.get('maxTotalSnapshots', float("inf")) -
|
||||||
- limits.get('totalSnapshotsUsed', 0))
|
limits.get('totalSnapshotsUsed', 0))
|
||||||
|
|
||||||
if snapshots_available <= 0 and "disabled" not in self.classes:
|
if snapshots_available <= 0 and "disabled" not in self.classes:
|
||||||
self.classes = [c for c in self.classes] + ['disabled']
|
self.classes = [c for c in self.classes] + ['disabled']
|
||||||
|
|
|
@ -280,8 +280,8 @@ class ExtendView(forms.ModalFormView):
|
||||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||||
try:
|
try:
|
||||||
usages = quotas.tenant_limit_usages(self.request)
|
usages = quotas.tenant_limit_usages(self.request)
|
||||||
usages['totalGigabytesUsed'] = (usages['totalGigabytesUsed']
|
usages['totalGigabytesUsed'] = (usages['totalGigabytesUsed'] -
|
||||||
- context['volume'].size)
|
context['volume'].size)
|
||||||
context['usages'] = usages
|
context['usages'] = usages
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(self.request)
|
exceptions.handle(self.request)
|
||||||
|
|
|
@ -48,8 +48,9 @@ class ApiaccessPage(basepage.BaseNavigationPage):
|
||||||
self.apiaccess_table.download_openstack_rc_v3()
|
self.apiaccess_table.download_openstack_rc_v3()
|
||||||
|
|
||||||
def list_of_files(self, directory, template):
|
def list_of_files(self, directory, template):
|
||||||
return [f for f in listdir(directory) if isfile(join(directory, f))
|
return [f for f in listdir(directory)
|
||||||
and f.endswith(template)]
|
if (isfile(join(directory, f)) and
|
||||||
|
f.endswith(template))]
|
||||||
|
|
||||||
def get_credentials_from_file(self, version, directory, template):
|
def get_credentials_from_file(self, version, directory, template):
|
||||||
self._wait_until(
|
self._wait_until(
|
||||||
|
|
|
@ -72,7 +72,7 @@ class FloatingipsPage(basepage.BaseNavigationPage):
|
||||||
floatingip_form = self.floatingips_table.allocate_ip()
|
floatingip_form = self.floatingips_table.allocate_ip()
|
||||||
floatingip_form.submit()
|
floatingip_form.submit()
|
||||||
ip = re.compile('(([2][5][0-5]\.)|([2][0-4][0-9]\.)'
|
ip = re.compile('(([2][5][0-5]\.)|([2][0-4][0-9]\.)'
|
||||||
+ '|([0-1]?[0-9]?[0-9]\.)){3}(([2][5][0-5])|'
|
'|([0-1]?[0-9]?[0-9]\.)){3}(([2][5][0-5])|'
|
||||||
'([2][0-4][0-9])|([0-1]?[0-9]?[0-9]))')
|
'([2][0-4][0-9])|([0-1]?[0-9]?[0-9]))')
|
||||||
match = ip.search((self._get_element(
|
match = ip.search((self._get_element(
|
||||||
*self._floatingips_fadein_popup_locator)).text)
|
*self._floatingips_fadein_popup_locator)).text)
|
||||||
|
|
|
@ -62,8 +62,7 @@ class NeutronNetworksTestCase(test.TestCase):
|
||||||
response = neutron.Networks().post(request)
|
response = neutron.Networks().post(request)
|
||||||
self.assertStatusCode(response, 201)
|
self.assertStatusCode(response, 201)
|
||||||
self.assertEqual(response['location'],
|
self.assertEqual(response['location'],
|
||||||
'/api/neutron/networks/'
|
'/api/neutron/networks/' + self.networks.first().id)
|
||||||
+ self.networks.first().id)
|
|
||||||
exp_resp = self._dictify_network(self.networks.first())
|
exp_resp = self._dictify_network(self.networks.first())
|
||||||
self.assertEqual(response.json, exp_resp)
|
self.assertEqual(response.json, exp_resp)
|
||||||
mock_network_create.assert_called_once_with(request, **expected)
|
mock_network_create.assert_called_once_with(request, **expected)
|
||||||
|
|
|
@ -457,9 +457,9 @@ class NeutronApiTests(test.APIMockTestCase):
|
||||||
expected_parent_port_ids.add(trunk['port_id'])
|
expected_parent_port_ids.add(trunk['port_id'])
|
||||||
expected_subport_ids |= set([p['port_id'] for p
|
expected_subport_ids |= set([p['port_id'] for p
|
||||||
in trunk['sub_ports']])
|
in trunk['sub_ports']])
|
||||||
expected_normal_port_ids = ({p['id'] for p in ports}
|
expected_normal_port_ids = ({p['id'] for p in ports} -
|
||||||
- expected_parent_port_ids
|
expected_parent_port_ids -
|
||||||
- expected_subport_ids)
|
expected_subport_ids)
|
||||||
|
|
||||||
ret_val = api.neutron.port_list_with_trunk_types(self.request)
|
ret_val = api.neutron.port_list_with_trunk_types(self.request)
|
||||||
|
|
||||||
|
@ -469,8 +469,8 @@ class NeutronApiTests(test.APIMockTestCase):
|
||||||
if isinstance(p, api.neutron.PortTrunkParent)}
|
if isinstance(p, api.neutron.PortTrunkParent)}
|
||||||
subport_ids = {p.id for p in ret_val
|
subport_ids = {p.id for p in ret_val
|
||||||
if isinstance(p, api.neutron.PortTrunkSubport)}
|
if isinstance(p, api.neutron.PortTrunkSubport)}
|
||||||
normal_port_ids = ({p.id for p in ret_val}
|
normal_port_ids = ({p.id for p in ret_val} -
|
||||||
- parent_port_ids - subport_ids)
|
parent_port_ids - subport_ids)
|
||||||
self.assertEqual(expected_parent_port_ids, parent_port_ids)
|
self.assertEqual(expected_parent_port_ids, parent_port_ids)
|
||||||
self.assertEqual(expected_subport_ids, subport_ids)
|
self.assertEqual(expected_subport_ids, subport_ids)
|
||||||
self.assertEqual(expected_normal_port_ids, normal_port_ids)
|
self.assertEqual(expected_normal_port_ids, normal_port_ids)
|
||||||
|
|
|
@ -46,9 +46,9 @@ def import_dashboard_config(modules):
|
||||||
if hasattr(submodule, 'DASHBOARD'):
|
if hasattr(submodule, 'DASHBOARD'):
|
||||||
dashboard = submodule.DASHBOARD
|
dashboard = submodule.DASHBOARD
|
||||||
config[dashboard].update(submodule.__dict__)
|
config[dashboard].update(submodule.__dict__)
|
||||||
elif (hasattr(submodule, 'PANEL')
|
elif (hasattr(submodule, 'PANEL') or
|
||||||
or hasattr(submodule, 'PANEL_GROUP')
|
hasattr(submodule, 'PANEL_GROUP') or
|
||||||
or hasattr(submodule, 'FEATURE')):
|
hasattr(submodule, 'FEATURE')):
|
||||||
# If enabled and local.enabled contains a same filename,
|
# If enabled and local.enabled contains a same filename,
|
||||||
# the file loaded later (i.e., local.enabled) will be used.
|
# the file loaded later (i.e., local.enabled) will be used.
|
||||||
name = submodule.__name__.rsplit('.', 1)[1]
|
name = submodule.__name__.rsplit('.', 1)[1]
|
||||||
|
@ -136,8 +136,8 @@ def update_dashboards(modules, horizon_config, installed_apps):
|
||||||
|
|
||||||
add_exceptions = config.get('ADD_EXCEPTIONS', {}).items()
|
add_exceptions = config.get('ADD_EXCEPTIONS', {}).items()
|
||||||
for category, exc_list in add_exceptions:
|
for category, exc_list in add_exceptions:
|
||||||
exceptions[category] = tuple(set(exceptions.get(category, ())
|
exceptions[category] = tuple(set(exceptions.get(category, ()) +
|
||||||
+ exc_list))
|
exc_list))
|
||||||
|
|
||||||
angular_modules.extend(config.get('ADD_ANGULAR_MODULES', []))
|
angular_modules.extend(config.get('ADD_ANGULAR_MODULES', []))
|
||||||
# avoid pulling in dashboard javascript dependencies multiple times
|
# avoid pulling in dashboard javascript dependencies multiple times
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -156,8 +156,7 @@ commands =
|
||||||
filename = *.py,django.wsgi
|
filename = *.py,django.wsgi
|
||||||
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/*
|
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/*
|
||||||
# E402 module level import not at top of file
|
# E402 module level import not at top of file
|
||||||
# W503 line break before binary operator
|
ignore = E402
|
||||||
ignore = E402,W503
|
|
||||||
# Enable the following hacking rules which are disabled by default
|
# Enable the following hacking rules which are disabled by default
|
||||||
# H106 Do not put vim configuration in source files.
|
# H106 Do not put vim configuration in source files.
|
||||||
# H203 Use assertIs(Not)None to check for None.
|
# H203 Use assertIs(Not)None to check for None.
|
||||||
|
|
Loading…
Reference in New Issue