Skip to content
Snippets Groups Projects
Commit ee61ad0c authored by Michal Urban's avatar Michal Urban
Browse files

implemented division between HardwareUsage and Limits objects

parent 5d41b0d1
No related branches found
No related tags found
No related merge requests found
Pipeline #173571 passed
......@@ -135,13 +135,13 @@ class HardwareUsage:
Used to wrap HeatStacks hardware usage.
"""
def __init__(self, used_vcpu, used_ram, used_instances, used_network, used_subnet, used_port):
self.vcpu = used_vcpu
self.ram = used_ram
self.instances = used_instances
self.network = used_network
self.subnet = used_subnet
self.port = used_port
def __init__(self, vcpu, ram, instances, network, subnet, port):
self.vcpu = vcpu
self.ram = ram
self.instances = instances
self.network = network
self.subnet = subnet
self.port = port
def __mul__(self, other):
if not isinstance(other, int):
......@@ -150,6 +150,13 @@ class HardwareUsage:
return HardwareUsage(self.vcpu*other, self.ram*other, self.instances*other,
self.network*other, self.subnet*other, self.port*other)
def __truediv__(self, other):
if not isinstance(other, Limits):
return NotImplemented
return HardwareUsage(**{key: round(value / (other.__dict__[key]), 3) for (key, value)
in self.__dict__.items()})
def __eq__(self, other: 'HardwareUsage'):
if not isinstance(other, HardwareUsage):
return NotImplemented
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment