Replace neutronclient with REST API calls in quotas commands

All quotas related commands to Neutron like
list/create/update/delete
are now made via keystoneauth

Change-Id: I5f0cb3e174c2f5453d2fe760bb39b2140fe1f201
This commit is contained in:
Sławek Kapłoński 2017-05-01 11:27:08 +00:00 committed by Slawek Kaplonski
parent be92751781
commit 77bac2b9d0
2 changed files with 13 additions and 26 deletions

View File

@ -647,21 +647,6 @@ class CinderQuotasDelete(task_manager.Task):
return client.cinder_client.quotas.delete(**self.args)
class NeutronQuotasSet(task_manager.Task):
def main(self, client):
return client.neutron_client.update_quota(**self.args)
class NeutronQuotasGet(task_manager.Task):
def main(self, client):
return client.neutron_client.show_quota(**self.args)['quota']
class NeutronQuotasDelete(task_manager.Task):
def main(self, client):
return client.neutron_client.delete_quota(**self.args)
class NovaLimitsGet(task_manager.Task):
def main(self, client):
return client.nova_client.limits.get(**self.args).to_dict()

View File

@ -2222,11 +2222,11 @@ class OperatorCloud(openstackcloud.OpenStackCloud):
if not proj:
raise OpenStackCloudException("project does not exist")
body = {'quota': kwargs}
with _utils.neutron_exceptions("network client call failed"):
self.manager.submit_task(
_tasks.NeutronQuotasSet(tenant_id=proj.id,
body=body))
self._network_client.put(
'/quotas/{project_id}.json'.format(project_id=proj.id),
json={'quota': kwargs},
error_message=("Error setting Neutron's quota for "
"project {0}".format(proj.id)))
def get_network_quotas(self, name_or_id):
""" Get network quotas for a project
@ -2239,9 +2239,10 @@ class OperatorCloud(openstackcloud.OpenStackCloud):
proj = self.get_project(name_or_id)
if not proj:
raise OpenStackCloudException("project does not exist")
with _utils.neutron_exceptions("network client call failed"):
return self.manager.submit_task(
_tasks.NeutronQuotasGet(tenant_id=proj.id))
return self._network_client.get(
'/quotas/{project_id}.json'.format(project_id=proj.id),
error_message=("Error fetching Neutron's quota for "
"project {0}".format(proj.id)))
def delete_network_quotas(self, name_or_id):
""" Delete network quotas for a project
@ -2255,9 +2256,10 @@ class OperatorCloud(openstackcloud.OpenStackCloud):
proj = self.get_project(name_or_id)
if not proj:
raise OpenStackCloudException("project does not exist")
with _utils.neutron_exceptions("network client call failed"):
return self.manager.submit_task(
_tasks.NeutronQuotasDelete(tenant_id=proj.id))
self._network_client.delete(
'/quotas/{project_id}.json'.format(project_id=proj.id),
error_message=("Error deleting Neutron's quota for "
"project {0}".format(proj.id)))
def list_magnum_services(self):
"""List all Magnum services.