Commit ba62e349 by Guba Sándor

vm: fixing Interface create_from_template()

parent 511666cb
...@@ -741,14 +741,22 @@ class Interface(Model): ...@@ -741,14 +741,22 @@ class Interface(Model):
queue=self.instance.node.host.hostname + '.net') queue=self.instance.node.host.hostname + '.net')
@classmethod @classmethod
def create_from_template(cls, instance, template): def create_from_template(cls, instance, template, owner=None):
"""Create a new interface for an instance based on an """Create a new interface for an instance based on an
InterfaceTemplate. InterfaceTemplate.
""" """
if template.managed: if template.managed:
host = Host(vlan=template.vlan,
mac=str(cls.generate_mac(instance, template.vlan))) host = Host()
# TODO Fix at firewall EUI host.vlan = template.vlan
host.mac = str(cls.generate_mac(instance, template.vlan))
# TODO Fix at firewall EUI mac
host.hostname = instance.vm_name
# Get adresses from firewall #TODO fix tupple to dict.
addresses = template.vlan.get_new_address()
host.ipv4 = addresses[0]
host.ipv6 = addresses[1]
host.owner = owner
host.save() host.save()
else: else:
host = None host = None
......
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