summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordennis@daedalus.ausil.us <>2007-01-29 04:51:01 (GMT)
committerYaakov M. Nemoy <loupgaroublond@gmail.com>2007-01-29 04:51:01 (GMT)
commitd6fc76abbc54adc53d3ca2e30772e50ee75b568b (patch)
treebb76f43913836bb7637bde5eb144b3fc173d99ec
parent59b233ef8b309b4c2071fb0fc216bcfd6657dc11 (diff)
downloadsmolt-d6fc76abbc54adc53d3ca2e30772e50ee75b568b.zip
smolt-d6fc76abbc54adc53d3ca2e30772e50ee75b568b.tar.gz
smolt-d6fc76abbc54adc53d3ca2e30772e50ee75b568b.tar.xz
fix so that it works on non bios archs
-rw-r--r--hw-client/Profile.py116
-rwxr-xr-xhw-client/readProfile5
-rwxr-xr-xhw-client/sendProfile3
3 files changed, 68 insertions, 56 deletions
diff --git a/hw-client/Profile.py b/hw-client/Profile.py
index 24a7064..6fbf038 100644
--- a/hw-client/Profile.py
+++ b/hw-client/Profile.py
@@ -1,11 +1,17 @@
#!/usr/bin/python
import hardware
-import software
import sys
import os
+import commands
import re
+initdefault_re = re.compile(r':(\d+):initdefault:')
+
+# use hardware to get what we need as different archs get data from different
+# functions. namely dmi is a bios only thing while ppc and sparc have the
+# information elsewhere.
+
class Profile:
def __init__(self):
try:
@@ -21,66 +27,68 @@ class Profile:
sys.stderr.write('Unable to determine UUID of system!\n')
sys.exit(1)
- self.hw = hardware.read_hal()
-
- self.lsbRelease = software.read_lsb_release()
-
- self.OS = software.read_os()
+ self.hw = hardware.Hardware()
- self.defaultRunlevel = software.read_runlevel()
-
- self.language = os.environ['LANG']
-
- cpuinfo = hardware.read_cpuinfo()
-
- try:
- self.platform = cpuinfo['platform']
- except:
- self.platform = 'Unknown'
-
- try:
- self.bogomips = cpuinfo['bogomips']
- except:
- self.bogomips = 1
-
- try:
- self.CPUVendor = '%s - %s' % (cpuinfo['type'], device['model'])
- except:
- self.CPUVendor = 'Unknown'
-
- try:
- self.numCPUs = cpuinfo['count']
- except:
- self.numCPUs = 1
+ self.lsbRelease = ''
+ if os.access('/usr/bin/lsb_release', os.X_OK):
+ self.lsbRelease = commands.getstatusoutput('/usr/bin/lsb_release')[1]
try:
- self.CPUSpeed = cpuinfo['speed']
- except:
- self.CPUSpeed = 0
-
- memory = hardware.read_memory()
-
- try:
- self.systemMemory = device['ram']
- except:
- self.systemMemory = 0
+ self.OS = file('/etc/redhat-release').read()
+ except IOError:
+ self.OS = 'Unknown'
+ self.defaultRunlevel = 'Unknown'
try:
- self.systemSwap = device['swap']
- except:
- self.systemSwap = 0
+ inittab = file('/etc/inittab').read()
+ match = initdefault_re.search(inittab)
+ if match:
+ self.defaultRunlevel = match.group(1)
+ except IOError:
+ sys.stderr.write('Unable to read /etc/inittab, continuing...')
- dmi = hardware.read_dmi()
+ self.language = os.environ['LANG']
- try:
- self.vendor = dmi['vendor']
- except:
- self.vendor = 'Unknown'
+ self.platform = self.bogomips = self.CPUVendor = self.numCPUs = self.CPUSpeed = self.systemMemory = self.systemSwap = self.vendor = self.system = ''
- try:
- self.system = dmi['system']
- except:
- self.system = 'Unknown'
+ for device in self.hw:
+ try:
+ self.platform = device['platform']
+ self.bogomips = device['bogomips']
+ self.CPUVendor = "%s - %s" % (device['type'], device['model'])
+ self.numCPUs = device['count']
+ self.CPUSpeed = device['speed']
+ except:
+ pass
+ try:
+ self.systemMemory = device['ram']
+ self.systemSwap = device['swap']
+ except:
+ pass
+ try:
+ self.vendor = device['vendor']
+ self.system = device['system']
+ except:
+ pass
+# Defaults for when hardware doesnt return anything. namely a new cpu type
+ if self.platform == '':
+ self.platform = 'Unknown'
+ if self.bogomips == '':
+ self.bogomips = 1
+ if self.CPUVendor == '':
+ self.CPUVendor = 'Unknown'
+ if self.numCPUs == '':
+ self.numCPUs = 1
+ if self.CPUSpeed == '':
+ self.CPUSpeed = 0
+ if self.systemMemory == '':
+ self.systemMemory = 0
+ if self.systemSwap == '':
+ self.systemSwap = 0
+ if self.vendor == '':
+ self.vendor = 'Unknown'
+ if self.system == '':
+ self.system = 'Unknown'
def get_host_string(self):
@@ -99,8 +107,6 @@ class Profile:
yield "UUID=%s&Bus=%s&Driver=%s&Class=%s&Description=%s" % (self.UUID, Bus, Driver, Class, Description)
def print_data(self):
- print 'We are about to send the following information to the Fedora Smolt server:'
- print
print '\tUUID: %s' % self.UUID
print '\tlsbRelease: %s' % self.lsbRelease
print '\tOS: %s' % self.OS
diff --git a/hw-client/readProfile b/hw-client/readProfile
index 67090a3..1b96f4f 100755
--- a/hw-client/readProfile
+++ b/hw-client/readProfile
@@ -4,7 +4,10 @@ import sys
sys.path.append('/usr/share/smolt/client')
import Profile
-
+# Read the profile
profile = Profile.Profile()
+#Print the profile
+print 'We would send the following information to the Fedora Smolt server:'
+print
profile.print_data()
diff --git a/hw-client/sendProfile b/hw-client/sendProfile
index e5641dd..ff4cc42 100755
--- a/hw-client/sendProfile
+++ b/hw-client/sendProfile
@@ -7,8 +7,11 @@ import urlgrabber.grabber
import Profile
+# read the profile
profile = Profile.Profile()
+print 'We are about to send the following information to the Fedora Smolt server:'
+print
profile.print_data()
print 'Transmitting ...'