Expose Quota.update API
There exists a method in the management API to change the quota for a given resource. This change exposes that API via a new "trove quota-update" command. Also, adds v1.Quotas to the python client. Note that this command requires admin privileges. Partial implements: blueprint bp/quota-management Change-Id: I6ca1a87fbc46781f83bc9b7bd33745783b8aaab1
This commit is contained in:
		
				
					committed by
					
						
						Peter Stachowski
					
				
			
			
				
	
			
			
			
						parent
						
							8c1fee10cd
						
					
				
				
					commit
					f5616b7d52
				
			
							
								
								
									
										4
									
								
								releasenotes/notes/quota-upgrade-aed30d50c1f58502.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								releasenotes/notes/quota-upgrade-aed30d50c1f58502.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
features:
 | 
			
		||||
  - Adds quota-show and quota-update commands to show the limits for all
 | 
			
		||||
    resources and to change the limit for a single resource.  These commands
 | 
			
		||||
    require admin privileges.
 | 
			
		||||
@@ -26,6 +26,7 @@ from troveclient.v1 import limits
 | 
			
		||||
# from troveclient.v1 import management
 | 
			
		||||
from troveclient.v1 import metadata
 | 
			
		||||
from troveclient.v1 import modules
 | 
			
		||||
from troveclient.v1 import quota
 | 
			
		||||
from troveclient.v1 import root
 | 
			
		||||
from troveclient.v1 import security_groups
 | 
			
		||||
from troveclient.v1 import users
 | 
			
		||||
@@ -81,7 +82,7 @@ class Client(object):
 | 
			
		||||
        self.modules = modules.Modules(self)
 | 
			
		||||
 | 
			
		||||
        # self.hosts = Hosts(self)
 | 
			
		||||
        # self.quota = Quotas(self)
 | 
			
		||||
        self.quota = quota.Quotas(self)
 | 
			
		||||
        # self.storage = StorageInfo(self)
 | 
			
		||||
        # self.management = Management(self)
 | 
			
		||||
        # self.management = MgmtClusters(self)
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ class Quotas(base.ManagerWithFind):
 | 
			
		||||
            raise Exception("Call to " + url + " did not return a body.")
 | 
			
		||||
        if 'quotas' not in body:
 | 
			
		||||
            raise Exception("Missing key value 'quotas' in response body.")
 | 
			
		||||
        return body['quotas']
 | 
			
		||||
        return [self.resource_class(self, quota) for quota in body['quotas']]
 | 
			
		||||
 | 
			
		||||
    def update(self, id, quotas):
 | 
			
		||||
        """Set limits for quotas."""
 | 
			
		||||
 
 | 
			
		||||
@@ -2137,3 +2137,24 @@ def do_log_save(cs, args):
 | 
			
		||||
#         args.datastore_version,
 | 
			
		||||
#         args.name,
 | 
			
		||||
#     )
 | 
			
		||||
 | 
			
		||||
@utils.arg('tenant_id', metavar='<tenant_id>',
 | 
			
		||||
           help='Id of tenant for which to show quotas.')
 | 
			
		||||
@utils.service_type('database')
 | 
			
		||||
def do_quota_show(cs, args):
 | 
			
		||||
    """Show quotas for a tenant."""
 | 
			
		||||
    utils.print_list(cs.quota.show(args.tenant_id),
 | 
			
		||||
                     ['resource', 'in_use', 'reserved', 'limit'])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@utils.arg('tenant_id', metavar='<tenant_id>',
 | 
			
		||||
           help='Id of tenant for which to update quotas.')
 | 
			
		||||
@utils.arg('resource', metavar='<resource>',
 | 
			
		||||
           help='Id of resource to change.')
 | 
			
		||||
@utils.arg('limit', metavar='<limit>', type=int,
 | 
			
		||||
           help='New limit to set for the named resource.')
 | 
			
		||||
@utils.service_type('database')
 | 
			
		||||
def do_quota_update(cs, args):
 | 
			
		||||
    """Update quotas for a tenant."""
 | 
			
		||||
    utils.print_dict(cs.quota.update(args.tenant_id,
 | 
			
		||||
                                     {args.resource: args.limit}))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user