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
b0ff5771
authored
Mar 09, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-31' into 'master'
Log Host life cycle
parents
e036da5c
9e66bb5d
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 @
b0ff5771
...
@@ -373,13 +373,14 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -373,13 +373,14 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
activity
.
resultant_state
=
'PENDING'
activity
.
resultant_state
=
'PENDING'
with
instance_activity
(
code_suffix
=
'create'
,
instance
=
inst
,
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
# create related entities
inst
.
disks
.
add
(
*
[
disk
.
get_exclusive
()
for
disk
in
disks
])
inst
.
disks
.
add
(
*
[
disk
.
get_exclusive
()
for
disk
in
disks
])
for
net
in
networks
:
for
net
in
networks
:
Interface
.
create
(
instance
=
inst
,
vlan
=
net
.
vlan
,
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
.
req_traits
.
add
(
*
req_traits
)
inst
.
tags
.
add
(
*
tags
)
inst
.
tags
.
add
(
*
tags
)
...
...
circle/vm/models/network.py
View file @
b0ff5771
...
@@ -8,6 +8,7 @@ from django.utils.translation import ugettext_lazy as _
...
@@ -8,6 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from
firewall.models
import
Vlan
,
Host
from
firewall.models
import
Vlan
,
Host
from
..tasks
import
net_tasks
from
..tasks
import
net_tasks
from
.activity
import
instance_activity
logger
=
getLogger
(
__name__
)
logger
=
getLogger
(
__name__
)
...
@@ -105,7 +106,7 @@ class Interface(Model):
...
@@ -105,7 +106,7 @@ class Interface(Model):
self
.
host
.
delete
()
self
.
host
.
delete
()
@classmethod
@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.
"""Create a new interface for a VM instance to the specified VLAN.
"""
"""
if
managed
:
if
managed
:
...
@@ -115,9 +116,19 @@ class Interface(Model):
...
@@ -115,9 +116,19 @@ class Interface(Model):
host
.
mac
=
str
(
cls
.
generate_mac
(
instance
,
vlan
))
host
.
mac
=
str
(
cls
.
generate_mac
(
instance
,
vlan
))
host
.
hostname
=
instance
.
vm_name
host
.
hostname
=
instance
.
vm_name
# Get adresses from firewall
# Get adresses from firewall
addresses
=
vlan
.
get_new_address
()
if
base_activity
is
None
:
host
.
ipv4
=
addresses
[
'ipv4'
]
act
=
instance_activity
(
code_suffix
=
'allocating_ip'
,
host
.
ipv6
=
addresses
[
'ipv6'
]
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
host
.
owner
=
owner
if
vlan
.
network_type
==
'public'
:
if
vlan
.
network_type
==
'public'
:
host
.
shared_ip
=
False
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