Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a9cb4a8f
authored
Apr 22, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-154'
Conflicts: circle/vm/operations.py
parents
5d753e30
e19eaa8e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
30 deletions
+49
-30
circle/dashboard/views.py
+1
-2
circle/vm/models/network.py
+5
-27
circle/vm/operations.py
+43
-1
No files found.
circle/dashboard/views.py
View file @
a9cb4a8f
...
@@ -396,8 +396,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -396,8 +396,7 @@ class VmDetailView(CheckedDetailView):
if
not
vlan
.
has_level
(
request
.
user
,
'user'
):
if
not
vlan
.
has_level
(
request
.
user
,
'user'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
try
:
try
:
Interface
.
create
(
vlan
=
vlan
,
instance
=
self
.
object
,
self
.
object
.
add_interface
(
vlan
=
vlan
,
user
=
request
.
user
)
managed
=
vlan
.
managed
,
owner
=
request
.
user
)
messages
.
success
(
request
,
_
(
"Successfully added new interface!"
))
messages
.
success
(
request
,
_
(
"Successfully added new interface!"
))
except
Exception
,
e
:
except
Exception
,
e
:
error
=
u' '
.
join
(
e
.
messages
)
error
=
u' '
.
join
(
e
.
messages
)
...
...
circle/vm/models/network.py
View file @
a9cb4a8f
...
@@ -58,10 +58,6 @@ class Interface(Model):
...
@@ -58,10 +58,6 @@ class Interface(Model):
return
'cloud-'
+
str
(
self
.
instance
.
id
)
+
'-'
+
str
(
self
.
vlan
.
vid
)
return
'cloud-'
+
str
(
self
.
instance
.
id
)
+
'-'
+
str
(
self
.
vlan
.
vid
)
@property
@property
def
destroyed
(
self
):
return
self
.
instance
.
destroyed_at
@property
def
mac
(
self
):
def
mac
(
self
):
try
:
try
:
return
self
.
host
.
mac
return
self
.
host
.
mac
...
@@ -138,34 +134,16 @@ class Interface(Model):
...
@@ -138,34 +134,16 @@ class Interface(Model):
return
iface
return
iface
def
deploy
(
self
):
def
deploy
(
self
):
if
self
.
destroyed
:
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'net'
)
from
.instance
import
Instance
return
net_tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
raise
Instance
.
InstanceDestroyedError
(
self
.
instance
,
queue
=
queue_name
)
.
get
()
"The associated instance "
"(
%
s) has already been "
"destroyed"
%
self
.
instance
)
net_tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
queue
=
self
.
instance
.
get_remote_queue_name
(
'net'
))
def
shutdown
(
self
):
def
shutdown
(
self
):
if
self
.
destroyed
:
from
.instance
import
Instance
raise
Instance
.
InstanceDestroyedError
(
self
.
instance
,
"The associated instance "
"(
%
s) has already been "
"destroyed"
%
self
.
instance
)
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'net'
)
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'net'
)
net_tasks
.
destroy
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
return
net_tasks
.
destroy
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
queue
=
queue_name
)
queue
=
queue_name
)
.
get
(
)
def
destroy
(
self
):
def
destroy
(
self
):
if
self
.
destroyed
:
return
self
.
shutdown
()
if
self
.
host
is
not
None
:
if
self
.
host
is
not
None
:
self
.
host
.
delete
()
self
.
host
.
delete
()
...
...
circle/vm/operations.py
View file @
a9cb4a8f
...
@@ -11,7 +11,8 @@ from celery.exceptions import TimeLimitExceeded
...
@@ -11,7 +11,8 @@ from celery.exceptions import TimeLimitExceeded
from
common.operations
import
Operation
,
register_operation
from
common.operations
import
Operation
,
register_operation
from
.tasks.local_tasks
import
async_instance_operation
,
async_node_operation
from
.tasks.local_tasks
import
async_instance_operation
,
async_node_operation
from
.models
import
(
from
.models
import
(
Instance
,
InstanceActivity
,
InstanceTemplate
,
Node
,
NodeActivity
,
Instance
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
Node
,
NodeActivity
,
)
)
...
@@ -56,6 +57,29 @@ class InstanceOperation(Operation):
...
@@ -56,6 +57,29 @@ class InstanceOperation(Operation):
user
=
user
)
user
=
user
)
class
AddInterfaceOperation
(
InstanceOperation
):
activity_code_suffix
=
'add_interface'
id
=
'add_interface'
name
=
_
(
"add interface"
)
description
=
_
(
"Add a new network interface for the specified VLAN to "
"the VM."
)
def
_operation
(
self
,
activity
,
user
,
system
,
vlan
,
managed
=
None
):
if
managed
is
None
:
managed
=
vlan
.
managed
net
=
Interface
.
create
(
base_activity
=
activity
,
instance
=
self
.
instance
,
managed
=
managed
,
owner
=
user
,
vlan
=
vlan
)
if
self
.
instance
.
is_running
:
net
.
deploy
()
return
net
register_operation
(
AddInterfaceOperation
)
class
DeployOperation
(
InstanceOperation
):
class
DeployOperation
(
InstanceOperation
):
activity_code_suffix
=
'deploy'
activity_code_suffix
=
'deploy'
id
=
'deploy'
id
=
'deploy'
...
@@ -107,6 +131,7 @@ class DestroyOperation(InstanceOperation):
...
@@ -107,6 +131,7 @@ class DestroyOperation(InstanceOperation):
if
self
.
instance
.
node
:
if
self
.
instance
.
node
:
# Destroy networks
# Destroy networks
with
activity
.
sub_activity
(
'destroying_net'
):
with
activity
.
sub_activity
(
'destroying_net'
):
self
.
instance
.
shutdown_net
()
self
.
instance
.
destroy_net
()
self
.
instance
.
destroy_net
()
# Delete virtual machine
# Delete virtual machine
...
@@ -179,6 +204,23 @@ class RebootOperation(InstanceOperation):
...
@@ -179,6 +204,23 @@ class RebootOperation(InstanceOperation):
register_operation
(
RebootOperation
)
register_operation
(
RebootOperation
)
class
RemoveInterfaceOperation
(
InstanceOperation
):
activity_code_suffix
=
'remove_interface'
id
=
'remove_interface'
name
=
_
(
"remove interface"
)
description
=
_
(
"Remove the specified network interface from the VM."
)
def
_operation
(
self
,
activity
,
user
,
system
,
interface
):
if
self
.
instance
.
is_running
:
interface
.
shutdown
()
interface
.
destroy
()
interface
.
delete
()
register_operation
(
RemoveInterfaceOperation
)
class
ResetOperation
(
InstanceOperation
):
class
ResetOperation
(
InstanceOperation
):
activity_code_suffix
=
'reset'
activity_code_suffix
=
'reset'
id
=
'reset'
id
=
'reset'
...
...
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