On 02/17/2017 01:21 PM, Manuel Luis Aznar wrote: > Hello there, > > I want to update the quota limit parameters for vcpu, memory and disk, > but I dont find the way. > > I manage to get the actual values but I am unable to manage how to > update this values. > > I am doing the following (I ommit the imports and conection stuff): > > system_service = connection.system_service() > > data_centers_service = system_service.data_centers_service() > > data_center = data_centers_service.list(search='name=Prueba2')[0] > > data_center_service = > data_centers_service.data_center_service(id=data_center.id > <http://data_center.id>) > > quotas_service = data_center_service.quotas_service() > > quota = quotas_service.list()[0] > > quota_service = quotas_service.quota_service(id=quota.id > <http://quota.id>) > > quota_cluster_limits_service = > quota_service.quota_cluster_limits_service() > > quotaclusterlimit = quota_cluster_limits_service.list()[0] > > quota_storage_limits_service = > quota_service.quota_storage_limits_service() > > quotastoragelimit = quota_storage_limits_service.list()[0] > > if after that I print the following: > quotaclusterlimit.memory_limit > quotaclusterlimit.vcpu_limit > quotastoragelimit.limit > > i see the actual values of the limits, but, I m not able to update that > values (I have been testing on how to do it). It seems that the only > method that let you update anything on a quota is using: > > quota_service.add(quota=...) > > I start creating a new quota object with these new limits by doing the > following: > > new_quotastoragelimit = ovirtsdk4.types.QuotaStorageLimit(limit=100) > new_quotaclusterlimit = > ovirtsdk4.types.QuotaClusterLimit(memory_limit=100,vcpu_limit=10) > > new_quota = > ovirtsdk4.types.Quota(quota_cluster_limits=new_quotaclusterlimit, > quota_storage_limits=new_quotastoragelimit) > > quota_service.update(quota=new_quota) > > I have directly tried to edit the printed values directly and then doing > the update but I got nothing (got event in the engine but the limit did > not change) > > quotaclusterlimit.memory_limit =100 > quotaclusterlimit.vcpu_limit = 10 > quotastoragelimit.limit = 100 > quota_service.update(quota=quota) # updating quota with itself > > I suppose that there would be a way on how to this, so if you can help, > i will really appreciate you. > > Thanks for all in advance to all > Manuel >
The API doesn't currently have a method to update a quota limit, so you will have to remove the existing one and add a new one. For example, if you want to change the storage quota of the 'mydata' storage domain to 100 GiB, you can do something like this: ---8<--- # Find the reference to the root of services: system_service = connection.system_service() # Find the data center and the service that manages it: dcs_service = system_service.data_centers_service() dc = dcs_service.list(search='name=mydc')[0] dc_service = dcs_service.data_center_service(dc.id) # Find the storage domain and the service that manages it: sds_service = system_service.storage_domains_service() sd = sds_service.list(search='name=mydata')[0] sd_service = sds_service.storage_domain_service(sd.id) # Find the quota and the service that manages it. Note that the service # that manages the quota doesn't support search, so we need to retrieve # all the quotas and filter explicitly. If the quota doesn't exist, # create it. quotas_service = dc_service.quotas_service() quotas = quotas_service.list() quota = next( (q for q in quotas if q.name == 'myquota'), None ) if quota is None: quota = quotas_service.add( quota=types.Quota( name='myquota', description='My quota', cluster_hard_limit_pct=20, cluster_soft_limit_pct=80, storage_hard_limit_pct=20, storage_soft_limit_pct=80 ) ) quota_service = quotas_service.quota_service(quota.id) # Find the quota limits for the storage domain that we are interested # on. If that limit exists we will delete it, and create it again with # the desired limit, in this example it will be 100 GiB. limits_service = quota_service.quota_storage_limits_service() limits = limits_service.list() limit = next( (l for l in limits if l.id == sd.id), None ) if limit is not None: limit_service = limits_service.limit_service(limit.id) limit_service.remove() limit = limits_service.add( limit=types.QuotaStorageLimit( name='mydatalimit', description='My storage domain limit', limit=100, storage_domain=types.StorageDomain( id=sd.id ) ), ) --->8--- _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users