client/tools/rhn-virtualization/virtualization/localvdsm.py | 4
client/tools/rhn-virtualization/virtualization/poller.py | 53 ++++++++----
client/tools/rhn-virtualization/virtualization/support.py | 10 +-
3 files changed, 43 insertions(+), 24 deletions(-)
New commits:
commit 0d6ee69617af7478159ee1b24e901bae8680f67f
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Tue Jan 19 11:09:59 2010 +0100
548812 - proper support for VDSM in rhn-virtualization
* distinguish between libvirt and vdsm interface when polling virt. host
for domain changes
* do not save virt. guest config files on a VDSM enabled host
* minor localvdsm.py polishing
diff --git a/client/tools/rhn-virtualization/virtualization/localvdsm.py
b/client/tools/rhn-virtualization/virtualization/localvdsm.py
index 71feb48..67d2b24 100644
--- a/client/tools/rhn-virtualization/virtualization/localvdsm.py
+++ b/client/tools/rhn-virtualization/virtualization/localvdsm.py
@@ -40,8 +40,8 @@ def getLocalVdsName(tsPath):
def connect():
tsPath = getTrustStorePath()
port = config.get('addresses', 'management_port')
- addr = getLocalVdsName(tsPath)
if tsPath:
+ addr = getLocalVdsName(tsPath)
from M2Crypto.m2xmlrpclib import SSL_Transport
from M2Crypto import SSL
@@ -58,7 +58,7 @@ def connect():
server = xmlrpclib.Server('https://%s:%s' % (addr, port),
SSL_Transport(ctx))
else:
- server = xmlrpclib.Server('http://%s:%s' % (addr, port))
+ server = xmlrpclib.Server('http://localhost:%s' % port)
return server
if __name__ == '__main__':
diff --git a/client/tools/rhn-virtualization/virtualization/poller.py
b/client/tools/rhn-virtualization/virtualization/poller.py
index 44aa232..bfe7953 100644
--- a/client/tools/rhn-virtualization/virtualization/poller.py
+++ b/client/tools/rhn-virtualization/virtualization/poller.py
@@ -41,7 +41,7 @@ from virtualization.util import hyphenize_uuid, \
is_fully_virt
from virtualization.poller_state_cache import PollerStateCache
-from virtualization.domain_directory import DomainDirectory
+from virtualization.domain_directory import DomainDirectory
###############################################################################
# Globals
###############################################################################
@@ -161,14 +161,20 @@ def poll_through_vdsm():
virt_type = VirtualizationType.FULLY
#Memory
- memory = int(domain['memSize'] * 1024);
+ memory = int(domain['memSize']) * 1024
+
+ # vcpus
+ if domain.has_key('smp'):
+ vcpus = domain['smp']
+ else:
+ vcpus = '1'
properties = {
PropertyType.NAME : domain['vmName'],
PropertyType.UUID : uuid,
PropertyType.TYPE : virt_type,
PropertyType.MEMORY : memory, # current memory
- PropertyType.VCPUS : domain['smp'],
+ PropertyType.VCPUS : vcpus,
PropertyType.STATE : status}
state[uuid] = properties
@@ -261,25 +267,38 @@ if __name__ == "__main__":
# First, handle the options.
_parse_options()
- # If no libvirt present, this program is pretty much useless. Just exit.
- if libvirt:
- # Now, crawl each of the domains on this host and obtain the new state.
+ # check for VDSM status
+ import commands
+ vdsm_enabled = False
+ status, msg = commands.getstatusoutput("/etc/init.d/vdsmd status")
+ if status == 0:
+ vdsm_enabled = True
+
+ # Crawl each of the domains on this host and obtain the new state.
+ if vdsm_enabled:
+ domain_list = poll_through_vdsm()
+ elif libvirt:
domain_list = poll_hypervisor()
+ else:
+ # If no libvirt nor vdsm is present, this program is pretty much
+ # useless. Just exit.
+ sys.exit(0)
+
+ if not domain_list:
+ # No domains returned, nothing to do, exit polling
+ sys.exit(0)
- if not domain_list:
- # No domains returned, nothing to do, exit polling
- sys.exit(0)
- # create the unkonwn domain config files
+ # create the unkonwn domain config files (for libvirt only)
+ if libvirt and not vdsm_enabled:
uuid_list = domain_list.keys()
domain = DomainDirectory()
domain.save_unknown_domain_configs(uuid_list)
- cached_state = PollerStateCache(domain_list,
- debug = options and options.debug)
+ cached_state = PollerStateCache(domain_list,
+ debug = options and options.debug)
- # Send notifications, if necessary.
- _send_notifications(cached_state)
-
- # Save the new state.
- cached_state.save()
+ # Send notifications, if necessary.
+ _send_notifications(cached_state)
+ # Save the new state.
+ cached_state.save()
diff --git a/client/tools/rhn-virtualization/virtualization/support.py
b/client/tools/rhn-virtualization/virtualization/support.py
index a32b5d5..cb7a46d 100755
--- a/client/tools/rhn-virtualization/virtualization/support.py
+++ b/client/tools/rhn-virtualization/virtualization/support.py
@@ -93,11 +93,11 @@ def refresh():
else:
domains = poller.poll_hypervisor()
- if not len(domains) and libvirt.open(None).getType() == 'Xen':
- # On a KVM/QEMU host, libvirt reports no domain entry for host itself.
- # On a Xen host, either there were no domains or xend might not be
- # running. Don't proceed further.
- return
+ if not len(domains) and libvirt.open(None).getType() == 'Xen':
+ # On a KVM/QEMU host, libvirt reports no domain entry for host itself
+ # On a Xen host, either there were no domains or xend might not be
+ # running. Don't proceed further.
+ return
domain_list = domains.values()
domain_uuids = domains.keys()
Show replies by date