Commit 85f074a6 by Dudás Ádám

vm: beautification

parent 0a40f809
...@@ -40,6 +40,7 @@ post_state_changed = Signal(providing_args=["new_state"]) ...@@ -40,6 +40,7 @@ post_state_changed = Signal(providing_args=["new_state"])
class InstanceActiveManager(Manager): class InstanceActiveManager(Manager):
def get_query_set(self): def get_query_set(self):
return super(InstanceActiveManager, return super(InstanceActiveManager,
self).get_query_set().filter(destroyed=None) self).get_query_set().filter(destroyed=None)
...@@ -133,6 +134,9 @@ class Node(TimeStampedModel): ...@@ -133,6 +134,9 @@ class Node(TimeStampedModel):
class Meta: class Meta:
permissions = () permissions = ()
def __unicode__(self):
return self.name
@property @property
@method_cache(10, 5) @method_cache(10, 5)
def online(self): def online(self):
...@@ -143,15 +147,15 @@ class Node(TimeStampedModel): ...@@ -143,15 +147,15 @@ class Node(TimeStampedModel):
@property @property
@method_cache(300) @method_cache(300)
def num_cores(self): def num_cores(self):
"""Number of CPU threads available to the virtual machines.""" """Number of CPU threads available to the virtual machines.
"""
return self.remote_query(vm_tasks.get_core_num) return self.remote_query(vm_tasks.get_core_num)
@property @property
@method_cache(300) @method_cache(300)
def ram_size(self): def ram_size(self):
"""Bytes of total memory in the node.""" """Bytes of total memory in the node.
"""
return self.remote_query(vm_tasks.get_ram_size) return self.remote_query(vm_tasks.get_ram_size)
@property @property
...@@ -208,9 +212,6 @@ class Node(TimeStampedModel): ...@@ -208,9 +212,6 @@ class Node(TimeStampedModel):
logger.info('Node %s update: domain %s in libvirt but not in db.', logger.info('Node %s update: domain %s in libvirt but not in db.',
self, i) self, i)
def __unicode__(self):
return self.name
class NodeActivity(ActivityModel): class NodeActivity(ActivityModel):
node = ForeignKey(Node, related_name='activity_log', node = ForeignKey(Node, related_name='activity_log',
...@@ -679,6 +680,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -679,6 +680,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
# Schedule # Schedule
if self.node is None: if self.node is None:
self.node = scheduler.get_node(self, Node.objects.all()) self.node = scheduler.get_node(self, Node.objects.all())
self.save() self.save()
# Deploy virtual images # Deploy virtual images
...@@ -687,6 +689,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -687,6 +689,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
disk.deploy() disk.deploy()
queue_name = self.get_remote_queue_name('vm') queue_name = self.get_remote_queue_name('vm')
# Deploy VM on remote machine # Deploy VM on remote machine
with act.sub_activity('deploying_vm'): with act.sub_activity('deploying_vm'):
vm_tasks.deploy.apply_async(args=[self.get_vm_desc()], vm_tasks.deploy.apply_async(args=[self.get_vm_desc()],
......
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 sign in to comment