PEP8 E126 has been resolved
Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1 Partial-Bug: #1085346
This commit is contained in:
parent
08a757b0d1
commit
afaa72185c
@ -33,7 +33,7 @@ class Breadcrumb(html.HTMLElement):
|
||||
def get_subfolders(self):
|
||||
if self.subfolder_path and not self._subfolders:
|
||||
(parent, slash, folder) = self.subfolder_path.strip('/') \
|
||||
.rpartition('/')
|
||||
.rpartition('/')
|
||||
while folder:
|
||||
path = "%s%s%s/" % (parent, slash, folder)
|
||||
self._subfolders.insert(0, (folder, path))
|
||||
|
@ -63,7 +63,7 @@ class HorizonMiddleware(object):
|
||||
if last_activity and (timestamp - last_activity).seconds > timeout:
|
||||
request.session.pop('last_activity')
|
||||
response = HttpResponseRedirect(
|
||||
'%s?next=%s' % (settings.LOGOUT_URL, request.path))
|
||||
'%s?next=%s' % (settings.LOGOUT_URL, request.path))
|
||||
reason = _("Session timed out.")
|
||||
utils.add_logout_reason(request, response, reason)
|
||||
return response
|
||||
|
@ -50,16 +50,16 @@ def filesizeformat(bytes, filesize_number_format):
|
||||
"%(size)d", bytes) % {'size': bytes}
|
||||
if bytes < 1024 * 1024:
|
||||
return translation.ugettext_lazy("%s KB") % \
|
||||
filesize_number_format(bytes / 1024)
|
||||
filesize_number_format(bytes / 1024)
|
||||
if bytes < 1024 * 1024 * 1024:
|
||||
return translation.ugettext_lazy("%s MB") % \
|
||||
filesize_number_format(bytes / (1024 * 1024))
|
||||
filesize_number_format(bytes / (1024 * 1024))
|
||||
if bytes < 1024 * 1024 * 1024 * 1024:
|
||||
return translation.ugettext_lazy("%s GB") % \
|
||||
filesize_number_format(bytes / (1024 * 1024 * 1024))
|
||||
filesize_number_format(bytes / (1024 * 1024 * 1024))
|
||||
if bytes < 1024 * 1024 * 1024 * 1024 * 1024:
|
||||
return translation.ugettext_lazy("%s TB") % \
|
||||
filesize_number_format(bytes / (1024 * 1024 * 1024 * 1024))
|
||||
filesize_number_format(bytes / (1024 * 1024 * 1024 * 1024))
|
||||
return translation.ugettext_lazy("%s PB") % \
|
||||
filesize_number_format(bytes / (1024 * 1024 * 1024 * 1024 * 1024))
|
||||
|
||||
|
@ -119,12 +119,12 @@ class SelectWidget(widgets.Select):
|
||||
if not isinstance(option_label, (basestring, Promise)):
|
||||
for data_attr in self.data_attrs:
|
||||
data_value = conditional_escape(
|
||||
force_unicode(getattr(option_label,
|
||||
data_attr, "")))
|
||||
force_unicode(getattr(option_label,
|
||||
data_attr, "")))
|
||||
other_html += ' data-%s="%s"' % (data_attr, data_value)
|
||||
|
||||
if self.transform:
|
||||
option_label = self.transform(option_label)
|
||||
return u'<option value="%s"%s>%s</option>' % (
|
||||
escape(option_value), other_html,
|
||||
conditional_escape(force_unicode(option_label)))
|
||||
escape(option_value), other_html,
|
||||
conditional_escape(force_unicode(option_label)))
|
||||
|
@ -775,8 +775,8 @@ class Workflow(html.HTMLElement):
|
||||
missing = self.depends_on - set(self.context.keys())
|
||||
if missing:
|
||||
raise exceptions.WorkflowValidationError(
|
||||
"Unable to complete the workflow. The values %s are "
|
||||
"required but not present." % ", ".join(missing))
|
||||
"Unable to complete the workflow. The values %s are "
|
||||
"required but not present." % ", ".join(missing))
|
||||
|
||||
# Validate each step. Cycle through all of them to catch all errors
|
||||
# in one pass before returning.
|
||||
|
@ -115,7 +115,7 @@ def volume_snapshot_list(request):
|
||||
|
||||
def volume_snapshot_create(request, volume_id, name, description):
|
||||
return cinderclient(request).volume_snapshots.create(
|
||||
volume_id, display_name=name, display_description=description)
|
||||
volume_id, display_name=name, display_description=description)
|
||||
|
||||
|
||||
def volume_snapshot_delete(request, snapshot_id):
|
||||
|
@ -232,9 +232,10 @@ class SecurityGroupManager(network_base.SecurityGroupManager):
|
||||
% instance_id)
|
||||
if body:
|
||||
# Wrap data in SG objects as novaclient would.
|
||||
sg_objs = [nova_security_groups.SecurityGroup(
|
||||
nclient.security_groups, sg, loaded=True)
|
||||
for sg in body.get('security_groups', [])]
|
||||
sg_objs = [
|
||||
nova_security_groups.SecurityGroup(
|
||||
nclient.security_groups, sg, loaded=True)
|
||||
for sg in body.get('security_groups', [])]
|
||||
# Then wrap novaclient's object with our own. Yes, sadly wrapping
|
||||
# with two layers of objects is necessary.
|
||||
security_groups = [SecurityGroup(sg) for sg in sg_objs]
|
||||
@ -365,7 +366,7 @@ def server_vnc_console(request, instance_id, console_type='novnc'):
|
||||
|
||||
def server_spice_console(request, instance_id, console_type='spice-html5'):
|
||||
return SPICEConsole(novaclient(request).servers.get_spice_console(
|
||||
instance_id, console_type)['console'])
|
||||
instance_id, console_type)['console'])
|
||||
|
||||
|
||||
def flavor_create(request, name, memory, vcpu, disk, flavorid='auto',
|
||||
@ -402,13 +403,13 @@ def flavor_access_list(request, flavor=None):
|
||||
def add_tenant_to_flavor(request, flavor, tenant):
|
||||
"""Add a tenant to the given flavor access list."""
|
||||
return novaclient(request).flavor_access.add_tenant_access(
|
||||
flavor=flavor, tenant=tenant)
|
||||
flavor=flavor, tenant=tenant)
|
||||
|
||||
|
||||
def remove_tenant_from_flavor(request, flavor, tenant):
|
||||
"""Remove a tenant from the given flavor access list."""
|
||||
return novaclient(request).flavor_access.remove_tenant_access(
|
||||
flavor=flavor, tenant=tenant)
|
||||
flavor=flavor, tenant=tenant)
|
||||
|
||||
|
||||
def flavor_get_extras(request, flavor_id, raw=False):
|
||||
@ -460,12 +461,12 @@ def server_create(request, name, image, flavor, key_name, user_data,
|
||||
block_device_mapping_v2=None, nics=None,
|
||||
availability_zone=None, instance_count=1, admin_pass=None):
|
||||
return Server(novaclient(request).servers.create(
|
||||
name, image, flavor, userdata=user_data,
|
||||
security_groups=security_groups,
|
||||
key_name=key_name, block_device_mapping=block_device_mapping,
|
||||
block_device_mapping_v2=block_device_mapping_v2,
|
||||
nics=nics, availability_zone=availability_zone,
|
||||
min_count=instance_count, admin_pass=admin_pass), request)
|
||||
name, image, flavor, userdata=user_data,
|
||||
security_groups=security_groups,
|
||||
key_name=key_name, block_device_mapping=block_device_mapping,
|
||||
block_device_mapping_v2=block_device_mapping_v2,
|
||||
nics=nics, availability_zone=availability_zone,
|
||||
min_count=instance_count, admin_pass=admin_pass), request)
|
||||
|
||||
|
||||
def server_delete(request, instance):
|
||||
|
@ -136,12 +136,12 @@ def vpnservice_create(request, **kwargs):
|
||||
:param router_id: router id for router of VPNService
|
||||
:param subnet_id: subnet id for subnet of VPNService
|
||||
"""
|
||||
body = {'vpnservice': {
|
||||
'admin_state_up': kwargs['admin_state_up'],
|
||||
'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'router_id': kwargs['router_id'],
|
||||
'subnet_id': kwargs['subnet_id']}
|
||||
body = {'vpnservice':
|
||||
{'admin_state_up': kwargs['admin_state_up'],
|
||||
'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'router_id': kwargs['router_id'],
|
||||
'subnet_id': kwargs['subnet_id']}
|
||||
}
|
||||
vpnservice = neutronclient(request).create_vpnservice(body).get(
|
||||
'vpnservice')
|
||||
@ -182,17 +182,15 @@ def ikepolicy_create(request, **kwargs):
|
||||
:param pfs: Perfect Forward Secrecy for IKEPolicy
|
||||
:param phase1_negotiation_mode: IKE Phase1 negotiation mode for IKEPolicy
|
||||
"""
|
||||
body = {'ikepolicy': {
|
||||
'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'auth_algorithm': kwargs['auth_algorithm'],
|
||||
'encryption_algorithm': kwargs[
|
||||
'encryption_algorithm'],
|
||||
'ike_version': kwargs['ike_version'],
|
||||
'lifetime': kwargs['lifetime'],
|
||||
'pfs': kwargs['pfs'],
|
||||
'phase1_negotiation_mode': kwargs[
|
||||
'phase1_negotiation_mode']}
|
||||
body = {'ikepolicy':
|
||||
{'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'auth_algorithm': kwargs['auth_algorithm'],
|
||||
'encryption_algorithm': kwargs['encryption_algorithm'],
|
||||
'ike_version': kwargs['ike_version'],
|
||||
'lifetime': kwargs['lifetime'],
|
||||
'pfs': kwargs['pfs'],
|
||||
'phase1_negotiation_mode': kwargs['phase1_negotiation_mode']}
|
||||
}
|
||||
ikepolicy = neutronclient(request).create_ikepolicy(body).get(
|
||||
'ikepolicy')
|
||||
@ -233,15 +231,15 @@ def ipsecpolicy_create(request, **kwargs):
|
||||
:param pfs: Perfect Forward Secrecy for IPSecPolicy
|
||||
:param transform_protocol: Transform Protocol for IPSecPolicy
|
||||
"""
|
||||
body = {'ipsecpolicy': {
|
||||
'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'auth_algorithm': kwargs['auth_algorithm'],
|
||||
'encapsulation_mode': kwargs['encapsulation_mode'],
|
||||
'encryption_algorithm': kwargs['encryption_algorithm'],
|
||||
'lifetime': kwargs['lifetime'],
|
||||
'pfs': kwargs['pfs'],
|
||||
'transform_protocol': kwargs['transform_protocol']}
|
||||
body = {'ipsecpolicy':
|
||||
{'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'auth_algorithm': kwargs['auth_algorithm'],
|
||||
'encapsulation_mode': kwargs['encapsulation_mode'],
|
||||
'encryption_algorithm': kwargs['encryption_algorithm'],
|
||||
'lifetime': kwargs['lifetime'],
|
||||
'pfs': kwargs['pfs'],
|
||||
'transform_protocol': kwargs['transform_protocol']}
|
||||
}
|
||||
ipsecpolicy = neutronclient(request).create_ipsecpolicy(body).get(
|
||||
'ipsecpolicy')
|
||||
@ -288,20 +286,20 @@ def ipsecsiteconnection_create(request, **kwargs):
|
||||
:param vpnservice_id: VPNService associated with this connection
|
||||
:param admin_state_up: admin state (default on)
|
||||
"""
|
||||
body = {'ipsec_site_connection': {
|
||||
'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'dpd': kwargs['dpd'],
|
||||
'ikepolicy_id': kwargs['ikepolicy_id'],
|
||||
'initiator': kwargs['initiator'],
|
||||
'ipsecpolicy_id': kwargs['ipsecpolicy_id'],
|
||||
'mtu': kwargs['mtu'],
|
||||
'peer_address': kwargs['peer_address'],
|
||||
'peer_cidrs': kwargs['peer_cidrs'],
|
||||
'peer_id': kwargs['peer_id'],
|
||||
'psk': kwargs['psk'],
|
||||
'vpnservice_id': kwargs['vpnservice_id'],
|
||||
'admin_state_up': kwargs['admin_state_up']}
|
||||
body = {'ipsec_site_connection':
|
||||
{'name': kwargs['name'],
|
||||
'description': kwargs['description'],
|
||||
'dpd': kwargs['dpd'],
|
||||
'ikepolicy_id': kwargs['ikepolicy_id'],
|
||||
'initiator': kwargs['initiator'],
|
||||
'ipsecpolicy_id': kwargs['ipsecpolicy_id'],
|
||||
'mtu': kwargs['mtu'],
|
||||
'peer_address': kwargs['peer_address'],
|
||||
'peer_cidrs': kwargs['peer_cidrs'],
|
||||
'peer_id': kwargs['peer_id'],
|
||||
'psk': kwargs['psk'],
|
||||
'vpnservice_id': kwargs['vpnservice_id'],
|
||||
'admin_state_up': kwargs['admin_state_up']}
|
||||
}
|
||||
ipsecsiteconnection = neutronclient(request).create_ipsec_site_connection(
|
||||
body).get('ipsec_site_connection')
|
||||
|
@ -23,7 +23,7 @@ from horizon import workflows
|
||||
|
||||
from openstack_dashboard.dashboards.admin.defaults import tabs as project_tabs
|
||||
from openstack_dashboard.dashboards.admin.defaults import workflows as \
|
||||
project_workflows
|
||||
project_workflows
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
|
||||
|
@ -238,8 +238,8 @@ class UpdateFlavorInfoAction(CreateFlavorInfoAction):
|
||||
for flavor in flavors:
|
||||
if flavor.name == name and flavor.id != flavor_id:
|
||||
raise forms.ValidationError(
|
||||
_('The name "%s" is already used by another '
|
||||
'flavor.') % name)
|
||||
_('The name "%s" is already used by another '
|
||||
'flavor.') % name)
|
||||
return self.cleaned_data
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack_dashboard.dashboards.project.images_and_snapshots \
|
||||
.images import forms
|
||||
.images import forms
|
||||
|
||||
|
||||
class AdminCreateImageForm(forms.CreateImageForm):
|
||||
|
@ -40,12 +40,12 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([self.images.list(),
|
||||
False])
|
||||
.AndReturn([self.images.list(),
|
||||
False])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(
|
||||
reverse('horizon:admin:images:index'))
|
||||
reverse('horizon:admin:images:index'))
|
||||
self.assertTemplateUsed(res, 'admin/images/index.html')
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
len(self.images.list()))
|
||||
|
@ -28,7 +28,7 @@ from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.project \
|
||||
.images_and_snapshots.images import views
|
||||
.images_and_snapshots.images import views
|
||||
|
||||
from openstack_dashboard.dashboards.admin.images import forms
|
||||
from openstack_dashboard.dashboards.admin.images \
|
||||
|
@ -71,7 +71,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
AndReturn([tenants, False])
|
||||
for server in servers:
|
||||
api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \
|
||||
AndReturn(full_flavors[server.flavor["id"]])
|
||||
AndReturn(full_flavors[server.flavor["id"]])
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -104,7 +104,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
AndReturn([tenants, False])
|
||||
for server in servers:
|
||||
api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \
|
||||
AndRaise(self.exceptions.nova)
|
||||
AndRaise(self.exceptions.nova)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(reverse('horizon:admin:instances:index'))
|
||||
|
@ -69,10 +69,10 @@ class AdminIndexView(tables.DataTableView):
|
||||
project_tables.AdminInstancesTable._meta.pagination_param, None)
|
||||
try:
|
||||
instances, self._more = api.nova.server_list(
|
||||
self.request,
|
||||
search_opts={'marker': marker,
|
||||
'paginate': True},
|
||||
all_tenants=True)
|
||||
self.request,
|
||||
search_opts={'marker': marker,
|
||||
'paginate': True},
|
||||
all_tenants=True)
|
||||
except Exception:
|
||||
self._more = False
|
||||
exceptions.handle(self.request,
|
||||
@ -105,7 +105,7 @@ class AdminIndexView(tables.DataTableView):
|
||||
# If the flavor_id is not in full_flavors list,
|
||||
# gets it via nova api.
|
||||
inst.full_flavor = api.nova.flavor_get(
|
||||
self.request, flavor_id)
|
||||
self.request, flavor_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve instance size information.')
|
||||
exceptions.handle(self.request, msg)
|
||||
|
@ -28,10 +28,10 @@ from openstack_dashboard.dashboards.admin.metering import tables
|
||||
def make_tenant_queries(request, days_before=30):
|
||||
try:
|
||||
tenants, more = api.keystone.tenant_list(
|
||||
request,
|
||||
domain=None,
|
||||
paginate=True,
|
||||
marker="tenant_marker")
|
||||
request,
|
||||
domain=None,
|
||||
paginate=True,
|
||||
marker="tenant_marker")
|
||||
except Exception:
|
||||
tenants = []
|
||||
exceptions.handle(request,
|
||||
@ -39,9 +39,9 @@ def make_tenant_queries(request, days_before=30):
|
||||
queries = {}
|
||||
for tenant in tenants:
|
||||
tenant_query = [{
|
||||
"field": "project_id",
|
||||
"op": "eq",
|
||||
"value": tenant.id}]
|
||||
"field": "project_id",
|
||||
"op": "eq",
|
||||
"value": tenant.id}]
|
||||
|
||||
queries[tenant.name] = tenant_query
|
||||
|
||||
|
@ -93,9 +93,9 @@ class SamplesView(TemplateView):
|
||||
queries = {}
|
||||
for tenant in tenants:
|
||||
tenant_query = [{
|
||||
"field": "project_id",
|
||||
"op": "eq",
|
||||
"value": tenant.id}]
|
||||
"field": "project_id",
|
||||
"op": "eq",
|
||||
"value": tenant.id}]
|
||||
|
||||
queries[tenant.name] = tenant_query
|
||||
|
||||
|
@ -154,7 +154,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
def test_network_create_get(self):
|
||||
tenants = self.tenants.list()
|
||||
api.keystone.tenant_list(IsA(
|
||||
http.HttpRequest)).AndReturn([tenants, False])
|
||||
http.HttpRequest)).AndReturn([tenants, False])
|
||||
# TODO(absubram): Remove if clause and create separate
|
||||
# test stubs for when profile_support is being used.
|
||||
# Additionally ensure those are always run even in default setting
|
||||
|
@ -78,7 +78,7 @@ class IndexView(tables.DataTableView):
|
||||
def get_data(self):
|
||||
tenants = []
|
||||
marker = self.request.GET.get(
|
||||
project_tables.TenantsTable._meta.pagination_param, None)
|
||||
project_tables.TenantsTable._meta.pagination_param, None)
|
||||
domain_context = self.request.session.get('domain_context', None)
|
||||
try:
|
||||
tenants, self._more = api.keystone.tenant_list(
|
||||
|
@ -522,11 +522,11 @@ class UpdateProject(workflows.Workflow):
|
||||
# update project info
|
||||
try:
|
||||
project = api.keystone.tenant_update(
|
||||
request,
|
||||
project_id,
|
||||
name=data['name'],
|
||||
description=data['description'],
|
||||
enabled=data['enabled'])
|
||||
request,
|
||||
project_id,
|
||||
name=data['name'],
|
||||
description=data['description'],
|
||||
enabled=data['enabled'])
|
||||
# Use the domain_id from the project if available
|
||||
domain_id = getattr(project, "domain_id", None)
|
||||
except Exception:
|
||||
|
@ -329,8 +329,8 @@ class UsersViewTests(test.BaseAdminViewTests):
|
||||
res = self.client.post(USER_UPDATE_URL, formData)
|
||||
|
||||
self.assertFormError(
|
||||
res, "form", 'password',
|
||||
['Password must be between 8 and 18 characters.'])
|
||||
res, "form", 'password',
|
||||
['Password must be between 8 and 18 characters.'])
|
||||
|
||||
@test.create_stubs({api.keystone: ('domain_get',
|
||||
'user_get',
|
||||
@ -360,8 +360,8 @@ class UsersViewTests(test.BaseAdminViewTests):
|
||||
res = self.client.post(USER_UPDATE_URL, formData)
|
||||
|
||||
self.assertFormError(
|
||||
res, "form", 'password',
|
||||
['Password must be between 8 and 18 characters.'])
|
||||
res, "form", 'password',
|
||||
['Password must be between 8 and 18 characters.'])
|
||||
|
||||
@test.create_stubs({api.keystone: ('user_update_enabled', 'user_list')})
|
||||
def test_enable_user(self):
|
||||
|
@ -63,7 +63,7 @@ class KeyPairViewTests(test.TestCase):
|
||||
|
||||
def test_create_keypair_get(self):
|
||||
res = self.client.get(
|
||||
reverse('horizon:project:access_and_security:keypairs:create'))
|
||||
reverse('horizon:project:access_and_security:keypairs:create'))
|
||||
self.assertTemplateUsed(res,
|
||||
'project/access_and_security/keypairs/create.html')
|
||||
|
||||
@ -74,7 +74,7 @@ class KeyPairViewTests(test.TestCase):
|
||||
kwargs={'keypair_name': keypair_name})
|
||||
res = self.client.get(url, context)
|
||||
self.assertTemplateUsed(
|
||||
res, 'project/access_and_security/keypairs/download.html')
|
||||
res, 'project/access_and_security/keypairs/download.html')
|
||||
|
||||
def test_generate_keypair_get(self):
|
||||
keypair = self.keypairs.first()
|
||||
@ -141,4 +141,4 @@ class KeyPairViewTests(test.TestCase):
|
||||
res = self.client.get(url, context)
|
||||
|
||||
self.assertRedirectsNoFollow(
|
||||
res, reverse('horizon:project:access_and_security:index'))
|
||||
res, reverse('horizon:project:access_and_security:index'))
|
||||
|
@ -97,8 +97,8 @@ class AddRule(forms.SelfHandlingForm):
|
||||
id = forms.CharField(widget=forms.HiddenInput())
|
||||
rule_menu = forms.ChoiceField(label=_('Rule'),
|
||||
widget=forms.Select(attrs={
|
||||
'class': 'switchable',
|
||||
'data-slug': 'rule_menu'}))
|
||||
'class': 'switchable',
|
||||
'data-slug': 'rule_menu'}))
|
||||
|
||||
# "direction" field is enabled only when custom mode.
|
||||
# It is because most common rules in local_settings.py is meaningful
|
||||
@ -365,15 +365,15 @@ class AddRule(forms.SelfHandlingForm):
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
rule = api.network.security_group_rule_create(
|
||||
request,
|
||||
filters.get_int_or_uuid(data['id']),
|
||||
data['direction'],
|
||||
data['ethertype'],
|
||||
data['ip_protocol'],
|
||||
data['from_port'],
|
||||
data['to_port'],
|
||||
data['cidr'],
|
||||
data['security_group'])
|
||||
request,
|
||||
filters.get_int_or_uuid(data['id']),
|
||||
data['direction'],
|
||||
data['ethertype'],
|
||||
data['ip_protocol'],
|
||||
data['from_port'],
|
||||
data['to_port'],
|
||||
data['cidr'],
|
||||
data['security_group'])
|
||||
messages.success(request,
|
||||
_('Successfully added rule: %s') % unicode(rule))
|
||||
return rule
|
||||
|
@ -187,7 +187,7 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
rule.ip_range['cidr'],
|
||||
None).AndReturn(rule)
|
||||
api.network.security_group_list(
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
formData = {'method': 'AddRule',
|
||||
@ -219,7 +219,7 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
rule.ip_range['cidr'],
|
||||
None).AndReturn(rule)
|
||||
api.network.security_group_list(
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
formData = {'method': 'AddRule',
|
||||
@ -620,7 +620,7 @@ class SecurityGroupsNeutronTests(SecurityGroupsViewTests):
|
||||
37, None, None, 'fe80::/48',
|
||||
None).AndReturn(rule)
|
||||
api.network.security_group_list(
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
formData = {'method': 'AddRule',
|
||||
@ -649,7 +649,7 @@ class SecurityGroupsNeutronTests(SecurityGroupsViewTests):
|
||||
'udp', 80, 80, '10.1.1.0/24',
|
||||
None).AndReturn(rule)
|
||||
api.network.security_group_list(
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
IsA(http.HttpRequest)).AndReturn(sec_group_list)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
formData = {'method': 'AddRule',
|
||||
|
@ -127,7 +127,7 @@ class AddRuleView(forms.ModalFormView):
|
||||
security_groups = []
|
||||
for group in groups:
|
||||
if group.id == filters.get_int_or_uuid(
|
||||
self.kwargs['security_group_id']):
|
||||
self.kwargs['security_group_id']):
|
||||
security_groups.append((group.id,
|
||||
_("%s (current)") % group.name))
|
||||
else:
|
||||
|
@ -143,7 +143,7 @@ class CreateImageForm(forms.SelfHandlingForm):
|
||||
image = api.glance.image_create(request, **meta)
|
||||
messages.success(request,
|
||||
_('Your image %s has been queued for creation.') %
|
||||
data['name'])
|
||||
data['name'])
|
||||
return image
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to create new image.'))
|
||||
|
@ -85,8 +85,8 @@ class ImageViewTests(test.TestCase):
|
||||
'description': u'Login with admin/admin',
|
||||
'source_type': u'url',
|
||||
'copy_from': u'http://cloud-images.ubuntu.com/releases/'
|
||||
u'oneiric/release/ubuntu-11.10-server-cloudimg'
|
||||
u'-amd64-disk1.img',
|
||||
u'oneiric/release/ubuntu-11.10-server-cloudimg'
|
||||
u'-amd64-disk1.img',
|
||||
'disk_format': u'qcow2',
|
||||
'minimum_disk': 15,
|
||||
'minimum_ram': 512,
|
||||
@ -161,8 +161,8 @@ class ImageViewTests(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(
|
||||
reverse('horizon:project:images_and_snapshots:images:detail',
|
||||
args=[image.id]))
|
||||
reverse('horizon:project:images_and_snapshots:images:detail',
|
||||
args=[image.id]))
|
||||
self.assertTemplateUsed(res,
|
||||
'project/images_and_snapshots/images/detail.html')
|
||||
self.assertEqual(res.context['image'].name, image.name)
|
||||
@ -177,8 +177,8 @@ class ImageViewTests(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(
|
||||
reverse('horizon:project:images_and_snapshots:images:detail',
|
||||
args=[image.id]))
|
||||
reverse('horizon:project:images_and_snapshots:images:detail',
|
||||
args=[image.id]))
|
||||
self.assertTemplateUsed(res,
|
||||
'project/images_and_snapshots/images/detail.html')
|
||||
self.assertEqual(res.context['image'].protected, image.protected)
|
||||
|
@ -108,7 +108,7 @@ class InstanceTests(test.TestCase):
|
||||
.AndRaise(self.exceptions.nova)
|
||||
for server in servers:
|
||||
api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \
|
||||
AndReturn(full_flavors[server.flavor["id"]])
|
||||
AndReturn(full_flavors[server.flavor["id"]])
|
||||
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
|
||||
.MultipleTimes().AndReturn(self.limits['absolute'])
|
||||
|
||||
@ -143,7 +143,7 @@ class InstanceTests(test.TestCase):
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)).AndReturn(flavors)
|
||||
for server in servers:
|
||||
api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \
|
||||
AndRaise(self.exceptions.nova)
|
||||
AndRaise(self.exceptions.nova)
|
||||
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
|
||||
.MultipleTimes().AndReturn(self.limits['absolute'])
|
||||
|
||||
@ -1328,9 +1328,9 @@ class InstanceTests(test.TestCase):
|
||||
'availability_zone_list',)})
|
||||
def test_launch_flavorlist_error(self):
|
||||
cinder.volume_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.volumes.list())
|
||||
.AndReturn(self.volumes.list())
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.volumes.list())
|
||||
.AndReturn(self.volumes.list())
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
filters={'is_public': True,
|
||||
'status': 'active'}) \
|
||||
|
@ -63,9 +63,9 @@ class IndexView(tables.DataTableView):
|
||||
# Gather our instances
|
||||
try:
|
||||
instances, self._more = api.nova.server_list(
|
||||
self.request,
|
||||
search_opts={'marker': marker,
|
||||
'paginate': True})
|
||||
self.request,
|
||||
search_opts={'marker': marker,
|
||||
'paginate': True})
|
||||
except Exception:
|
||||
self._more = False
|
||||
instances = []
|
||||
|
@ -382,15 +382,15 @@ class SetAccessControlsAction(workflows.Action):
|
||||
"authentication."),
|
||||
add_item_link=KEYPAIR_IMPORT_URL)
|
||||
admin_pass = forms.RegexField(
|
||||
label=_("Admin Pass"),
|
||||
required=False,
|
||||
widget=forms.PasswordInput(render_value=False),
|
||||
regex=validators.password_validator(),
|
||||
error_messages={'invalid': validators.password_validator_msg()})
|
||||
label=_("Admin Pass"),
|
||||
required=False,
|
||||
widget=forms.PasswordInput(render_value=False),
|
||||
regex=validators.password_validator(),
|
||||
error_messages={'invalid': validators.password_validator_msg()})
|
||||
confirm_admin_pass = forms.CharField(
|
||||
label=_("Confirm Admin Pass"),
|
||||
required=False,
|
||||
widget=forms.PasswordInput(render_value=False))
|
||||
label=_("Confirm Admin Pass"),
|
||||
required=False,
|
||||
widget=forms.PasswordInput(render_value=False))
|
||||
groups = forms.MultipleChoiceField(label=_("Security Groups"),
|
||||
required=True,
|
||||
initial=["default"],
|
||||
|
@ -777,5 +777,5 @@ class LoadBalancerTests(test.TestCase):
|
||||
self.assertEqual(workflow.name, workflows.DeletePMAssociation.name)
|
||||
|
||||
expected_objs = [
|
||||
'<DeletePMAssociationStep: deletepmassociationaction>', ]
|
||||
'<DeletePMAssociationStep: deletepmassociationaction>', ]
|
||||
self.assertQuerysetEqual(workflow.steps, expected_objs)
|
||||
|
@ -272,7 +272,7 @@ class UpdateMonitorView(forms.ModalFormView):
|
||||
monitor_id = self.kwargs['monitor_id']
|
||||
try:
|
||||
self._object = api.lbaas.pool_health_monitor_get(
|
||||
self.request, monitor_id)
|
||||
self.request, monitor_id)
|
||||
except Exception as e:
|
||||
redirect = self.success_url
|
||||
msg = _('Unable to retrieve health monitor details. %s') % e
|
||||
|
@ -555,7 +555,7 @@ class DeletePMAssociationAction(workflows.Action):
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(DeletePMAssociationAction, self).__init__(
|
||||
request, *args, **kwargs)
|
||||
request, *args, **kwargs)
|
||||
|
||||
def populate_monitor_id_choices(self, request, context):
|
||||
self.fields['monitor_id'].label = (_("Select a health monitor of %s") %
|
||||
@ -585,7 +585,7 @@ class DeletePMAssociationStep(workflows.Step):
|
||||
|
||||
def contribute(self, data, context):
|
||||
context = super(DeletePMAssociationStep, self).contribute(
|
||||
data, context)
|
||||
data, context)
|
||||
if data:
|
||||
return context
|
||||
|
||||
|
@ -104,16 +104,16 @@ class UpdateSubnetInfoAction(CreateSubnetInfoAction):
|
||||
label=_("IP Version"))
|
||||
|
||||
gateway_ip = fields.IPField(
|
||||
label=_("Gateway IP (optional)"),
|
||||
required=False,
|
||||
initial="",
|
||||
help_text=_("IP address of Gateway (e.g. 192.168.0.254). "
|
||||
"You need to specify an explicit address "
|
||||
"to set the gateway. "
|
||||
"If you want to use no gateway, "
|
||||
"check 'Disable Gateway' below."),
|
||||
version=fields.IPv4 | fields.IPv6,
|
||||
mask=False)
|
||||
label=_("Gateway IP (optional)"),
|
||||
required=False,
|
||||
initial="",
|
||||
help_text=_("IP address of Gateway (e.g. 192.168.0.254). "
|
||||
"You need to specify an explicit address "
|
||||
"to set the gateway. "
|
||||
"If you want to use no gateway, "
|
||||
"check 'Disable Gateway' below."),
|
||||
version=fields.IPv4 | fields.IPv6,
|
||||
mask=False)
|
||||
no_gateway = forms.BooleanField(label=_("Disable Gateway"),
|
||||
initial=False, required=False)
|
||||
|
||||
|
@ -97,18 +97,18 @@ class CreateSubnetInfoAction(workflows.Action):
|
||||
ip_version = forms.ChoiceField(choices=[(4, 'IPv4'), (6, 'IPv6')],
|
||||
label=_("IP Version"))
|
||||
gateway_ip = fields.IPField(
|
||||
label=_("Gateway IP"),
|
||||
required=False,
|
||||
initial="",
|
||||
help_text=_("IP address of Gateway (e.g. 192.168.0.254) "
|
||||
"The default value is the first IP of the "
|
||||
"network address (e.g. 192.168.0.1 for "
|
||||
"192.168.0.0/24). "
|
||||
"If you use the default, leave blank. "
|
||||
"If you want to use no gateway, "
|
||||
"check 'Disable Gateway' below."),
|
||||
version=fields.IPv4 | fields.IPv6,
|
||||
mask=False)
|
||||
label=_("Gateway IP"),
|
||||
required=False,
|
||||
initial="",
|
||||
help_text=_("IP address of Gateway (e.g. 192.168.0.254) "
|
||||
"The default value is the first IP of the "
|
||||
"network address (e.g. 192.168.0.1 for "
|
||||
"192.168.0.0/24). "
|
||||
"If you use the default, leave blank. "
|
||||
"If you want to use no gateway, "
|
||||
"check 'Disable Gateway' below."),
|
||||
version=fields.IPv4 | fields.IPv6,
|
||||
mask=False)
|
||||
no_gateway = forms.BooleanField(label=_("Disable Gateway"),
|
||||
initial=False, required=False)
|
||||
|
||||
|
@ -104,7 +104,7 @@ class DetailView(tables.MultiTableView):
|
||||
router.set_id_as_name_if_empty(length=0)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve details for router "%s".') \
|
||||
% (router_id)
|
||||
% (router_id)
|
||||
exceptions.handle(self.request, msg, redirect=self.failure_url)
|
||||
|
||||
if router.external_gateway_info:
|
||||
|
@ -52,10 +52,10 @@ def d3_data(request, stack_id=''):
|
||||
if resources:
|
||||
for resource in resources:
|
||||
resource_image = mappings.get_resource_image(
|
||||
resource.resource_status,
|
||||
resource.resource_type)
|
||||
resource.resource_status,
|
||||
resource.resource_type)
|
||||
resource_status = mappings.get_resource_status(
|
||||
resource.resource_status)
|
||||
resource.resource_status)
|
||||
if resource_status in ('IN_PROGRESS', 'INIT'):
|
||||
in_progress = True
|
||||
else:
|
||||
|
@ -41,19 +41,14 @@ class CreateForm(forms.SelfHandlingForm):
|
||||
widget=fields.SelectWidget(
|
||||
attrs={'class': 'snapshot-selector'},
|
||||
data_attrs=('size', 'display_name'),
|
||||
transform=lambda x:
|
||||
("%s (%sGB)" % (x.display_name,
|
||||
x.size))),
|
||||
transform=lambda x: "%s (%sGB)" % (x.display_name, x.size)),
|
||||
required=False)
|
||||
image_source = forms.ChoiceField(
|
||||
label=_("Use image as a source"),
|
||||
widget=fields.SelectWidget(
|
||||
attrs={'class': 'image-selector'},
|
||||
data_attrs=('size', 'name'),
|
||||
transform=lambda x:
|
||||
("%s (%s)" %
|
||||
(x.name,
|
||||
filesizeformat(x.bytes)))),
|
||||
transform=lambda x: "%s (%s)" % (x.name, filesizeformat(x.bytes))),
|
||||
required=False)
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
@ -258,8 +253,8 @@ class AttachForm(forms.SelfHandlingForm):
|
||||
instances = []
|
||||
for instance in instance_list:
|
||||
if instance.status in tables.ACTIVE_STATES and \
|
||||
not any(instance.id == att["server_id"]
|
||||
for att in volume.attachments):
|
||||
not any(instance.id == att["server_id"]
|
||||
for att in volume.attachments):
|
||||
instances.append((instance.id, '%s (%s)' % (instance.name,
|
||||
instance.id)))
|
||||
if instances:
|
||||
|
@ -150,8 +150,8 @@ class IKEPoliciesTable(tables.DataTable):
|
||||
auth_algorithm = tables.Column('auth_algorithm',
|
||||
verbose_name=_('Authorization algorithm'))
|
||||
encryption_algorithm = tables.Column(
|
||||
'encryption_algorithm',
|
||||
verbose_name=_('Encryption algorithm'))
|
||||
'encryption_algorithm',
|
||||
verbose_name=_('Encryption algorithm'))
|
||||
pfs = tables.Column("pfs", verbose_name=_('PFS'))
|
||||
|
||||
class Meta:
|
||||
@ -168,8 +168,8 @@ class IPSecPoliciesTable(tables.DataTable):
|
||||
auth_algorithm = tables.Column('auth_algorithm',
|
||||
verbose_name=_('Authorization algorithm'))
|
||||
encryption_algorithm = tables.Column(
|
||||
'encryption_algorithm',
|
||||
verbose_name=_('Encryption algorithm'))
|
||||
'encryption_algorithm',
|
||||
verbose_name=_('Encryption algorithm'))
|
||||
pfs = tables.Column("pfs", verbose_name=_('PFS'))
|
||||
|
||||
class Meta:
|
||||
|
@ -293,12 +293,11 @@ class VPNTests(test.TestCase):
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
form_data = {
|
||||
'name': vpnservice['name'],
|
||||
'description': vpnservice['description'],
|
||||
'subnet_id': vpnservice['subnet_id'],
|
||||
'router_id': vpnservice['router_id'],
|
||||
'admin_state_up': vpnservice['admin_state_up']}
|
||||
form_data = {'name': vpnservice['name'],
|
||||
'description': vpnservice['description'],
|
||||
'subnet_id': vpnservice['subnet_id'],
|
||||
'router_id': vpnservice['router_id'],
|
||||
'admin_state_up': vpnservice['admin_state_up']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDVPNSERVICE_PATH), form_data)
|
||||
|
||||
@ -323,12 +322,11 @@ class VPNTests(test.TestCase):
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
form_data = {
|
||||
'name': vpnservice['name'],
|
||||
'description': vpnservice['description'],
|
||||
'subnet_id': '',
|
||||
'router_id': '',
|
||||
'admin_state_up': vpnservice['admin_state_up']}
|
||||
form_data = {'name': vpnservice['name'],
|
||||
'description': vpnservice['description'],
|
||||
'subnet_id': '',
|
||||
'router_id': '',
|
||||
'admin_state_up': vpnservice['admin_state_up']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDVPNSERVICE_PATH), form_data)
|
||||
|
||||
@ -362,18 +360,17 @@ class VPNTests(test.TestCase):
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
form_data = {
|
||||
'name': ikepolicy['name'],
|
||||
'description': ikepolicy['description'],
|
||||
'auth_algorithm': ikepolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ikepolicy[
|
||||
'encryption_algorithm'],
|
||||
'ike_version': ikepolicy['ike_version'],
|
||||
'lifetime_units': ikepolicy['lifetime']['units'],
|
||||
'lifetime_value': ikepolicy['lifetime']['value'],
|
||||
'phase1_negotiation_mode': ikepolicy[
|
||||
'phase1_negotiation_mode'],
|
||||
'pfs': ikepolicy['pfs']}
|
||||
form_data = {'name': ikepolicy['name'],
|
||||
'description': ikepolicy['description'],
|
||||
'auth_algorithm': ikepolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ikepolicy[
|
||||
'encryption_algorithm'],
|
||||
'ike_version': ikepolicy['ike_version'],
|
||||
'lifetime_units': ikepolicy['lifetime']['units'],
|
||||
'lifetime_value': ikepolicy['lifetime']['value'],
|
||||
'phase1_negotiation_mode': ikepolicy[
|
||||
'phase1_negotiation_mode'],
|
||||
'pfs': ikepolicy['pfs']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDIKEPOLICY_PATH), form_data)
|
||||
|
||||
@ -383,18 +380,17 @@ class VPNTests(test.TestCase):
|
||||
def test_add_ikepolicy_post_error(self):
|
||||
ikepolicy = self.ikepolicies.first()
|
||||
|
||||
form_data = {
|
||||
'name': ikepolicy['name'],
|
||||
'description': ikepolicy['description'],
|
||||
'auth_algorithm': ikepolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ikepolicy[
|
||||
'encryption_algorithm'],
|
||||
'ike_version': ikepolicy['ike_version'],
|
||||
'lifetime_units': ikepolicy['lifetime']['units'],
|
||||
'lifetime_value': 10,
|
||||
'phase1_negotiation_mode': ikepolicy[
|
||||
'phase1_negotiation_mode'],
|
||||
'pfs': ikepolicy['pfs']}
|
||||
form_data = {'name': ikepolicy['name'],
|
||||
'description': ikepolicy['description'],
|
||||
'auth_algorithm': ikepolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ikepolicy[
|
||||
'encryption_algorithm'],
|
||||
'ike_version': ikepolicy['ike_version'],
|
||||
'lifetime_units': ikepolicy['lifetime']['units'],
|
||||
'lifetime_value': 10,
|
||||
'phase1_negotiation_mode': ikepolicy[
|
||||
'phase1_negotiation_mode'],
|
||||
'pfs': ikepolicy['pfs']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDIKEPOLICY_PATH), form_data)
|
||||
|
||||
@ -428,19 +424,18 @@ class VPNTests(test.TestCase):
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
form_data = {
|
||||
'name': ipsecpolicy['name'],
|
||||
'description': ipsecpolicy['description'],
|
||||
'auth_algorithm': ipsecpolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ipsecpolicy[
|
||||
'encryption_algorithm'],
|
||||
'encapsulation_mode': ipsecpolicy[
|
||||
'encapsulation_mode'],
|
||||
'lifetime_units': ipsecpolicy['lifetime']['units'],
|
||||
'lifetime_value': ipsecpolicy['lifetime']['value'],
|
||||
'pfs': ipsecpolicy['pfs'],
|
||||
'transform_protocol': ipsecpolicy[
|
||||
'transform_protocol']}
|
||||
form_data = {'name': ipsecpolicy['name'],
|
||||
'description': ipsecpolicy['description'],
|
||||
'auth_algorithm': ipsecpolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ipsecpolicy[
|
||||
'encryption_algorithm'],
|
||||
'encapsulation_mode': ipsecpolicy[
|
||||
'encapsulation_mode'],
|
||||
'lifetime_units': ipsecpolicy['lifetime']['units'],
|
||||
'lifetime_value': ipsecpolicy['lifetime']['value'],
|
||||
'pfs': ipsecpolicy['pfs'],
|
||||
'transform_protocol': ipsecpolicy[
|
||||
'transform_protocol']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDIPSECPOLICY_PATH), form_data)
|
||||
|
||||
@ -450,19 +445,18 @@ class VPNTests(test.TestCase):
|
||||
def test_add_ipsecpolicy_post_error(self):
|
||||
ipsecpolicy = self.ipsecpolicies.first()
|
||||
|
||||
form_data = {
|
||||
'name': ipsecpolicy['name'],
|
||||
'description': ipsecpolicy['description'],
|
||||
'auth_algorithm': ipsecpolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ipsecpolicy[
|
||||
'encryption_algorithm'],
|
||||
'encapsulation_mode': ipsecpolicy[
|
||||
'encapsulation_mode'],
|
||||
'lifetime_units': ipsecpolicy['lifetime']['units'],
|
||||
'lifetime_value': 10,
|
||||
'pfs': ipsecpolicy['pfs'],
|
||||
'transform_protocol': ipsecpolicy[
|
||||
'transform_protocol']}
|
||||
form_data = {'name': ipsecpolicy['name'],
|
||||
'description': ipsecpolicy['description'],
|
||||
'auth_algorithm': ipsecpolicy['auth_algorithm'],
|
||||
'encryption_algorithm': ipsecpolicy[
|
||||
'encryption_algorithm'],
|
||||
'encapsulation_mode': ipsecpolicy[
|
||||
'encapsulation_mode'],
|
||||
'lifetime_units': ipsecpolicy['lifetime']['units'],
|
||||
'lifetime_value': 10,
|
||||
'pfs': ipsecpolicy['pfs'],
|
||||
'transform_protocol': ipsecpolicy[
|
||||
'transform_protocol']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDIPSECPOLICY_PATH), form_data)
|
||||
|
||||
@ -540,24 +534,23 @@ class VPNTests(test.TestCase):
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
form_data = {
|
||||
'name': ipsecsiteconnection['name'],
|
||||
'description': ipsecsiteconnection['description'],
|
||||
'dpd_action': ipsecsiteconnection['dpd']['action'],
|
||||
'dpd_interval': ipsecsiteconnection['dpd']['interval'],
|
||||
'dpd_timeout': ipsecsiteconnection['dpd']['timeout'],
|
||||
'ikepolicy_id': ipsecsiteconnection['ikepolicy_id'],
|
||||
'initiator': ipsecsiteconnection['initiator'],
|
||||
'ipsecpolicy_id': ipsecsiteconnection[
|
||||
'ipsecpolicy_id'],
|
||||
'mtu': ipsecsiteconnection['mtu'],
|
||||
'peer_address': ipsecsiteconnection['peer_address'],
|
||||
'peer_cidrs': ipsecsiteconnection['peer_cidrs'],
|
||||
'peer_id': ipsecsiteconnection['peer_id'],
|
||||
'psk': ipsecsiteconnection['psk'],
|
||||
'vpnservice_id': ipsecsiteconnection['vpnservice_id'],
|
||||
'admin_state_up': ipsecsiteconnection[
|
||||
'admin_state_up']}
|
||||
form_data = {'name': ipsecsiteconnection['name'],
|
||||
'description': ipsecsiteconnection['description'],
|
||||
'dpd_action': ipsecsiteconnection['dpd']['action'],
|
||||
'dpd_interval': ipsecsiteconnection['dpd']['interval'],
|
||||
'dpd_timeout': ipsecsiteconnection['dpd']['timeout'],
|
||||
'ikepolicy_id': ipsecsiteconnection['ikepolicy_id'],
|
||||
'initiator': ipsecsiteconnection['initiator'],
|
||||
'ipsecpolicy_id': ipsecsiteconnection[
|
||||
'ipsecpolicy_id'],
|
||||
'mtu': ipsecsiteconnection['mtu'],
|
||||
'peer_address': ipsecsiteconnection['peer_address'],
|
||||
'peer_cidrs': ipsecsiteconnection['peer_cidrs'],
|
||||
'peer_id': ipsecsiteconnection['peer_id'],
|
||||
'psk': ipsecsiteconnection['psk'],
|
||||
'vpnservice_id': ipsecsiteconnection['vpnservice_id'],
|
||||
'admin_state_up': ipsecsiteconnection[
|
||||
'admin_state_up']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDVPNCONNECTION_PATH), form_data)
|
||||
|
||||
@ -587,23 +580,22 @@ class VPNTests(test.TestCase):
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
form_data = {
|
||||
'name': ipsecsiteconnection['name'],
|
||||
'description': ipsecsiteconnection['description'],
|
||||
'dpd_action': ipsecsiteconnection['dpd']['action'],
|
||||
'dpd_interval': ipsecsiteconnection['dpd']['interval'],
|
||||
'dpd_timeout': ipsecsiteconnection['dpd']['timeout'],
|
||||
'ikepolicy_id': '',
|
||||
'initiator': ipsecsiteconnection['initiator'],
|
||||
'ipsecpolicy_id': '',
|
||||
'mtu': ipsecsiteconnection['mtu'],
|
||||
'peer_address': ipsecsiteconnection['peer_address'],
|
||||
'peer_cidrs': ipsecsiteconnection['peer_cidrs'],
|
||||
'peer_id': ipsecsiteconnection['peer_id'],
|
||||
'psk': ipsecsiteconnection['psk'],
|
||||
'vpnservice_id': '',
|
||||
'admin_state_up': ipsecsiteconnection[
|
||||
'admin_state_up']}
|
||||
form_data = {'name': ipsecsiteconnection['name'],
|
||||
'description': ipsecsiteconnection['description'],
|
||||
'dpd_action': ipsecsiteconnection['dpd']['action'],
|
||||
'dpd_interval': ipsecsiteconnection['dpd']['interval'],
|
||||
'dpd_timeout': ipsecsiteconnection['dpd']['timeout'],
|
||||
'ikepolicy_id': '',
|
||||
'initiator': ipsecsiteconnection['initiator'],
|
||||
'ipsecpolicy_id': '',
|
||||
'mtu': ipsecsiteconnection['mtu'],
|
||||
'peer_address': ipsecsiteconnection['peer_address'],
|
||||
'peer_cidrs': ipsecsiteconnection['peer_cidrs'],
|
||||
'peer_id': ipsecsiteconnection['peer_id'],
|
||||
'psk': ipsecsiteconnection['psk'],
|
||||
'vpnservice_id': '',
|
||||
'admin_state_up': ipsecsiteconnection[
|
||||
'admin_state_up']}
|
||||
|
||||
res = self.client.post(reverse(self.ADDVPNCONNECTION_PATH), form_data)
|
||||
|
||||
|
@ -25,19 +25,20 @@ class UserSettingsView(forms.ModalFormView):
|
||||
template_name = 'settings/user/settings.html'
|
||||
|
||||
def get_initial(self):
|
||||
return {'language': self.request.session.get(
|
||||
settings.LANGUAGE_COOKIE_NAME,
|
||||
self.request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME,
|
||||
self.request.LANGUAGE_CODE)),
|
||||
'timezone': self.request.session.get(
|
||||
'django_timezone',
|
||||
self.request.COOKIES.get('django_timezone', 'UTC')),
|
||||
'pagesize': self.request.session.get(
|
||||
'horizon_pagesize',
|
||||
self.request.COOKIES.get(
|
||||
'horizon_pagesize',
|
||||
getattr(settings,
|
||||
'API_RESULT_PAGE_SIZE', 20)))}
|
||||
return {
|
||||
'language': self.request.session.get(
|
||||
settings.LANGUAGE_COOKIE_NAME,
|
||||
self.request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME,
|
||||
self.request.LANGUAGE_CODE)),
|
||||
'timezone': self.request.session.get(
|
||||
'django_timezone',
|
||||
self.request.COOKIES.get('django_timezone', 'UTC')),
|
||||
'pagesize': self.request.session.get(
|
||||
'horizon_pagesize',
|
||||
self.request.COOKIES.get(
|
||||
'horizon_pagesize',
|
||||
getattr(settings,
|
||||
'API_RESULT_PAGE_SIZE', 20)))}
|
||||
|
||||
def form_valid(self, form):
|
||||
return form.handle(self.request, form.cleaned_data)
|
||||
|
@ -28,7 +28,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from openstack_dashboard import exceptions
|
||||
|
||||
warnings.formatwarning = lambda message, category, *args, **kwargs: \
|
||||
'%s: %s' % (category.__name__, message)
|
||||
'%s: %s' % (category.__name__, message)
|
||||
|
||||
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
BIN_DIR = os.path.abspath(os.path.join(ROOT_PATH, '..', 'bin'))
|
||||
|
@ -142,13 +142,13 @@ class LbaasApiTests(test.APITestCase):
|
||||
@test.create_stubs({neutronclient: ('list_pools',)})
|
||||
def test_pools_get(self):
|
||||
pools = {'pools': [{
|
||||
'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'name': 'pool1name',
|
||||
'description': 'pool1description',
|
||||
'subnet_id': '12381d38-c3eb-4fee-9763-12de3338041e',
|
||||
'protocol': 'HTTP',
|
||||
'lb_method': 'ROUND_ROBIN',
|
||||
'admin_state_up': True}, ]}
|
||||
'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'name': 'pool1name',
|
||||
'description': 'pool1description',
|
||||
'subnet_id': '12381d38-c3eb-4fee-9763-12de3338041e',
|
||||
'protocol': 'HTTP',
|
||||
'lb_method': 'ROUND_ROBIN',
|
||||
'admin_state_up': True}, ]}
|
||||
neutronclient.list_pools().AndReturn(pools)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -207,14 +207,14 @@ class LbaasApiTests(test.APITestCase):
|
||||
'admin_state_up': True
|
||||
}
|
||||
monitor = {'health_monitor': {
|
||||
'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'type': 'PING',
|
||||
'delay': '10',
|
||||
'timeout': '10',
|
||||
'max_retries': '10',
|
||||
'admin_state_up': True}}
|
||||
'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'type': 'PING',
|
||||
'delay': '10',
|
||||
'timeout': '10',
|
||||
'max_retries': '10',
|
||||
'admin_state_up': True}}
|
||||
neutronclient.create_health_monitor({
|
||||
'health_monitor': form_data}).AndReturn(monitor)
|
||||
'health_monitor': form_data}).AndReturn(monitor)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
ret_val = api.lbaas.pool_health_monitor_create(
|
||||
@ -224,15 +224,15 @@ class LbaasApiTests(test.APITestCase):
|
||||
@test.create_stubs({neutronclient: ('list_health_monitors',)})
|
||||
def test_pool_health_monitors_get(self):
|
||||
monitors = {'health_monitors': [
|
||||
{'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'type': 'PING',
|
||||
'delay': '10',
|
||||
'timeout': '10',
|
||||
'max_retries': '10',
|
||||
'http_method': 'GET',
|
||||
'url_path': '/monitor',
|
||||
'expected_codes': '200',
|
||||
'admin_state_up': True}, ]}
|
||||
{'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'type': 'PING',
|
||||
'delay': '10',
|
||||
'timeout': '10',
|
||||
'max_retries': '10',
|
||||
'http_method': 'GET',
|
||||
'url_path': '/monitor',
|
||||
'expected_codes': '200',
|
||||
'admin_state_up': True}, ]}
|
||||
|
||||
neutronclient.list_health_monitors().AndReturn(monitors)
|
||||
self.mox.ReplayAll()
|
||||
@ -287,13 +287,13 @@ class LbaasApiTests(test.APITestCase):
|
||||
@test.create_stubs({neutronclient: ('list_members',)})
|
||||
def test_members_get(self):
|
||||
members = {'members': [
|
||||
{'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'pool_id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'address': '10.0.1.2',
|
||||
'protocol_port': '80',
|
||||
'weight': '10',
|
||||
'admin_state_up': True
|
||||
}, ]}
|
||||
{'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'pool_id': 'abcdef-c3eb-4fee-9763-12de3338041e',
|
||||
'address': '10.0.1.2',
|
||||
'protocol_port': '80',
|
||||
'weight': '10',
|
||||
'admin_state_up': True
|
||||
}, ]}
|
||||
neutronclient.list_members().AndReturn(members)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -29,11 +29,12 @@ class VPNaasApiTests(test.APITestCase):
|
||||
def test_vpnservice_create(self):
|
||||
vpnservice1 = self.api_vpnservices.first()
|
||||
form_data = {
|
||||
'name': vpnservice1['name'],
|
||||
'description': vpnservice1['description'],
|
||||
'subnet_id': vpnservice1['subnet_id'],
|
||||
'router_id': vpnservice1['router_id'],
|
||||
'admin_state_up': vpnservice1['admin_state_up']}
|
||||
'name': vpnservice1['name'],
|
||||
'description': vpnservice1['description'],
|
||||
'subnet_id': vpnservice1['subnet_id'],
|
||||
'router_id': vpnservice1['router_id'],
|
||||
'admin_state_up': vpnservice1['admin_state_up']
|
||||
}
|
||||
|
||||
vpnservice = {'vpnservice': self.api_vpnservices.first()}
|
||||
neutronclient.create_vpnservice(
|
||||
@ -76,16 +77,15 @@ class VPNaasApiTests(test.APITestCase):
|
||||
def test_ikepolicy_create(self):
|
||||
ikepolicy1 = self.api_ikepolicies.first()
|
||||
form_data = {
|
||||
'name': ikepolicy1['name'],
|
||||
'description': ikepolicy1['description'],
|
||||
'auth_algorithm': ikepolicy1['auth_algorithm'],
|
||||
'encryption_algorithm': ikepolicy1[
|
||||
'encryption_algorithm'],
|
||||
'ike_version': ikepolicy1['ike_version'],
|
||||
'lifetime': ikepolicy1['lifetime'],
|
||||
'phase1_negotiation_mode': ikepolicy1[
|
||||
'phase1_negotiation_mode'],
|
||||
'pfs': ikepolicy1['pfs']}
|
||||
'name': ikepolicy1['name'],
|
||||
'description': ikepolicy1['description'],
|
||||
'auth_algorithm': ikepolicy1['auth_algorithm'],
|
||||
'encryption_algorithm': ikepolicy1['encryption_algorithm'],
|
||||
'ike_version': ikepolicy1['ike_version'],
|
||||
'lifetime': ikepolicy1['lifetime'],
|
||||
'phase1_negotiation_mode': ikepolicy1['phase1_negotiation_mode'],
|
||||
'pfs': ikepolicy1['pfs']
|
||||
}
|
||||
|
||||
ikepolicy = {'ikepolicy': self.api_ikepolicies.first()}
|
||||
neutronclient.create_ikepolicy(
|
||||
@ -128,17 +128,15 @@ class VPNaasApiTests(test.APITestCase):
|
||||
def test_ipsecpolicy_create(self):
|
||||
ipsecpolicy1 = self.api_ipsecpolicies.first()
|
||||
form_data = {
|
||||
'name': ipsecpolicy1['name'],
|
||||
'description': ipsecpolicy1['description'],
|
||||
'auth_algorithm': ipsecpolicy1['auth_algorithm'],
|
||||
'encryption_algorithm': ipsecpolicy1[
|
||||
'encryption_algorithm'],
|
||||
'encapsulation_mode': ipsecpolicy1[
|
||||
'encapsulation_mode'],
|
||||
'lifetime': ipsecpolicy1['lifetime'],
|
||||
'pfs': ipsecpolicy1['pfs'],
|
||||
'transform_protocol': ipsecpolicy1[
|
||||
'transform_protocol']}
|
||||
'name': ipsecpolicy1['name'],
|
||||
'description': ipsecpolicy1['description'],
|
||||
'auth_algorithm': ipsecpolicy1['auth_algorithm'],
|
||||
'encryption_algorithm': ipsecpolicy1['encryption_algorithm'],
|
||||
'encapsulation_mode': ipsecpolicy1['encapsulation_mode'],
|
||||
'lifetime': ipsecpolicy1['lifetime'],
|
||||
'pfs': ipsecpolicy1['pfs'],
|
||||
'transform_protocol': ipsecpolicy1['transform_protocol']
|
||||
}
|
||||
|
||||
ipsecpolicy = {'ipsecpolicy': self.api_ipsecpolicies.first()}
|
||||
neutronclient.create_ipsecpolicy(
|
||||
@ -181,21 +179,20 @@ class VPNaasApiTests(test.APITestCase):
|
||||
def test_ipsecsiteconnection_create(self):
|
||||
ipsecsiteconnection1 = self.api_ipsecsiteconnections.first()
|
||||
form_data = {
|
||||
'name': ipsecsiteconnection1['name'],
|
||||
'description': ipsecsiteconnection1['description'],
|
||||
'dpd': ipsecsiteconnection1['dpd'],
|
||||
'ikepolicy_id': ipsecsiteconnection1['ikepolicy_id'],
|
||||
'initiator': ipsecsiteconnection1['initiator'],
|
||||
'ipsecpolicy_id': ipsecsiteconnection1[
|
||||
'ipsecpolicy_id'],
|
||||
'mtu': ipsecsiteconnection1['mtu'],
|
||||
'peer_address': ipsecsiteconnection1['peer_address'],
|
||||
'peer_cidrs': ipsecsiteconnection1['peer_cidrs'],
|
||||
'peer_id': ipsecsiteconnection1['peer_id'],
|
||||
'psk': ipsecsiteconnection1['psk'],
|
||||
'vpnservice_id': ipsecsiteconnection1['vpnservice_id'],
|
||||
'admin_state_up': ipsecsiteconnection1[
|
||||
'admin_state_up']}
|
||||
'name': ipsecsiteconnection1['name'],
|
||||
'description': ipsecsiteconnection1['description'],
|
||||
'dpd': ipsecsiteconnection1['dpd'],
|
||||
'ikepolicy_id': ipsecsiteconnection1['ikepolicy_id'],
|
||||
'initiator': ipsecsiteconnection1['initiator'],
|
||||
'ipsecpolicy_id': ipsecsiteconnection1['ipsecpolicy_id'],
|
||||
'mtu': ipsecsiteconnection1['mtu'],
|
||||
'peer_address': ipsecsiteconnection1['peer_address'],
|
||||
'peer_cidrs': ipsecsiteconnection1['peer_cidrs'],
|
||||
'peer_id': ipsecsiteconnection1['peer_id'],
|
||||
'psk': ipsecsiteconnection1['psk'],
|
||||
'vpnservice_id': ipsecsiteconnection1['vpnservice_id'],
|
||||
'admin_state_up': ipsecsiteconnection1['admin_state_up']
|
||||
}
|
||||
|
||||
ipsecsiteconnection = {'ipsec_site_connection':
|
||||
self.api_ipsecsiteconnections.first()}
|
||||
|
@ -136,7 +136,7 @@ def data(TEST):
|
||||
|
||||
TEST.api_network_profile_binding.add(network_profile_binding_dict)
|
||||
TEST.network_profile_binding.add(neutron.Profile(
|
||||
network_profile_binding_dict))
|
||||
network_profile_binding_dict))
|
||||
|
||||
# policy profile binding
|
||||
policy_profile_binding_dict = {'profile_id':
|
||||
@ -145,7 +145,7 @@ def data(TEST):
|
||||
|
||||
TEST.api_policy_profile_binding.add(policy_profile_binding_dict)
|
||||
TEST.policy_profile_binding.add(neutron.Profile(
|
||||
policy_profile_binding_dict))
|
||||
policy_profile_binding_dict))
|
||||
|
||||
# ports on 1st network
|
||||
port_dict = {'admin_state_up': True,
|
||||
|
@ -143,10 +143,10 @@ class QuotaTests(test.APITestCase):
|
||||
expected_output = self.get_usages(with_volume=False)
|
||||
|
||||
expected_output.update({
|
||||
'ram': {'available': 10000, 'used': 0, 'quota': 10000},
|
||||
'floating_ips': {'available': 1, 'used': 0, 'quota': 1},
|
||||
'instances': {'available': 10, 'used': 0, 'quota': 10},
|
||||
'cores': {'available': 10, 'used': 0, 'quota': 10}})
|
||||
'ram': {'available': 10000, 'used': 0, 'quota': 10000},
|
||||
'floating_ips': {'available': 1, 'used': 0, 'quota': 1},
|
||||
'instances': {'available': 10, 'used': 0, 'quota': 10},
|
||||
'cores': {'available': 10, 'used': 0, 'quota': 10}})
|
||||
|
||||
# Compare internal structure of usages to expected.
|
||||
self.assertEqual(quota_usages.usages, expected_output)
|
||||
|
@ -34,9 +34,9 @@ class TemplateRenderTest(test.TestCase):
|
||||
"auth_url": "http://tests.com",
|
||||
"tenant_name": "ENG Perf R&D"}
|
||||
out = loader.render_to_string(
|
||||
'project/access_and_security/api_access/openrc.sh.template',
|
||||
context,
|
||||
template.Context(context))
|
||||
'project/access_and_security/api_access/openrc.sh.template',
|
||||
context,
|
||||
template.Context(context))
|
||||
|
||||
self.assertFalse("&" in out)
|
||||
self.assertTrue("ENG Perf R&D" in out)
|
||||
@ -48,9 +48,9 @@ class TemplateRenderTest(test.TestCase):
|
||||
"auth_url": "http://tests.com",
|
||||
"tenant_name": 'o"; sudo rm -rf /'}
|
||||
out = loader.render_to_string(
|
||||
'project/access_and_security/api_access/openrc.sh.template',
|
||||
context,
|
||||
template.Context(context))
|
||||
'project/access_and_security/api_access/openrc.sh.template',
|
||||
context,
|
||||
template.Context(context))
|
||||
|
||||
self.assertFalse('o"' in out)
|
||||
self.assertTrue('\"' in out)
|
||||
@ -62,9 +62,9 @@ class TemplateRenderTest(test.TestCase):
|
||||
"auth_url": "http://tests.com",
|
||||
"tenant_name": 'o\"; sudo rm -rf /'}
|
||||
out = loader.render_to_string(
|
||||
'project/access_and_security/api_access/openrc.sh.template',
|
||||
context,
|
||||
template.Context(context))
|
||||
'project/access_and_security/api_access/openrc.sh.template',
|
||||
context,
|
||||
template.Context(context))
|
||||
|
||||
self.assertFalse('o\"' in out)
|
||||
self.assertFalse('o"' in out)
|
||||
|
3
tox.ini
3
tox.ini
@ -32,11 +32,10 @@ downloadcache = ~/cache/pip
|
||||
[flake8]
|
||||
builtins = _
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py
|
||||
# E126 continuation line over-indented for hanging indent
|
||||
# E127 continuation line over-indented for visual indent
|
||||
# E128 continuation line under-indented for visual indent
|
||||
# H102 Apache 2.0 license header not found
|
||||
# H4xx docstrings
|
||||
# H701 empty localization string
|
||||
# H702 Formatting operation should be outside of localization method call
|
||||
ignore = E126,E127,E128,H102,H4,H701,H702
|
||||
ignore = E127,E128,H102,H4,H701,H702
|
||||
|
Loading…
x
Reference in New Issue
Block a user