Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b2ef4090
authored
Oct 10, 2016
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add azure_id to Interface model. Call create_azure_interface task
on interface creation.
parent
0dc48b29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletions
+38
-1
circle/vm/migrations/0007_interface_azure_id.py
+19
-0
circle/vm/models/network.py
+15
-1
circle/vm/tasks/net_tasks.py
+4
-0
No files found.
circle/vm/migrations/0007_interface_azure_id.py
0 → 100644
View file @
b2ef4090
# -*- 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
),
),
]
circle/vm/models/network.py
View file @
b2ef4090
...
...
@@ -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
):
...
...
circle/vm/tasks/net_tasks.py
View file @
b2ef4090
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment