Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8fdeebb8
authored
Oct 15, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add node option for deploy operation
closes #337
parent
345a3659
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
6 deletions
+37
-6
circle/dashboard/forms.py
+14
-0
circle/dashboard/views/vm.py
+17
-4
circle/vm/operations.py
+6
-2
No files found.
circle/dashboard/forms.py
View file @
8fdeebb8
...
@@ -943,6 +943,20 @@ class VmAddInterfaceForm(forms.Form):
...
@@ -943,6 +943,20 @@ class VmAddInterfaceForm(forms.Form):
return
helper
return
helper
class
VmDeployForm
(
forms
.
Form
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
choices
=
kwargs
.
pop
(
'choices'
,
None
)
super
(
VmDeployForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
if
choices
is
not
None
:
self
.
fields
.
insert
(
0
,
'node'
,
forms
.
ModelChoiceField
(
queryset
=
choices
,
label
=
_
(
'Node'
),
help_text
=
_
(
"Deploy virtual machine to this node "
"(blank allows scheduling automatically)."
)))
class
CircleAuthenticationForm
(
AuthenticationForm
):
class
CircleAuthenticationForm
(
AuthenticationForm
):
# fields: username, password
# fields: username, password
...
...
circle/dashboard/views/vm.py
View file @
8fdeebb8
...
@@ -60,7 +60,7 @@ from ..forms import (
...
@@ -60,7 +60,7 @@ from ..forms import (
VmAddInterfaceForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
VmSaveForm
,
VmAddInterfaceForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
VmSaveForm
,
VmRenewForm
,
VmStateChangeForm
,
VmListSearchForm
,
VmCustomizeForm
,
VmRenewForm
,
VmStateChangeForm
,
VmListSearchForm
,
VmCustomizeForm
,
TransferOwnershipForm
,
VmDiskResizeForm
,
RedeployForm
,
VmDiskRemoveForm
,
TransferOwnershipForm
,
VmDiskResizeForm
,
RedeployForm
,
VmDiskRemoveForm
,
VmMigrateForm
,
VmMigrateForm
,
VmDeployForm
,
)
)
from
..models
import
Favourite
,
Profile
from
..models
import
Favourite
,
Profile
...
@@ -605,7 +605,6 @@ class VmStateChangeView(FormOperationMixin, VmOperationView):
...
@@ -605,7 +605,6 @@ class VmStateChangeView(FormOperationMixin, VmOperationView):
op
=
'emergency_change_state'
op
=
'emergency_change_state'
icon
=
'legal'
icon
=
'legal'
effect
=
'danger'
effect
=
'danger'
show_in_toolbar
=
True
form_class
=
VmStateChangeForm
form_class
=
VmStateChangeForm
wait_for_result
=
0.5
wait_for_result
=
0.5
...
@@ -628,9 +627,23 @@ class RedeployView(FormOperationMixin, VmOperationView):
...
@@ -628,9 +627,23 @@ class RedeployView(FormOperationMixin, VmOperationView):
wait_for_result
=
0.5
wait_for_result
=
0.5
class
VmDeployView
(
FormOperationMixin
,
VmOperationView
):
op
=
'deploy'
icon
=
'play'
effect
=
'success'
form_class
=
VmDeployForm
def
get_form_kwargs
(
self
):
kwargs
=
super
(
VmOperationView
,
self
)
.
get_form_kwargs
()
if
self
.
request
.
user
.
is_superuser
:
online
=
(
n
.
pk
for
n
in
Node
.
objects
.
filter
(
enabled
=
True
)
if
n
.
online
)
kwargs
[
'choices'
]
=
Node
.
objects
.
filter
(
pk__in
=
online
)
return
kwargs
vm_ops
=
OrderedDict
([
vm_ops
=
OrderedDict
([
(
'deploy'
,
VmOperationView
.
factory
(
(
'deploy'
,
VmDeployView
),
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
(
'wake_up'
,
VmOperationView
.
factory
(
(
'wake_up'
,
VmOperationView
.
factory
(
op
=
'wake_up'
,
icon
=
'sun-o'
,
effect
=
'success'
)),
op
=
'wake_up'
,
icon
=
'sun-o'
,
effect
=
'success'
)),
(
'sleep'
,
VmOperationView
.
factory
(
(
'sleep'
,
VmOperationView
.
factory
(
...
...
circle/vm/operations.py
View file @
8fdeebb8
...
@@ -324,10 +324,14 @@ class DeployOperation(InstanceOperation):
...
@@ -324,10 +324,14 @@ class DeployOperation(InstanceOperation):
"deployed to node:
%(node)
s"
),
"deployed to node:
%(node)
s"
),
node
=
self
.
instance
.
node
)
node
=
self
.
instance
.
node
)
def
_operation
(
self
,
activity
):
def
_operation
(
self
,
activity
,
node
=
None
):
# Allocate VNC port and host node
# Allocate VNC port and host node
self
.
instance
.
allocate_vnc_port
()
self
.
instance
.
allocate_vnc_port
()
self
.
instance
.
allocate_node
()
if
node
is
not
None
:
self
.
instance
.
node
=
node
self
.
instance
.
save
()
else
:
self
.
instance
.
allocate_node
()
# Deploy virtual images
# Deploy virtual images
self
.
instance
.
_deploy_disks
(
parent_activity
=
activity
)
self
.
instance
.
_deploy_disks
(
parent_activity
=
activity
)
...
...
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