Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
c7920a85
authored
Apr 17, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: operation for adding a new network interface to a VM
parent
9dc923fd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
circle/dashboard/views.py
+1
-2
circle/vm/operations.py
+25
-1
No files found.
circle/dashboard/views.py
View file @
c7920a85
...
@@ -404,8 +404,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -404,8 +404,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/operations.py
View file @
c7920a85
...
@@ -10,7 +10,8 @@ from celery.exceptions import TimeLimitExceeded
...
@@ -10,7 +10,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
,
)
)
...
@@ -58,6 +59,29 @@ def register_instance_operation(op_cls, op_id=None):
...
@@ -58,6 +59,29 @@ def register_instance_operation(op_cls, op_id=None):
return
register_operation
(
Instance
,
op_cls
,
op_id
)
return
register_operation
(
Instance
,
op_cls
,
op_id
)
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_instance_operation
(
AddInterfaceOperation
)
class
DeployOperation
(
InstanceOperation
):
class
DeployOperation
(
InstanceOperation
):
activity_code_suffix
=
'deploy'
activity_code_suffix
=
'deploy'
id
=
'deploy'
id
=
'deploy'
...
...
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