Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-server
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-server
Commits
992883f9
Commit
992883f9
authored
14 years ago
by
Antoine Millet
Browse files
Options
Downloads
Patches
Plain Diff
Added undefine method handler.
parent
38300207
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ccserver/handlers.py
+39
-0
39 additions, 0 deletions
ccserver/handlers.py
with
39 additions
and
0 deletions
ccserver/handlers.py
+
39
−
0
View file @
992883f9
...
...
@@ -242,6 +242,45 @@ class CliHandler(OnlineCCHandler):
self
.
_check
(
conn
,
'
resume
'
,
query
)
return
self
.
_vm_action
(
query
,
'
vm_resume
'
)
@listed
def
undefine
(
self
,
conn
,
query
,
delete_storage
=
True
):
'''
Undefine selected virtual machines.
:param query: the tql query to select objects.
:param delete_storage: delete storage of vm.
:return: a dict where key is the id of a selected object, and the value
a tuple (errcode, message) where errcode is (success|error|warn) and
message an error message or the output of the command in case of
success.
'''
self
.
_check
(
conn
,
'
undefine
'
,
query
)
#FIXME: When tag globbing will be implemented, the list of tags to
# show will be: r, p, h, disk*
# I ask "all tags" pending implementation.
objects
=
self
.
_server
.
list
(
query
,
show
=
set
((
'
*
'
,)))
errs
=
Reporter
()
for
obj
in
objects
:
if
obj
[
'
r
'
]
!=
'
vm
'
:
errs
.
error
(
obj
[
'
id
'
],
'
bad role
'
)
continue
try
:
hvcon
=
self
.
_server
.
get_connection
(
obj
[
'
p
'
])
except
KeyError
:
errs
.
error
(
obj
[
'
id
'
],
'
hypervisor not connected
'
)
else
:
if
delete_storage
:
for
disk
in
obj
.
get
(
'
disk
'
,
''
).
split
():
pool
=
obj
.
get
(
'
disk%s_pool
'
%
disk
)
name
=
obj
.
get
(
'
disk%s_vol
'
%
disk
)
hvcon
.
proxy
.
vol_delete
(
pool
,
name
)
hvcon
.
proxy
.
vm_undefine
(
obj
[
'
h
'
])
errs
.
success
(
obj
[
'
id
'
],
'
vm undefined
'
)
return
errs
.
get_dict
()
@listed
def
passwd
(
self
,
conn
,
query
,
password
,
method
=
'
ssha
'
):
'''
...
...
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