Remove "--resources" option for "quota delete".
Python-kingbirdclient uses python requests and it cannot send body along with the curl-request. So removed the option of sending resources(body). Made Kingbird-client compatible with Keystone_v2 and Keystone_v3. Change-Id: I9d7c0055d747245f76d1cbd1213ff74cb11d1faf
This commit is contained in:
parent
af6959c68f
commit
ec51bdb8da
|
@ -74,8 +74,8 @@ class ResourceManager(object):
|
|||
json_object['usage'][values]))
|
||||
return resource
|
||||
|
||||
def _delete(self, url, data=None):
|
||||
resp = self.http_client.delete(url, data)
|
||||
def _delete(self, url):
|
||||
resp = self.http_client.delete(url)
|
||||
if resp.status_code != 200:
|
||||
self._raise_api_exception(resp)
|
||||
|
||||
|
|
|
@ -122,10 +122,12 @@ def authenticate(kingbird_url=None, username=None,
|
|||
endpoint_type=endpoint_type
|
||||
)
|
||||
|
||||
# For Keystone version 'V2.0' and other.
|
||||
serv_endpoint = endpoint_type if keystone.version == 'v2.0' else 'url'
|
||||
if service_type in catalog:
|
||||
service = catalog.get(service_type)
|
||||
kingbird_url = service[0].get(
|
||||
endpoint_type) if service else None
|
||||
serv_endpoint) if service else None
|
||||
|
||||
return kingbird_url, token, project_id, user_id
|
||||
|
||||
|
|
|
@ -50,14 +50,10 @@ class quota_manager(base.ResourceManager):
|
|||
url = '/%s/os-quota-sets/%s' % (tenant, target_tenant_id)
|
||||
return self._update(url, data)
|
||||
|
||||
def delete_quota(self, target_tenant_id, resources=None):
|
||||
data = dict()
|
||||
if resources:
|
||||
resources = resources.split(',')
|
||||
data["quota_set"] = str(resources)
|
||||
def delete_quota(self, target_tenant_id):
|
||||
tenant = self.http_client.project_id
|
||||
url = '/%s/os-quota-sets/%s' % (tenant, target_tenant_id)
|
||||
return self._delete(url, data)
|
||||
return self._delete(url)
|
||||
|
||||
def sync_quota(self, target_tenant_id):
|
||||
tenant = self.http_client.project_id
|
||||
|
|
|
@ -296,28 +296,17 @@ class DeleteQuota(command.Command):
|
|||
help='ID of tenant to delete quotas.'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--resources',
|
||||
help='resources to which quotas have to be deleted.'
|
||||
'--<cores,ram,etc...> comma seperated values(csv)'
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
kingbird_client = self.app.client_manager.sync_engine
|
||||
target_tenant = parsed_args.tenant
|
||||
resources = parsed_args.resources
|
||||
try:
|
||||
kingbird_client.quota_manager.\
|
||||
delete_quota(target_tenant, resources)
|
||||
if resources:
|
||||
print("Request to delete %s for tenant %s has been accepted." %
|
||||
(parsed_args.resources, parsed_args.tenant))
|
||||
else:
|
||||
print("Request to delete quotas"
|
||||
" for tenant %s has been accepted." %
|
||||
(parsed_args.tenant))
|
||||
delete_quota(target_tenant)
|
||||
print("Request to delete quotas"
|
||||
" for tenant %s has been accepted." %
|
||||
(parsed_args.tenant))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
error_msg = "Unable to delete quota for specified resource."
|
||||
|
|
|
@ -83,7 +83,7 @@ class TestCLIQuotaManagerV1(base.BaseCommandTest):
|
|||
def test_delete_quota(self):
|
||||
self.call(quota_cmd.DeleteQuota, app_args=[FAKE_TENANT])
|
||||
self.client.quota_manager.delete_quota.\
|
||||
assert_called_once_with(FAKE_TENANT, None)
|
||||
assert_called_once_with(FAKE_TENANT)
|
||||
|
||||
def test_sync_quota(self):
|
||||
self.call(quota_cmd.SyncQuota, app_args=[FAKE_TENANT])
|
||||
|
|
Loading…
Reference in New Issue