Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9e66bb5d
authored
Mar 06, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: create subactivity for ip address allocations
parent
70fcc92b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
circle/vm/models/instance.py
+3
-2
circle/vm/models/network.py
+15
-4
No files found.
circle/vm/models/instance.py
View file @
9e66bb5d
...
...
@@ -373,13 +373,14 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
activity
.
resultant_state
=
'PENDING'
with
instance_activity
(
code_suffix
=
'create'
,
instance
=
inst
,
on_commit
=
__on_commit
,
user
=
inst
.
owner
):
on_commit
=
__on_commit
,
user
=
inst
.
owner
)
as
act
:
# create related entities
inst
.
disks
.
add
(
*
[
disk
.
get_exclusive
()
for
disk
in
disks
])
for
net
in
networks
:
Interface
.
create
(
instance
=
inst
,
vlan
=
net
.
vlan
,
owner
=
inst
.
owner
,
managed
=
net
.
managed
)
owner
=
inst
.
owner
,
managed
=
net
.
managed
,
base_activity
=
act
)
inst
.
req_traits
.
add
(
*
req_traits
)
inst
.
tags
.
add
(
*
tags
)
...
...
circle/vm/models/network.py
View file @
9e66bb5d
...
...
@@ -8,6 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from
firewall.models
import
Vlan
,
Host
from
..tasks
import
net_tasks
from
.activity
import
instance_activity
logger
=
getLogger
(
__name__
)
...
...
@@ -105,7 +106,7 @@ class Interface(Model):
self
.
host
.
delete
()
@classmethod
def
create
(
cls
,
instance
,
vlan
,
managed
,
owner
=
None
):
def
create
(
cls
,
instance
,
vlan
,
managed
,
owner
=
None
,
base_activity
=
None
):
"""Create a new interface for a VM instance to the specified VLAN.
"""
if
managed
:
...
...
@@ -115,9 +116,19 @@ class Interface(Model):
host
.
mac
=
str
(
cls
.
generate_mac
(
instance
,
vlan
))
host
.
hostname
=
instance
.
vm_name
# Get adresses from firewall
addresses
=
vlan
.
get_new_address
()
host
.
ipv4
=
addresses
[
'ipv4'
]
host
.
ipv6
=
addresses
[
'ipv6'
]
if
base_activity
is
None
:
act
=
instance_activity
(
code_suffix
=
'allocating_ip'
,
instance
=
instance
,
user
=
owner
)
else
:
act
=
base_activity
.
sub_activity
(
'allocating_ip'
)
with
act
as
act
:
addresses
=
vlan
.
get_new_address
()
host
.
ipv4
=
addresses
[
'ipv4'
]
host
.
ipv6
=
addresses
[
'ipv6'
]
act
.
result
=
(
'new addresses: ipv4:
%(ip4)
s, ipv6:
%(ip6)
s, '
'vlan:
%(vlan)
s'
%
{
'ip4'
:
host
.
ipv4
,
'ip6'
:
host
.
ipv6
,
'vlan'
:
vlan
.
name
})
host
.
owner
=
owner
if
vlan
.
network_type
==
'public'
:
host
.
shared_ip
=
False
...
...
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