summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGurhan Ozen <gozen@redhat.com>2008-09-29 23:28:44 +0000
committerGurhan Ozen <gozen@redhat.com>2008-09-29 23:28:44 +0000
commitb9fd16df421eaa6de3556b41d99f9d28fe6fb368 (patch)
tree9d4d90e5c0f5dad7ea3525ab1d66bf86d4a817b2
parent15e81aa1e6a775abfaa1cc47d7ea4cb8b6b9c330 (diff)
do hvm capability checking on xen kernel and the rest of inventory checking on a vanilla kernelrh-tests-distribution-inventory-1_1-19
-rw-r--r--Tasks/distribution/inventory/Makefile1
-rwxr-xr-xTasks/distribution/inventory/push-inventory.py136
-rwxr-xr-xTasks/distribution/inventory/runtest.sh39
3 files changed, 107 insertions, 69 deletions
diff --git a/Tasks/distribution/inventory/Makefile b/Tasks/distribution/inventory/Makefile
index e005a91..914d7e9 100644
--- a/Tasks/distribution/inventory/Makefile
+++ b/Tasks/distribution/inventory/Makefile
@@ -76,6 +76,5 @@ $(METADATA): Makefile
@echo "TestTime: 15m" >> $(METADATA)
@echo "Requires: anaconda" >> $(METADATA)
@echo "Requires: smolt" >> $(METADATA)
- @echo "Requires: kernel-xen" >> $(METADATA)
diff --git a/Tasks/distribution/inventory/push-inventory.py b/Tasks/distribution/inventory/push-inventory.py
index e30c684..3ef8032 100755
--- a/Tasks/distribution/inventory/push-inventory.py
+++ b/Tasks/distribution/inventory/push-inventory.py
@@ -43,81 +43,85 @@ def push_inventory(hostname, inventory):
except:
raise
+# some machines just fail to boot with kernel-xen package.. but we need xen
+# kernel to determine the hvm capability of the box correctly. We'll read
+# hvm-capability in xen kernel and the rest in vanilla kernel.
def read_inventory():
# get the data from SMOLT but modify it for how RHTS expects to see it
# Eventually we'll switch over to SMOLT properly.
data = {}
- data['MODULE'] = []
- data['CPUFLAGS'] = []
- data['PCIID'] = []
- data['USBID'] = []
- data['HVM'] = False
- data['DISK'] = []
- data['DISKSPACE'] = 0
- data['NR_DISKS'] = 0
-
- cpu_info = smolt.read_cpuinfo()
- memory = smolt.read_memory()
- profile = smolt.Hardware()
-
- data['ARCH'] = cpu_info['platform']
- data['CPUSPEED'] = cpu_info['speed']
- try:
- data['CPUFAMILY'] = cpu_info['model_number']
- except:
- data['CPUFAMILY'] = cpu_info['model_rev']
- data['CPUVENDOR'] = cpu_info['type']
- data['CPUMODEL'] = cpu_info['model']
- data['CPUMODELNUMBER'] = cpu_info['model_ver']
- data['PROCESSORS'] = cpu_info['count']
- data['VENDOR'] = "%s" % profile.host.systemVendor
- data['MODEL'] = "%s" % profile.host.systemModel
- data['FORMFACTOR'] = "%s" % profile.host.formfactor
-
- # Round memory up to the next base 2
- n=0
- memory = int(memory['ram'])
- while memory > ( 2 << n):
- n=n+1
- data['MEMORY'] = 2 << n
-
- for cpuflag in cpu_info['other'].split(" "):
- data['CPUFLAGS'].append(cpuflag)
-
- for VendorID, DeviceID, SubsysVendorID, SubsysDeviceID, Bus, Driver, Type, Description in profile.deviceIter():
- if VendorID and DeviceID:
- if Bus == "pci":
- data['PCIID'].append("%04x:%04x" % ( VendorID, DeviceID))
- if Bus == "usb":
- data['USBID'].append("%04x:%04x" % ( VendorID, DeviceID))
-
- modules = commands.getstatusoutput('/sbin/lsmod')[1].split('\n')[1:]
- for module in modules:
- data['MODULE'].append(module.split()[0])
-
- # checking for whether or not the machine is hvm-enabled.
- caps = ""
- if os.path.exists("/sys/hypervisor/properties/capabilities"):
- caps = open("/sys/hypervisor/properties/capabilities").read()
- if caps.find("hvm") != -1:
- data['HVM'] = True
-
- # calculating available diskspace
- diskset = partedUtils.DiskSet()
- diskset.openDevices()
- for diskname in diskset.disks.keys():
- disksize = int(math.ceil(partedUtils.getDeviceSizeMB(diskset.disks[diskname].dev)))
- data['DISK'].append("%d " % (disksize))
- data['DISKSPACE'] += disksize
- data['NR_DISKS'] += 1
-
+ if ( os.uname()[2].find("xen") == -1 ):
+ data['MODULE'] = []
+ data['CPUFLAGS'] = []
+ data['PCIID'] = []
+ data['USBID'] = []
+ data['DISK'] = []
+ data['DISKSPACE'] = 0
+ data['NR_DISKS'] = 0
+
+ cpu_info = smolt.read_cpuinfo()
+ memory = smolt.read_memory()
+ profile = smolt.Hardware()
+
+ data['ARCH'] = cpu_info['platform']
+ data['CPUSPEED'] = cpu_info['speed']
+ try:
+ data['CPUFAMILY'] = cpu_info['model_number']
+ except:
+ data['CPUFAMILY'] = cpu_info['model_rev']
+ data['CPUVENDOR'] = cpu_info['type']
+ data['CPUMODEL'] = cpu_info['model']
+ data['CPUMODELNUMBER'] = cpu_info['model_ver']
+ data['PROCESSORS'] = cpu_info['count']
+ data['VENDOR'] = "%s" % profile.host.systemVendor
+ data['MODEL'] = "%s" % profile.host.systemModel
+ data['FORMFACTOR'] = "%s" % profile.host.formfactor
+
+ # Round memory up to the next base 2
+ n=0
+ memory = int(memory['ram'])
+ while memory > ( 2 << n):
+ n=n+1
+ data['MEMORY'] = 2 << n
+
+ for cpuflag in cpu_info['other'].split(" "):
+ data['CPUFLAGS'].append(cpuflag)
+
+ for VendorID, DeviceID, SubsysVendorID, SubsysDeviceID, Bus, Driver, Type, Description in profile.deviceIter():
+ if VendorID and DeviceID:
+ if Bus == "pci":
+ data['PCIID'].append("%04x:%04x" % ( VendorID, DeviceID))
+ if Bus == "usb":
+ data['USBID'].append("%04x:%04x" % ( VendorID, DeviceID))
+
+ modules = commands.getstatusoutput('/sbin/lsmod')[1].split('\n')[1:]
+ for module in modules:
+ data['MODULE'].append(module.split()[0])
+
+
+ # calculating available diskspace
+ diskset = partedUtils.DiskSet()
+ diskset.openDevices()
+ for diskname in diskset.disks.keys():
+ disksize = int(math.ceil(partedUtils.getDeviceSizeMB(diskset.disks[diskname].dev)))
+ data['DISK'].append("%d " % (disksize))
+ data['DISKSPACE'] += disksize
+ data['NR_DISKS'] += 1
+ else:
+ data['HVM'] = False
+ # checking for whether or not the machine is hvm-enabled.
+ caps = ""
+ if os.path.exists("/sys/hypervisor/properties/capabilities"):
+ caps = open("/sys/hypervisor/properties/capabilities").read()
+ if caps.find("hvm") != -1:
+ data['HVM'] = True
return data
-
+
def usage():
print USAGE_TEXT
sys.exit(-1)
-
+
def main():
global lab_server, hostname
diff --git a/Tasks/distribution/inventory/runtest.sh b/Tasks/distribution/inventory/runtest.sh
index eef377a..92788aa 100755
--- a/Tasks/distribution/inventory/runtest.sh
+++ b/Tasks/distribution/inventory/runtest.sh
@@ -13,6 +13,41 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-# Author: Bill Peck
+# Author: Bill Peck, Gurhan Ozen
-rhts-run-simple-test $TEST ./push-inventory.py
+arch=$(uname -i)
+
+#Virtualization is only supported on i386, x86_64 or ia64... So we'll seek for
+# hvm data only on those.
+if [[ $arch == "i386" || $arch == "x86_64" || $arch == ia64 ]]; then
+
+ if [ -z $REBOOTCOUNT ]; then
+ echo "REBOOTCOUNT variable is not set. Are you in rhts??"
+ exit 0;
+ fi
+
+ if [[ $REBOOTCOUNT == 0 ]]; then
+ rhts-run-simple-test $TEST/all_but_hvm ./push-inventory.py
+ yum -y install kernel-xen
+ if ! rpm -q kernel-xen; then
+ echo "kernel-xen isn't installed. Can't check for HVM capability"
+ report_result ${TEST}/hvm FAIL 0
+ exit 0
+ fi
+ if [[ ${arch} == ia64 ]]; then
+ perl -pi.bak -e 's/\tlabel=linux$/\tlabel=linux.old/' /boot/efi/efi/redhat/elilo.conf
+ perl -pi.bak2 -e 's/\tlabel=.*?xen$/\tlabel=linux/' /boot/efi/efi/redhat/elilo.conf
+ else
+ perl -pi.bak -e 's/^default=.*?$/default=0/g' /boot/grub/grub.conf
+ fi
+ rhts-reboot
+ else
+ rhts-run-simple-test $TEST/hvm ./push-inventory.py
+ fi
+
+else
+
+ rhts-run-simple-test $TEST ./push-inventory.py
+
+fi
+