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
867b1cbe
Commit
867b1cbe
authored
12 years ago
by
Anael Beutot
Browse files
Options
Downloads
Patches
Plain Diff
Updated hypervisor tags.
parent
9e017ea9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ccnode/hypervisor/__init__.py
+14
-6
14 additions, 6 deletions
ccnode/hypervisor/__init__.py
ccnode/hypervisor/tags.py
+13
-5
13 additions, 5 deletions
ccnode/hypervisor/tags.py
ccnode/node.py
+2
-1
2 additions, 1 deletion
ccnode/node.py
with
29 additions
and
12 deletions
ccnode/hypervisor/__init__.py
+
14
−
6
View file @
867b1cbe
import
logging
import
weakref
import
libvirt
...
...
@@ -17,10 +18,11 @@ class Handler(HostHandler):
def
__init__
(
self
,
*
args
,
**
kwargs
):
"""
:param proxy: sjRpc proxy
:param hypervisor_name: hypervisor name
"""
HostHandler
.
__init__
(
self
,
*
args
,
**
kwargs
)
for
t
in
tag_inspector
(
tags
):
for
t
in
tag_inspector
(
tags
,
self
):
self
.
tags
[
t
.
name
]
=
t
# set tag hv
...
...
@@ -29,7 +31,9 @@ class Handler(HostHandler):
# initialize hypervisor instance
global
hypervisor
if
hypervisor
is
None
:
hypervisor
=
Hypervisor
()
hypervisor
=
Hypervisor
(
kwargs
.
pop
(
'
hypervisor_name
'
,
None
))
self
.
hypervisor
=
weakref
.
proxy
(
hypervisor
)
# register domains
proxy
=
kwargs
.
pop
(
'
proxy
'
)
...
...
@@ -74,7 +78,11 @@ class Handler(HostHandler):
class
Hypervisor
(
object
):
"""
Container for all hypervisor related state.
"""
def
__init__
(
self
):
def
__init__
(
self
,
name
=
None
):
#: hv attributes
self
.
name
=
name
self
.
type
=
u
'
kvm
'
self
.
event_loop
=
EventLoop
()
# This tells libvirt what event loop implementation it
# should use
...
...
@@ -135,17 +143,17 @@ class Hypervisor(object):
@property
def
vm_started
(
self
):
"""
Number of VMs started.
"""
return
self
.
_count_domain
(
lambda
d
:
d
.
stat
us
==
'
started
'
)
return
self
.
_count_domain
(
lambda
d
:
d
.
stat
e
==
'
running
'
)
@property
def
vm_stopped
(
self
):
"""
Number of VMs stopped.
"""
return
self
.
_count_domain
(
lambda
d
:
d
.
stat
us
==
'
stopped
'
)
return
self
.
_count_domain
(
lambda
d
:
d
.
stat
e
==
'
stopped
'
)
@property
def
vm_paused
(
self
):
"""
Number of VMs paused.
"""
return
self
.
_count_domain
(
lambda
d
:
d
.
stat
us
==
'
paused
'
)
return
self
.
_count_domain
(
lambda
d
:
d
.
stat
e
==
'
paused
'
)
@property
def
vm_total
(
self
):
...
...
This diff is collapsed.
Click to expand it.
ccnode/hypervisor/tags.py
+
13
−
5
View file @
867b1cbe
from
ccnode.hypervisor
import
lib
as
libvirt_
from
ccnode.utils
import
and_
...
...
@@ -8,10 +9,11 @@ def htype():
return
u
'
kvm
'
def
hv
():
def
hv
(
handl
):
"""
Hypervisor name.
"""
# What is the point of this tag ? if the information not already in a and id
# ?
return
handl
.
hypervisor
.
name
def
hvm
():
...
...
@@ -39,10 +41,12 @@ def hvm():
def
hvver
():
"""
Hypervisor version.
"""
return
libvirt_
.
connection
.
getVersion
()
def
libvirtver
():
"""
Version of running libvirt.
"""
return
libvirt_
.
connection
.
getLibVersion
()
# jobs
...
...
@@ -58,17 +62,21 @@ def sto():
# dynamic sto
# Vm related tags
def
nvm
():
def
nvm
(
handl
):
"""
Number of VMS in the current hypervisor.
"""
return
handl
.
hypervisor
.
vm_total
def
vmpaused
():
def
vmpaused
(
handl
):
"""
Count of VMs paused.
"""
return
handl
.
hypervisor
.
vm_paused
def
vmstarted
():
def
vmstarted
(
handl
):
"""
Count of VMs started.
"""
return
handl
.
hypervisor
.
vm_started
def
vmstopped
():
def
vmstopped
(
handl
):
"""
Count of VMs Stopped.
"""
return
handl
.
hypervisor
.
vm_stopped
This diff is collapsed.
Click to expand it.
ccnode/node.py
+
2
−
1
View file @
867b1cbe
...
...
@@ -105,7 +105,8 @@ class Node(Thread):
elif
role
==
u
'
hv
'
:
logger
.
debug
(
u
'
Role hypervisor affected.
'
)
from
ccnode.hypervisor
import
Handler
as
HypervisorHandler
self
.
connection
.
rpc
.
set_handler
(
HypervisorHandler
(
proxy
=
self
.
proxy
))
self
.
connection
.
rpc
.
set_handler
(
HypervisorHandler
(
proxy
=
self
.
proxy
,
hypervisor_name
=
self
.
user_name
))
self
.
role
=
u
'
hv
'
else
:
logger
.
debug
(
u
'
Wrong role returned: %s
'
,
role
)
...
...
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