Unverified Commit 95b4668a authored by efikalti's avatar efikalti Committed by Avraam Tsantekidis

LAM-41 quotas checking

parent dad119ea
......@@ -286,36 +286,36 @@ class Provisioner:
# quotas = self.get_quotas()
# Check for VMs
pending_vm = quotas[project_id]['cyclades.vm']['pending']
limit_vm = quotas[project_id]['cyclades.vm']['limit']
usage_vm = quotas[project_id]['cyclades.vm']['usage']
pending_vm = quotas[project_id]['cyclades.vm']['project_pending']
limit_vm = quotas[project_id]['cyclades.vm']['project_limit']
usage_vm = quotas[project_id]['cyclades.vm']['project_usage']
available_vm = limit_vm - usage_vm - pending_vm
if available_vm < kwargs['cluster_size']:
msg = 'Cyclades VMs out of limit'
raise ClientError(msg, error_quotas_cluster_size)
return False
# Check for CPUs
pending_cpu = quotas[project_id]['cyclades.cpu']['pending']
limit_cpu = quotas[project_id]['cyclades.cpu']['limit']
usage_cpu = quotas[project_id]['cyclades.cpu']['usage']
pending_cpu = quotas[project_id]['cyclades.cpu']['project_pending']
limit_cpu = quotas[project_id]['cyclades.cpu']['project_limit']
usage_cpu = quotas[project_id]['cyclades.cpu']['project_usage']
available_cpu = limit_cpu - usage_cpu - pending_cpu
if available_cpu < kwargs['vcpus']:
msg = 'Cyclades cpu out of limit'
raise ClientError(msg, error_quotas_cpu)
return False
# Check for RAM
pending_ram = quotas[project_id]['cyclades.ram']['pending']
limit_ram = quotas[project_id]['cyclades.ram']['limit']
usage_ram = quotas[project_id]['cyclades.ram']['usage']
pending_ram = quotas[project_id]['cyclades.ram']['project_pending']
limit_ram = quotas[project_id]['cyclades.ram']['project_limit']
usage_ram = quotas[project_id]['cyclades.ram']['project_usage']
available_ram = (limit_ram - usage_ram - pending_ram) / self.Bytes_to_MB
if available_ram < kwargs['ram']:
msg = 'Cyclades ram out of limit'
raise ClientError(msg, error_quotas_ram)
return False
# Check for Disk space
pending_cd = quotas[project_id]['cyclades.ram']['pending']
limit_cd = quotas[project_id]['cyclades.disk']['limit']
usage_cd = quotas[project_id]['cyclades.disk']['usage']
pending_cd = quotas[project_id]['cyclades.ram']['project_pending']
limit_cd = quotas[project_id]['cyclades.disk']['project_limit']
usage_cd = quotas[project_id]['cyclades.disk']['project_usage']
available_cyclades_disk_GB = (limit_cd - usage_cd - pending_cd) / self.Bytes_to_GB
if available_cyclades_disk_GB < kwargs['disk']:
msg = 'Cyclades disk out of limit'
......@@ -323,16 +323,16 @@ class Provisioner:
return False
# Check for public IPs
list_float_ips = self.network_client.list_floatingips()
pending_ips = quotas[project_id]['cyclades.floating_ip']['pending']
limit_ips = quotas[project_id]['cyclades.floating_ip']['limit']
usage_ips = quotas[project_id]['cyclades.floating_ip']['usage']
pending_ips = quotas[project_id]['cyclades.floating_ip']['project_pending']
limit_ips = quotas[project_id]['cyclades.floating_ip']['project_limit']
usage_ips = quotas[project_id]['cyclades.floating_ip']['project_usage']
available_ips = limit_ips - usage_ips - pending_ips
for d in list_float_ips:
if d['instance_id'] is None and d['port_id'] is None:
available_ips += 1
if available_ips < kwargs['ip_request']:
msg = 'Public IPs out of limit'
raise ClientError(msg, error_quotas_cyclades_disk)
raise ClientError(msg, error_get_ip)
return False
# Check for networks
pending_net = quotas[project_id]['cyclades.network.private']['project_pending']
......@@ -341,7 +341,7 @@ class Provisioner:
available_networks = limit_net - usage_net - pending_net
if available_networks < kwargs['network_request']:
msg = 'Private Network out of limit'
raise ClientError(msg, error_quotas_cyclades_disk)
raise ClientError(msg, error_get_network_quota)
return False
return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment