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
68b2b3b2
Commit
68b2b3b2
authored
12 years ago
by
Anael Beutot
Browse files
Options
Downloads
Patches
Plain Diff
Added tag for hypervisors showing total cpu and memory allocated to VMs.
parent
b3dcf60b
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
cloudcontrol/node/hypervisor/__init__.py
+11
-1
11 additions, 1 deletion
cloudcontrol/node/hypervisor/__init__.py
cloudcontrol/node/hypervisor/tags.py
+30
-0
30 additions, 0 deletions
cloudcontrol/node/hypervisor/tags.py
with
41 additions
and
1 deletion
cloudcontrol/node/hypervisor/__init__.py
+
11
−
1
View file @
68b2b3b2
...
...
@@ -100,6 +100,11 @@ class Handler(HostHandler):
for
dom
in
self
.
hypervisor
.
domains
.
itervalues
():
self
.
tag_db
.
add_sub_object
(
dom
.
name
,
dom
.
tags
.
itervalues
())
# we must refresh those tags only when domains tags are registered to
# have the calculated values
for
tag
in
(
'
cpualloc
'
,
'
cpurunning
'
,
'
memalloc
'
,
'
memrunning
'
):
self
.
tag_db
[
'
__main__
'
][
tag
].
update_value
()
self
.
rpc_handler
.
update
(
dict
(
vm_define
=
self
.
vm_define
,
vm_undefine
=
self
.
vm_undefine
,
...
...
@@ -149,6 +154,10 @@ class Handler(HostHandler):
logger
.
error
(
'
Connection to libvirt lost, trying to restart
'
)
# update connection state
self
.
virt_connected
=
False
# refresh those tags
for
tag
in
(
'
cpualloc
'
,
'
cpurunning
'
,
'
memalloc
'
,
'
memrunning
'
):
self
.
tag_db
[
'
__main__
'
][
tag
].
update_value
()
# unregister tags that will be re registered later
for
storage
in
self
.
hypervisor
.
storage
.
storages
:
self
.
tag_db
.
remove_tags
((
...
...
@@ -817,7 +826,8 @@ class Hypervisor(object):
def
update_domain_count
(
self
):
"""
Update domain state count tags.
"""
# update domain state counts
for
tag
in
(
'
nvm
'
,
'
vmpaused
'
,
'
vmstarted
'
,
'
vmstopped
'
):
for
tag
in
(
'
nvm
'
,
'
vmpaused
'
,
'
vmstarted
'
,
'
vmstopped
'
,
'
cpualloc
'
,
'
cpurunning
'
,
'
memalloc
'
,
'
memrunning
'
):
self
.
handler
.
tag_db
[
'
__main__
'
][
tag
].
update_value
()
def
vm_define
(
self
,
xml_desc
):
...
...
This diff is collapsed.
Click to expand it.
cloudcontrol/node/hypervisor/tags.py
+
30
−
0
View file @
68b2b3b2
...
...
@@ -129,3 +129,33 @@ def vmstarted(handl):
def
vmstopped
(
handl
):
"""
Count of VMs Stopped.
"""
return
handl
.
hypervisor
.
vm_stopped
@_check_virt_connected
def
cpurunning
(
handl
):
"""
CPU total used by running VMs on the hypervisor.
"""
return
sum
(
int
(
vm
.
tags
[
'
cpu
'
].
value
)
for
vm
in
handl
.
hypervisor
.
domains
.
itervalues
()
if
vm
.
tags
[
'
cpu
'
].
value
and
vm
.
state
==
'
running
'
)
@_check_virt_connected
def
cpualloc
(
handl
):
"""
CPU total used by all VMs on the hypervisor.
"""
return
sum
(
int
(
vm
.
tags
[
'
cpu
'
].
value
)
for
vm
in
handl
.
hypervisor
.
domains
.
itervalues
()
if
vm
.
tags
[
'
cpu
'
].
value
)
@_check_virt_connected
def
memrunning
(
handl
):
"""
Memory used by running VMs on the hypervisor.
"""
return
sum
(
int
(
vm
.
tags
[
'
mem
'
].
value
)
for
vm
in
handl
.
hypervisor
.
domains
.
itervalues
()
if
vm
.
tags
[
'
mem
'
].
value
and
vm
.
state
==
'
running
'
)
@_check_virt_connected
def
memalloc
(
handl
):
"""
Memory used by all VMs on the hypervisor.
"""
return
sum
(
int
(
vm
.
tags
[
'
mem
'
].
value
)
for
vm
in
handl
.
hypervisor
.
domains
.
itervalues
()
if
vm
.
tags
[
'
mem
'
].
value
)
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