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
269d97c7
authored
Apr 22, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into issue-vm-detail-fixes
parents
dedcfc62
a9cb4a8f
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 @
269d97c7
...
...
@@ -419,8 +419,7 @@ class VmDetailView(CheckedDetailView):
if
not
vlan
.
has_level
(
request
.
user
,
'user'
):
raise
PermissionDenied
()
try
:
Interface
.
create
(
vlan
=
vlan
,
instance
=
self
.
object
,
managed
=
vlan
.
managed
,
owner
=
request
.
user
)
self
.
object
.
add_interface
(
vlan
=
vlan
,
user
=
request
.
user
)
messages
.
success
(
request
,
_
(
"Successfully added new interface!"
))
except
Exception
,
e
:
error
=
u' '
.
join
(
e
.
messages
)
...
...
circle/vm/models/network.py
View file @
269d97c7
...
...
@@ -59,10 +59,6 @@ class Interface(Model):
return
'cloud-'
+
str
(
self
.
instance
.
id
)
+
'-'
+
str
(
self
.
vlan
.
vid
)
@property
def
destroyed
(
self
):
return
self
.
instance
.
destroyed_at
@property
def
mac
(
self
):
try
:
return
self
.
host
.
mac
...
...
@@ -139,34 +135,16 @@ class Interface(Model):
return
iface
def
deploy
(
self
):
if
self
.
destroyed
:
from
.instance
import
Instance
raise
Instance
.
InstanceDestroyedError
(
self
.
instance
,
"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'
))
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'net'
)
return
net_tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
queue
=
queue_name
)
.
get
()
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'
)
net_tasks
.
destroy
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
queue
=
queue_name
)
return
net_tasks
.
destroy
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
queue
=
queue_name
)
.
get
(
)
def
destroy
(
self
):
if
self
.
destroyed
:
return
self
.
shutdown
()
if
self
.
host
is
not
None
:
self
.
host
.
delete
()
...
...
circle/vm/operations.py
View file @
269d97c7
...
...
@@ -11,7 +11,8 @@ from celery.exceptions import TimeLimitExceeded
from
common.operations
import
Operation
,
register_operation
from
.tasks.local_tasks
import
async_instance_operation
,
async_node_operation
from
.models
import
(
Instance
,
InstanceActivity
,
InstanceTemplate
,
Node
,
NodeActivity
,
Instance
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
Node
,
NodeActivity
,
)
...
...
@@ -56,6 +57,29 @@ class InstanceOperation(Operation):
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
):
activity_code_suffix
=
'deploy'
id
=
'deploy'
...
...
@@ -107,6 +131,7 @@ class DestroyOperation(InstanceOperation):
if
self
.
instance
.
node
:
# Destroy networks
with
activity
.
sub_activity
(
'destroying_net'
):
self
.
instance
.
shutdown_net
()
self
.
instance
.
destroy_net
()
# Delete virtual machine
...
...
@@ -179,6 +204,23 @@ class RebootOperation(InstanceOperation):
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
):
activity_code_suffix
=
'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