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
284053f9
authored
Nov 02, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add UpdateNodeOperation
parent
c2b89065
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
circle/dashboard/views/node.py
+2
-0
circle/vm/operations.py
+57
-0
No files found.
circle/dashboard/views/node.py
View file @
284053f9
...
@@ -68,6 +68,8 @@ node_ops = OrderedDict([
...
@@ -68,6 +68,8 @@ node_ops = OrderedDict([
op
=
'passivate'
,
icon
=
'play-circle-o'
,
effect
=
'info'
)),
op
=
'passivate'
,
icon
=
'play-circle-o'
,
effect
=
'info'
)),
(
'disable'
,
NodeOperationView
.
factory
(
(
'disable'
,
NodeOperationView
.
factory
(
op
=
'disable'
,
icon
=
'times-circle-o'
,
effect
=
'danger'
)),
op
=
'disable'
,
icon
=
'times-circle-o'
,
effect
=
'danger'
)),
(
'update_node'
,
NodeOperationView
.
factory
(
op
=
'update_node'
,
icon
=
'refresh'
,
effect
=
'warning'
)),
(
'reset'
,
NodeOperationView
.
factory
(
(
'reset'
,
NodeOperationView
.
factory
(
op
=
'reset'
,
icon
=
'stethoscope'
,
effect
=
'danger'
)),
op
=
'reset'
,
icon
=
'stethoscope'
,
effect
=
'danger'
)),
(
'flush'
,
NodeOperationView
.
factory
(
(
'flush'
,
NodeOperationView
.
factory
(
...
...
circle/vm/operations.py
View file @
284053f9
...
@@ -26,6 +26,7 @@ from StringIO import StringIO
...
@@ -26,6 +26,7 @@ from StringIO import StringIO
from
tarfile
import
TarFile
,
TarInfo
from
tarfile
import
TarFile
,
TarInfo
import
time
import
time
from
urlparse
import
urlsplit
from
urlparse
import
urlsplit
from
salt.client
import
LocalClient
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -1191,6 +1192,62 @@ class DisableOperation(NodeOperation):
...
@@ -1191,6 +1192,62 @@ class DisableOperation(NodeOperation):
@register_operation
@register_operation
class
UpdateNodeOperation
(
NodeOperation
):
id
=
'update_node'
name
=
_
(
"update node"
)
description
=
_
(
"Update node."
)
required_perms
=
()
online_required
=
False
async_queue
=
"localhost.man.slow"
def
minion_cmd
(
self
,
module
,
params
,
timeout
=
3600
):
name
=
self
.
node
.
host
.
hostname
client
=
LocalClient
()
data
=
client
.
cmd
(
name
,
module
,
timeout
=
timeout
,
kwarg
=
{
'mods'
:
params
})
try
:
return
data
[
name
]
except
KeyError
:
raise
HumanReadableException
.
create
(
ugettext_noop
(
"No minions matched the target."
))
def
_operation
(
self
,
activity
):
with
activity
.
sub_activity
(
'upgrade_packages'
,
readable_name
=
ugettext_noop
(
'upgrade packages'
))
as
sa
:
data
=
self
.
minion_cmd
(
'pkg.upgrade'
,
[])
upgraded
=
len
(
filter
(
lambda
x
:
x
[
'old'
]
and
x
[
'new'
],
data
.
values
()))
installed
=
len
(
filter
(
lambda
x
:
not
x
[
'old'
]
and
x
[
'new'
],
data
.
values
()))
removed
=
len
(
filter
(
lambda
x
:
x
[
'old'
]
and
not
x
[
'new'
],
data
.
values
()))
sa
.
result
=
create_readable
(
ugettext_noop
(
"Upgraded:
%(upgraded)
s, Installed:
%(installed)
s, "
"Removed:
%(removed)
s"
),
upgraded
=
upgraded
,
installed
=
installed
,
removed
=
removed
)
data
=
self
.
minion_cmd
(
'state.sls'
,
[
'node'
,
'nfs-client'
])
failed
=
0
for
k
,
v
in
data
.
iteritems
():
logger
.
debug
(
'salt state
%
s
%
s'
,
k
,
v
)
act_name
=
': '
.
join
(
k
.
split
(
'_|-'
)[:
2
])
if
not
v
[
"result"
]
or
v
[
"changes"
]:
act
=
activity
.
create_sub
(
act_name
[:
70
],
readable_name
=
act_name
)
act
.
result
=
create_readable
(
ugettext_noop
(
"Changes:
%(changes)
s Comment:
%(comment)
s"
),
changes
=
v
[
"changes"
],
comment
=
v
[
"comment"
])
act
.
finish
(
v
[
"result"
])
if
not
v
[
"result"
]:
failed
+=
1
if
failed
:
raise
HumanReadableException
.
create
(
ugettext_noop
(
"Failed:
%(failed)
s"
),
failed
=
failed
)
@register_operation
class
ScreenshotOperation
(
RemoteInstanceOperation
):
class
ScreenshotOperation
(
RemoteInstanceOperation
):
id
=
'screenshot'
id
=
'screenshot'
name
=
_
(
"screenshot"
)
name
=
_
(
"screenshot"
)
...
...
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