How to set quota for openstack project/tenant using python-openstacksdk

489 views Asked by At

I have creatd a new project using openstacksdk. I want to set certain amount of CPU, RAM and floatingIPs available for that project to manage usage. How can I set Quota for the new project created?

1

There are 1 answers

0
Atmesh Mishra On BEST ANSWER

Current openstackSDK (0.9.19) does not have function to allocate quota. This can be done using openstack API.

conn = connection.Connection(auth_url='URL', project_name='PROJECT', username='USERNAME', password='ADMIN_PASSWORD', verify=False)

token = conn.authorize()

header = {'X-AUTH-TOKEN': token,'Content-Type': 'application/json'}    
request_body = {"quota_set": {"instances": "3" ,"ram": "40960", "cores": "20"}}
data_json = json.dumps(request_body, sort_keys=True, indent=4, separators=(',', ': '))
r = requests.put(nova_url,headers=header,data=data_json,verify=False)