diff --git a/horizon/utils/filters.py b/horizon/utils/filters.py index ec4dc2f1..2404c417 100644 --- a/horizon/utils/filters.py +++ b/horizon/utils/filters.py @@ -62,6 +62,7 @@ def timesince_sortable(dt): return mark_safe("%s" % (seconds, timesince(dt))) + @register.filter def get_item(dictionary, key): return dictionary.get(key) diff --git a/manila_ui/__init__.py b/manila_ui/__init__.py index 09565208..4902b6d1 100644 --- a/manila_ui/__init__.py +++ b/manila_ui/__init__.py @@ -16,4 +16,4 @@ import pbr.version __version__ = pbr.version.VersionInfo( - 'manila_ui').version_string() \ No newline at end of file + 'manila_ui').version_string() diff --git a/manila_ui/api/manila.py b/manila_ui/api/manila.py index 38baf725..bb8004be 100644 --- a/manila_ui/api/manila.py +++ b/manila_ui/api/manila.py @@ -156,8 +156,8 @@ def share_network_get(request, share_net_id): def share_network_update(request, share_net_id, name=None, description=None): - return manilaclient(request).share_networks.update(share_net_id, - name=name, description=description) + return manilaclient(request).share_networks.update( + share_net_id, name=name, description=description) def share_network_delete(request, share_network_id): @@ -165,7 +165,8 @@ def share_network_delete(request, share_network_id): def security_service_list(request, search_opts=None): - return manilaclient(request).security_services.list(detailed=True, + return manilaclient(request).security_services.list( + detailed=True, search_opts=search_opts) diff --git a/manila_ui/dashboards/admin/defaults/tables.py b/manila_ui/dashboards/admin/defaults/tables.py index ae770025..d8f5d039 100644 --- a/manila_ui/dashboards/admin/defaults/tables.py +++ b/manila_ui/dashboards/admin/defaults/tables.py @@ -71,7 +71,7 @@ class QuotasTable(tables.DataTable): def get_object_id(self, obj): return obj.name - class Meta: + class Meta(object): name = "quotas" verbose_name = _("Quotas") table_actions = (QuotaFilterAction, UpdateDefaultQuotas) diff --git a/manila_ui/dashboards/admin/shares/forms.py b/manila_ui/dashboards/admin/shares/forms.py index 8ad7a0df..d5e046b3 100644 --- a/manila_ui/dashboards/admin/shares/forms.py +++ b/manila_ui/dashboards/admin/shares/forms.py @@ -38,7 +38,8 @@ class CreateShareType(forms.SelfHandlingForm): name = forms.CharField(max_length="255", label=_("Name")) spec_driver_handles_share_servers = forms.CharField( max_length="5", label=_("Driver handles share servers")) - extra_specs = forms.CharField(required=False, label=_("Extra specs"), + extra_specs = forms.CharField( + required=False, label=_("Extra specs"), widget=forms.widgets.Textarea(attrs=ST_EXTRA_SPECS_FORM_ATTRS)) def handle(self, request, data): @@ -86,7 +87,8 @@ class UpdateShareType(forms.SelfHandlingForm): es_str += "%s=%s\r\n" % (k, v) self.initial["extra_specs"] = es_str - extra_specs = forms.CharField(required=False, label=_("Extra specs"), + extra_specs = forms.CharField( + required=False, label=_("Extra specs"), widget=forms.widgets.Textarea(attrs=ST_EXTRA_SPECS_FORM_ATTRS)) def handle(self, request, data): @@ -152,7 +154,7 @@ class CreateShareNetworkForm(forms.SelfHandlingForm): neutron_net_id = forms.ChoiceField(choices=(), label=_("Neutron Net ID")) neutron_subnet_id = forms.ChoiceField(choices=(), label=_("Neutron Subnet ID")) - #security_service = forms.MultipleChoiceField( + # security_service = forms.MultipleChoiceField( # widget=forms.SelectMultiple, # label=_("Security Service")) project = forms.ChoiceField(choices=(), label=_("Project")) @@ -173,9 +175,9 @@ class CreateShareNetworkForm(forms.SelfHandlingForm): choice in subnet_choices] tenants, has_more = keystone.tenant_list(request) self.fields['project'].choices = [(' ', ' ')] + \ - [(choice.id, - choice.name) for - choice in tenants] + [(choice.id, + choice.name) for + choice in tenants] def handle(self, request, data): try: diff --git a/manila_ui/dashboards/admin/shares/tables.py b/manila_ui/dashboards/admin/shares/tables.py index 29183b90..15bda5bb 100644 --- a/manila_ui/dashboards/admin/shares/tables.py +++ b/manila_ui/dashboards/admin/shares/tables.py @@ -80,7 +80,7 @@ class ShareTypesTable(tables.DataTable): def get_object_id(self, share_type): return str(share_type.id) - class Meta: + class Meta(object): name = "share_types" verbose_name = _("Share Types") table_actions = (CreateShareType, DeleteShareType, @@ -115,7 +115,7 @@ class SharesTable(shares_tables.SharesTable): verbose_name=_("Share Server"), link=get_share_server_link) - class Meta: + class Meta(object): name = "shares" verbose_name = _("Shares") status_columns = ["status"] @@ -188,7 +188,7 @@ class SnapshotsTable(tables.DataTable): def get_object_display(self, obj): return obj.name - class Meta: + class Meta(object): name = "snapshots" verbose_name = _("Snapshots") status_columns = ["status"] @@ -217,7 +217,7 @@ class DeleteShareNetwork(tables.DeleteAction): def allowed(self, request, obj): if obj: # NOTE: set always True until statuses become used - #return obj.status in ["INACTIVE", "ERROR"] + # return obj.status in ["INACTIVE", "ERROR"] return True return True @@ -257,7 +257,7 @@ class SecurityServiceTable(tables.DataTable): def get_object_id(self, security_service): return str(security_service.id) - class Meta: + class Meta(object): name = "security_services" verbose_name = _("Security Services") table_actions = (DeleteSecurityService,) @@ -295,11 +295,11 @@ class ShareNetworkTable(tables.DataTable): neutron_net_id = tables.Column("neutron_net", verbose_name=_("Neutron Net")) neutron_subnet_id = tables.Column("neutron_subnet", - verbose_name=_("Neutron Subnet")) + verbose_name=_("Neutron Subnet")) segmentation_id = tables.Column("segmentation_id", verbose_name=_("Segmentation Id")) # NOTE: removed statuses until it become used - #status = tables.Column("status", verbose_name=_("Status")) + # status = tables.Column("status", verbose_name=_("Status")) def get_object_display(self, share_network): return share_network.name or str(share_network.id) @@ -307,13 +307,14 @@ class ShareNetworkTable(tables.DataTable): def get_object_id(self, share_network): return str(share_network.id) - class Meta: + class Meta(object): name = "share_networks" verbose_name = _("Share Networks") table_actions = (DeleteShareNetwork, ) row_class = UpdateShareNetworkRow row_actions = (DeleteShareNetwork, ) + class SharesServersFilterAction(tables.FilterAction): def filter(self, table, shares, filter_string): @@ -355,7 +356,7 @@ class ShareServerTable(tables.DataTable): def get_object_id(self, share_server): return six.text_type(share_server.id) - class Meta: + class Meta(object): name = "share_servers" status_columns = ["status"] verbose_name = _("Share Server") diff --git a/manila_ui/dashboards/admin/shares/tabs.py b/manila_ui/dashboards/admin/shares/tabs.py index c3c487c5..055dd351 100644 --- a/manila_ui/dashboards/admin/shares/tabs.py +++ b/manila_ui/dashboards/admin/shares/tabs.py @@ -21,12 +21,12 @@ from horizon import tabs from openstack_dashboard.api import neutron from manila_ui.api import manila -from manila_ui.dashboards.admin.shares.tables import SharesTable -from manila_ui.dashboards.admin.shares.tables import SnapshotsTable from manila_ui.dashboards.admin.shares.tables import SecurityServiceTable from manila_ui.dashboards.admin.shares.tables import ShareNetworkTable from manila_ui.dashboards.admin.shares.tables import ShareServerTable +from manila_ui.dashboards.admin.shares.tables import SharesTable from manila_ui.dashboards.admin.shares.tables import ShareTypesTable +from manila_ui.dashboards.admin.shares.tables import SnapshotsTable from manila_ui.dashboards.admin.shares import utils @@ -53,7 +53,7 @@ class SnapshotsTab(tabs.TableTab): msg = _("Unable to retrieve snapshot list.") exceptions.handle(self.request, msg) return [] - #Gather our tenants to correlate against IDs + # Gather our tenants to correlate against IDs utils.set_tenant_name_to_objects(self.request, snapshots) return snapshots @@ -72,7 +72,7 @@ class SharesTab(tabs.TableTab): exceptions.handle(self.request, _('Unable to retrieve share list.')) return [] - #Gather our tenants to correlate against IDs + # Gather our tenants to correlate against IDs utils.set_tenant_name_to_objects(self.request, shares) return shares @@ -131,7 +131,7 @@ class ShareNetworkTab(tabs.TableTab): neutron_net_names = dict([(net.id, net.name) for net in neutron.network_list(self.request)]) neutron_subnet_names = dict([(net.id, net.name) for net in - neutron.subnet_list(self.request)]) + neutron.subnet_list(self.request)]) for share in share_networks: share.neutron_net = neutron_net_names.get( share.neutron_net_id) or share.neutron_net_id diff --git a/manila_ui/dashboards/admin/shares/urls.py b/manila_ui/dashboards/admin/shares/urls.py index 1976e4fd..a5fd95cd 100644 --- a/manila_ui/dashboards/admin/shares/urls.py +++ b/manila_ui/dashboards/admin/shares/urls.py @@ -21,7 +21,8 @@ from manila_ui.dashboards.project.shares.share_networks\ from manila_ui.dashboards.project.shares.snapshots\ import views as project_snapshot_views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^(?P[^/]+)/$', views.DetailView.as_view(), name='detail'), url(r'^snapshots/(?P[^/]+)$', diff --git a/manila_ui/dashboards/admin/shares/views.py b/manila_ui/dashboards/admin/shares/views.py index 150d1dcc..59a278d9 100644 --- a/manila_ui/dashboards/admin/shares/views.py +++ b/manila_ui/dashboards/admin/shares/views.py @@ -79,6 +79,7 @@ class UpdateShareTypeView(forms.ModalFormView): "extra_specs": share_type.extra_specs, } + class ShareServDetail(tabs.TabView): tab_group_class = project_tabs.ShareServerDetailTabs template_name = 'admin/shares/detail_share_server.html' diff --git a/manila_ui/dashboards/project/shares/security_services/forms.py b/manila_ui/dashboards/project/shares/security_services/forms.py index 3d950d5b..a796612d 100644 --- a/manila_ui/dashboards/project/shares/security_services/forms.py +++ b/manila_ui/dashboards/project/shares/security_services/forms.py @@ -66,8 +66,7 @@ class Create(forms.SelfHandlingForm): security_service = manila.security_service_create( request, **data) messages.success(request, _('Successfully created security ' - 'service: %s') - % data['name']) + 'service: %s') % data['name']) return security_service except Exception: exceptions.handle(request, @@ -77,8 +76,8 @@ class Create(forms.SelfHandlingForm): class Update(forms.SelfHandlingForm): name = forms.CharField(max_length="255", label=_("Share Name")) - description = forms.CharField(widget=forms.Textarea, - label=_("Description"), required=False) + description = forms.CharField( + widget=forms.Textarea, label=_("Description"), required=False) def handle(self, request, data): sec_service_id = self.initial['sec_service_id'] @@ -87,8 +86,8 @@ class Update(forms.SelfHandlingForm): name=data['name'], description=data['description']) - message = _('Successfully updated security service "%s"')\ - % data['name'] + message = _('Successfully updated security service ' + '"%s"') % data['name'] messages.success(request, message) return True except Exception: diff --git a/manila_ui/dashboards/project/shares/security_services/tables.py b/manila_ui/dashboards/project/shares/security_services/tables.py index 4eccef47..da992316 100644 --- a/manila_ui/dashboards/project/shares/security_services/tables.py +++ b/manila_ui/dashboards/project/shares/security_services/tables.py @@ -58,7 +58,7 @@ class SecurityServiceTable(tables.DataTable): def get_object_id(self, security_service): return str(security_service.id) - class Meta: + class Meta(object): name = "security_services" verbose_name = _("Security Services") table_actions = (Create, Delete) diff --git a/manila_ui/dashboards/project/shares/share_networks/forms.py b/manila_ui/dashboards/project/shares/share_networks/forms.py index 8f4613d4..081feec0 100644 --- a/manila_ui/dashboards/project/shares/share_networks/forms.py +++ b/manila_ui/dashboards/project/shares/share_networks/forms.py @@ -96,7 +96,7 @@ class Create(forms.SelfHandlingForm): class Update(forms.SelfHandlingForm): name = forms.CharField(max_length="255", label=_("Share Name")) description = forms.CharField(widget=forms.Textarea, - label=_("Description"), required=False) + label=_("Description"), required=False) def handle(self, request, data, *args, **kwargs): share_net_id = self.initial['share_network_id'] diff --git a/manila_ui/dashboards/project/shares/share_networks/tables.py b/manila_ui/dashboards/project/shares/share_networks/tables.py index ffc31b05..2c5567a9 100644 --- a/manila_ui/dashboards/project/shares/share_networks/tables.py +++ b/manila_ui/dashboards/project/shares/share_networks/tables.py @@ -15,7 +15,6 @@ # under the License. from django.core.urlresolvers import NoReverseMatch # noqa -from django.core.urlresolvers import reverse from django.template.defaultfilters import title # noqa from django.utils.translation import string_concat # noqa from django.utils.translation import ugettext_lazy as _ @@ -25,7 +24,6 @@ from horizon import tables from manila_ui.api import manila from openstack_dashboard.api import neutron -from openstack_dashboard.usage import quotas DELETABLE_STATES = ("INACTIVE", "ERROR") @@ -51,7 +49,7 @@ class Delete(tables.DeleteAction): def allowed(self, request, obj=None): if obj: # NOTE: leave it True until statuses become used - #return obj.status in DELETABLE_STATES + # return obj.status in DELETABLE_STATES return True return True @@ -64,8 +62,8 @@ class EditShareNetwork(tables.LinkAction): policy_rules = (("share", "share_network:update"),) def allowed(self, request, obj_id): - sn = manila.share_network_get(request, obj_id) - #return sn.status in EDITABLE_STATES + # sn = manila.share_network_get(request, obj_id) + # return sn.status in EDITABLE_STATES # NOTE: leave it always True, until statuses become used return True @@ -102,7 +100,7 @@ class ShareNetworkTable(tables.DataTable): segmentation_id = tables.Column("segmentation_id", verbose_name=_("Segmentation Id")) # NOTE: disable status column until it become used - #status = tables.Column("status", verbose_name=_("Status"), + # status = tables.Column("status", verbose_name=_("Status"), # status=True, # status_choices=STATUS_CHOICES) @@ -112,10 +110,10 @@ class ShareNetworkTable(tables.DataTable): def get_object_id(self, share_network): return str(share_network.id) - class Meta: + class Meta(object): name = "share_networks" verbose_name = _("Share Networks") table_actions = (Create, Delete, ) - #status_columns = ["status"] + # status_columns = ["status"] row_class = UpdateRow row_actions = (EditShareNetwork, Delete, ) diff --git a/manila_ui/dashboards/project/shares/share_networks/tabs.py b/manila_ui/dashboards/project/shares/share_networks/tabs.py index c58d4e71..230e0a57 100644 --- a/manila_ui/dashboards/project/shares/share_networks/tabs.py +++ b/manila_ui/dashboards/project/shares/share_networks/tabs.py @@ -36,7 +36,7 @@ class ShareNetworkTab(tabs.TableTab): neutron_net_names = dict([(net.id, net.name) for net in neutron.network_list(self.request)]) neutron_subnet_names = dict([(net.id, net.name) for net in - neutron.subnet_list(self.request)]) + neutron.subnet_list(self.request)]) for sn in share_networks: sn.neutron_net = neutron_net_names.get( sn.neutron_net_id) or sn.neutron_net_id or "-" diff --git a/manila_ui/dashboards/project/shares/share_networks/tests.py b/manila_ui/dashboards/project/shares/share_networks/tests.py index fcb2db58..4f8bf915 100644 --- a/manila_ui/dashboards/project/shares/share_networks/tests.py +++ b/manila_ui/dashboards/project/shares/share_networks/tests.py @@ -42,7 +42,7 @@ class ShareNetworksViewTests(test.TestCase): api.neutron.subnet_list = mock.Mock(return_value=self.subnets.list()) api.manila.share_network_create = mock.Mock() url = reverse('horizon:project:shares:create_share_network') - res = self.client.post(url, formData) + self.client.post(url, formData) api.manila.share_network_create.assert_called_with( mock.ANY, name=formData['name'], neutron_net_id=neutron_net_id, neutron_subnet_id=formData['subnet-choices-%s' % neutron_net_id], diff --git a/manila_ui/dashboards/project/shares/share_networks/workflows.py b/manila_ui/dashboards/project/shares/share_networks/workflows.py index c5d80413..3f93e1f1 100644 --- a/manila_ui/dashboards/project/shares/share_networks/workflows.py +++ b/manila_ui/dashboards/project/shares/share_networks/workflows.py @@ -36,7 +36,7 @@ class UpdateShareNetworkInfoAction(workflows.Action): self.fields['name'].initial = share_network.name self.fields['description'].initial = share_network.description - class Meta: + class Meta(object): name = _("Share Network Info") help_text = _("From here you can update share network info. ") slug = "update-share_network_info" @@ -83,7 +83,7 @@ class AddSecurityServiceAction(workflows.MembershipAction): self.fields[field_name].choices = sec_services_choices self.fields[field_name].initial = sec_services_initial - class Meta: + class Meta(object): name = _("Security services within share network") slug = "add_security_service" @@ -125,7 +125,8 @@ class UpdateShareNetworkWorkflow(workflows.Workflow): name=context['name']) sec_services = manila.security_service_list(request, search_opts={ 'share_network_id': context['id']}) - sec_services_old = set([sec_service.id for sec_service in sec_services]) + sec_services_old = set([sec_service.id + for sec_service in sec_services]) sec_services_new = set(context['security_service']) for sec_service in sec_services_new - sec_services_old: manila.share_network_security_service_add(request, diff --git a/manila_ui/dashboards/project/shares/shares/forms.py b/manila_ui/dashboards/project/shares/shares/forms.py index 4887c9c7..c27ffc73 100644 --- a/manila_ui/dashboards/project/shares/shares/forms.py +++ b/manila_ui/dashboards/project/shares/shares/forms.py @@ -30,7 +30,7 @@ from horizon.utils.memoized import memoized # noqa from manila_ui.api import manila from manila_ui.dashboards import utils -#from openstack_dashboard.usage import quotas +# from openstack_dashboard.usage import quotas class CreateForm(forms.SelfHandlingForm): @@ -43,7 +43,7 @@ class CreateForm(forms.SelfHandlingForm): share_type = forms.ChoiceField( label=_("Share Type"), required=True, widget=forms.Select( - attrs={'class': 'switchable','data-slug': 'sharetype'})) + attrs={'class': 'switchable', 'data-slug': 'sharetype'})) share_source_type = forms.ChoiceField( label=_("Share Source"), required=False, widget=forms.Select( @@ -82,9 +82,9 @@ class CreateForm(forms.SelfHandlingForm): self.fields['share_type'].initial = orig_share.share_type except Exception: pass - self.fields['size'].help_text = _('Share size must be equal ' - 'to or greater than the snapshot size (%sGB)') \ - % snapshot.size + self.fields['size'].help_text = _( + 'Share size must be equal to or greater than the snapshot ' + 'size (%sGB)') % snapshot.size del self.fields['share_source_type'] except Exception: exceptions.handle(request, @@ -95,7 +95,7 @@ class CreateForm(forms.SelfHandlingForm): try: snapshot_list = manila.share_snapshot_list(request) snapshots = [s for s in snapshot_list - if s.status == 'available'] + if s.status == 'available'] if snapshots: source_type_choices.append(("snapshot", _("Snapshot"))) @@ -106,12 +106,12 @@ class CreateForm(forms.SelfHandlingForm): del self.fields['snapshot'] except Exception: exceptions.handle(request, _("Unable to retrieve " - "share snapshots.")) + "share snapshots.")) if source_type_choices: choices = ([('no_source_type', _("No source, empty share"))] + - source_type_choices) + source_type_choices) self.fields['share_source_type'].choices = choices else: del self.fields['share_source_type'] @@ -129,7 +129,8 @@ class CreateForm(forms.SelfHandlingForm): [(sn.id, sn.name or sn.id) for sn in share_networks]) sn_field_name = self.sn_field_name_prefix + st.name sn_field = forms.ChoiceField( - label=_("Share Network"), required=True, choices=sn_choices, + label=_("Share Network"), required=True, + choices=sn_choices, widget=forms.Select(attrs={ 'class': 'switched', 'data-switch-on': 'sharetype', @@ -158,36 +159,36 @@ class CreateForm(forms.SelfHandlingForm): def handle(self, request, data): try: - #usages = quotas.tenant_limit_usages(self.request) - #availableGB = usages['maxTotalShareGigabytes'] - \ + # usages = quotas.tenant_limit_usages(self.request) + # availableGB = usages['maxTotalShareGigabytes'] - \ # usages['gigabytesUsed'] - #availableVol = usages['maxTotalShares'] - usages['sharesUsed'] + # availableVol = usages['maxTotalShares'] - usages['sharesUsed'] snapshot_id = None source_type = data.get('share_source_type', None) share_network = data.get('share_network', None) if (data.get("snapshot", None) and - source_type in [None, 'snapshot']): + source_type in [None, 'snapshot']): # Create from Snapshot snapshot = self.get_snapshot(request, data["snapshot"]) snapshot_id = snapshot.id if (data['size'] < snapshot.size): - error_message = _('The share size cannot be less than ' - 'the snapshot size (%sGB)') % snapshot.size + error_message = _('The share size cannot be less than the ' + 'snapshot size (%sGB)') % snapshot.size raise ValidationError(error_message) else: if type(data['size']) is str: data['size'] = int(data['size']) # - #if availableGB < data['size']: + # if availableGB < data['size']: # error_message = _('A share of %(req)iGB cannot be created as ' # 'you only have %(avail)iGB of your quota ' # 'available.') # params = {'req': data['size'], # 'avail': availableGB} # raise ValidationError(error_message % params) - #elif availableVol <= 0: + # elif availableVol <= 0: # error_message = _('You are already using all of your ' # 'available' # ' shares.') diff --git a/manila_ui/dashboards/project/shares/shares/tables.py b/manila_ui/dashboards/project/shares/shares/tables.py index e9d0ed61..072ae9e7 100644 --- a/manila_ui/dashboards/project/shares/shares/tables.py +++ b/manila_ui/dashboards/project/shares/shares/tables.py @@ -121,7 +121,8 @@ class UpdateRow(tables.Row): if not share.name: share.name = share_id if share.share_network_id: - share_net = manila.share_network_get(request, share.share_network_id) + share_net = manila.share_network_get(request, + share.share_network_id) share.share_network = share_net.name or share_net.id else: share.share_network = None @@ -229,7 +230,7 @@ class RulesTable(tables.DataTable): def get_object_display(self, obj): return obj.id - class Meta: + class Meta(object): name = "rules" verbose_name = _("Rules") status_columns = ["status"] @@ -253,7 +254,7 @@ class SharesTable(SharesTableBase): verbose_name=_("Share Network"), empty_value="-") - class Meta: + class Meta(object): name = "shares" verbose_name = _("Shares") status_columns = ["status"] diff --git a/manila_ui/dashboards/project/shares/shares/tabs.py b/manila_ui/dashboards/project/shares/shares/tabs.py index 655b56da..6a63ca14 100644 --- a/manila_ui/dashboards/project/shares/shares/tabs.py +++ b/manila_ui/dashboards/project/shares/shares/tabs.py @@ -51,7 +51,7 @@ class SharesTab(tabs.TableTab): exceptions.handle(self.request, _('Unable to retrieve share list.')) return [] - #Gather our tenants to correlate against IDs + # Gather our tenants to correlate against IDs return shares diff --git a/manila_ui/dashboards/project/shares/shares/tests.py b/manila_ui/dashboards/project/shares/shares/tests.py index 5eba2f8c..50f28e57 100644 --- a/manila_ui/dashboards/project/shares/shares/tests.py +++ b/manila_ui/dashboards/project/shares/shares/tests.py @@ -40,7 +40,7 @@ class ShareViewTests(test.TestCase): api.manila.share_snapshot_list = mock.Mock(return_value=[]) api.manila.share_network_list = mock.Mock(return_value=share_nets) url = reverse('horizon:project:shares:create') - res = self.client.post(url, formData) + self.client.post(url, formData) api.manila.share_create.assert_called_with( mock.ANY, formData['size'], formData['name'], formData['description'], formData['type'], snapshot_id=None, @@ -94,7 +94,7 @@ class ShareViewTests(test.TestCase): api.manila.share_network_list = mock.Mock(return_value=share_nets) url = reverse('horizon:project:shares:create') url = url + '?snapshot_id=%s' % snapshot.id - res = self.client.post(url, formData) + self.client.post(url, formData) api.manila.share_create.assert_called_with( mock.ANY, formData['size'], formData['name'], formData['description'], formData['type'], snapshot_id=None, @@ -180,7 +180,8 @@ class ShareViewTests(test.TestCase): api.manila.share_allow.assert_called_once_with( mock.ANY, share.id, access_type=formData['type'], access=formData['access_to']) - self.assertRedirectsNoFollow(res, + self.assertRedirectsNoFollow( + res, reverse('horizon:project:shares:manage_rules', args=[share.id])) def test_delete_rule(self): @@ -195,6 +196,6 @@ class ShareViewTests(test.TestCase): api.manila.share_rules_list = mock.Mock( return_value=[rule]) url = reverse('horizon:project:shares:manage_rules', args=[share.id]) - res = self.client.post(url, formData) + self.client.post(url, formData) api.manila.share_deny.assert_called_with( mock.ANY, test_data.share.id, rule.id) diff --git a/manila_ui/dashboards/project/shares/snapshots/forms.py b/manila_ui/dashboards/project/shares/snapshots/forms.py index 01859a95..4a4157ea 100644 --- a/manila_ui/dashboards/project/shares/snapshots/forms.py +++ b/manila_ui/dashboards/project/shares/snapshots/forms.py @@ -33,8 +33,9 @@ from manila_ui.api import manila class CreateSnapshotForm(forms.SelfHandlingForm): name = forms.CharField(max_length="255", label=_("Snapshot Name")) - description = forms.CharField(widget=forms.Textarea, - label=_("Description"), required=False) + description = forms.CharField( + widget=forms.Textarea, + label=_("Description"), required=False) def __init__(self, request, *args, **kwargs): super(CreateSnapshotForm, self).__init__(request, *args, **kwargs) @@ -46,8 +47,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm): def handle(self, request, data): try: - share = manila.share_get(request, - data['share_id']) + share = manila.share_get(request, data['share_id']) force = False message = _('Creating share snapshot "%s".') % data['name'] if share.status == 'in-use': @@ -55,10 +55,10 @@ class CreateSnapshotForm(forms.SelfHandlingForm): message = _('Forcing to create snapshot "%s" ' 'from attached share.') % data['name'] snapshot = manila.share_snapshot_create(request, - data['share_id'], - data['name'], - data['description'], - force=force) + data['share_id'], + data['name'], + data['description'], + force=force) messages.success(request, message) return snapshot diff --git a/manila_ui/dashboards/project/shares/snapshots/tables.py b/manila_ui/dashboards/project/shares/snapshots/tables.py index ebb1b747..794ced21 100644 --- a/manila_ui/dashboards/project/shares/snapshots/tables.py +++ b/manila_ui/dashboards/project/shares/snapshots/tables.py @@ -157,7 +157,7 @@ class SnapshotsTable(tables.DataTable): def get_object_display(self, obj): return obj.name - class Meta: + class Meta(object): name = "snapshots" verbose_name = _("Snapshots") status_columns = ["status"] diff --git a/manila_ui/dashboards/project/shares/snapshots/tabs.py b/manila_ui/dashboards/project/shares/snapshots/tabs.py index 15318462..b20e62a1 100644 --- a/manila_ui/dashboards/project/shares/snapshots/tabs.py +++ b/manila_ui/dashboards/project/shares/snapshots/tabs.py @@ -45,7 +45,7 @@ class SnapshotsTab(tabs.TableTab): msg = _("Unable to retrieve share snapshots list.") exceptions.handle(self.request, msg) return [] - #Gather our tenants to correlate against IDs + # Gather our tenants to correlate against IDs return snapshots diff --git a/manila_ui/dashboards/project/shares/snapshots/tests.py b/manila_ui/dashboards/project/shares/snapshots/tests.py index 7a279e8b..a4c01e45 100644 --- a/manila_ui/dashboards/project/shares/snapshots/tests.py +++ b/manila_ui/dashboards/project/shares/snapshots/tests.py @@ -39,7 +39,7 @@ class SnapshotSnapshotViewTests(test.TestCase): api.manila.share_get = mock.Mock(return_value=share) url = reverse('horizon:project:shares:create_snapshot', args=[share.id]) - res = self.client.post(url, formData) + self.client.post(url, formData) api.manila.share_snapshot_create.assert_called_with( mock.ANY, share.id, formData['name'], formData['description'], force=False) diff --git a/manila_ui/dashboards/project/shares/test_data.py b/manila_ui/dashboards/project/shares/test_data.py index 9fa2a456..21421bf5 100644 --- a/manila_ui/dashboards/project/shares/test_data.py +++ b/manila_ui/dashboards/project/shares/test_data.py @@ -13,57 +13,57 @@ # under the License. import collections +from manilaclient.v1 import quotas from manilaclient.v1 import security_services from manilaclient.v1 import share_networks from manilaclient.v1 import share_snapshots from manilaclient.v1 import shares -from manilaclient.v1 import quotas from openstack_dashboard import api from openstack_dashboard.usage import quotas as usage_quotas -share = shares.Share(shares.ShareManager(None), - {'id': "11023e92-8008-4c8b-8059-7f2293ff3887", - 'status': 'available', - 'size': 40, - 'name': 'Share name', - 'description': 'Share description', - 'share_proto': 'NFS', - 'created_at': '2014-01-27 10:30:00', - 'share_network_id': - '7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) +share = shares.Share( + shares.ShareManager(None), + {'id': "11023e92-8008-4c8b-8059-7f2293ff3887", + 'status': 'available', + 'size': 40, + 'name': 'Share name', + 'description': 'Share description', + 'share_proto': 'NFS', + 'created_at': '2014-01-27 10:30:00', + 'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) -nameless_share = shares.Share(shares.ShareManager(None), - {'id': "4b069dd0-6eaa-4272-8abc-5448a68f1cce", - 'status': 'available', - 'size': 10, - 'name': '', - 'description': '', - 'share_proto': 'NFS', - 'export_location': "/dev/hda", - 'created_at': '2010-11-21 18:34:25', - 'share_type': 'vol_type_1', - 'share_network_id': - '7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) +nameless_share = shares.Share( + shares.ShareManager(None), + {'id': "4b069dd0-6eaa-4272-8abc-5448a68f1cce", + 'status': 'available', + 'size': 10, + 'name': '', + 'description': '', + 'share_proto': 'NFS', + 'export_location': "/dev/hda", + 'created_at': '2010-11-21 18:34:25', + 'share_type': 'vol_type_1', + 'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) -other_share = shares.Share(shares.ShareManager(None), - {'id': "21023e92-8008-1234-8059-7f2293ff3889", - 'status': 'in-use', - 'size': 10, - 'name': u'my_share', - 'description': '', - 'share_proto': 'NFS', - 'created_at': '2013-04-01 10:30:00', - 'share_type': None, - 'share_network_id': - '7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) +other_share = shares.Share( + shares.ShareManager(None), + {'id': "21023e92-8008-1234-8059-7f2293ff3889", + 'status': 'in-use', + 'size': 10, + 'name': u'my_share', + 'description': '', + 'share_proto': 'NFS', + 'created_at': '2013-04-01 10:30:00', + 'share_type': None, + 'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) rule = collections.namedtuple('Access', ['access_type', 'access_to', 'status', 'id']) user_rule = rule('user', 'someuser', 'active', - '10837072-c49e-11e3-bd64-60a44c371189') + '10837072-c49e-11e3-bd64-60a44c371189') ip_rule = rule('ip', '1.1.1.1', 'active', '2cc8e2f8-c49e-11e3-bd64-60a44c371189') @@ -114,14 +114,10 @@ quota_data = dict(shares='1', quota = quotas.QuotaSet(quotas.QuotaSetManager(None), quota_data) # Quota Usages -quota_usage_data = {'gigabytes': {'used': 0, - 'quota': 1000}, - 'shares': {'used': 0, - 'quota': 10}, - 'snapshots': {'used': 0, - 'quota': 10}, - 'share_networks': {'used': 0, - 'quota': 10}} +quota_usage_data = {'gigabytes': {'used': 0, 'quota': 1000}, + 'shares': {'used': 0, 'quota': 10}, + 'snapshots': {'used': 0, 'quota': 10}, + 'share_networks': {'used': 0, 'quota': 10}} quota_usage = usage_quotas.QuotaUsage() for k, v in quota_usage_data.items(): quota_usage.add_quota(api.base.Quota(k, v['quota'])) diff --git a/manila_ui/dashboards/project/shares/urls.py b/manila_ui/dashboards/project/shares/urls.py index 6ef19ee6..ee0d9bb1 100644 --- a/manila_ui/dashboards/project/shares/urls.py +++ b/manila_ui/dashboards/project/shares/urls.py @@ -28,7 +28,8 @@ from manila_ui.dashboards.project.shares.snapshots\ from manila_ui.dashboards.project.shares import views -urlpatterns = patterns('openstack_dashboard.dashboards.project.shares.views', +urlpatterns = patterns( + 'openstack_dashboard.dashboards.project.shares.views', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^create/$', shares_views.CreateView.as_view(), name='create'), url(r'^create_security_service$', diff --git a/manila_ui/tests/base.py b/manila_ui/tests/base.py index 185fd6fd..1c30cdb5 100644 --- a/manila_ui/tests/base.py +++ b/manila_ui/tests/base.py @@ -20,4 +20,4 @@ from oslotest import base class TestCase(base.BaseTestCase): - """Test case base class for all unit tests.""" \ No newline at end of file + """Test case base class for all unit tests.""" diff --git a/manila_ui/tests/keystone_data.py b/manila_ui/tests/keystone_data.py index 2c3d4a1c..157a97c1 100644 --- a/manila_ui/tests/keystone_data.py +++ b/manila_ui/tests/keystone_data.py @@ -229,28 +229,28 @@ def data(TEST): TEST.user.service_catalog = copy.deepcopy(SERVICE_CATALOG) group_dict = {'id': "1", - 'name': 'group_one', - 'description': 'group one description', - 'project_id': '1', - 'domain_id': '1'} + 'name': 'group_one', + 'description': 'group one description', + 'project_id': '1', + 'domain_id': '1'} group = groups.Group(groups.GroupManager(None), group_dict) group_dict = {'id': "2", - 'name': 'group_two', - 'description': 'group two description', - 'project_id': '1', - 'domain_id': '1'} + 'name': 'group_two', + 'description': 'group two description', + 'project_id': '1', + 'domain_id': '1'} group2 = groups.Group(groups.GroupManager(None), group_dict) group_dict = {'id': "3", - 'name': 'group_three', - 'description': 'group three description', - 'project_id': '1', - 'domain_id': '1'} + 'name': 'group_three', + 'description': 'group three description', + 'project_id': '1', + 'domain_id': '1'} group3 = groups.Group(groups.GroupManager(None), group_dict) group_dict = {'id': "4", - 'name': 'group_four', - 'description': 'group four description', - 'project_id': '2', - 'domain_id': '2'} + 'name': 'group_four', + 'description': 'group four description', + 'project_id': '2', + 'domain_id': '2'} group4 = groups.Group(groups.GroupManager(None), group_dict) TEST.groups.add(group, group2, group3, group4) diff --git a/manila_ui/tests/test_manila_ui.py b/manila_ui/tests/test_manila_ui.py index b3bc662c..dc1bdfec 100644 --- a/manila_ui/tests/test_manila_ui.py +++ b/manila_ui/tests/test_manila_ui.py @@ -25,4 +25,4 @@ from manila_ui.tests import base class TestManila_ui(base.TestCase): def test_something(self): - pass \ No newline at end of file + pass diff --git a/requirements.txt b/requirements.txt index c34e7e6f..3e3e7d66 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,12 +8,6 @@ Babel>=1.3 Django>=1.4.2,<1.7 django_compressor>=1.4 django_openstack_auth>=1.1.7,!=1.1.8 -eventlet>=0.16.1 -kombu>=2.5.0 iso8601>=0.1.9 -netaddr>=0.7.12 -os-cloud-config python-keystoneclient>=1.1.0 -pytz>=2013.6 - python-manilaclient>=1.0.2 diff --git a/setup.py b/setup.py index 5b522ebe..73637574 100644 --- a/setup.py +++ b/setup.py @@ -27,4 +27,4 @@ except ImportError: setuptools.setup( setup_requires=['pbr'], - pbr=True) \ No newline at end of file + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt index e2d2f575..c6129890 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,6 @@ # process, which may cause wedges in the gate later. hacking<0.11,>=0.10.0 - coverage>=3.6 discover python-subunit>=0.0.18 @@ -12,4 +11,4 @@ oslosphinx>=2.2.0 # Apache-2.0 oslotest>=1.2.0 # Apache-2.0 testrepository>=0.0.18 testscenarios>=0.4 -testtools>=0.9.36,!=1.2.0 \ No newline at end of file +testtools>=0.9.36,!=1.2.0 diff --git a/tox.ini b/tox.ini index 59ab33fe..69cef359 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 1.6 -envlist = py33,py34,py26,py27,pypy,pep8 +envlist = py33,py34,py27,pep8 skipsdist = True [testenv] @@ -28,9 +28,9 @@ commands = python setup.py build_sphinx commands = oslo_debug_helper {posargs} [flake8] -# E123, E125 skipped as they are invalid PEP-8. - show-source = True -ignore = E123,E125 +# E123, E125 skipped as they are invalid PEP-8. +# H405 multi line docstring summary not separated with an empty line +ignore = E123,E125,H405 builtins = _ -exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build \ No newline at end of file +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,.ropeproject