Commit b2ef4090 by Szabolcs Gelencser

Add azure_id to Interface model. Call create_azure_interface task

on interface creation.
parent 0dc48b29
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('vm', '0006_auto_20161009_1702'),
]
operations = [
migrations.AddField(
model_name='interface',
name='azure_id',
field=models.TextField(null=True),
),
]
......@@ -20,7 +20,9 @@ from __future__ import absolute_import, unicode_literals
from logging import getLogger
from netaddr import EUI, mac_unix
from django.db.models import Model, ForeignKey, BooleanField, CharField
from django.db.models import (
Model, ForeignKey, BooleanField, CharField, TextField
)
from django.utils.translation import ugettext_lazy as _, ugettext_noop
from common.models import create_readable
......@@ -70,6 +72,7 @@ class Interface(Model):
instance = ForeignKey('Instance', verbose_name=_('instance'),
related_name='interface_set')
model = CharField(max_length=10, choices=MODEL_TYPES, default='virtio')
azure_id = TextField(null=True)
class Meta:
app_label = 'vm'
......@@ -161,6 +164,17 @@ class Interface(Model):
iface = cls(vlan=vlan, host=host, instance=instance)
iface.save()
logger.debug("sending task to create azure interface")
azure_id = net_tasks.create_azure_interface.apply_async(
args=[iface.pk, vlan.name],
queue="localhost.net.fast"
).get()
if azure_id:
logger.debug("created azure interface with id: %s" % azure_id)
iface.azure_id = azure_id
iface.save()
return iface
def deploy(self):
......
......@@ -18,6 +18,10 @@
from manager.mancelery import celery
@celery.task(name='netdriver.create_azure_interface')
def create_azure_interface(ifacepk, vlan_name):
pass
@celery.task(name='netdriver.create')
def create(params):
pass
......
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