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
bff353e8
authored
Sep 25, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add redeploy operation
Closes
#262
parent
1e4c94ea
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
1 deletions
+50
-1
circle/dashboard/forms.py
+11
-0
circle/dashboard/views/vm.py
+11
-1
circle/vm/models/instance.py
+1
-0
circle/vm/operations.py
+27
-0
No files found.
circle/dashboard/forms.py
View file @
bff353e8
...
@@ -770,6 +770,17 @@ class VmStateChangeForm(forms.Form):
...
@@ -770,6 +770,17 @@ class VmStateChangeForm(forms.Form):
return
helper
return
helper
class
RedeployForm
(
forms
.
Form
):
with_emergency_change_state
=
forms
.
BooleanField
(
required
=
False
,
initial
=
True
,
label
=
_
(
"use emergency state change"
))
@property
def
helper
(
self
):
helper
=
FormHelper
(
self
)
helper
.
form_tag
=
False
return
helper
class
VmCreateDiskForm
(
forms
.
Form
):
class
VmCreateDiskForm
(
forms
.
Form
):
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
"Name"
))
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
"Name"
))
size
=
forms
.
CharField
(
size
=
forms
.
CharField
(
...
...
circle/dashboard/views/vm.py
View file @
bff353e8
...
@@ -58,7 +58,7 @@ from ..forms import (
...
@@ -58,7 +58,7 @@ from ..forms import (
AclUserOrGroupAddForm
,
VmResourcesForm
,
TraitsForm
,
RawDataForm
,
AclUserOrGroupAddForm
,
VmResourcesForm
,
TraitsForm
,
RawDataForm
,
VmAddInterfaceForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
VmSaveForm
,
VmAddInterfaceForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
VmSaveForm
,
VmRenewForm
,
VmStateChangeForm
,
VmListSearchForm
,
VmCustomizeForm
,
VmRenewForm
,
VmStateChangeForm
,
VmListSearchForm
,
VmCustomizeForm
,
TransferOwnershipForm
,
VmDiskResizeForm
,
TransferOwnershipForm
,
VmDiskResizeForm
,
RedeployForm
,
)
)
from
..models
import
Favourite
,
Profile
from
..models
import
Favourite
,
Profile
...
@@ -599,6 +599,15 @@ class VmStateChangeView(FormOperationMixin, VmOperationView):
...
@@ -599,6 +599,15 @@ class VmStateChangeView(FormOperationMixin, VmOperationView):
return
val
return
val
class
RedeployView
(
FormOperationMixin
,
VmOperationView
):
op
=
'redeploy'
icon
=
'stethoscope'
effect
=
'danger'
show_in_toolbar
=
True
form_class
=
RedeployForm
wait_for_result
=
0.5
vm_ops
=
OrderedDict
([
vm_ops
=
OrderedDict
([
(
'deploy'
,
VmOperationView
.
factory
(
(
'deploy'
,
VmOperationView
.
factory
(
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
...
@@ -620,6 +629,7 @@ vm_ops = OrderedDict([
...
@@ -620,6 +629,7 @@ vm_ops = OrderedDict([
(
'recover'
,
VmOperationView
.
factory
(
(
'recover'
,
VmOperationView
.
factory
(
op
=
'recover'
,
icon
=
'medkit'
,
effect
=
'warning'
)),
op
=
'recover'
,
icon
=
'medkit'
,
effect
=
'warning'
)),
(
'nostate'
,
VmStateChangeView
),
(
'nostate'
,
VmStateChangeView
),
(
'redeploy'
,
RedeployView
),
(
'destroy'
,
VmOperationView
.
factory
(
(
'destroy'
,
VmOperationView
.
factory
(
extra_bases
=
[
TokenOperationView
],
extra_bases
=
[
TokenOperationView
],
op
=
'destroy'
,
icon
=
'times'
,
effect
=
'danger'
)),
op
=
'destroy'
,
icon
=
'times'
,
effect
=
'danger'
)),
...
...
circle/vm/models/instance.py
View file @
bff353e8
...
@@ -275,6 +275,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -275,6 +275,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
(
'change_resources'
,
_
(
'Can change resources of a running VM.'
)),
(
'change_resources'
,
_
(
'Can change resources of a running VM.'
)),
(
'set_resources'
,
_
(
'Can change resources of a new VM.'
)),
(
'set_resources'
,
_
(
'Can change resources of a new VM.'
)),
(
'create_vm'
,
_
(
'Can create a new VM.'
)),
(
'create_vm'
,
_
(
'Can create a new VM.'
)),
(
'redeploy'
,
_
(
'Can redeploy a VM.'
)),
(
'config_ports'
,
_
(
'Can configure port forwards.'
)),
(
'config_ports'
,
_
(
'Can configure port forwards.'
)),
(
'recover'
,
_
(
'Can recover a destroyed VM.'
)),
(
'recover'
,
_
(
'Can recover a destroyed VM.'
)),
(
'emergency_change_state'
,
_
(
'Can change VM state to NOSTATE.'
)),
(
'emergency_change_state'
,
_
(
'Can change VM state to NOSTATE.'
)),
...
...
circle/vm/operations.py
View file @
bff353e8
...
@@ -827,6 +827,33 @@ class ChangeStateOperation(InstanceOperation):
...
@@ -827,6 +827,33 @@ class ChangeStateOperation(InstanceOperation):
self
.
instance
.
save
()
self
.
instance
.
save
()
@register_operation
class
RedeployOperation
(
InstanceOperation
):
activity_code_suffix
=
'redeploy'
id
=
'redeploy'
name
=
_
(
"redeploy"
)
description
=
_
(
"Change the virtual machine state to NOSTATE "
"and redeploy the VM. This operation allows starting "
"machines formerly running on a failed node."
)
acl_level
=
"owner"
required_perms
=
(
'vm.redeploy'
,
)
concurrency_check
=
False
def
_operation
(
self
,
user
,
activity
,
with_emergency_change_state
=
True
):
if
with_emergency_change_state
:
ChangeStateOperation
(
self
.
instance
)
.
call
(
parent_activity
=
activity
,
user
=
user
,
new_state
=
'NOSTATE'
,
interrupt
=
False
,
reset_node
=
True
)
else
:
ShutOffOperation
(
self
.
instance
)
.
call
(
parent_activity
=
activity
,
user
=
user
)
self
.
instance
.
_update_status
()
DeployOperation
(
self
.
instance
)
.
call
(
parent_activity
=
activity
,
user
=
user
)
class
NodeOperation
(
Operation
):
class
NodeOperation
(
Operation
):
async_operation
=
abortable_async_node_operation
async_operation
=
abortable_async_node_operation
host_cls
=
Node
host_cls
=
Node
...
...
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