Chris Lalancette
2008-Jun-04 19:47 UTC
[Ovirt-devel] [PATCH]: Fix ovirt-identify-node to work at boot time
Problem: ovirt-identify-node was calling libvirt functions. However, libvirtd isn't running at this point in boot, so calling these functions fails. Solution: Luckily, we can get almost all of this information from python's built-in facilities (and we will be able to get it from bash later as well). So make native python calls to get this information. Longer term, I think we'll probably want to do this in 2 stages (1st stage just grab the keytab, and 2nd stage actually send over relevant information). But this should fix it for now. Warning: it's only been lightly tested so far, so beware. Signed-off-by: Chris Lalancette <clalance at redhat.com> -------------- next part -------------- A non-text attachment was scrubbed... Name: ovirt-host-info.patch Type: text/x-patch Size: 2390 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20080604/7b24158b/attachment.bin>
Daniel P. Berrange
2008-Jun-04 19:57 UTC
[Ovirt-devel] [PATCH]: Fix ovirt-identify-node to work at boot time
On Wed, Jun 04, 2008 at 09:47:08PM +0200, Chris Lalancette wrote:> Problem: ovirt-identify-node was calling libvirt functions. However, libvirtd > isn't running at this point in boot, so calling these functions fails.Surely libvirtd should be set to run before any oVirt services on the host start. There's a clear line of dependancy from oVirt to libvirt so the startup should reflect that. Dan -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Hugh O. Brock
2008-Jun-04 20:45 UTC
[Ovirt-devel] [PATCH]: Fix ovirt-identify-node to work at boot time
On Wed, Jun 04, 2008 at 09:47:08PM +0200, Chris Lalancette wrote:> Problem: ovirt-identify-node was calling libvirt functions. However, libvirtd > isn't running at this point in boot, so calling these functions fails. > > Solution: Luckily, we can get almost all of this information from python's > built-in facilities (and we will be able to get it from bash later as well). So > make native python calls to get this information. > > Longer term, I think we'll probably want to do this in 2 stages (1st stage just > grab the keytab, and 2nd stage actually send over relevant information). But > this should fix it for now. > > Warning: it's only been lightly tested so far, so beware. > > Signed-off-by: Chris Lalancette <clalance at redhat.com>> diff --git a/ovirt-host-creator/common-post.ks b/ovirt-host-creator/common-post.ks > index c18d3cb..1449a8e 100644 > --- a/ovirt-host-creator/common-post.ks > +++ b/ovirt-host-creator/common-post.ks > @@ -37,6 +37,7 @@ cat > /sbin/ovirt-identify-node << \EOF > import libvirt > import socket > import sys > +import os > from optparse import OptionParser > > def log(msg): > @@ -46,28 +47,34 @@ class IdentifyNode: > """This class allows the managed node to connect to the WUI host > and notify it that the node is awake and ready to participate.""" > > - def __init__(self, server, port): > - > - conn = libvirt.openReadOnly(None) > - if conn == None: > - log('Failed to open connection to the hypervisor') > - sys.exit(1) > - info = conn.getInfo() > + def cpuspeed(self): > + speed = 2000 > + f = open('/proc/cpuinfo', 'r') > + lines = f.readlines() > + f.close() > + for line in lines: > + if line.find('cpu MHz') != -1: > + speed = line.split(':')[1].split('.')[0].strip() > + break > + > + return speed > > + def __init__(self, server, port): > self.hostname = 'management.priv.ovirt.org' > self.server_name = server > self.server_port = port > - self.host_info = { > - # FIXME: This is the same as we had before I think.. using hostname for the UUID. > - # There was a fixme for this before that we should have better UUIDs. > - "UUID" : conn.getHostname(), > - "ARCH" : info[0], > - "MEMSIZE" : "%d" % info[1], > - "NUMCPUS" : "%d" % info[2], > - "CPUSPEED" : "%d" % info[3], > - "HOSTNAME" : conn.getHostname(), > - "HYPERVISOR_TYPE" : conn.getType() > - } > + > + self.host_info = { > + # FIXME: we shouldn't use the hostname as the UUID > + "UUID" : socket.getfqdn(), > + "ARCH" : os.uname()[4], > + "MEMSIZE" : str((os.sysconf('SC_PHYS_PAGES') * os.sysconf('SC_PAGESIZE')) / 1024 / 1024), > + "NUMCPUS" : str(os.sysconf('SC_NPROCESSORS_ONLN')), > + "CPUSPEED" : self.cpuspeed(), > + "HOSTNAME" : socket.getfqdn(), > + "HYPERVISOR_TYPE" : "QEMU" > + > + } > > self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > self.socket.connect((self.server_name,self.server_port))ACK Committing this now. --Hugh