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
51820950
Commit
51820950
authored
14 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
cleanup
parent
1e3a7beb
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/libvirtwrapper.py
+10
-13
10 additions, 13 deletions
ccnode/libvirtwrapper.py
ccnode/utils.py
+12
-0
12 additions, 0 deletions
ccnode/utils.py
etc/cc-node.conf
+9
-9
9 additions, 9 deletions
etc/cc-node.conf
with
31 additions
and
22 deletions
ccnode/libvirtwrapper.py
+
10
−
13
View file @
51820950
# -*- coding: utf-8 -*-
import
libvirt
import
re
import
psutil
import
xml.dom.minidom
from
logging
import
debug
,
info
from
logging
import
error
,
warning
,
info
,
debug
from
time
import
sleep
from
common
import
Hypervisor
,
VM
,
Storage
,
StoragePool
,
StorageVolume
from
utils
import
RWLock
from
exceptions
import
HypervisorError
,
VMError
,
StoragePoolError
KVM_LIBVIRT_SESSION
=
'
qemu:///system
'
...
...
@@ -29,10 +29,10 @@ class LibvirtHypervisor(Hypervisor):
'''
try
:
if
hv_type
==
'
kvm
'
:
debu
g
(
"
LibvirtHypervisor: initialized as KVM
"
)
warnin
g
(
"
LibvirtHypervisor: initialized as KVM
"
)
self
.
_lvcon_handle
=
libvirt
.
open
(
KVM_LIBVIRT_SESSION
)
elif
hv_type
==
'
xen
'
:
debu
g
(
"
LibvirtHypervisor: initialized as Xen
"
)
warnin
g
(
"
LibvirtHypervisor: initialized as Xen
"
)
self
.
_lvcon_handle
=
libvirt
.
open
(
XEN_LIBVIRT_SESSION
)
else
:
raise
NotImplemented
(
'
Unknown hypervisor type
'
)
...
...
@@ -55,24 +55,22 @@ class LibvirtHypervisor(Hypervisor):
running
=
{}
defined
=
{}
#debug("_vm_cache_rebuild: listing running domains")
for
dom_id
in
self
.
_lvcon_handle
.
listDomainsID
():
#debug("domid=%i" % dom_id)
try
:
vm
=
LibvirtVm
(
self
,
self
.
_lvcon_handle
.
lookupByID
(
dom_id
))
running
[
vm
.
get_name
()]
=
vm
except
Exception
as
err
:
debug
(
"
%s: %s
"
%
(
err
,
err
))
debug
(
"
_cache_vm_rebuild: listDomainsID: `%s` -> `%s`
"
,
repr
(
err
),
err
)
#debug("_vm_cache_rebuild: listing defined domains")
for
dom_name
in
self
.
_lvcon_handle
.
listDefinedDomains
():
#debug("domid=%s" % dom_name)
try
:
vm
=
LibvirtVm
(
self
,
self
.
_lvcon_handle
.
lookupByName
(
dom_name
))
defined
[
vm
.
get_name
()]
=
vm
except
Exception
as
err
:
debug
(
"
%s: %s
"
%
(
err
,
err
))
debug
(
"
_cache_vm_rebuild: listDefinedDomains: `%s` -> `%s`
"
,
repr
(
err
),
err
)
with
self
.
_vm_cache_lock
.
write
:
self
.
_vm_cache_running
=
running
...
...
@@ -92,8 +90,7 @@ class LibvirtHypervisor(Hypervisor):
try
:
data
=
self
.
_lvcon_handle
.
getVersion
()
if
data
:
version
=
data
version
=
data
except
:
pass
return
version
...
...
@@ -537,7 +534,7 @@ class LibvirtVm(VM):
if
xarch
in
self
.
ARCH
:
arch
=
self
.
ARCH
[
xarch
]
except
:
pass
pass
return
arch
def
get_cpu_core
(
self
):
...
...
This diff is collapsed.
Click to expand it.
ccnode/utils.py
+
12
−
0
View file @
51820950
...
...
@@ -6,6 +6,8 @@ class RWLock(object):
'''
'''
def
__init__
(
self
):
'''
'''
self
.
_mutex
=
Lock
()
self
.
_writemutex
=
Lock
()
self
.
_readers
=
0
...
...
@@ -17,17 +19,23 @@ class RWLock(object):
'''
'''
def
__init__
(
self
,
rwlock
):
'''
'''
self
.
_parent
=
rwlock
class
_WLock
(
_Lock
):
'''
'''
def
__enter__
(
self
):
'''
'''
with
self
.
_parent
.
_mutex
:
self
.
_parent
.
_writers
+=
1
self
.
_parent
.
_writemutex
.
acquire
()
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
'''
'''
with
self
.
_parent
.
_mutex
:
self
.
_parent
.
_writers
-=
1
self
.
_parent
.
_writemutex
.
release
()
...
...
@@ -36,6 +44,8 @@ class RWLock(object):
'''
'''
def
__enter__
(
self
):
'''
'''
self
.
_parent
.
_mutex
.
acquire
()
if
self
.
_parent
.
_writers
>
0
or
self
.
_parent
.
_readers
==
0
:
self
.
_parent
.
_mutex
.
release
()
...
...
@@ -45,6 +55,8 @@ class RWLock(object):
self
.
_parent
.
_mutex
.
release
()
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
'''
'''
self
.
_parent
.
_mutex
.
acquire
()
self
.
_parent
.
_readers
-=
1
if
self
.
_parent
.
_readers
==
0
:
...
...
This diff is collapsed.
Click to expand it.
etc/cc-node.conf
+
9
−
9
View file @
51820950
[
node
]
# address and port of the CloudControl server
address
=
address
=
10
.
15
.
255
.
42
#port = 1984
# account created for this node on the server
login
=
password
=
login
=
$$
LOGIN
$$
password
=
$$
PASSWORD
$$
# logging verbosity level 0-3
verbosity
=
#
verbosity =
0
# hypervisor detection and connection, set to 'no' on regular hosts or when
# the node should not attempt to use local hypervisors
detect_hypervisor
=
yes
#detect_hypervisor = yes
# allow remote command execution (or host shutdown/reboot)
#command_execution = yes
# TO BE REMOVED IN LATER RELEASES
# force usage of Xen
force_xen
=
no
# allow remote command execution (or host shutdown/reboot)
command_execution
=
yes
#
force_xen
=
no
\ No newline at end of file
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