Fix pep8 violations

This commit is contained in:
Gary W. Smith 2015-04-09 15:31:13 -07:00
parent 2dd906428c
commit 72cdc8488d
33 changed files with 157 additions and 159 deletions

View File

@ -62,6 +62,7 @@ def timesince_sortable(dt):
return mark_safe("<span data-seconds=\"%d\">%s</span>" % return mark_safe("<span data-seconds=\"%d\">%s</span>" %
(seconds, timesince(dt))) (seconds, timesince(dt)))
@register.filter @register.filter
def get_item(dictionary, key): def get_item(dictionary, key):
return dictionary.get(key) return dictionary.get(key)

View File

@ -16,4 +16,4 @@ import pbr.version
__version__ = pbr.version.VersionInfo( __version__ = pbr.version.VersionInfo(
'manila_ui').version_string() 'manila_ui').version_string()

View File

@ -156,8 +156,8 @@ def share_network_get(request, share_net_id):
def share_network_update(request, share_net_id, name=None, description=None): def share_network_update(request, share_net_id, name=None, description=None):
return manilaclient(request).share_networks.update(share_net_id, return manilaclient(request).share_networks.update(
name=name, description=description) share_net_id, name=name, description=description)
def share_network_delete(request, share_network_id): 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): 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) search_opts=search_opts)

View File

@ -71,7 +71,7 @@ class QuotasTable(tables.DataTable):
def get_object_id(self, obj): def get_object_id(self, obj):
return obj.name return obj.name
class Meta: class Meta(object):
name = "quotas" name = "quotas"
verbose_name = _("Quotas") verbose_name = _("Quotas")
table_actions = (QuotaFilterAction, UpdateDefaultQuotas) table_actions = (QuotaFilterAction, UpdateDefaultQuotas)

View File

@ -38,7 +38,8 @@ class CreateShareType(forms.SelfHandlingForm):
name = forms.CharField(max_length="255", label=_("Name")) name = forms.CharField(max_length="255", label=_("Name"))
spec_driver_handles_share_servers = forms.CharField( spec_driver_handles_share_servers = forms.CharField(
max_length="5", label=_("Driver handles share servers")) 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)) widget=forms.widgets.Textarea(attrs=ST_EXTRA_SPECS_FORM_ATTRS))
def handle(self, request, data): def handle(self, request, data):
@ -86,7 +87,8 @@ class UpdateShareType(forms.SelfHandlingForm):
es_str += "%s=%s\r\n" % (k, v) es_str += "%s=%s\r\n" % (k, v)
self.initial["extra_specs"] = es_str 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)) widget=forms.widgets.Textarea(attrs=ST_EXTRA_SPECS_FORM_ATTRS))
def handle(self, request, data): def handle(self, request, data):
@ -152,7 +154,7 @@ class CreateShareNetworkForm(forms.SelfHandlingForm):
neutron_net_id = forms.ChoiceField(choices=(), label=_("Neutron Net ID")) neutron_net_id = forms.ChoiceField(choices=(), label=_("Neutron Net ID"))
neutron_subnet_id = forms.ChoiceField(choices=(), neutron_subnet_id = forms.ChoiceField(choices=(),
label=_("Neutron Subnet ID")) label=_("Neutron Subnet ID"))
#security_service = forms.MultipleChoiceField( # security_service = forms.MultipleChoiceField(
# widget=forms.SelectMultiple, # widget=forms.SelectMultiple,
# label=_("Security Service")) # label=_("Security Service"))
project = forms.ChoiceField(choices=(), label=_("Project")) project = forms.ChoiceField(choices=(), label=_("Project"))
@ -173,9 +175,9 @@ class CreateShareNetworkForm(forms.SelfHandlingForm):
choice in subnet_choices] choice in subnet_choices]
tenants, has_more = keystone.tenant_list(request) tenants, has_more = keystone.tenant_list(request)
self.fields['project'].choices = [(' ', ' ')] + \ self.fields['project'].choices = [(' ', ' ')] + \
[(choice.id, [(choice.id,
choice.name) for choice.name) for
choice in tenants] choice in tenants]
def handle(self, request, data): def handle(self, request, data):
try: try:

View File

@ -80,7 +80,7 @@ class ShareTypesTable(tables.DataTable):
def get_object_id(self, share_type): def get_object_id(self, share_type):
return str(share_type.id) return str(share_type.id)
class Meta: class Meta(object):
name = "share_types" name = "share_types"
verbose_name = _("Share Types") verbose_name = _("Share Types")
table_actions = (CreateShareType, DeleteShareType, table_actions = (CreateShareType, DeleteShareType,
@ -115,7 +115,7 @@ class SharesTable(shares_tables.SharesTable):
verbose_name=_("Share Server"), verbose_name=_("Share Server"),
link=get_share_server_link) link=get_share_server_link)
class Meta: class Meta(object):
name = "shares" name = "shares"
verbose_name = _("Shares") verbose_name = _("Shares")
status_columns = ["status"] status_columns = ["status"]
@ -188,7 +188,7 @@ class SnapshotsTable(tables.DataTable):
def get_object_display(self, obj): def get_object_display(self, obj):
return obj.name return obj.name
class Meta: class Meta(object):
name = "snapshots" name = "snapshots"
verbose_name = _("Snapshots") verbose_name = _("Snapshots")
status_columns = ["status"] status_columns = ["status"]
@ -217,7 +217,7 @@ class DeleteShareNetwork(tables.DeleteAction):
def allowed(self, request, obj): def allowed(self, request, obj):
if obj: if obj:
# NOTE: set always True until statuses become used # NOTE: set always True until statuses become used
#return obj.status in ["INACTIVE", "ERROR"] # return obj.status in ["INACTIVE", "ERROR"]
return True return True
return True return True
@ -257,7 +257,7 @@ class SecurityServiceTable(tables.DataTable):
def get_object_id(self, security_service): def get_object_id(self, security_service):
return str(security_service.id) return str(security_service.id)
class Meta: class Meta(object):
name = "security_services" name = "security_services"
verbose_name = _("Security Services") verbose_name = _("Security Services")
table_actions = (DeleteSecurityService,) table_actions = (DeleteSecurityService,)
@ -295,11 +295,11 @@ class ShareNetworkTable(tables.DataTable):
neutron_net_id = tables.Column("neutron_net", neutron_net_id = tables.Column("neutron_net",
verbose_name=_("Neutron Net")) verbose_name=_("Neutron Net"))
neutron_subnet_id = tables.Column("neutron_subnet", neutron_subnet_id = tables.Column("neutron_subnet",
verbose_name=_("Neutron Subnet")) verbose_name=_("Neutron Subnet"))
segmentation_id = tables.Column("segmentation_id", segmentation_id = tables.Column("segmentation_id",
verbose_name=_("Segmentation Id")) verbose_name=_("Segmentation Id"))
# NOTE: removed statuses until it become used # 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): def get_object_display(self, share_network):
return share_network.name or str(share_network.id) return share_network.name or str(share_network.id)
@ -307,13 +307,14 @@ class ShareNetworkTable(tables.DataTable):
def get_object_id(self, share_network): def get_object_id(self, share_network):
return str(share_network.id) return str(share_network.id)
class Meta: class Meta(object):
name = "share_networks" name = "share_networks"
verbose_name = _("Share Networks") verbose_name = _("Share Networks")
table_actions = (DeleteShareNetwork, ) table_actions = (DeleteShareNetwork, )
row_class = UpdateShareNetworkRow row_class = UpdateShareNetworkRow
row_actions = (DeleteShareNetwork, ) row_actions = (DeleteShareNetwork, )
class SharesServersFilterAction(tables.FilterAction): class SharesServersFilterAction(tables.FilterAction):
def filter(self, table, shares, filter_string): def filter(self, table, shares, filter_string):
@ -355,7 +356,7 @@ class ShareServerTable(tables.DataTable):
def get_object_id(self, share_server): def get_object_id(self, share_server):
return six.text_type(share_server.id) return six.text_type(share_server.id)
class Meta: class Meta(object):
name = "share_servers" name = "share_servers"
status_columns = ["status"] status_columns = ["status"]
verbose_name = _("Share Server") verbose_name = _("Share Server")

View File

@ -21,12 +21,12 @@ from horizon import tabs
from openstack_dashboard.api import neutron from openstack_dashboard.api import neutron
from manila_ui.api import manila 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 SecurityServiceTable
from manila_ui.dashboards.admin.shares.tables import ShareNetworkTable 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 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 ShareTypesTable
from manila_ui.dashboards.admin.shares.tables import SnapshotsTable
from manila_ui.dashboards.admin.shares import utils from manila_ui.dashboards.admin.shares import utils
@ -53,7 +53,7 @@ class SnapshotsTab(tabs.TableTab):
msg = _("Unable to retrieve snapshot list.") msg = _("Unable to retrieve snapshot list.")
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return [] return []
#Gather our tenants to correlate against IDs # Gather our tenants to correlate against IDs
utils.set_tenant_name_to_objects(self.request, snapshots) utils.set_tenant_name_to_objects(self.request, snapshots)
return snapshots return snapshots
@ -72,7 +72,7 @@ class SharesTab(tabs.TableTab):
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve share list.')) _('Unable to retrieve share list.'))
return [] return []
#Gather our tenants to correlate against IDs # Gather our tenants to correlate against IDs
utils.set_tenant_name_to_objects(self.request, shares) utils.set_tenant_name_to_objects(self.request, shares)
return shares return shares
@ -131,7 +131,7 @@ class ShareNetworkTab(tabs.TableTab):
neutron_net_names = dict([(net.id, net.name) for net in neutron_net_names = dict([(net.id, net.name) for net in
neutron.network_list(self.request)]) neutron.network_list(self.request)])
neutron_subnet_names = dict([(net.id, net.name) for net in 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: for share in share_networks:
share.neutron_net = neutron_net_names.get( share.neutron_net = neutron_net_names.get(
share.neutron_net_id) or share.neutron_net_id share.neutron_net_id) or share.neutron_net_id

View File

@ -21,7 +21,8 @@ from manila_ui.dashboards.project.shares.share_networks\
from manila_ui.dashboards.project.shares.snapshots\ from manila_ui.dashboards.project.shares.snapshots\
import views as project_snapshot_views import views as project_snapshot_views
urlpatterns = patterns('', urlpatterns = patterns(
'',
url(r'^$', views.IndexView.as_view(), name='index'), url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P<share_id>[^/]+)/$', views.DetailView.as_view(), name='detail'), url(r'^(?P<share_id>[^/]+)/$', views.DetailView.as_view(), name='detail'),
url(r'^snapshots/(?P<snapshot_id>[^/]+)$', url(r'^snapshots/(?P<snapshot_id>[^/]+)$',

View File

@ -79,6 +79,7 @@ class UpdateShareTypeView(forms.ModalFormView):
"extra_specs": share_type.extra_specs, "extra_specs": share_type.extra_specs,
} }
class ShareServDetail(tabs.TabView): class ShareServDetail(tabs.TabView):
tab_group_class = project_tabs.ShareServerDetailTabs tab_group_class = project_tabs.ShareServerDetailTabs
template_name = 'admin/shares/detail_share_server.html' template_name = 'admin/shares/detail_share_server.html'

View File

@ -66,8 +66,7 @@ class Create(forms.SelfHandlingForm):
security_service = manila.security_service_create( security_service = manila.security_service_create(
request, **data) request, **data)
messages.success(request, _('Successfully created security ' messages.success(request, _('Successfully created security '
'service: %s') 'service: %s') % data['name'])
% data['name'])
return security_service return security_service
except Exception: except Exception:
exceptions.handle(request, exceptions.handle(request,
@ -77,8 +76,8 @@ class Create(forms.SelfHandlingForm):
class Update(forms.SelfHandlingForm): class Update(forms.SelfHandlingForm):
name = forms.CharField(max_length="255", label=_("Share Name")) name = forms.CharField(max_length="255", label=_("Share Name"))
description = forms.CharField(widget=forms.Textarea, description = forms.CharField(
label=_("Description"), required=False) widget=forms.Textarea, label=_("Description"), required=False)
def handle(self, request, data): def handle(self, request, data):
sec_service_id = self.initial['sec_service_id'] sec_service_id = self.initial['sec_service_id']
@ -87,8 +86,8 @@ class Update(forms.SelfHandlingForm):
name=data['name'], name=data['name'],
description=data['description']) description=data['description'])
message = _('Successfully updated security service "%s"')\ message = _('Successfully updated security service '
% data['name'] '"%s"') % data['name']
messages.success(request, message) messages.success(request, message)
return True return True
except Exception: except Exception:

View File

@ -58,7 +58,7 @@ class SecurityServiceTable(tables.DataTable):
def get_object_id(self, security_service): def get_object_id(self, security_service):
return str(security_service.id) return str(security_service.id)
class Meta: class Meta(object):
name = "security_services" name = "security_services"
verbose_name = _("Security Services") verbose_name = _("Security Services")
table_actions = (Create, Delete) table_actions = (Create, Delete)

View File

@ -96,7 +96,7 @@ class Create(forms.SelfHandlingForm):
class Update(forms.SelfHandlingForm): class Update(forms.SelfHandlingForm):
name = forms.CharField(max_length="255", label=_("Share Name")) name = forms.CharField(max_length="255", label=_("Share Name"))
description = forms.CharField(widget=forms.Textarea, description = forms.CharField(widget=forms.Textarea,
label=_("Description"), required=False) label=_("Description"), required=False)
def handle(self, request, data, *args, **kwargs): def handle(self, request, data, *args, **kwargs):
share_net_id = self.initial['share_network_id'] share_net_id = self.initial['share_network_id']

View File

@ -15,7 +15,6 @@
# under the License. # under the License.
from django.core.urlresolvers import NoReverseMatch # noqa from django.core.urlresolvers import NoReverseMatch # noqa
from django.core.urlresolvers import reverse
from django.template.defaultfilters import title # noqa from django.template.defaultfilters import title # noqa
from django.utils.translation import string_concat # noqa from django.utils.translation import string_concat # noqa
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@ -25,7 +24,6 @@ from horizon import tables
from manila_ui.api import manila from manila_ui.api import manila
from openstack_dashboard.api import neutron from openstack_dashboard.api import neutron
from openstack_dashboard.usage import quotas
DELETABLE_STATES = ("INACTIVE", "ERROR") DELETABLE_STATES = ("INACTIVE", "ERROR")
@ -51,7 +49,7 @@ class Delete(tables.DeleteAction):
def allowed(self, request, obj=None): def allowed(self, request, obj=None):
if obj: if obj:
# NOTE: leave it True until statuses become used # NOTE: leave it True until statuses become used
#return obj.status in DELETABLE_STATES # return obj.status in DELETABLE_STATES
return True return True
return True return True
@ -64,8 +62,8 @@ class EditShareNetwork(tables.LinkAction):
policy_rules = (("share", "share_network:update"),) policy_rules = (("share", "share_network:update"),)
def allowed(self, request, obj_id): def allowed(self, request, obj_id):
sn = manila.share_network_get(request, obj_id) # sn = manila.share_network_get(request, obj_id)
#return sn.status in EDITABLE_STATES # return sn.status in EDITABLE_STATES
# NOTE: leave it always True, until statuses become used # NOTE: leave it always True, until statuses become used
return True return True
@ -102,7 +100,7 @@ class ShareNetworkTable(tables.DataTable):
segmentation_id = tables.Column("segmentation_id", segmentation_id = tables.Column("segmentation_id",
verbose_name=_("Segmentation Id")) verbose_name=_("Segmentation Id"))
# NOTE: disable status column until it become used # 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=True,
# status_choices=STATUS_CHOICES) # status_choices=STATUS_CHOICES)
@ -112,10 +110,10 @@ class ShareNetworkTable(tables.DataTable):
def get_object_id(self, share_network): def get_object_id(self, share_network):
return str(share_network.id) return str(share_network.id)
class Meta: class Meta(object):
name = "share_networks" name = "share_networks"
verbose_name = _("Share Networks") verbose_name = _("Share Networks")
table_actions = (Create, Delete, ) table_actions = (Create, Delete, )
#status_columns = ["status"] # status_columns = ["status"]
row_class = UpdateRow row_class = UpdateRow
row_actions = (EditShareNetwork, Delete, ) row_actions = (EditShareNetwork, Delete, )

View File

@ -36,7 +36,7 @@ class ShareNetworkTab(tabs.TableTab):
neutron_net_names = dict([(net.id, net.name) for net in neutron_net_names = dict([(net.id, net.name) for net in
neutron.network_list(self.request)]) neutron.network_list(self.request)])
neutron_subnet_names = dict([(net.id, net.name) for net in 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: for sn in share_networks:
sn.neutron_net = neutron_net_names.get( sn.neutron_net = neutron_net_names.get(
sn.neutron_net_id) or sn.neutron_net_id or "-" sn.neutron_net_id) or sn.neutron_net_id or "-"

View File

@ -42,7 +42,7 @@ class ShareNetworksViewTests(test.TestCase):
api.neutron.subnet_list = mock.Mock(return_value=self.subnets.list()) api.neutron.subnet_list = mock.Mock(return_value=self.subnets.list())
api.manila.share_network_create = mock.Mock() api.manila.share_network_create = mock.Mock()
url = reverse('horizon:project:shares:create_share_network') 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( api.manila.share_network_create.assert_called_with(
mock.ANY, name=formData['name'], neutron_net_id=neutron_net_id, mock.ANY, name=formData['name'], neutron_net_id=neutron_net_id,
neutron_subnet_id=formData['subnet-choices-%s' % neutron_net_id], neutron_subnet_id=formData['subnet-choices-%s' % neutron_net_id],

View File

@ -36,7 +36,7 @@ class UpdateShareNetworkInfoAction(workflows.Action):
self.fields['name'].initial = share_network.name self.fields['name'].initial = share_network.name
self.fields['description'].initial = share_network.description self.fields['description'].initial = share_network.description
class Meta: class Meta(object):
name = _("Share Network Info") name = _("Share Network Info")
help_text = _("From here you can update share network info. ") help_text = _("From here you can update share network info. ")
slug = "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].choices = sec_services_choices
self.fields[field_name].initial = sec_services_initial self.fields[field_name].initial = sec_services_initial
class Meta: class Meta(object):
name = _("Security services within share network") name = _("Security services within share network")
slug = "add_security_service" slug = "add_security_service"
@ -125,7 +125,8 @@ class UpdateShareNetworkWorkflow(workflows.Workflow):
name=context['name']) name=context['name'])
sec_services = manila.security_service_list(request, search_opts={ sec_services = manila.security_service_list(request, search_opts={
'share_network_id': context['id']}) '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']) sec_services_new = set(context['security_service'])
for sec_service in sec_services_new - sec_services_old: for sec_service in sec_services_new - sec_services_old:
manila.share_network_security_service_add(request, manila.share_network_security_service_add(request,

View File

@ -30,7 +30,7 @@ from horizon.utils.memoized import memoized # noqa
from manila_ui.api import manila from manila_ui.api import manila
from manila_ui.dashboards import utils from manila_ui.dashboards import utils
#from openstack_dashboard.usage import quotas # from openstack_dashboard.usage import quotas
class CreateForm(forms.SelfHandlingForm): class CreateForm(forms.SelfHandlingForm):
@ -43,7 +43,7 @@ class CreateForm(forms.SelfHandlingForm):
share_type = forms.ChoiceField( share_type = forms.ChoiceField(
label=_("Share Type"), required=True, label=_("Share Type"), required=True,
widget=forms.Select( widget=forms.Select(
attrs={'class': 'switchable','data-slug': 'sharetype'})) attrs={'class': 'switchable', 'data-slug': 'sharetype'}))
share_source_type = forms.ChoiceField( share_source_type = forms.ChoiceField(
label=_("Share Source"), required=False, label=_("Share Source"), required=False,
widget=forms.Select( widget=forms.Select(
@ -82,9 +82,9 @@ class CreateForm(forms.SelfHandlingForm):
self.fields['share_type'].initial = orig_share.share_type self.fields['share_type'].initial = orig_share.share_type
except Exception: except Exception:
pass pass
self.fields['size'].help_text = _('Share size must be equal ' self.fields['size'].help_text = _(
'to or greater than the snapshot size (%sGB)') \ 'Share size must be equal to or greater than the snapshot '
% snapshot.size 'size (%sGB)') % snapshot.size
del self.fields['share_source_type'] del self.fields['share_source_type']
except Exception: except Exception:
exceptions.handle(request, exceptions.handle(request,
@ -95,7 +95,7 @@ class CreateForm(forms.SelfHandlingForm):
try: try:
snapshot_list = manila.share_snapshot_list(request) snapshot_list = manila.share_snapshot_list(request)
snapshots = [s for s in snapshot_list snapshots = [s for s in snapshot_list
if s.status == 'available'] if s.status == 'available']
if snapshots: if snapshots:
source_type_choices.append(("snapshot", source_type_choices.append(("snapshot",
_("Snapshot"))) _("Snapshot")))
@ -106,12 +106,12 @@ class CreateForm(forms.SelfHandlingForm):
del self.fields['snapshot'] del self.fields['snapshot']
except Exception: except Exception:
exceptions.handle(request, _("Unable to retrieve " exceptions.handle(request, _("Unable to retrieve "
"share snapshots.")) "share snapshots."))
if source_type_choices: if source_type_choices:
choices = ([('no_source_type', choices = ([('no_source_type',
_("No source, empty share"))] + _("No source, empty share"))] +
source_type_choices) source_type_choices)
self.fields['share_source_type'].choices = choices self.fields['share_source_type'].choices = choices
else: else:
del self.fields['share_source_type'] 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.id, sn.name or sn.id) for sn in share_networks])
sn_field_name = self.sn_field_name_prefix + st.name sn_field_name = self.sn_field_name_prefix + st.name
sn_field = forms.ChoiceField( sn_field = forms.ChoiceField(
label=_("Share Network"), required=True, choices=sn_choices, label=_("Share Network"), required=True,
choices=sn_choices,
widget=forms.Select(attrs={ widget=forms.Select(attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'sharetype', 'data-switch-on': 'sharetype',
@ -158,36 +159,36 @@ class CreateForm(forms.SelfHandlingForm):
def handle(self, request, data): def handle(self, request, data):
try: try:
#usages = quotas.tenant_limit_usages(self.request) # usages = quotas.tenant_limit_usages(self.request)
#availableGB = usages['maxTotalShareGigabytes'] - \ # availableGB = usages['maxTotalShareGigabytes'] - \
# usages['gigabytesUsed'] # usages['gigabytesUsed']
#availableVol = usages['maxTotalShares'] - usages['sharesUsed'] # availableVol = usages['maxTotalShares'] - usages['sharesUsed']
snapshot_id = None snapshot_id = None
source_type = data.get('share_source_type', None) source_type = data.get('share_source_type', None)
share_network = data.get('share_network', None) share_network = data.get('share_network', None)
if (data.get("snapshot", None) and if (data.get("snapshot", None) and
source_type in [None, 'snapshot']): source_type in [None, 'snapshot']):
# Create from Snapshot # Create from Snapshot
snapshot = self.get_snapshot(request, snapshot = self.get_snapshot(request,
data["snapshot"]) data["snapshot"])
snapshot_id = snapshot.id snapshot_id = snapshot.id
if (data['size'] < snapshot.size): if (data['size'] < snapshot.size):
error_message = _('The share size cannot be less than ' error_message = _('The share size cannot be less than the '
'the snapshot size (%sGB)') % snapshot.size 'snapshot size (%sGB)') % snapshot.size
raise ValidationError(error_message) raise ValidationError(error_message)
else: else:
if type(data['size']) is str: if type(data['size']) is str:
data['size'] = int(data['size']) data['size'] = int(data['size'])
# #
#if availableGB < data['size']: # if availableGB < data['size']:
# error_message = _('A share of %(req)iGB cannot be created as ' # error_message = _('A share of %(req)iGB cannot be created as '
# 'you only have %(avail)iGB of your quota ' # 'you only have %(avail)iGB of your quota '
# 'available.') # 'available.')
# params = {'req': data['size'], # params = {'req': data['size'],
# 'avail': availableGB} # 'avail': availableGB}
# raise ValidationError(error_message % params) # raise ValidationError(error_message % params)
#elif availableVol <= 0: # elif availableVol <= 0:
# error_message = _('You are already using all of your ' # error_message = _('You are already using all of your '
# 'available' # 'available'
# ' shares.') # ' shares.')

View File

@ -121,7 +121,8 @@ class UpdateRow(tables.Row):
if not share.name: if not share.name:
share.name = share_id share.name = share_id
if share.share_network_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 share.share_network = share_net.name or share_net.id
else: else:
share.share_network = None share.share_network = None
@ -229,7 +230,7 @@ class RulesTable(tables.DataTable):
def get_object_display(self, obj): def get_object_display(self, obj):
return obj.id return obj.id
class Meta: class Meta(object):
name = "rules" name = "rules"
verbose_name = _("Rules") verbose_name = _("Rules")
status_columns = ["status"] status_columns = ["status"]
@ -253,7 +254,7 @@ class SharesTable(SharesTableBase):
verbose_name=_("Share Network"), verbose_name=_("Share Network"),
empty_value="-") empty_value="-")
class Meta: class Meta(object):
name = "shares" name = "shares"
verbose_name = _("Shares") verbose_name = _("Shares")
status_columns = ["status"] status_columns = ["status"]

View File

@ -51,7 +51,7 @@ class SharesTab(tabs.TableTab):
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve share list.')) _('Unable to retrieve share list.'))
return [] return []
#Gather our tenants to correlate against IDs # Gather our tenants to correlate against IDs
return shares return shares

View File

@ -40,7 +40,7 @@ class ShareViewTests(test.TestCase):
api.manila.share_snapshot_list = mock.Mock(return_value=[]) api.manila.share_snapshot_list = mock.Mock(return_value=[])
api.manila.share_network_list = mock.Mock(return_value=share_nets) api.manila.share_network_list = mock.Mock(return_value=share_nets)
url = reverse('horizon:project:shares:create') url = reverse('horizon:project:shares:create')
res = self.client.post(url, formData) self.client.post(url, formData)
api.manila.share_create.assert_called_with( api.manila.share_create.assert_called_with(
mock.ANY, formData['size'], formData['name'], mock.ANY, formData['size'], formData['name'],
formData['description'], formData['type'], snapshot_id=None, 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) api.manila.share_network_list = mock.Mock(return_value=share_nets)
url = reverse('horizon:project:shares:create') url = reverse('horizon:project:shares:create')
url = url + '?snapshot_id=%s' % snapshot.id 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( api.manila.share_create.assert_called_with(
mock.ANY, formData['size'], formData['name'], mock.ANY, formData['size'], formData['name'],
formData['description'], formData['type'], snapshot_id=None, formData['description'], formData['type'], snapshot_id=None,
@ -180,7 +180,8 @@ class ShareViewTests(test.TestCase):
api.manila.share_allow.assert_called_once_with( api.manila.share_allow.assert_called_once_with(
mock.ANY, share.id, access_type=formData['type'], mock.ANY, share.id, access_type=formData['type'],
access=formData['access_to']) access=formData['access_to'])
self.assertRedirectsNoFollow(res, self.assertRedirectsNoFollow(
res,
reverse('horizon:project:shares:manage_rules', args=[share.id])) reverse('horizon:project:shares:manage_rules', args=[share.id]))
def test_delete_rule(self): def test_delete_rule(self):
@ -195,6 +196,6 @@ class ShareViewTests(test.TestCase):
api.manila.share_rules_list = mock.Mock( api.manila.share_rules_list = mock.Mock(
return_value=[rule]) return_value=[rule])
url = reverse('horizon:project:shares:manage_rules', args=[share.id]) 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( api.manila.share_deny.assert_called_with(
mock.ANY, test_data.share.id, rule.id) mock.ANY, test_data.share.id, rule.id)

View File

@ -33,8 +33,9 @@ from manila_ui.api import manila
class CreateSnapshotForm(forms.SelfHandlingForm): class CreateSnapshotForm(forms.SelfHandlingForm):
name = forms.CharField(max_length="255", label=_("Snapshot Name")) name = forms.CharField(max_length="255", label=_("Snapshot Name"))
description = forms.CharField(widget=forms.Textarea, description = forms.CharField(
label=_("Description"), required=False) widget=forms.Textarea,
label=_("Description"), required=False)
def __init__(self, request, *args, **kwargs): def __init__(self, request, *args, **kwargs):
super(CreateSnapshotForm, self).__init__(request, *args, **kwargs) super(CreateSnapshotForm, self).__init__(request, *args, **kwargs)
@ -46,8 +47,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
def handle(self, request, data): def handle(self, request, data):
try: try:
share = manila.share_get(request, share = manila.share_get(request, data['share_id'])
data['share_id'])
force = False force = False
message = _('Creating share snapshot "%s".') % data['name'] message = _('Creating share snapshot "%s".') % data['name']
if share.status == 'in-use': if share.status == 'in-use':
@ -55,10 +55,10 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
message = _('Forcing to create snapshot "%s" ' message = _('Forcing to create snapshot "%s" '
'from attached share.') % data['name'] 'from attached share.') % data['name']
snapshot = manila.share_snapshot_create(request, snapshot = manila.share_snapshot_create(request,
data['share_id'], data['share_id'],
data['name'], data['name'],
data['description'], data['description'],
force=force) force=force)
messages.success(request, message) messages.success(request, message)
return snapshot return snapshot

View File

@ -157,7 +157,7 @@ class SnapshotsTable(tables.DataTable):
def get_object_display(self, obj): def get_object_display(self, obj):
return obj.name return obj.name
class Meta: class Meta(object):
name = "snapshots" name = "snapshots"
verbose_name = _("Snapshots") verbose_name = _("Snapshots")
status_columns = ["status"] status_columns = ["status"]

View File

@ -45,7 +45,7 @@ class SnapshotsTab(tabs.TableTab):
msg = _("Unable to retrieve share snapshots list.") msg = _("Unable to retrieve share snapshots list.")
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return [] return []
#Gather our tenants to correlate against IDs # Gather our tenants to correlate against IDs
return snapshots return snapshots

View File

@ -39,7 +39,7 @@ class SnapshotSnapshotViewTests(test.TestCase):
api.manila.share_get = mock.Mock(return_value=share) api.manila.share_get = mock.Mock(return_value=share)
url = reverse('horizon:project:shares:create_snapshot', url = reverse('horizon:project:shares:create_snapshot',
args=[share.id]) args=[share.id])
res = self.client.post(url, formData) self.client.post(url, formData)
api.manila.share_snapshot_create.assert_called_with( api.manila.share_snapshot_create.assert_called_with(
mock.ANY, share.id, formData['name'], formData['description'], mock.ANY, share.id, formData['name'], formData['description'],
force=False) force=False)

View File

@ -13,57 +13,57 @@
# under the License. # under the License.
import collections import collections
from manilaclient.v1 import quotas
from manilaclient.v1 import security_services from manilaclient.v1 import security_services
from manilaclient.v1 import share_networks from manilaclient.v1 import share_networks
from manilaclient.v1 import share_snapshots from manilaclient.v1 import share_snapshots
from manilaclient.v1 import shares from manilaclient.v1 import shares
from manilaclient.v1 import quotas
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.usage import quotas as usage_quotas from openstack_dashboard.usage import quotas as usage_quotas
share = shares.Share(shares.ShareManager(None), share = shares.Share(
{'id': "11023e92-8008-4c8b-8059-7f2293ff3887", shares.ShareManager(None),
'status': 'available', {'id': "11023e92-8008-4c8b-8059-7f2293ff3887",
'size': 40, 'status': 'available',
'name': 'Share name', 'size': 40,
'description': 'Share description', 'name': 'Share name',
'share_proto': 'NFS', 'description': 'Share description',
'created_at': '2014-01-27 10:30:00', 'share_proto': 'NFS',
'share_network_id': 'created_at': '2014-01-27 10:30:00',
'7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) 'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d'})
nameless_share = shares.Share(shares.ShareManager(None), nameless_share = shares.Share(
{'id': "4b069dd0-6eaa-4272-8abc-5448a68f1cce", shares.ShareManager(None),
'status': 'available', {'id': "4b069dd0-6eaa-4272-8abc-5448a68f1cce",
'size': 10, 'status': 'available',
'name': '', 'size': 10,
'description': '', 'name': '',
'share_proto': 'NFS', 'description': '',
'export_location': "/dev/hda", 'share_proto': 'NFS',
'created_at': '2010-11-21 18:34:25', 'export_location': "/dev/hda",
'share_type': 'vol_type_1', 'created_at': '2010-11-21 18:34:25',
'share_network_id': 'share_type': 'vol_type_1',
'7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) 'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d'})
other_share = shares.Share(shares.ShareManager(None), other_share = shares.Share(
{'id': "21023e92-8008-1234-8059-7f2293ff3889", shares.ShareManager(None),
'status': 'in-use', {'id': "21023e92-8008-1234-8059-7f2293ff3889",
'size': 10, 'status': 'in-use',
'name': u'my_share', 'size': 10,
'description': '', 'name': u'my_share',
'share_proto': 'NFS', 'description': '',
'created_at': '2013-04-01 10:30:00', 'share_proto': 'NFS',
'share_type': None, 'created_at': '2013-04-01 10:30:00',
'share_network_id': 'share_type': None,
'7f3d1c33-8d00-4511-29df-a2def31f3b5d'}) 'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d'})
rule = collections.namedtuple('Access', ['access_type', 'access_to', 'status', rule = collections.namedtuple('Access', ['access_type', 'access_to', 'status',
'id']) 'id'])
user_rule = rule('user', 'someuser', 'active', 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', ip_rule = rule('ip', '1.1.1.1', 'active',
'2cc8e2f8-c49e-11e3-bd64-60a44c371189') '2cc8e2f8-c49e-11e3-bd64-60a44c371189')
@ -114,14 +114,10 @@ quota_data = dict(shares='1',
quota = quotas.QuotaSet(quotas.QuotaSetManager(None), quota_data) quota = quotas.QuotaSet(quotas.QuotaSetManager(None), quota_data)
# Quota Usages # Quota Usages
quota_usage_data = {'gigabytes': {'used': 0, quota_usage_data = {'gigabytes': {'used': 0, 'quota': 1000},
'quota': 1000}, 'shares': {'used': 0, 'quota': 10},
'shares': {'used': 0, 'snapshots': {'used': 0, 'quota': 10},
'quota': 10}, 'share_networks': {'used': 0, 'quota': 10}}
'snapshots': {'used': 0,
'quota': 10},
'share_networks': {'used': 0,
'quota': 10}}
quota_usage = usage_quotas.QuotaUsage() quota_usage = usage_quotas.QuotaUsage()
for k, v in quota_usage_data.items(): for k, v in quota_usage_data.items():
quota_usage.add_quota(api.base.Quota(k, v['quota'])) quota_usage.add_quota(api.base.Quota(k, v['quota']))

View File

@ -28,7 +28,8 @@ from manila_ui.dashboards.project.shares.snapshots\
from manila_ui.dashboards.project.shares import views 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'^$', views.IndexView.as_view(), name='index'),
url(r'^create/$', shares_views.CreateView.as_view(), name='create'), url(r'^create/$', shares_views.CreateView.as_view(), name='create'),
url(r'^create_security_service$', url(r'^create_security_service$',

View File

@ -20,4 +20,4 @@ from oslotest import base
class TestCase(base.BaseTestCase): class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests.""" """Test case base class for all unit tests."""

View File

@ -229,28 +229,28 @@ def data(TEST):
TEST.user.service_catalog = copy.deepcopy(SERVICE_CATALOG) TEST.user.service_catalog = copy.deepcopy(SERVICE_CATALOG)
group_dict = {'id': "1", group_dict = {'id': "1",
'name': 'group_one', 'name': 'group_one',
'description': 'group one description', 'description': 'group one description',
'project_id': '1', 'project_id': '1',
'domain_id': '1'} 'domain_id': '1'}
group = groups.Group(groups.GroupManager(None), group_dict) group = groups.Group(groups.GroupManager(None), group_dict)
group_dict = {'id': "2", group_dict = {'id': "2",
'name': 'group_two', 'name': 'group_two',
'description': 'group two description', 'description': 'group two description',
'project_id': '1', 'project_id': '1',
'domain_id': '1'} 'domain_id': '1'}
group2 = groups.Group(groups.GroupManager(None), group_dict) group2 = groups.Group(groups.GroupManager(None), group_dict)
group_dict = {'id': "3", group_dict = {'id': "3",
'name': 'group_three', 'name': 'group_three',
'description': 'group three description', 'description': 'group three description',
'project_id': '1', 'project_id': '1',
'domain_id': '1'} 'domain_id': '1'}
group3 = groups.Group(groups.GroupManager(None), group_dict) group3 = groups.Group(groups.GroupManager(None), group_dict)
group_dict = {'id': "4", group_dict = {'id': "4",
'name': 'group_four', 'name': 'group_four',
'description': 'group four description', 'description': 'group four description',
'project_id': '2', 'project_id': '2',
'domain_id': '2'} 'domain_id': '2'}
group4 = groups.Group(groups.GroupManager(None), group_dict) group4 = groups.Group(groups.GroupManager(None), group_dict)
TEST.groups.add(group, group2, group3, group4) TEST.groups.add(group, group2, group3, group4)

View File

@ -25,4 +25,4 @@ from manila_ui.tests import base
class TestManila_ui(base.TestCase): class TestManila_ui(base.TestCase):
def test_something(self): def test_something(self):
pass pass

View File

@ -8,12 +8,6 @@ Babel>=1.3
Django>=1.4.2,<1.7 Django>=1.4.2,<1.7
django_compressor>=1.4 django_compressor>=1.4
django_openstack_auth>=1.1.7,!=1.1.8 django_openstack_auth>=1.1.7,!=1.1.8
eventlet>=0.16.1
kombu>=2.5.0
iso8601>=0.1.9 iso8601>=0.1.9
netaddr>=0.7.12
os-cloud-config
python-keystoneclient>=1.1.0 python-keystoneclient>=1.1.0
pytz>=2013.6
python-manilaclient>=1.0.2 python-manilaclient>=1.0.2

View File

@ -27,4 +27,4 @@ except ImportError:
setuptools.setup( setuptools.setup(
setup_requires=['pbr'], setup_requires=['pbr'],
pbr=True) pbr=True)

View File

@ -3,7 +3,6 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking<0.11,>=0.10.0 hacking<0.11,>=0.10.0
coverage>=3.6 coverage>=3.6
discover discover
python-subunit>=0.0.18 python-subunit>=0.0.18
@ -12,4 +11,4 @@ oslosphinx>=2.2.0 # Apache-2.0
oslotest>=1.2.0 # Apache-2.0 oslotest>=1.2.0 # Apache-2.0
testrepository>=0.0.18 testrepository>=0.0.18
testscenarios>=0.4 testscenarios>=0.4
testtools>=0.9.36,!=1.2.0 testtools>=0.9.36,!=1.2.0

10
tox.ini
View File

@ -1,6 +1,6 @@
[tox] [tox]
minversion = 1.6 minversion = 1.6
envlist = py33,py34,py26,py27,pypy,pep8 envlist = py33,py34,py27,pep8
skipsdist = True skipsdist = True
[testenv] [testenv]
@ -28,9 +28,9 @@ commands = python setup.py build_sphinx
commands = oslo_debug_helper {posargs} commands = oslo_debug_helper {posargs}
[flake8] [flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True 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 = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,.ropeproject