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
4dd4ec1c
Commit
4dd4ec1c
authored
12 years ago
by
Anael Beutot
Browse files
Options
Downloads
Patches
Plain Diff
VM tags new tag API.
parent
b39958ea
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/hypervisor/domains/__init__.py
+10
-1
10 additions, 1 deletion
ccnode/hypervisor/domains/__init__.py
ccnode/hypervisor/domains/vm_tags.py
+9
-4
9 additions, 4 deletions
ccnode/hypervisor/domains/vm_tags.py
with
19 additions
and
5 deletions
ccnode/hypervisor/domains/__init__.py
+
10
−
1
View file @
4dd4ec1c
...
...
@@ -29,7 +29,7 @@ class VirtualMachine(object):
self
.
uuid
=
dom
.
UUIDString
()
self
.
name
=
dom
.
name
()
#: state of VM: started, stoped, paused
self
.
state
=
STATE
[
dom
.
info
()[
0
]]
self
.
_
state
=
STATE
[
dom
.
info
()[
0
]]
#: tags for this VM
self
.
tags
=
dict
((
t
.
name
,
t
)
for
t
in
tag_inspector
(
vm_tags
,
self
))
# define dynamic tags
...
...
@@ -55,6 +55,15 @@ class VirtualMachine(object):
logger
.
debug
(
'
Virtual Machine tags: %s
'
,
self
.
tags
)
@property
def
state
(
self
):
return
self
.
_state
@state.setter
def
state
(
self
,
value
):
self
.
_state
=
value
self
.
tags
[
'
status
'
].
value
=
value
@property
def
lv_dom
(
self
):
"""
Libvirt domain instance.
"""
...
...
This diff is collapsed.
Click to expand it.
ccnode/hypervisor/domains/vm_tags.py
+
9
−
4
View file @
4dd4ec1c
from
xml.etree
import
cElementTree
as
et
from
StringIO
import
StringIO
from
ccnode.tags
import
ttl
,
refresh
def
uuid
(
dom
):
"""
Unique identifier of the domain.
"""
return
dom
.
uuid
@ttl
(
5
)
def
status
(
dom
):
return
dom
.
state
status
.
ttl
=
5
def
hv
(
dom
):
...
...
@@ -40,9 +42,10 @@ def cpu(dom):
return
dom
.
lv_dom
.
info
()[
3
]
@ttl
(
10
)
@refresh
(
5
)
def
cpuuse
():
pass
cpuuse
.
ttl
=
10
def
mem
(
dom
):
...
...
@@ -65,13 +68,15 @@ def vncport(dom):
logger
.
exception
(
'
VNCPort
'
)
@ttl
(
10
)
@refresh
(
10
)
def
disk
(
dom
):
"""
Get backend disks.
"""
return
u
'
'
.
join
(
map
(
str
,
xrange
(
len
(
dom
.
disks
))))
or
None
disk
.
ttl
=
10
@ttl
(
10
)
@refresh
(
10
)
def
nic
(
dom
):
"""
VM network interfaces.
"""
return
u
'
'
.
join
(
map
(
str
,
xrange
(
len
(
dom
.
nics
))))
or
None
disk
.
nic
=
10
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