Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
bebb9c9a
"cloudcontrol/node/jobs.py" did not exist on "f4553ddc307d77cc90f2572c3c46d652c0116b61"
Commit
bebb9c9a
authored
14 years ago
by
Benziane Chakib
Browse files
Options
Downloads
Patches
Plain Diff
Added suspend and resume method for the node handler
parent
856c8ef2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ccnode/ccnodehandlers.py
+54
-5
54 additions, 5 deletions
ccnode/ccnodehandlers.py
ccnode/kvm.py
+28
-2
28 additions, 2 deletions
ccnode/kvm.py
with
82 additions
and
7 deletions
ccnode/ccnodehandlers.py
+
54
−
5
View file @
bebb9c9a
...
...
@@ -176,8 +176,8 @@ class NodeHandler(RpcHandler):
self
.
hv_handle
.
stop_vm
(
vm
,
stop_mode
)
except
VMError
as
err
:
logging
.
warning
(
'
Error while stopping %s: %s
'
%
(
vm
,
err
))
continue
logging
.
info
(
'
stop_vm: vm %s stopping
'
%
vm
)
else
:
logging
.
info
(
'
stop_vm: vm %s stopping
'
%
vm
)
@pure
def
start_vm
(
self
,
vm_names
=
None
):
...
...
@@ -189,15 +189,55 @@ class NodeHandler(RpcHandler):
:type vm_names: :class:`list` of strings
'''
if
vm_names
is
None
:
vm_names
=
[
vm
.
get_name
()
for
vm
in
self
.
hv_handle
.
_vm_list
]
vm_names
=
gen_vm_names
(
self
.
hv_handle
)
logging
.
debug
(
'
start_vm: starting vms %s
'
%
vm_names
)
for
vm
in
vm_names
:
try
:
self
.
hv_handle
.
start_vm
(
vm
)
except
VMError
as
err
:
logging
.
warning
(
'
Error while starting %s: %s
'
%
(
vm
,
err
))
continue
logging
.
info
(
'
start_vm: vm %s starting
'
%
vm
)
else
:
logging
.
info
(
'
start_vm: vm %s starting
'
%
vm
)
@pure
def
suspend_vm
(
self
,
vm_names
=
None
):
'''
Suspends the specifed list of vms
If vm_names is None all vms in hypervisor will be suspended
:param vm_names: the list of vms to suspend
:type vm_names: :class:`list` of strings
'''
if
vm_names
is
None
:
vm_names
=
gen_vm_names
(
self
.
hv_handle
)
logging
.
debug
(
'
suspend_vm: suspending vms %s
'
%
vm_names
)
for
vm
in
vm_names
:
try
:
self
.
hv_handle
.
suspend_vm
(
vm
)
except
VMError
as
err
:
logging
.
info
(
'
Error while suspending %s: %s
'
%
(
vm
,
err
))
else
:
logging
.
info
(
'
suspend_vm: vm %s suspended
'
%
vm
)
@pure
def
resume_vm
(
self
,
vm_names
=
None
):
'''
Resumes the specified list of vms
If vm_names is None all vms in hypervisor will be resumed
:param vm_names: the list of vms to resume
:type vm_names: :class:`str`
'''
if
vm_names
is
None
:
vm_names
=
gen_vm_names
(
self
.
hv_handle
)
logging
.
debug
(
'
resume_vm: resuming vms %s
'
%
vm_names
)
for
vm
in
vm_names
:
try
:
self
.
hv_handle
.
resume_vm
(
vm
)
except
VMError
as
err
:
logging
.
info
(
'
Error while resuming %s: %s
'
%
(
vm
,
err
))
else
:
logging
.
info
(
'
resume_vm: vm %s resumed
'
%
vm
)
@pure
def
execute_command
(
self
,
command
):
...
...
@@ -210,3 +250,12 @@ class NodeHandler(RpcHandler):
'''
result
=
self
.
hv_handle
.
local_excecute
(
command
)
return
result
### Helper Functions
def
gen_vm_names
(
hypervisor
):
'''
generates a list of vm names defined in hypervisor
'''
return
[
vm
.
get_name
()
for
vm
in
hypervisor
.
_vm_list
]
This diff is collapsed.
Click to expand it.
ccnode/kvm.py
+
28
−
2
View file @
bebb9c9a
...
...
@@ -56,14 +56,40 @@ class KvmHypervisor(LibvirtHypervisor):
'''
Poweroff the specifed vm with the specified options
:param name: the name of the vm
:
:param name: the name of the vm
:type name: :class:`str`
'''
for
vm
in
self
.
_vm_list
:
if
vm
.
get_name
()
==
name
:
vm
.
shutdown
()
if
stop_mode
else
vm
.
force_poweroff
()
return
raise
VMError
(
'
Virtual Machine %s not found:
'
%
name
)
raise
VMError
(
'
Virtual Machine %s not found:
'
%
name
)
def
suspend_vm
(
self
,
name
):
'''
Suspends the specifed vm
:param name: the name of the vm
:type name: :class:`str`
'''
for
vm
in
self
.
_vm_list
:
if
vm
.
get_name
()
==
name
:
vm
.
suspend
()
return
raise
VMError
(
'
Virtual machine %s not found:
'
%
name
)
def
resume_vm
(
self
,
name
):
'''
Resumes the specifed vm
:param name: the name of the vm
:type name: :class:`str`
'''
for
vm
in
self
.
_vm_list
:
if
vm
.
get_name
()
==
name
:
vm
.
resume
()
return
raise
VMError
(
'
Virtual machine %s not found:
'
%
name
)
def
local_excecute
(
self
,
command
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment