Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
3ab3e26a
authored
Aug 19, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: allow forcibly interrupting activities
fixes #256
parent
1e2a59ed
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
4 deletions
+48
-4
circle/dashboard/forms.py
+21
-0
circle/dashboard/views.py
+18
-3
circle/vm/operations.py
+9
-1
No files found.
circle/dashboard/forms.py
View file @
3ab3e26a
...
@@ -714,6 +714,27 @@ class VmRenewForm(forms.Form):
...
@@ -714,6 +714,27 @@ class VmRenewForm(forms.Form):
return
helper
return
helper
class
VmStateChangeForm
(
forms
.
Form
):
interrupt
=
forms
.
BooleanField
(
required
=
False
,
label
=
_
(
"Forcibly interrupt all running activities."
),
help_text
=
_
(
"Set all activities to finished state, "
"but don't interrupt any tasks."
))
def
__init__
(
self
,
*
args
,
**
kwargs
):
show_interrupt
=
kwargs
.
pop
(
'show_interrupt'
)
super
(
VmStateChangeForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
if
not
show_interrupt
:
self
.
fields
[
'interrupt'
]
.
widget
=
HiddenInput
()
@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.py
View file @
3ab3e26a
...
@@ -67,7 +67,7 @@ from .forms import (
...
@@ -67,7 +67,7 @@ from .forms import (
CircleAuthenticationForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
CircleAuthenticationForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
GroupCreateForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
GroupCreateForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
VmSaveForm
,
UserKeyForm
,
VmRenewForm
,
VmSaveForm
,
UserKeyForm
,
VmRenewForm
,
VmStateChangeForm
,
CirclePasswordChangeForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
CirclePasswordChangeForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
TraitsForm
,
RawDataForm
,
GroupPermissionForm
,
AclUserAddForm
,
TraitsForm
,
RawDataForm
,
GroupPermissionForm
,
AclUserAddForm
,
VmResourcesForm
,
VmAddInterfaceForm
,
VmListSearchForm
VmResourcesForm
,
VmAddInterfaceForm
,
VmListSearchForm
...
@@ -936,6 +936,22 @@ class VmRenewView(FormOperationMixin, TokenOperationView, VmOperationView):
...
@@ -936,6 +936,22 @@ class VmRenewView(FormOperationMixin, TokenOperationView, VmOperationView):
return
extra
return
extra
class
VmStateChangeView
(
FormOperationMixin
,
VmOperationView
):
op
=
'emergency_change_state'
icon
=
'legal'
effect
=
'danger'
show_in_toolbar
=
True
form_class
=
VmStateChangeForm
wait_for_result
=
0.5
def
get_form_kwargs
(
self
):
inst
=
self
.
get_op
()
.
instance
show_interrupt
=
active_activities
.
exists
()
val
=
super
(
VmStateChangeView
,
self
)
.
get_form_kwargs
()
val
.
update
({
'show_interrupt'
:
show_interrupt
})
return
val
vm_ops
=
OrderedDict
([
vm_ops
=
OrderedDict
([
(
'deploy'
,
VmOperationView
.
factory
(
(
'deploy'
,
VmOperationView
.
factory
(
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
...
@@ -956,8 +972,7 @@ vm_ops = OrderedDict([
...
@@ -956,8 +972,7 @@ vm_ops = OrderedDict([
op
=
'shut_off'
,
icon
=
'ban'
,
effect
=
'warning'
)),
op
=
'shut_off'
,
icon
=
'ban'
,
effect
=
'warning'
)),
(
'recover'
,
VmOperationView
.
factory
(
(
'recover'
,
VmOperationView
.
factory
(
op
=
'recover'
,
icon
=
'medkit'
,
effect
=
'warning'
)),
op
=
'recover'
,
icon
=
'medkit'
,
effect
=
'warning'
)),
(
'nostate'
,
VmOperationView
.
factory
(
(
'nostate'
,
VmStateChangeView
),
op
=
'emergency_change_state'
,
icon
=
'legal'
,
effect
=
'danger'
)),
(
'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/operations.py
View file @
3ab3e26a
...
@@ -788,9 +788,17 @@ class ChangeStateOperation(InstanceOperation):
...
@@ -788,9 +788,17 @@ class ChangeStateOperation(InstanceOperation):
"resources."
)
"resources."
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
(
'vm.emergency_change_state'
,
)
required_perms
=
(
'vm.emergency_change_state'
,
)
concurrency_check
=
False
def
_operation
(
self
,
user
,
activity
,
new_state
=
"NOSTATE"
):
def
_operation
(
self
,
user
,
activity
,
new_state
=
"NOSTATE"
,
interrupt
=
False
):
activity
.
resultant_state
=
new_state
activity
.
resultant_state
=
new_state
if
interrupt
:
msg_txt
=
ugettext_noop
(
"Activity is forcibly interrupted."
)
message
=
create_readable
(
msg_txt
,
msg_txt
)
for
i
in
InstanceActivity
.
objects
.
filter
(
finished__isnull
=
True
,
instance
=
self
.
instance
):
i
.
finish
(
False
,
result
=
message
)
logger
.
error
(
'Forced finishing activity
%
s'
,
i
)
register_operation
(
ChangeStateOperation
)
register_operation
(
ChangeStateOperation
)
...
...
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