Commit 2564bc5d by Dudás Ádám

vm: fix tags

parent 046c28f9
...@@ -17,10 +17,10 @@ from model_utils.models import TimeStampedModel ...@@ -17,10 +17,10 @@ from model_utils.models import TimeStampedModel
from taggit.managers import TaggableManager from taggit.managers import TaggableManager
from .tasks import local_tasks, vm_tasks, net_tasks from .tasks import local_tasks, vm_tasks, net_tasks
from acl.models import AclBase
from common.models import ActivityModel, activitycontextimpl
from firewall.models import Vlan, Host from firewall.models import Vlan, Host
from storage.models import Disk from storage.models import Disk
from common.models import ActivityModel, activitycontextimpl
from acl.models import AclBase
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
pwgen = User.objects.make_random_password pwgen = User.objects.make_random_password
...@@ -77,7 +77,7 @@ class VirtualMachineDescModel(BaseResourceConfigModel): ...@@ -77,7 +77,7 @@ class VirtualMachineDescModel(BaseResourceConfigModel):
'Show boot device selection menu on boot.')) 'Show boot device selection menu on boot.'))
raw_data = TextField(verbose_name=_('raw_data'), blank=True, help_text=_( raw_data = TextField(verbose_name=_('raw_data'), blank=True, help_text=_(
'Additional libvirt domain parameters in XML format.')) 'Additional libvirt domain parameters in XML format.'))
tags = TaggableManager() tags = TaggableManager(blank=True, verbose_name=_("tags"))
class Meta: class Meta:
abstract = True abstract = True
...@@ -102,7 +102,7 @@ class Node(TimeStampedModel): ...@@ -102,7 +102,7 @@ class Node(TimeStampedModel):
enabled = BooleanField(verbose_name=_('enabled'), default=False, enabled = BooleanField(verbose_name=_('enabled'), default=False,
help_text=_('Indicates whether the node can ' help_text=_('Indicates whether the node can '
'be used for hosting.')) 'be used for hosting.'))
tags = TaggableManager() tags = TaggableManager(blank=True, verbose_name=_("tags"))
class Meta: class Meta:
permissions = () permissions = ()
...@@ -350,7 +350,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -350,7 +350,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
@classmethod @classmethod
def create_from_template(cls, template, owner, disks=None, networks=None, def create_from_template(cls, template, owner, disks=None, networks=None,
**kwargs): tags=None, **kwargs):
"""Create a new instance based on an InstanceTemplate. """Create a new instance based on an InstanceTemplate.
Can also specify parameters as keyword arguments which should override Can also specify parameters as keyword arguments which should override
...@@ -361,6 +361,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -361,6 +361,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
networks = (template.interface_set.all() if networks is None networks = (template.interface_set.all() if networks is None
else networks) else networks)
tags = template.tags.all() if tags is None else tags
# prepare parameters # prepare parameters
kwargs['template'] = template kwargs['template'] = template
kwargs['owner'] = owner kwargs['owner'] = owner
...@@ -389,6 +391,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -389,6 +391,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
# TODO fix this port fw # TODO fix this port fw
i.host.add_port(proto, private=port) i.host.add_port(proto, private=port)
inst.tags.add(*tags)
return inst return inst
@permalink @permalink
......
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