Merge "rm invalid args when updating quotas with nova api"
This commit is contained in:
commit
a53d6491a9
@ -55,7 +55,8 @@ def cinderclient(request):
|
|||||||
request.user.token.id,
|
request.user.token.id,
|
||||||
project_id=request.user.tenant_id,
|
project_id=request.user.tenant_id,
|
||||||
auth_url=cinder_url,
|
auth_url=cinder_url,
|
||||||
insecure=insecure)
|
insecure=insecure,
|
||||||
|
http_log_debug=settings.DEBUG)
|
||||||
c.client.auth_token = request.user.token.id
|
c.client.auth_token = request.user.token.id
|
||||||
c.client.management_url = cinder_url
|
c.client.management_url = cinder_url
|
||||||
return c
|
return c
|
||||||
|
@ -26,7 +26,8 @@ from horizon import exceptions
|
|||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard.test import helpers as test
|
from openstack_dashboard.test import helpers as test
|
||||||
from openstack_dashboard.usage import quotas
|
from openstack_dashboard.usage import quotas
|
||||||
from .workflows import CreateProject, UpdateProject
|
from .workflows import CreateProject, UpdateProject, NOVA_QUOTA_FIELDS, \
|
||||||
|
CINDER_QUOTA_FIELDS
|
||||||
from .views import QUOTA_FIELDS
|
from .views import QUOTA_FIELDS
|
||||||
|
|
||||||
INDEX_URL = reverse('horizon:admin:projects:index')
|
INDEX_URL = reverse('horizon:admin:projects:index')
|
||||||
@ -151,9 +152,16 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
role_id=role.id)
|
role_id=role.id)
|
||||||
|
|
||||||
|
nova_updated_quota = dict([(key, quota_data[key]) for key in
|
||||||
|
NOVA_QUOTA_FIELDS])
|
||||||
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
project.id,
|
project.id,
|
||||||
**quota_data)
|
**nova_updated_quota)
|
||||||
|
cinder_updated_quota = dict([(key, quota_data[key]) for key in
|
||||||
|
CINDER_QUOTA_FIELDS])
|
||||||
|
api.cinder.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
|
project.id,
|
||||||
|
**cinder_updated_quota)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
@ -274,9 +282,11 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
role_id=role.id)
|
role_id=role.id)
|
||||||
|
|
||||||
|
nova_updated_quota = dict([(key, quota_data[key]) for key in
|
||||||
|
NOVA_QUOTA_FIELDS])
|
||||||
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
project.id,
|
project.id,
|
||||||
**quota_data) \
|
**nova_updated_quota) \
|
||||||
.AndRaise(self.exceptions.nova)
|
.AndRaise(self.exceptions.nova)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
@ -295,6 +305,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
'get_default_role',
|
'get_default_role',
|
||||||
'add_tenant_user_role'),
|
'add_tenant_user_role'),
|
||||||
quotas: ('get_default_quota_data',),
|
quotas: ('get_default_quota_data',),
|
||||||
|
api.cinder: ('tenant_quota_update',),
|
||||||
api.nova: ('tenant_quota_update',)})
|
api.nova: ('tenant_quota_update',)})
|
||||||
def test_add_project_user_update_error(self):
|
def test_add_project_user_update_error(self):
|
||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
@ -336,9 +347,17 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
break
|
break
|
||||||
break
|
break
|
||||||
|
|
||||||
|
nova_updated_quota = dict([(key, quota_data[key]) for key in
|
||||||
|
NOVA_QUOTA_FIELDS])
|
||||||
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
project.id,
|
project.id,
|
||||||
**quota_data)
|
**nova_updated_quota)
|
||||||
|
|
||||||
|
cinder_updated_quota = dict([(key, quota_data[key]) for key in
|
||||||
|
CINDER_QUOTA_FIELDS])
|
||||||
|
api.cinder.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
|
project.id,
|
||||||
|
**cinder_updated_quota)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
@ -541,13 +560,17 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
user_id='3',
|
user_id='3',
|
||||||
role_id='1')
|
role_id='1')
|
||||||
|
|
||||||
|
nova_updated_quota = dict([(key, updated_quota[key]) for key in
|
||||||
|
NOVA_QUOTA_FIELDS])
|
||||||
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
project.id,
|
project.id,
|
||||||
**updated_quota)
|
**nova_updated_quota)
|
||||||
|
|
||||||
|
cinder_updated_quota = dict([(key, updated_quota[key]) for key in
|
||||||
|
CINDER_QUOTA_FIELDS])
|
||||||
api.cinder.tenant_quota_update(IsA(http.HttpRequest),
|
api.cinder.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
project.id,
|
project.id,
|
||||||
volumes=updated_quota['volumes'],
|
**cinder_updated_quota)
|
||||||
gigabytes=updated_quota['gigabytes'])
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
# submit form data
|
# submit form data
|
||||||
@ -739,9 +762,11 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
user_id='3',
|
user_id='3',
|
||||||
role_id='2')
|
role_id='2')
|
||||||
|
|
||||||
|
nova_updated_quota = dict([(key, updated_quota[key]) for key in
|
||||||
|
NOVA_QUOTA_FIELDS])
|
||||||
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
api.nova.tenant_quota_update(IsA(http.HttpRequest),
|
||||||
project.id,
|
project.id,
|
||||||
**updated_quota) \
|
**nova_updated_quota) \
|
||||||
.AndRaise(self.exceptions.nova)
|
.AndRaise(self.exceptions.nova)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
@ -33,22 +33,12 @@ from openstack_dashboard.usage import quotas
|
|||||||
from openstack_dashboard.dashboards.admin.users.views import CreateView
|
from openstack_dashboard.dashboards.admin.users.views import CreateView
|
||||||
from .forms import CreateUser
|
from .forms import CreateUser
|
||||||
from .tables import TenantsTable, TenantUsersTable, AddUsersTable
|
from .tables import TenantsTable, TenantUsersTable, AddUsersTable
|
||||||
from .workflows import CreateProject, UpdateProject
|
from .workflows import CreateProject, UpdateProject, NOVA_QUOTA_FIELDS, \
|
||||||
|
CINDER_QUOTA_FIELDS
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
QUOTA_FIELDS = NOVA_QUOTA_FIELDS + CINDER_QUOTA_FIELDS
|
||||||
QUOTA_FIELDS = ("metadata_items",
|
|
||||||
"cores",
|
|
||||||
"instances",
|
|
||||||
"injected_files",
|
|
||||||
"injected_file_content_bytes",
|
|
||||||
"volumes",
|
|
||||||
"gigabytes",
|
|
||||||
"ram",
|
|
||||||
"floating_ips",
|
|
||||||
"security_groups",
|
|
||||||
"security_group_rules")
|
|
||||||
|
|
||||||
PROJECT_INFO_FIELDS = ("name",
|
PROJECT_INFO_FIELDS = ("name",
|
||||||
"description",
|
"description",
|
||||||
|
@ -32,10 +32,22 @@ from openstack_dashboard import api
|
|||||||
from openstack_dashboard.api import cinder, nova
|
from openstack_dashboard.api import cinder, nova
|
||||||
from openstack_dashboard.api.base import is_service_enabled
|
from openstack_dashboard.api.base import is_service_enabled
|
||||||
|
|
||||||
|
|
||||||
INDEX_URL = "horizon:admin:projects:index"
|
INDEX_URL = "horizon:admin:projects:index"
|
||||||
ADD_USER_URL = "horizon:admin:projects:create_user"
|
ADD_USER_URL = "horizon:admin:projects:create_user"
|
||||||
|
|
||||||
|
NOVA_QUOTA_FIELDS = ("metadata_items",
|
||||||
|
"cores",
|
||||||
|
"instances",
|
||||||
|
"injected_files",
|
||||||
|
"injected_file_content_bytes",
|
||||||
|
"ram",
|
||||||
|
"floating_ips",
|
||||||
|
"security_groups",
|
||||||
|
"security_group_rules",)
|
||||||
|
|
||||||
|
CINDER_QUOTA_FIELDS = ("volumes",
|
||||||
|
"gigabytes",)
|
||||||
|
|
||||||
|
|
||||||
class UpdateProjectQuotaAction(workflows.Action):
|
class UpdateProjectQuotaAction(workflows.Action):
|
||||||
ifcb_label = _("Injected File Content Bytes")
|
ifcb_label = _("Injected File Content Bytes")
|
||||||
@ -81,8 +93,7 @@ class UpdateProjectQuota(workflows.Step):
|
|||||||
|
|
||||||
class CreateProjectInfoAction(workflows.Action):
|
class CreateProjectInfoAction(workflows.Action):
|
||||||
name = forms.CharField(label=_("Name"))
|
name = forms.CharField(label=_("Name"))
|
||||||
description = forms.CharField(
|
description = forms.CharField(widget=forms.widgets.Textarea(),
|
||||||
widget=forms.widgets.Textarea(),
|
|
||||||
label=_("Description"),
|
label=_("Description"),
|
||||||
required=False)
|
required=False)
|
||||||
enabled = forms.BooleanField(label=_("Enabled"),
|
enabled = forms.BooleanField(label=_("Enabled"),
|
||||||
@ -249,23 +260,17 @@ class CreateProject(workflows.Workflow):
|
|||||||
'and set project quotas.'
|
'and set project quotas.'
|
||||||
% users_to_add))
|
% users_to_add))
|
||||||
|
|
||||||
# update the project quota
|
# Update the project quota.
|
||||||
ifcb = data['injected_file_content_bytes']
|
nova_data = dict([(key, data[key]) for key in NOVA_QUOTA_FIELDS])
|
||||||
try:
|
try:
|
||||||
api.nova.tenant_quota_update(
|
nova.tenant_quota_update(request, project_id, **nova_data)
|
||||||
request,
|
|
||||||
|
if is_service_enabled(request, 'volume'):
|
||||||
|
cinder_data = dict([(key, data[key]) for key in
|
||||||
|
CINDER_QUOTA_FIELDS])
|
||||||
|
cinder.tenant_quota_update(request,
|
||||||
project_id,
|
project_id,
|
||||||
metadata_items=data['metadata_items'],
|
**cinder_data)
|
||||||
injected_file_content_bytes=ifcb,
|
|
||||||
volumes=data['volumes'],
|
|
||||||
gigabytes=data['gigabytes'],
|
|
||||||
ram=data['ram'],
|
|
||||||
floating_ips=data['floating_ips'],
|
|
||||||
instances=data['instances'],
|
|
||||||
injected_files=data['injected_files'],
|
|
||||||
cores=data['cores'],
|
|
||||||
security_groups=data['security_groups'],
|
|
||||||
security_group_rules=data['security_group_rules'])
|
|
||||||
except:
|
except:
|
||||||
exceptions.handle(request, _('Unable to set project quotas.'))
|
exceptions.handle(request, _('Unable to set project quotas.'))
|
||||||
return True
|
return True
|
||||||
@ -384,31 +389,18 @@ class UpdateProject(workflows.Workflow):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# update the project quota
|
# update the project quota
|
||||||
ifcb = data['injected_file_content_bytes']
|
nova_data = dict([(key, data[key]) for key in NOVA_QUOTA_FIELDS])
|
||||||
try:
|
try:
|
||||||
# TODO(gabriel): Once nova-volume is fully deprecated the
|
nova.tenant_quota_update(request,
|
||||||
# "volumes" and "gigabytes" quotas should no longer be sent to
|
|
||||||
# the nova API to be updated anymore.
|
|
||||||
nova.tenant_quota_update(
|
|
||||||
request,
|
|
||||||
project_id,
|
project_id,
|
||||||
metadata_items=data['metadata_items'],
|
**nova_data)
|
||||||
injected_file_content_bytes=ifcb,
|
|
||||||
volumes=data['volumes'],
|
|
||||||
gigabytes=data['gigabytes'],
|
|
||||||
ram=data['ram'],
|
|
||||||
floating_ips=data['floating_ips'],
|
|
||||||
instances=data['instances'],
|
|
||||||
injected_files=data['injected_files'],
|
|
||||||
cores=data['cores'],
|
|
||||||
security_groups=data['security_groups'],
|
|
||||||
security_group_rules=data['security_group_rules'])
|
|
||||||
|
|
||||||
if is_service_enabled(request, 'volume'):
|
if is_service_enabled(request, 'volume'):
|
||||||
|
cinder_data = dict([(key, data[key]) for key in
|
||||||
|
CINDER_QUOTA_FIELDS])
|
||||||
cinder.tenant_quota_update(request,
|
cinder.tenant_quota_update(request,
|
||||||
project_id,
|
project_id,
|
||||||
volumes=data['volumes'],
|
**cinder_data)
|
||||||
gigabytes=data['gigabytes'])
|
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
exceptions.handle(request, _('Modified project information and '
|
exceptions.handle(request, _('Modified project information and '
|
||||||
|
Loading…
Reference in New Issue
Block a user