diff --git a/acktools/tests/acktools_tests.py b/acktools/tests/acktools_tests.py index 34bb828c..8a9523dc 100644 --- a/acktools/tests/acktools_tests.py +++ b/acktools/tests/acktools_tests.py @@ -8,17 +8,13 @@ class MockProcess: - returncode = 0 - stderr = None - def __init__(self, output, err=None): self.output = output - if err: - self.returncode = 1 - self.stderr = err + self.returncode = 1 if err else 0 + self.__stderr = err def stderr(self): - return self.stderr + return self.__stderr def stdout(self): return self.output diff --git a/autocertkit/ack_cli.py b/autocertkit/ack_cli.py index 1aaa55bb..29938455 100755 --- a/autocertkit/ack_cli.py +++ b/autocertkit/ack_cli.py @@ -417,15 +417,10 @@ def main(config, test_run_file): session = get_xapi_session(config) - # Release current logger before running logrotate. - utils.release_logging() - - # Run log rotate before ACK produces any log. - for host_ref in session.xenapi.host.get_all(): - session.xenapi.host.call_plugin(host_ref, 'autocertkit', - 'run_ack_logrotate', {}) - utils.configure_logging('auto-cert-kit') + # Start Logger + utils.init_ack_logging(session) + # Pre checks before running tests pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) @@ -446,6 +441,7 @@ def main(config, test_run_file): test_file, output = test_runner.run_tests_from_file(test_run_file) if __name__ == "__main__": + # Parse Args config = parse_cmd_args() # Default config file diff --git a/autocertkit/cpu_tests.py b/autocertkit/cpu_tests.py index ee4aac28..8a4a0942 100644 --- a/autocertkit/cpu_tests.py +++ b/autocertkit/cpu_tests.py @@ -33,8 +33,6 @@ import testbase from utils import * -log = get_logger('auto-cert-kit') - class PerfTestClass(testbase.CPUTestClass): """A somewhat generic test class for CPU performance tests diff --git a/autocertkit/network_tests.py b/autocertkit/network_tests.py index f8d037d5..23779137 100644 --- a/autocertkit/network_tests.py +++ b/autocertkit/network_tests.py @@ -36,8 +36,6 @@ import sys import math -log = get_logger('auto-cert-kit') - class FixedOffloadException(Exception): pass diff --git a/autocertkit/operations_tests.py b/autocertkit/operations_tests.py index bdf7c6f2..366b561e 100644 --- a/autocertkit/operations_tests.py +++ b/autocertkit/operations_tests.py @@ -32,8 +32,6 @@ import time from utils import * -log = get_logger('auto-cert-kit') - class VMOpsTestClass(testbase.OperationsTestClass): """Test class to determine proper operation of the most diff --git a/autocertkit/ssh.py b/autocertkit/ssh.py index 4dc39cb0..eb6015db 100644 --- a/autocertkit/ssh.py +++ b/autocertkit/ssh.py @@ -37,25 +37,10 @@ import time import gc import paramiko +from utils import * SSHPORT = 22 -# Symbols we want to export from the package. -__all__ = ["SSHSession", - "SFTPSession", - "SSHCommand", - "SSH", - "SSHread", - "getPublicKey"] - - -def getPublicKey(): - filename = ".ssh/id_dsa.pub" - f = file(filename, "r") - data = f.read() - f.close() - return string.strip(data) - class SSHSession: @@ -168,230 +153,6 @@ def __del__(self): self.close() -class SFTPSession(SSHSession): - """An SFTP session guarded for target lockups.""" - - def __init__(self, - ip, - log, - username="root", - timeout=300, - password=None, - nowarn=False): - self.log = log - self.log.debug("SFTP session to %s@%s" % (username, ip)) - self.ip = ip - self.username = username - self.timeout = timeout - self.password = password - self.nowarn = nowarn - SSHSession.__init__(self, - ip, - log, - username=username, - timeout=timeout, - password=password, - nowarn=nowarn) - try: - # We do this rather than the simple trans.open_sftp_client() because - # if we don't then we don't get a timeout set so we can hang - # forever - c = self.trans.open_channel("session") - c.settimeout(timeout) - c.invoke_subsystem("sftp") - self.client = paramiko.SFTPClient(c) - except: - self.reply = "SFTP connection failed" - self.toreply = 1 - self.close() - - def getClient(self): - # This is UNSAFE - the client object may change if we auto reconnect! - return self.client - - def check(self): - # Check if the connection is still active, if not, try and re-open the - # connection (this handles the case where the connection has dropped - # due to a transient network error)... - - alive = True - - # First see if the transport is alive - if not self.trans.is_active(): - alive = False - else: - try: - d = self.client.listdir() - except: - alive = False - - if not alive: - log.warn( - "SFTP session appears to have gone away, attempting to reconnect...") - self.__init__(self.ip, - self.log, - username=self.username, - timeout=self.timeout, - password=self.password, - nowarn=self.nowarn) - - def close(self): - if self.client: - try: - self.client.close() - except Exception, e: - log.debug("SFTP close exception %s" % (str(e))) - if self.trans: - try: - self.trans.close() - except Exception, e: - log.debug("SFTP trans close exception %s" % (str(e))) - - def copyTo(self, source, dest, preserve=True): - log.debug("SFTP local:%s to remote:%s" % (source, dest)) - self.client.put(source, dest) - if preserve: - st = os.lstat(source) - if preserve == True: - self.client.chmod(dest, st.st_mode) - self.client.utime(dest, (st.st_atime, st.st_mtime)) - - def copyFrom(self, source, dest, preserve=True, threshold=None, - sizethresh=None): - log.debug("SFTP remote:%s to local:%s" % (source, dest)) - self.check() - st = self.client.stat(source) - if threshold and st.st_mtime < threshold: - log.debug("Skipping %s, too old" % (source)) - return - elif sizethresh and st.st_size > long(sizethresh): - log.debug("Skipping %s, too big (%u)" % - (source, st.st_size)) - return - self.client.get(source, dest) - if preserve: - if preserve == True: - os.chmod(dest, st.st_mode) - os.utime(dest, (st.st_atime, st.st_mtime)) - - def copyTreeTo(self, source, dest, preserve=True): - """Recursive copy to the remote host - - source: local directory being root of the tree - dest: remote directory to be the new root of the tree - """ - log.debug("SFTP recursive local:%s to remote:%s" % - (source, dest)) - self.check() - source = os.path.normpath(source) - dirs = os.walk(source) - for dir in dirs: - (dirname, dirnames, filenames) = dir - # Create the remote directory - dirname = os.path.normpath(dirname) - relpath = dirname[len(source):] - if len(relpath) > 0 and relpath[0] == "/": - relpath = relpath[1:] - targetpath = os.path.normpath(os.path.join(dest, relpath)) - try: - self.client.lstat(targetpath) - # Already exists - if preserve == True: - self.client.chmod(targetpath, os.lstat(dirname).st_mode) - except IOError, e: - self.client.mkdir(targetpath, os.lstat(dirname).st_mode) - # Copy all the files in - for file in filenames: - srcfile = os.path.join(dirname, file) - dstfile = os.path.join(targetpath, file) - st = os.lstat(srcfile) - self.client.put(srcfile, dstfile) - if preserve: - if preserve == True: - self.client.chmod(dstfile, st.st_mode) - self.client.utime(dstfile, (st.st_atime, st.st_mtime)) - - def copyTreeFromRecurse(self, source, dest, preserve=True, threshold=None, - sizethresh=None): - # make sure local destination exists - if not os.path.exists(dest): - os.makedirs(dest) - if preserve: - os.chmod(dest, self.client.lstat(source).st_mode) - d = self.client.listdir(source) - for i in d: - try: - dummy = self.client.listdir("%s/%s" % (source, i)) - isdir = True - except: - isdir = False - if isdir: - self.copyTreeFromRecurse("%s/%s" % (source, i), - "%s/%s" % (dest, i), - preserve=preserve, - threshold=threshold, - sizethresh=sizethresh) - else: - log.debug("About to copy %s/%s" % (source, i)) - st = self.client.stat("%s/%s" % (source, i)) - if threshold and st.st_mtime < threshold: - log.debug("Skipping %s/%s, too old" % - (source, i)) - elif sizethresh and st.st_size > long(sizethresh): - log.debug("Skipping %s/%s, too big (%u)" % - (source, i, st.st_size)) - else: - self.client.get("%s/%s" % (source, i), - "%s/%s" % (dest, i)) - if preserve: - if preserve == True: - os.chmod("%s/%s" % (dest, i), st.st_mode) - os.utime("%s/%s" % (dest, i), - (st.st_atime, st.st_mtime)) - - def copyTreeFrom(self, source, dest, preserve=True, threshold=None, - sizethresh=None): - """Recursive copy from the remote host - - source: remote directory being root of the tree - dest: local directory to be the new root of the tree - """ - log.debug("SFTP recursive remote:%s to local:%s" % - (source, dest)) - self.check() - self.copyTreeFromRecurse(source, - dest, - preserve=preserve, - threshold=threshold, - sizethresh=sizethresh) - - def copyLogsFrom(self, pathlist, dest, threshold=None, sizethresh=None): - """Copy any files or directory trees from pathlist remotely to - dest locally""" - log.debug("SFTP log fetch of %s to local:%s" % - (`pathlist`, dest)) - for p in pathlist: - # Directory? - log.debug("Trying to fetch %s." % (p)) - try: - d = self.client.listdir(p) - self.copyTreeFrom(p, "%s/%s" % (dest, os.path.basename(p)), - preserve="utime", threshold=threshold, - sizethresh=sizethresh) - except: - # File? - try: - s = self.client.lstat(p) - self.copyFrom(p, "%s/%s" % (dest, os.path.basename(p)), - preserve="utime", threshold=threshold, - sizethresh=sizethresh) - except: - pass - - def __del__(self): - SSHSession.__del__(self) - - class SSHCommand(SSHSession): """An SSH session guarded for target lockups.""" @@ -485,88 +246,3 @@ def read(self, retval="code", fh=None): def __del__(self): SSHSession.__del__(self) - - -def SSH(ip, - command, - username="root", - timeout=300, - retval="code", - password=None, - idempotent=False, - nowarn=False, - newlineok=False, - getreply=True, - nolog=False, - outfile=None): - tries = 0 - while True: - tries = tries + 1 - log.debug("SSH %s@%s %s (attempt %u)" % - (username, ip, command, tries)) - try: - s = SSHCommand(ip, - command, - username=username, - timeout=timeout, - password=password, - nowarn=nowarn, - newlineok=newlineok, - nolog=nolog) - if outfile: - try: - f = file(outfile, 'w') - reply = s.read(retval="code", fh=f) - finally: - f.close() - return reply - elif getreply: - reply = s.read(retval=retval) - return reply - else: - return None - except Exception, e: - if tries >= 3 or not idempotent: - raise e - if string.find(str(e), "SSH command exited with error") > -1: - raise e - if not nowarn: - log.debug("Retrying ssh connection %s@%s %s after %s" - % (username, ip, command, str(e))) - time.sleep(5) - - -def SSHread(ip, - command, - log, - username="root", - timeout=300, - password=None, - idempotent=False, - nowarn=False, - newlineok=False): - tries = 0 - while True: - tries = tries + 1 - log.debug("SSH %s@%s %s (attempt %u)" % - (username, ip, command, tries)) - try: - s = SSHCommand(ip, - command, - log, - username=username, - timeout=timeout, - password=password, - nowarn=nowarn, - newlineok=newlineok) - reply = s.read(retval="string") - return reply - except Exception, e: - if tries >= 3 or not idempotent: - raise e - if string.find(str(e), "SSH command exited with error") > -1: - raise e - if not nowarn: - log.debug("Retrying ssh connection %s@%s %s after %s" - % (username, ip, command, str(e))) - time.sleep(5) diff --git a/autocertkit/storage_tests.py b/autocertkit/storage_tests.py index 327a39f9..ccbca38c 100644 --- a/autocertkit/storage_tests.py +++ b/autocertkit/storage_tests.py @@ -33,8 +33,6 @@ import testbase from utils import * -log = get_logger('auto-cert-kit') - class PerfTestClass(testbase.LocalStorageTestClass): """A somewhat generic test class for local storage diff --git a/autocertkit/test_generators.py b/autocertkit/test_generators.py index a610b3e9..04f973e1 100644 --- a/autocertkit/test_generators.py +++ b/autocertkit/test_generators.py @@ -294,7 +294,7 @@ def get_device_config(self): """Retrieve XenServer version info from the pool master""" rec = super(OperationsTestGenerator, self).get_device_config() rec = utils.combine_recs(rec, utils.get_xs_info(self.session)) - rec = utils.combine_recs(rec, utils.get_system_info()) + rec = utils.combine_recs(rec, utils.get_system_info(self.session)) return rec ############################################################################## diff --git a/autocertkit/test_report.py b/autocertkit/test_report.py index e481f383..920e3c31 100644 --- a/autocertkit/test_report.py +++ b/autocertkit/test_report.py @@ -57,7 +57,8 @@ def wrap_text(string, width): def print_system_info(stream): """ Retrieve system information from SMBIOS and write to given stream. """ - sys_info = search_dmidecode("System Information") + session = get_local_xapi_session() + sys_info = search_dmidecode(session, "System Information") stream.write("#########################\n") stream.write("System Information from SMBIOS\n") stream.write('\n'.join(sys_info)) diff --git a/autocertkit/test_runner.py b/autocertkit/test_runner.py index 658e1041..7cdfcb54 100644 --- a/autocertkit/test_runner.py +++ b/autocertkit/test_runner.py @@ -278,9 +278,6 @@ def get_test_class(fqtn): if __name__ == "__main__": # Main function entry point - global log - - log = configure_logging('auto-cert-kit') parser = OptionParser(usage="%prog [-c] [-t]", version="%prog 0.1") diff --git a/autocertkit/testbase.py b/autocertkit/testbase.py index fc4fd285..ec12a113 100644 --- a/autocertkit/testbase.py +++ b/autocertkit/testbase.py @@ -34,7 +34,6 @@ import re import signal from utils import * -log = get_logger('auto-cert-kit') class TestClass(object): diff --git a/autocertkit/tests/config.py b/autocertkit/tests/config.py new file mode 100644 index 00000000..972c4cf0 --- /dev/null +++ b/autocertkit/tests/config.py @@ -0,0 +1,17 @@ +""" +Mock Values of XenServer Host for unittest +""" + +CONFIG = {} +CONFIG["host"] = {} +CONFIG["expected"] = {} +CONFIG["host"]["ack_version"] = ["1.2.3"] +CONFIG["host"]["xs_software_version"] = [{'platform_name': 'XCP', 'product_version': '7.0.93', 'build_number': '133861c', 'xapi': '1.9', 'xen': '4.7.1-1-d', 'hostname': '0222bde6733f', 'network_backend': 'bridge', 'platform_version': '2.1.4', + 'product_version_text_short': '7.0', 'product_brand': 'XenServer', 'xencenter_max': '2.6', 'linux': '4.4.0+2', 'date': '2016-12-22', 'product_version_text': '7.0', 'xencenter_min': '2.6', 'dbv': '2016.0520'} + ] + +with open("autocertkit/tests/rawdata/dmidecode.out") as f: + CONFIG["host"]["dmidecode"] = [f.read()] + +with open("autocertkit/tests/rawdata/get_system_info.expected") as f: + CONFIG["expected"]["get_system_info"] = [eval(f.read())] diff --git a/autocertkit/tests/frontend-test.py b/autocertkit/tests/frontend-test.py index b4a025f3..506098ac 100644 --- a/autocertkit/tests/frontend-test.py +++ b/autocertkit/tests/frontend-test.py @@ -11,8 +11,6 @@ from autocertkit import utils, ack_cli -utils.configure_logging('ack_tests') - class NetworkConfRobustTests(unittest.TestCase): """ Checking functionality and robust of netconf parser. """ diff --git a/autocertkit/tests/rawdata/dmidecode.out b/autocertkit/tests/rawdata/dmidecode.out new file mode 100644 index 00000000..65c01559 --- /dev/null +++ b/autocertkit/tests/rawdata/dmidecode.out @@ -0,0 +1,1018 @@ +# dmidecode 2.12-dmifs +SMBIOS 2.7 present. +91 structures occupying 6665 bytes. +Table at 0xCF42C000. + +Handle 0xDA00, DMI type 218, 11 bytes +OEM-specific Type + Header and Data: + DA 0B 00 DA B2 00 17 20 0E 10 01 + +Handle 0x0000, DMI type 0, 24 bytes +BIOS Information + Vendor: Dell Inc. + Version: 2.1.3 + Release Date: 01/20/2014 + Address: 0xF0000 + Runtime Size: 64 kB + ROM Size: 8192 kB + Characteristics: + ISA is supported + PCI is supported + PNP is supported + BIOS is upgradeable + BIOS shadowing is allowed + Boot from CD is supported + Selectable boot is supported + EDD is supported + Japanese floppy for Toshiba 1.2 MB is supported (int 13h) + 5.25"/360 kB floppy services are supported (int 13h) + 5.25"/1.2 MB floppy services are supported (int 13h) + 3.5"/720 kB floppy services are supported (int 13h) + 8042 keyboard services are supported (int 9h) + Serial services are supported (int 14h) + CGA/mono video services are supported (int 10h) + ACPI is supported + USB legacy is supported + BIOS boot specification is supported + Function key-initiated network boot is supported + Targeted content distribution is supported + UEFI is supported + BIOS Revision: 2.1 + +Handle 0x0100, DMI type 1, 27 bytes +System Information + Manufacturer: Dell Inc. + Product Name: PowerEdge M520 + Version: Not Specified + Serial Number: B7ZB5Z1 + UUID: 4C4C4544-0037-5A10-8042-C2C04F355A31 + Wake-up Type: Power Switch + SKU Number: SKU=NotProvided;ModelName=PowerEdge M520 + Family: Not Specified + +Handle 0x0200, DMI type 2, 14 bytes +Base Board Information + Manufacturer: Dell Inc. + Product Name: 0DW6GX + Version: A01 + Serial Number: .B7ZB5Z1.CN70163381000M.03. + Asset Tag: + Features: + Board is a hosting board + Board is removable + Board is replaceable + Board is hot swappable + Location In Chassis: Slot 03 + Chassis Handle: 0x0300 + Type: Server Blade + +Handle 0x0201, DMI type 2, 14 bytes +Base Board Information + Manufacturer: Dell Inc. + Product Name: + Version: + Serial Number: .DSNB5Z1..03. + Asset Tag: + Features: + Board is removable + Board is replaceable + Board is hot swappable + Location In Chassis: Slot 03 + Chassis Handle: 0x0300 + Type: Interconnect Board + +Handle 0x0300, DMI type 3, 25 bytes +Chassis Information + Manufacturer: Dell Inc. + Type: Multi-system + Lock: Not Present + Version: PowerEdge M1000e + Serial Number: DSNB5Z1 + Asset Tag: + Boot-up State: Safe + Power Supply State: Safe + Thermal State: Safe + Security Status: Unknown + OEM Information: 0x00000000 + Height: 10 U + Number Of Power Cords: Unspecified + Contained Elements: 1 + Server Blade (1-16) + SKU Number: Not Specified + +Handle 0x0400, DMI type 4, 40 bytes +Processor Information + Socket Designation: CPU1 + Type: Central Processor + Family: Xeon + Manufacturer: Intel + ID: D7 06 02 00 FF FB EB BF + Signature: Type 0, Family 6, Model 45, Stepping 7 + Flags: + FPU (Floating-point unit on-chip) + VME (Virtual mode extension) + DE (Debugging extension) + PSE (Page size extension) + TSC (Time stamp counter) + MSR (Model specific registers) + PAE (Physical address extension) + MCE (Machine check exception) + CX8 (CMPXCHG8 instruction supported) + APIC (On-chip APIC hardware supported) + SEP (Fast system call) + MTRR (Memory type range registers) + PGE (Page global enable) + MCA (Machine check architecture) + CMOV (Conditional move instruction supported) + PAT (Page attribute table) + PSE-36 (36-bit page size extension) + CLFSH (CLFLUSH instruction supported) + DS (Debug store) + ACPI (ACPI supported) + MMX (MMX technology supported) + FXSR (FXSAVE and FXSTOR instructions supported) + SSE (Streaming SIMD extensions) + SSE2 (Streaming SIMD extensions 2) + SS (Self-snoop) + HTT (Multi-threading) + TM (Thermal monitor supported) + PBE (Pending break enabled) + Version: Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz + Voltage: 1.2 V + External Clock: 7200 MHz + Max Speed: 3600 MHz + Current Speed: 1900 MHz + Status: Populated, Enabled + Upgrade: Socket LGA1356 + L1 Cache Handle: 0x0700 + L2 Cache Handle: 0x0701 + L3 Cache Handle: 0x0702 + Serial Number: Not Specified + Asset Tag: Not Specified + Part Number: Not Specified + Core Count: 6 + Core Enabled: 6 + Thread Count: 12 + Characteristics: + 64-bit capable + Multi-Core + Hardware Thread + Execute Protection + Enhanced Virtualization + Power/Performance Control + +Handle 0x0401, DMI type 4, 40 bytes +Processor Information + Socket Designation: CPU2 + Type: Central Processor + Family: Xeon + Manufacturer: Intel + ID: D7 06 02 00 FF FB EB BF + Signature: Type 0, Family 6, Model 45, Stepping 7 + Flags: + FPU (Floating-point unit on-chip) + VME (Virtual mode extension) + DE (Debugging extension) + PSE (Page size extension) + TSC (Time stamp counter) + MSR (Model specific registers) + PAE (Physical address extension) + MCE (Machine check exception) + CX8 (CMPXCHG8 instruction supported) + APIC (On-chip APIC hardware supported) + SEP (Fast system call) + MTRR (Memory type range registers) + PGE (Page global enable) + MCA (Machine check architecture) + CMOV (Conditional move instruction supported) + PAT (Page attribute table) + PSE-36 (36-bit page size extension) + CLFSH (CLFLUSH instruction supported) + DS (Debug store) + ACPI (ACPI supported) + MMX (MMX technology supported) + FXSR (FXSAVE and FXSTOR instructions supported) + SSE (Streaming SIMD extensions) + SSE2 (Streaming SIMD extensions 2) + SS (Self-snoop) + HTT (Multi-threading) + TM (Thermal monitor supported) + PBE (Pending break enabled) + Version: Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz + Voltage: 1.2 V + External Clock: 7200 MHz + Max Speed: 3600 MHz + Current Speed: 1900 MHz + Status: Populated, Idle + Upgrade: Socket LGA1356 + L1 Cache Handle: 0x0703 + L2 Cache Handle: 0x0704 + L3 Cache Handle: 0x0705 + Serial Number: Not Specified + Asset Tag: Not Specified + Part Number: Not Specified + Core Count: 6 + Core Enabled: 6 + Thread Count: 12 + Characteristics: + 64-bit capable + Multi-Core + Hardware Thread + Execute Protection + Enhanced Virtualization + Power/Performance Control + +Handle 0x0700, DMI type 7, 19 bytes +Cache Information + Socket Designation: Not Specified + Configuration: Enabled, Not Socketed, Level 1 + Operational Mode: Write Through + Location: Internal + Installed Size: 192 kB + Maximum Size: 192 kB + Supported SRAM Types: + Unknown + Installed SRAM Type: Unknown + Speed: Unknown + Error Correction Type: Single-bit ECC + System Type: Data + Associativity: 8-way Set-associative + +Handle 0x0701, DMI type 7, 19 bytes +Cache Information + Socket Designation: Not Specified + Configuration: Enabled, Not Socketed, Level 2 + Operational Mode: Write Through + Location: Internal + Installed Size: 1536 kB + Maximum Size: 1536 kB + Supported SRAM Types: + Unknown + Installed SRAM Type: Unknown + Speed: Unknown + Error Correction Type: Single-bit ECC + System Type: Unified + Associativity: 8-way Set-associative + +Handle 0x0702, DMI type 7, 19 bytes +Cache Information + Socket Designation: Not Specified + Configuration: Enabled, Not Socketed, Level 3 + Operational Mode: Write Back + Location: Internal + Installed Size: 15360 kB + Maximum Size: 15360 kB + Supported SRAM Types: + Unknown + Installed SRAM Type: Unknown + Speed: Unknown + Error Correction Type: Single-bit ECC + System Type: Unified + Associativity: 20-way Set-associative + +Handle 0x0703, DMI type 7, 19 bytes +Cache Information + Socket Designation: Not Specified + Configuration: Enabled, Not Socketed, Level 1 + Operational Mode: Write Through + Location: Internal + Installed Size: 192 kB + Maximum Size: 192 kB + Supported SRAM Types: + Unknown + Installed SRAM Type: Unknown + Speed: Unknown + Error Correction Type: Single-bit ECC + System Type: Data + Associativity: 8-way Set-associative + +Handle 0x0704, DMI type 7, 19 bytes +Cache Information + Socket Designation: Not Specified + Configuration: Enabled, Not Socketed, Level 2 + Operational Mode: Write Through + Location: Internal + Installed Size: 1536 kB + Maximum Size: 1536 kB + Supported SRAM Types: + Unknown + Installed SRAM Type: Unknown + Speed: Unknown + Error Correction Type: Single-bit ECC + System Type: Unified + Associativity: 8-way Set-associative + +Handle 0x0705, DMI type 7, 19 bytes +Cache Information + Socket Designation: Not Specified + Configuration: Enabled, Not Socketed, Level 3 + Operational Mode: Write Back + Location: Internal + Installed Size: 15360 kB + Maximum Size: 15360 kB + Supported SRAM Types: + Unknown + Installed SRAM Type: Unknown + Speed: Unknown + Error Correction Type: Single-bit ECC + System Type: Unified + Associativity: 20-way Set-associative + +Handle 0x0800, DMI type 8, 9 bytes +Port Connector Information + Internal Reference Designator: Not Specified + Internal Connector Type: None + External Reference Designator: Not Specified + External Connector Type: Access Bus (USB) + Port Type: USB + +Handle 0x0801, DMI type 8, 9 bytes +Port Connector Information + Internal Reference Designator: Not Specified + Internal Connector Type: None + External Reference Designator: Not Specified + External Connector Type: Access Bus (USB) + Port Type: USB + +Handle 0x0802, DMI type 126, 9 bytes +Inactive + +Handle 0x0803, DMI type 126, 9 bytes +Inactive + +Handle 0x0804, DMI type 126, 9 bytes +Inactive + +Handle 0x0805, DMI type 8, 9 bytes +Port Connector Information + Internal Reference Designator: Not Specified + Internal Connector Type: None + External Reference Designator: Not Specified + External Connector Type: RJ-45 + Port Type: Network Port + +Handle 0x0806, DMI type 8, 9 bytes +Port Connector Information + Internal Reference Designator: Not Specified + Internal Connector Type: None + External Reference Designator: Not Specified + External Connector Type: RJ-45 + Port Type: Network Port + +Handle 0x0807, DMI type 8, 9 bytes +Port Connector Information + Internal Reference Designator: Not Specified + Internal Connector Type: None + External Reference Designator: Not Specified + External Connector Type: RJ-45 + Port Type: Network Port + +Handle 0x0808, DMI type 8, 9 bytes +Port Connector Information + Internal Reference Designator: Not Specified + Internal Connector Type: None + External Reference Designator: Not Specified + External Connector Type: RJ-45 + Port Type: Network Port + +Handle 0x0900, DMI type 9, 17 bytes +System Slot Information + Designation: MEZZ1_FAB_C + Type: x8 PCI Express 3 x8 + Current Usage: Available + Length: Other + Characteristics: + 3.3 V is provided + PME signal is supported + +Handle 0x0901, DMI type 126, 17 bytes +Inactive + +Handle 0x0902, DMI type 9, 17 bytes +System Slot Information + Designation: MEZZ2_FAB_B + Type: x8 PCI Express 3 x8 + Current Usage: Available + Length: Other + Characteristics: + 3.3 V is provided + PME signal is supported + +Handle 0x0903, DMI type 126, 17 bytes +Inactive + +Handle 0x0904, DMI type 126, 17 bytes +Inactive + +Handle 0x0905, DMI type 126, 17 bytes +Inactive + +Handle 0x0906, DMI type 126, 17 bytes +Inactive + +Handle 0x0907, DMI type 126, 17 bytes +Inactive + +Handle 0x0908, DMI type 126, 17 bytes +Inactive + +Handle 0x0909, DMI type 126, 17 bytes +Inactive + +Handle 0x090A, DMI type 126, 17 bytes +Inactive + +Handle 0x090B, DMI type 126, 17 bytes +Inactive + +Handle 0x090C, DMI type 126, 17 bytes +Inactive + +Handle 0x090D, DMI type 126, 17 bytes +Inactive + +Handle 0x0B00, DMI type 11, 5 bytes +OEM Strings + String 1: Dell System + String 2: 5[0000] + String 3: 17[FFFFFFFFFFFFFFFF] + String 4: 17[FFFFFFFFFFFFFFFF] + String 5: 17[FFFFFFFFFFFFFFFF] + String 6: 17[FFFFFFFFFFFFFFFF] + +Handle 0x7E00, DMI type 126, 170 bytes +Inactive + +Handle 0x0C00, DMI type 12, 5 bytes +System Configuration Options + Option 1: NVRAM_CLR: Clear user settable NVRAM areas and set defaults + Option 2: PWRD_EN: Close to enable password + +Handle 0x0D00, DMI type 13, 22 bytes +BIOS Language Information + Language Description Format: Long + Installable Languages: 1 + en|US|iso8859-1 + Currently Installed Language: en|US|iso8859-1 + +Handle 0x1000, DMI type 16, 23 bytes +Physical Memory Array + Location: System Board Or Motherboard + Use: System Memory + Error Correction Type: Multi-bit ECC + Maximum Capacity: 384 GB + Error Information Handle: Not Provided + Number Of Devices: 12 + +Handle 0x1100, DMI type 126, 34 bytes +Inactive + +Handle 0x1101, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 1 + Locator: DIMM_A1 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E603872 + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x1102, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 1 + Locator: DIMM_A2 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E203843 + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x1103, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 1 + Locator: DIMM_A3 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E203841 + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x1104, DMI type 126, 34 bytes +Inactive + +Handle 0x1105, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 2 + Locator: DIMM_A4 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E303849 + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x1106, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: No Module Installed + Form Factor: DIMM + Set: 2 + Locator: DIMM_A5 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous + Speed: Unknown + Manufacturer: + Serial Number: + Asset Tag: + Part Number: + Rank: Unknown + Configured Clock Speed: Unknown + +Handle 0x1107, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: No Module Installed + Form Factor: DIMM + Set: 2 + Locator: DIMM_A6 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous + Speed: Unknown + Manufacturer: + Serial Number: + Asset Tag: + Part Number: + Rank: Unknown + Configured Clock Speed: Unknown + +Handle 0x1108, DMI type 126, 34 bytes +Inactive + +Handle 0x1109, DMI type 126, 34 bytes +Inactive + +Handle 0x110A, DMI type 126, 34 bytes +Inactive + +Handle 0x110B, DMI type 126, 34 bytes +Inactive + +Handle 0x110C, DMI type 126, 34 bytes +Inactive + +Handle 0x110D, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 4 + Locator: DIMM_B1 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E503870 + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x110E, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 4 + Locator: DIMM_B2 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E303845 + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x110F, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 4 + Locator: DIMM_B3 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E40383F + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x1110, DMI type 126, 34 bytes +Inactive + +Handle 0x1111, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 8192 MB + Form Factor: DIMM + Set: 5 + Locator: DIMM_B4 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous Registered (Buffered) + Speed: 1333 MHz + Manufacturer: 00AD00B300AD + Serial Number: 1E103847 + Asset Tag: 01132963 + Part Number: HMT31GR7CFR4A-H9 + Rank: 2 + Configured Clock Speed: 1333 MHz + +Handle 0x1112, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: No Module Installed + Form Factor: DIMM + Set: 5 + Locator: DIMM_B5 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous + Speed: Unknown + Manufacturer: + Serial Number: + Asset Tag: + Part Number: + Rank: Unknown + Configured Clock Speed: Unknown + +Handle 0x1113, DMI type 17, 34 bytes +Memory Device + Array Handle: 0x1000 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: No Module Installed + Form Factor: DIMM + Set: 5 + Locator: DIMM_B6 + Bank Locator: Not Specified + Type: DDR3 + Type Detail: Synchronous + Speed: Unknown + Manufacturer: + Serial Number: + Asset Tag: + Part Number: + Rank: Unknown + Configured Clock Speed: Unknown + +Handle 0x1114, DMI type 126, 34 bytes +Inactive + +Handle 0x1115, DMI type 126, 34 bytes +Inactive + +Handle 0x1116, DMI type 126, 34 bytes +Inactive + +Handle 0x1117, DMI type 126, 34 bytes +Inactive + +Handle 0x1300, DMI type 19, 31 bytes +Memory Array Mapped Address + Starting Address: 0x00000000000 + Ending Address: 0x000CFFFFFFF + Range Size: 3328 MB + Physical Array Handle: 0x1000 + Partition Width: 2 + +Handle 0x1301, DMI type 19, 31 bytes +Memory Array Mapped Address + Starting Address: 0x00100000000 + Ending Address: 0x0102FFFFFFF + Range Size: 62208 MB + Physical Array Handle: 0x1000 + Partition Width: 2 + +Handle 0x2000, DMI type 32, 11 bytes +System Boot Information + Status: No errors detected + +Handle 0x2600, DMI type 38, 18 bytes +IPMI Device Information + Interface Type: KCS (Keyboard Control Style) + Specification Version: 2.0 + I2C Slave Address: 0x10 + NV Storage Device: Not Present + Base Address: 0x0000000000000CA8 (I/O) + Register Spacing: 32-bit Boundaries + Interrupt Polarity: Active High + Interrupt Trigger Mode: Edge + Interrupt Number: a + +Handle 0x2900, DMI type 41, 11 bytes +Onboard Device + Reference Designation: Embedded NIC 1 + Type: Ethernet + Status: Enabled + Type Instance: 1 + Bus Address: 0000:05:00.0 + +Handle 0x2901, DMI type 41, 11 bytes +Onboard Device + Reference Designation: Embedded NIC 2 + Type: Ethernet + Status: Enabled + Type Instance: 2 + Bus Address: 0000:05:00.1 + +Handle 0x2902, DMI type 41, 11 bytes +Onboard Device + Reference Designation: Embedded NIC 3 + Type: Ethernet + Status: Enabled + Type Instance: 3 + Bus Address: 0000:06:00.0 + +Handle 0x2903, DMI type 41, 11 bytes +Onboard Device + Reference Designation: Embedded NIC 4 + Type: Ethernet + Status: Enabled + Type Instance: 4 + Bus Address: 0000:06:00.1 + +Handle 0x2904, DMI type 126, 11 bytes +Inactive + +Handle 0x2905, DMI type 41, 11 bytes +Onboard Device + Reference Designation: Integrated RAID + Type: SAS Controller + Status: Enabled + Type Instance: 4 + Bus Address: 0000:01:00.0 + +Handle 0x2906, DMI type 41, 11 bytes +Onboard Device + Reference Designation: Embedded Video + Type: Video + Status: Enabled + Type Instance: 4 + Bus Address: 0000:0a:00.0 + +Handle 0x2907, DMI type 41, 11 bytes +Onboard Device + Reference Designation: + Type: SATA Controller + Status: Enabled + Type Instance: 1 + Bus Address: 0000:00:1f.2 + +Handle 0xB100, DMI type 177, 12 bytes +OEM-specific Type + Header and Data: + B1 0C 00 B1 00 02 00 00 00 00 00 00 + +Handle 0xD000, DMI type 208, 16 bytes +OEM-specific Type + Header and Data: + D0 10 00 D0 02 00 FE 00 DC 04 00 00 00 01 00 00 + +Handle 0xC200, DMI type 194, 137 bytes +OEM-specific Type + Header and Data: + C2 89 00 C2 70 00 71 00 00 10 2D 2E 42 00 11 FE + 01 43 00 11 FE 00 00 00 11 9F 20 00 00 11 9F 00 + 6E 01 11 9F 20 6D 01 11 9F 00 31 40 11 FB 00 32 + 40 11 FB 04 9D 00 11 FD 02 9E 00 11 FD 00 9F 00 + 26 FE 01 A0 00 26 FE 00 28 40 26 DF 20 29 40 26 + DF 00 38 02 27 BF 40 39 02 27 BF 00 00 00 27 FC + 01 00 00 27 FC 02 00 00 27 FC 03 00 00 27 F3 04 + 00 00 27 F3 08 00 00 27 F3 0C 08 7C 27 7F 00 09 + 7C 27 7F 80 FF FF 00 00 00 + +Handle 0xC201, DMI type 194, 252 bytes +OEM-specific Type + Header and Data: + C2 FC 01 C2 70 00 71 00 03 40 5A 6D 6C 01 57 FC + 00 6A 01 57 FC 01 12 02 57 EF 00 11 02 57 EF 10 + 00 00 5B FB 04 00 00 5B FB 00 77 01 54 FC 00 78 + 01 54 FC 01 53 02 54 FC 02 33 40 54 CF 00 34 40 + 54 CF 10 35 40 54 CF 20 36 40 54 CF 30 1A 40 54 + FB 04 1B 40 54 FB 00 1C 40 54 F7 08 1D 40 54 F7 + 00 43 40 58 DF 20 42 40 58 DF 00 22 40 58 EF 10 + 23 40 58 EF 00 24 40 58 BF 40 25 40 58 BF 00 00 + 00 58 FC 01 00 00 58 FC 02 00 00 58 FC 03 00 00 + 58 F3 04 00 00 58 F3 08 00 00 58 F3 0C 2D 02 55 + FE 01 2E 02 55 FE 00 D8 00 55 7F 80 D9 00 55 7F + 00 58 02 56 DF 00 61 02 56 DF 20 4D 02 56 BF 00 + 4E 02 56 BF 40 2D 01 56 7F 80 2E 01 56 7F 00 28 + 03 5B 7F 00 29 03 5B 7F 80 00 C0 5C 00 0A 03 C0 + 67 00 05 83 00 76 00 00 84 00 77 00 00 2A 03 5B + 9F 00 2B 03 5B 9F 20 FF FF 00 00 00 + +Handle 0xC202, DMI type 194, 82 bytes +OEM-specific Type + Header and Data: + C2 52 02 C2 70 00 71 00 03 40 5A 6D 2C 03 5B 9F + 40 05 03 5A FC 00 06 03 5A FC 01 31 03 5A FC 02 + 07 03 5A F3 00 08 03 5A F3 04 32 03 5A F3 08 00 + 00 5A CF 00 00 00 5A CF 10 00 00 5A CF 20 00 00 + 5A 3F 00 00 00 5A 3F 40 00 00 5A 3F 80 FF FF 00 + 00 00 + +Handle 0xC203, DMI type 194, 252 bytes +OEM-specific Type + Header and Data: + C2 FC 03 C2 72 00 73 00 00 40 5D 5E D3 00 00 00 + 02 D4 00 02 00 02 13 7C 28 F7 00 12 7C 28 F7 08 + 00 90 2C 00 00 01 90 2D 00 00 4A 01 46 BF 40 4B + 01 46 BF 00 00 00 49 D7 28 00 00 49 DF 20 00 00 + 49 F7 08 DB 00 49 D7 00 00 00 49 7F 00 00 00 49 + 7F 80 00 00 49 F8 00 00 00 49 F8 01 00 00 49 F8 + 02 00 00 49 F8 03 00 00 49 F8 04 00 00 49 F8 05 + DE 00 63 FE 01 DF 00 63 FE 00 26 40 42 FE 01 27 + 40 42 FE 00 FF 02 42 F7 08 00 03 42 F7 00 01 03 + 42 EF 10 02 03 42 EF 00 0B 7C 42 DF 00 0A 7C 42 + DF 20 0C 7C 42 BF 40 0D 7C 42 BF 00 17 01 4A FE + 00 18 01 4A FE 01 19 01 4A FD 00 1A 01 4A FD 02 + 00 00 4A FB 00 00 00 4A FB 04 00 00 4A F7 00 00 + 00 4A F7 08 35 01 4B FC 00 37 01 4B FC 01 38 01 + 4B FC 02 39 01 4B FC 03 F7 02 4B 7F 80 F8 02 4B + 7F 00 02 40 46 DF 00 FF FF 00 00 00 + +Handle 0xC204, DMI type 194, 252 bytes +OEM-specific Type + Header and Data: + C2 FC 04 C2 72 00 73 00 00 40 5D 5E 01 40 46 DF + 20 CF 01 40 FD 02 D0 01 40 FD 00 FC 01 45 BF 00 + FD 01 45 BF 40 00 00 45 7F 80 00 00 45 7F 00 A1 + 02 45 FB 00 A2 02 45 FB 04 D1 00 46 FE 00 D2 00 + 46 FE 01 71 01 46 FB 04 72 01 46 FB 00 73 01 46 + F7 08 74 01 46 F7 00 40 01 47 EF 10 41 01 47 EF + 00 EB 01 47 FD 00 EA 01 47 FD 02 33 02 40 07 08 + 32 02 40 07 10 31 02 40 07 20 00 00 40 07 30 00 + 00 40 07 40 00 00 40 07 50 00 00 40 07 60 6E 02 + 40 07 00 4B 02 47 DF 00 4C 02 47 DF 20 10 7C 47 + 7F 80 11 7C 47 7F 00 C5 02 48 BF 00 C6 02 48 BF + 40 CB 02 48 DF 00 CC 02 48 DF 20 C4 01 50 FE 00 + C5 01 50 FE 01 99 02 5C F7 00 98 02 5C F7 08 AE + 02 5C FB 00 AD 02 5C FB 04 B6 02 5C 3F 40 B7 02 + 5C 3F 80 B8 02 5C 3F 00 E9 02 41 E7 00 EA 02 41 + E7 08 EB 02 41 E7 10 FF FF 00 00 00 + +Handle 0xC205, DMI type 194, 252 bytes +OEM-specific Type + Header and Data: + C2 FC 05 C2 72 00 73 00 00 40 5D 5E ED 02 41 BF + 00 EE 02 41 BF 40 D8 02 4F F8 00 D9 02 4F F8 01 + DA 02 4F F8 02 DC 02 4F F8 04 DD 02 4F F8 03 DE + 02 4F E7 00 DF 02 4F E7 08 E0 02 4F E7 18 E1 02 + 4F 1F 00 00 00 4F 1F C0 E2 02 4F 1F A0 E3 02 4F + 1F 20 E4 02 4F 1F 40 E5 02 4F 1F 60 E6 02 4F 1F + 80 F2 02 47 F3 00 00 00 47 F3 04 F4 02 47 F3 08 + F5 02 47 F3 0C 06 7C 47 BF 40 07 7C 47 BF 00 19 + 03 4E CF 00 1A 03 4E CF 10 1B 03 4E CF 20 1E 03 + 4E F3 00 1C 03 4E F3 08 1D 03 4E F3 04 1F 03 4E + BF 00 20 03 4E BF 40 2D 03 60 BF 00 2E 03 60 BF + 40 00 00 19 F3 00 00 00 19 F3 04 00 00 19 F3 08 + 00 00 19 CF 00 00 00 19 CF 10 00 00 19 CF 20 00 + 00 19 3F 00 00 00 19 3F 40 00 00 19 3F 80 3A 03 + 4B F3 00 3B 03 4B F3 04 3C 03 4B F3 08 3D 03 4B + F3 0C 14 7C 53 FE 01 FF FF 00 00 00 + +Handle 0xC206, DMI type 194, 62 bytes +OEM-specific Type + Header and Data: + C2 3E 06 C2 72 00 73 00 00 40 5D 5E 15 7C 53 FE + 00 00 7C 7F FE 01 01 7C 7F FE 00 02 7C 7F F9 00 + 03 7C 7F F9 02 04 7C 7F F9 04 05 7C 7F F9 06 3E + 03 48 EF 00 3F 03 48 EF 10 FF FF 00 00 00 + +Handle 0xD800, DMI type 216, 9 bytes +OEM-specific Type + Header and Data: + D8 09 00 D8 01 02 01 F0 03 + Strings: + MATROX + VGA/VBE BIOS, Version V3.8WO + +Handle 0xDE00, DMI type 222, 16 bytes +OEM-specific Type + Header and Data: + DE 10 00 DE 00 20 FF FF 00 00 00 00 00 00 00 00 + +Handle 0xE100, DMI type 225, 61 bytes +OEM-specific Type + Header and Data: + E1 3D 00 E1 01 01 00 04 00 02 01 04 00 03 01 11 + 00 04 02 11 00 05 03 11 00 06 05 11 00 07 06 11 + 00 08 07 11 00 0F 0D 11 00 10 0E 11 00 11 0F 11 + 00 12 11 11 00 13 12 11 00 14 13 11 00 + Strings: + CPU.Socket.1 + CPU.Socket.2 + DIMM.Socket.A1 + DIMM.Socket.A2 + DIMM.Socket.A3 + DIMM.Socket.A4 + DIMM.Socket.A5 + DIMM.Socket.A6 + DIMM.Socket.A7 + DIMM.Socket.A8 + DIMM.Socket.A9 + DIMM.Socket.A10 + DIMM.Socket.A11 + DIMM.Socket.A12 + DIMM.Socket.B1 + DIMM.Socket.B2 + DIMM.Socket.B3 + DIMM.Socket.B4 + DIMM.Socket.B5 + DIMM.Socket.B6 + DIMM.Socket.B7 + DIMM.Socket.B8 + DIMM.Socket.B9 + DIMM.Socket.B10 + DIMM.Socket.B11 + DIMM.Socket.B12 + +Handle 0x7F00, DMI type 127, 4 bytes +End Of Table + diff --git a/autocertkit/tests/rawdata/get_system_info.expected b/autocertkit/tests/rawdata/get_system_info.expected new file mode 100644 index 00000000..4525d836 --- /dev/null +++ b/autocertkit/tests/rawdata/get_system_info.expected @@ -0,0 +1 @@ +{'system_product_name': u'PowerEdge M520', 'system_serial_number': u'B7ZB5Z1', 'system_family': u'Not Specified', 'BIOS_vendor': u'Dell Inc.', 'chassis_type': u'Multi-system', 'system_uuid': u'4C4C4544-0037-5A10-8042-C2C04F355A31', 'system_manufacturer': u'Dell Inc.', 'chassis_manufacturer': u'Dell Inc.', 'BIOS_release_date': u'01/20/2014', 'BIOS_version': u'2.1.3', 'BIOS_revision': u'2.1', 'system_version': u'Not Specified'} diff --git a/autocertkit/tests/test_generators_tests.py b/autocertkit/tests/test_generators_tests.py index c4935b56..8ddd21cd 100644 --- a/autocertkit/tests/test_generators_tests.py +++ b/autocertkit/tests/test_generators_tests.py @@ -5,8 +5,6 @@ import sys from autocertkit import test_generators, testbase, utils -utils.configure_logging('ack_tests') - def expect_system_exit(func, code='0'): try: diff --git a/autocertkit/tests/testbase_tests.py b/autocertkit/tests/testbase_tests.py index cf1f5765..8a9d3b33 100644 --- a/autocertkit/tests/testbase_tests.py +++ b/autocertkit/tests/testbase_tests.py @@ -5,8 +5,6 @@ from autocertkit import utils, test_generators, testbase import sys -utils.configure_logging('ack_tests') - class TagsTests(unittest_base.DevTestCase): """Test that tags are enumerated correctly for a specified testclass""" diff --git a/autocertkit/tests/utils_tests.py b/autocertkit/tests/utils_tests.py index 2d7ac0aa..5fc355fe 100644 --- a/autocertkit/tests/utils_tests.py +++ b/autocertkit/tests/utils_tests.py @@ -6,12 +6,11 @@ import sys import shutil import xenapi_mock +from config import CONFIG from autocertkit import utils from datetime import datetime -utils.configure_logging('ack_tests') - K = 1024 M = K * 1024 G = M * 1024 @@ -235,32 +234,67 @@ def test_get_pool_slaves(self): [host.opaque for host in self.session.hosts[1:]]) +class NetworkLibMethodsTests(unittest.TestCase): + """ + Host related functions unit tests. + """ + + def setUp(self): + self.session = xenapi_mock.Session() + + def test_device_linkstate(self): + utils.set_nic_device_status(self.session, 'eth0', 'down') + utils.set_nic_device_status(self.session, 'eth1', 'up') + self.assertRaises(Exception, lambda: utils.set_nic_device_status( + self.session, 'invalidEth', 'up')) + + class SimpleMethodsTests(unittest.TestCase): """ Simple methods in utils module test """ + def setUp(self): + self.session = xenapi_mock.Session() + def test_kis_64_bit(self): self.assertTrue(utils.is_64_bit("x86_64")) self.assertFalse(utils.is_64_bit("i386")) self.assertFalse(utils.is_64_bit("i686")) + def test_logging_methods(self): + utils.init_ack_logging(self.session) + + def test_get_xenserver_version(self): + self.session.hosts[0].xs_software_version = { + 'product_version': '7.0.93'} + self.assertEqual(utils.get_xenserver_version(self.session), "7.0.93") -class CheckGetMethodsTests(unittest.TestCase): + def test_get_xcp_version(self): + self.session.hosts[0].xs_software_version = { + 'platform_version': '2.1.4'} + self.assertEqual(utils.get_xcp_version(self.session), "2.1.4") def test_get_ack_version(self): - s1 = xenapi_mock.Session() - self.assertEqual(utils.get_ack_version(s1), "1.2.3") + self.assertEqual(utils.get_ack_version(self.session), "1.2.3") self.assertEqual(utils.get_ack_version( - s1, s1.hosts[1].opaque), "1.2.3") + self.session, self.session.hosts[1].opaque), "1.2.3") - s1.hosts[1].setAckVersion(None) + self.session.hosts[1].setAckVersion(None) self.assertEqual(utils.get_ack_version( - s1, s1.hosts[0].opaque), "1.2.3") - self.assertEqual(utils.get_ack_version(s1, s1.hosts[1].opaque), None) + self.session, self.session.hosts[0].opaque), "1.2.3") + self.assertEqual(utils.get_ack_version( + self.session, self.session.hosts[1].opaque), None) + + self.session.fail_plugin = True + self.assertEqual(utils.get_ack_version(self.session), None) - s1.fail_plugin = True - self.assertEqual(utils.get_ack_version(s1), None) + def test_get_system_info(self): + self.session.hosts[0].dmidecode = "" + self.assertDictEqual(utils.get_system_info(self.session), {}) + self.session.hosts[0].dmidecode = CONFIG["host"]["dmidecode"][0] + self.assertDictEqual(utils.get_system_info(self.session), CONFIG[ + "expected"]["get_system_info"][0]) if __name__ == '__main__': unittest.main() diff --git a/autocertkit/tests/xenapi_mock.py b/autocertkit/tests/xenapi_mock.py index a850a607..19060da5 100644 --- a/autocertkit/tests/xenapi_mock.py +++ b/autocertkit/tests/xenapi_mock.py @@ -9,6 +9,7 @@ import random import json from XenAPI import XenAPI +from config import CONFIG class XenObjectMock(object): @@ -144,6 +145,10 @@ def host(self): def network(self): return self.__network + @property + def status(self): + return "up" if self.plugged and self.enabled else "down" + class Pool(XenObjectMock): """Pool data structure for XenAPI Pool mock""" @@ -169,7 +174,9 @@ def __init__(self, networks): pif.network.addPIF(pif) self.__enabled = True self.__vms = [VM(self, True)] # Control Domain - self.__ack_version = "1.2.3" + self.__ack_version = CONFIG["host"]["ack_version"][0] + self.xs_software_version = CONFIG["host"]["xs_software_version"][0] + self.dmidecode = CONFIG["host"]["dmidecode"][0] self.__supportedPlugins = {"autocertkit": AckPluginMethods(self)} @property @@ -221,7 +228,7 @@ def removePlugin(self, name): class HostMetrics(XenObjectMock): - """Host metric data structure for XenAPI Hose Metrics mock""" + """Host metric data structure for XenAPI Host Metrics mock""" def __init__(self): super(HostMetrics, self).__init__() @@ -418,6 +425,9 @@ def get_uuid(self, opaque): def get_PIFs(self, opaque): return [pif.opaque for pif in self.__getHost(opaque).PIFs] + def get_software_version(self, opaque): + return self.__getHost(opaque).xs_software_version + def get_management_interface(self, opaque): return self.__getHost(opaque).PIFs[0].opaque @@ -489,8 +499,25 @@ def __init__(self, host): def __getattr__(self, name): return self.__defaultOutput - def __defaultOutput(self, *args): + def __defaultOutput(self, args): return json.dumps("") - def get_ack_version(self, *args): + def get_ack_version(self, args): return json.dumps(self.__hostObj.ackVersion) + + def get_dmidecode_output(self, args): + return json.dumps(self.__hostObj.dmidecode) + + def set_nic_device_status(self, args): + print args + pif = [p for p in self.__hostObj.PIFs if p.device == args['device']] + pif[0].plugged = True if args['status'] == "up" else False + + def get_local_device_linkstate(self, args): + pif = [p for p in self.__hostObj.PIFs if p.device == args['device']][0] + out = {} + out['link'] = "unknown" if not pif else ( + "yes" if pif.plugged else "no") + out['operstate'] = "down" if not pif else pif.status + out['carrier'] = "running" if out['operstate'] == "up" else "" + return json.dumps(out) diff --git a/autocertkit/utils.py b/autocertkit/utils.py index 738b2254..73fe82af 100644 --- a/autocertkit/utils.py +++ b/autocertkit/utils.py @@ -57,11 +57,10 @@ DROID_VM = 'droid_vm' DEFAULT_PASSWORD = 'citrix' FOR_CLEANUP = "for_cleanup" -DROID_VM_LOC = '/opt/xensource/packages/files/auto-cert-kit/vpx-dlvm.xva' -XE = '/opt/xensource/bin/xe' DROID_TEMPLATE_TAG = "droid_vm_template" REBOOT_ERROR_CODE = 3 REBOOT_FLAG_FILE = "/opt/xensource/packages/files/auto-cert-kit/reboot" +LOG_NAME = "auto-cert-kit" LOG_LOC = "/var/log/auto-cert-kit.log" # Capability Tags @@ -71,6 +70,37 @@ XAPI_RUNNING_STATE = "Running" +# Logger +def configure_logging(): + """Method for configuring Logging""" + global log + log = acktools.log.configure_log(LOG_NAME, LOG_LOC) + +configure_logging() + + +def release_logging(): + """Release logging object.""" + if log: + acktools.log.release_log(log) + + +def log_basic_info(session): + log.info("Auto Cert Kit Version: %s" % get_ack_version(session)) + log.info("Host Software Version: %s" % get_xs_info(session)) + log.info("Kernel Version : %s" % get_kernel_version(session)) + + +def init_ack_logging(session, rotate=True): + release_logging() + if rotate: + for host_ref in session.xenapi.host.get_all(): + call_ack_plugin(session, 'run_ack_logrotate', {}, host=host_ref) + configure_logging() + log_basic_info(session) + + +# Exceptions class TestCaseError(Exception): """A subclassed exception object, which is raised by any test failure""" @@ -536,39 +566,6 @@ def validate_rec(self, rec): if key not in rec.keys(): raise Exception("Error: invalid input rec '%s'" % rec) - def to_rec(self): - rec = {} - for key in self.required_keys: - rec[key] = getattr(self, key) - return rec - -# Logging setup - -log = None - - -def configure_logging(name): - """Method for configuring Logging""" - global log - if not log: - log = acktools.log.configure_log(name, LOG_LOC) - return log - - -def release_logging(): - """Release logging object.""" - global log - acktools.log.release_log(log) - log = None - -if not log: - log = configure_logging('auto-cert-kit') - - -def get_logger(name): - """Method to return instance of logger""" - return logging.getLogger(name) - def get_local_xapi_session(): """Login to Xapi locally. This will only work if this script is being run @@ -578,13 +575,6 @@ def get_local_xapi_session(): return session -def get_remote_xapi_session(creds): - """Return a remote xapi session based on creds""" - session = XenAPI.Session("http://%s" % creds['host']) - session.login_with_password(creds['user'], creds['pass']) - return session - - def get_pool_master(session): """Returns the reference to host which is currently master over the pool which can be seen with the given session""" @@ -697,19 +687,6 @@ def host_crash(session, do_cleanup=False): raise Exception("Failed to crash host.") -def retrieve_latest_crashdump(session, host=None, fromxapi=False): - """Retrieve latest one from crashdump list""" - cds = retrieve_crashdumps(session, host, fromxapi) - if not cds: - return None - - latest = sorted(cds, key=lambda cd: cd['timestamp'], reverse=True)[0] - - log.debug("Latest crashdump: %s" % latest) - - return latest - - def retrieve_crashdumps(session, host=None, fromxapi=False): """Retrive all list of crashdump of master.""" if not host: @@ -737,25 +714,6 @@ def retrieve_crashdumps(session, host=None, fromxapi=False): return cds -def print_test_results(tracker): - """Method for pretty printing results""" - for mlist in tracker: - for testclass in mlist: - for test in testclass: - print "****Test Name:", test['test_name'], "****" - print "Test Result:", test['result'] - if test.has_key('info'): - print "Additional Info:", test['info'] - if test.has_key('data'): - print "Data:", test['data'] - if test.has_key('config'): - print "Config:", test['config'] - if test.has_key('exception'): - print "Exceptions:", test['exception'], "\n" - else: - print - - def get_pool_slaves(session): """Returns a list of references for each host in a pool which is not a pool master""" @@ -816,65 +774,6 @@ def eval_expr(expr, val): condition) -def append_result_node(dom, parent_node, result): - """parent_node is an xml node to be appended to, result - is a dictionary item""" - element = dom.createElement("test") - parent_node.appendChild(element) - for key in result.keys(): - k = dom.createElement(key) - element.appendChild(k) - k.appendChild(dom.createTextNode(result[key])) - - -def make_local_call(call): - """Function wrapper for making a simple call to shell""" - log.debug(' '.join(call)) - process = subprocess.Popen(call, stdout=subprocess.PIPE) - stdout, stderr = process.communicate() - if process.returncode == 0: - return str(stdout).strip() - else: - log.debug("ERR: %s, %s" % (stdout, stderr)) - sys.exit() - - -def save_bugtool(): - """Saves a bugtool and returns the name""" - print "Collecting a bugtool report:" - call = ["xen-bugtool", "--yestoall"] - info = make_local_call(call) - where = info.find('/var/opt/xen/bug-report') - return ((info[where:]).split())[0] - - -def compress_output_files(mylist): - """Compress all output files to bz2 and return the name""" - print "Compressing output files...""" - tar = tarfile.open("auto-cert-kit-logs.tar.bz2", "w:bz2") - for myfile in mylist: - tar.add(myfile) - tar.close() - - -def output_test_results(tracker): - """Outputs an xml results doc and creates a xen-bugtool, - then bzip2 them together""" - xml_file_name = ('cert_log_%s.xml' % datetime.datetime.now()) - myfile = open(xml_file_name, 'w') - doc = xml.dom.minidom.Document() - top_element = doc.createElement("results") - doc.appendChild(top_element) - for all_results in tracker: - for test_class in all_results: - for test_result in test_class: - append_result_node(doc, top_element, test_result) - myfile.write(doc.toprettyxml()) - myfile.close() - bugtool = save_bugtool() - compress_output_files([xml_file_name, bugtool]) - - def create_network(session, name_label, description, other_config): """Method for creating a XAPI network""" net_ref = session.xenapi.network.create({'name_label': name_label, @@ -921,17 +820,6 @@ def get_pifs_by_device(session, device, hosts=[]): (device, hosts)) -def get_network_by_device(session, device): - pifs = get_pifs_by_device(session, device) - network_refs = [] - for pif in pifs: - ref = session.xenapi.PIF.get_network(pif) - if ref not in network_refs: - network_refs.append(ref) - assert(len(network_refs) == 1) - return network_refs.pop() - - def get_physical_devices_by_network(session, network): """Taking a network, enumerate the list of physical devices attached to each component PIF. This may require some unwrapping (e.g. bonds) @@ -1029,18 +917,6 @@ def create_vlan(session, pif_ref, network_ref, vlan_id): return session.xenapi.VLAN.create(pif_ref, str(vlan_id), network_ref) -def get_droid_templates(session, brand=DROID_TEMPLATE_TAG): - """Return the reference to the template for the - demo linux VM. This is obtained by searching for - a template with the other_config key 'droid_template_vm'.""" - vms = session.xenapi.VM.get_all() - droid_vms = [] - for vm in vms: - if brand in session.xenapi.VM.get_other_config(vm): - droid_vms.append(vm) - return droid_vms - - def brand_vm(session, vm_ref, brand=DROID_VM): """Take a VM, or template and brand it with a key in other_config""" oc = session.xenapi.VM.get_other_config(vm_ref) @@ -1102,17 +978,6 @@ def make_vm_noninteractive(session, vm_ref): session.xenapi.VM.set_PV_args(vm_ref, 'noninteractive') -def xenstore_read(path): - """Uses the local xenstore utility to read a specified path""" - process = subprocess.Popen(['/usr/bin/xenstore-read', path], - stdout=subprocess.PIPE) - stdout, stderr = process.communicate() - if process.returncode == 0: - return stdout - else: - raise TestCaseError(stderr) - - def should_timeout(start, timeout): """Method for evaluating whether a time limit has been met""" return time.time() - start > float(timeout) @@ -1287,20 +1152,6 @@ def ssh_command(ip, username, password, cmd_str, dbg_str=None, attempts=10): raise Exception("An unkown error has occured!") -def add_network_interface(vm_ip, interface_name, interface_ip, - interface_netmask, username="root", - password=DEFAULT_PASSWORD, dhcp=False): - """Configures a network interface inside a linux VM""" - log.debug("add_network_interface for %s" % vm_ip) - if dhcp: - cmd = "ifconfig %s up" % interface_name - else: - cmd = "ifconfig %s %s netmask %s up" % \ - (interface_name, interface_ip, interface_netmask) - - ssh_command(vm_ip, username, password, cmd, cmd, attempts=10) - - def plug_pif(session, pif): """ Plug given pif""" log.debug("Plugging PIF: %s" % pif) @@ -1522,24 +1373,6 @@ def get_module_names(name_filter): return modules -def change_vm_power_state(session, vm_ref): - """Toggles VM powerstate between halted and running""" - vm_power_state = session.xenapi.VM.get_power_state(vm_ref) - print "Current VM power state: %s" % vm_power_state - if vm_power_state == 'Running': - log.debug("%s is shutting down" % vm_ref) - session.xenapi.VM.clean_shutdown(vm_ref) - log.debug("%s shutdown complete" % vm_ref) - elif vm_power_state == 'Halted': - log.debug("%s is booting" % vm_ref) - session.xenapi.VM.start(vm_ref, False, False) - - -def arg_encode(string): - """Encode a string for sending over XML-RPC to plugin""" - return string.replace('/', '/').replace('.', '.') - - def droid_template_import(session, host_ref, sr_uuid): """Import the droid template into the specified SR""" # Note, the filename should be fully specified. @@ -1547,21 +1380,6 @@ def droid_template_import(session, host_ref, sr_uuid): return call_ack_plugin(session, 'droid_template_import', args, host=host_ref) -def get_default_sr(session): - """Returns the SR reference marked as default in the pool""" - pool_ref = session.xenapi.pool.get_all()[0] - sr_ref = session.xenapi.pool.get_default_SR(pool_ref) - try: - # A call to check 'freshness' of default SR reference - log.debug("Default SR: %s" % session.xenapi.SR.get_name_label(sr_ref)) - return sr_ref - except XenAPI.Failure, exn: - if exn.details[0] == 'HANDLE_INVALID': - raise Exception("Pool is not configured to have shared storage!") - else: - raise exn - - def get_local_sr(session, host): """Returns the ref object the local SR on the master host""" all_pbds = session.xenapi.PBD.get_all_records() @@ -1603,7 +1421,7 @@ def find_storage_for_host(session, host_ref, exclude_types=['iso', 'udev']): return rel_srs -def import_droid_vm(session, host_ref, creds=None, loc=DROID_VM_LOC): +def import_droid_vm(session, host_ref, creds=None): """Import VM template from Dom0 for use in tests""" sr_refs = find_storage_for_host(session, host_ref) @@ -1980,20 +1798,6 @@ def droid_set_static(session, vm_ref, protocol, iface, ip, netmask, gw): return call_ack_plugin(session, 'droid_set_static_conf', args) -def get_non_management_pifs(session): - """Return a list of pif refs for non management devices""" - pifs = session.xenapi.PIF.get_all_records() - results = [] - for pif_ref, rec in pifs.iteritems(): - if not rec['management']: - results.append(pif_ref) - - if not results: - raise Exception("No management PIFs were found!") - - return results - - class TimeoutFunction: """Wrapper class for providing a timemout for the execution of a function""" @@ -2003,7 +1807,7 @@ def __init__(self, function, timeout, exception=''): self.function = function self.exception = exception - def handle_timeout(self, signum, frame): + def handle_timeout(self, *args, **kwargs): raise TimeoutFunctionException(self.exception) def __call__(self, *args): @@ -2051,8 +1855,9 @@ def call_ack_plugin(session, method, args={}, host=None): 'autocertkit', method, args) - log.debug("Plugin Output: %s" % res) - return json_loads(res) + log.debug("Plugin Output: %s" % ( + "%s[...check plugin log for more]" % res[:1000] if res and len(res) > 1000 else res)) + return json_loads(res) if res else None def get_hw_offloads(session, device): @@ -2115,31 +1920,14 @@ def set_hw_offload(session, device, offload, state): 'state': state}) -def parse_csv_list(string): - arr = string.split(',') - res = [] - for item in arr: - res.append(item.strip()) - return res - - -def set_nic_device_status(session, interface, status, creds=None): +def set_nic_device_status(session, interface, status): """Function to set an ifconfig ethX interface up or down""" log.debug("Bringing %s network interface %s" % (status, interface)) - call = ['ifconfig', interface, status] - if not creds: - res = make_local_call(call) - # only if it is dom0/host wait for link state actually changed. - wait_for_linkstate(session, interface, status) - else: - res = ssh_command(creds['host'], - creds['user'], - creds['pass'], - ' '.join(call)) + call_ack_plugin(session, 'set_nic_device_status', + {'device': interface, 'status': status}) + wait_for_linkstate(session, interface, status) time.sleep(5) - return res - class TestThread(threading.Thread): """Threading class that runs a function""" @@ -2213,11 +2001,11 @@ def _get_type_and_value(entry): return r -def get_system_info(): +def get_system_info(session): """Returns some information of system and bios.""" rec = {} - biosinfo = search_dmidecode("BIOS Information") + biosinfo = search_dmidecode(session, "BIOS Information") if biosinfo: entries = _get_type_and_value(biosinfo[0]) if 'Vendor' in entries: @@ -2229,7 +2017,7 @@ def get_system_info(): if 'BIOS Revision' in entries: rec['BIOS_revision'] = entries['BIOS Revision'] - sysinfo = search_dmidecode("System Information") + sysinfo = search_dmidecode(session, "System Information") if sysinfo: entries = _get_type_and_value(sysinfo[0]) if 'Manufacturer' in entries: @@ -2245,7 +2033,7 @@ def get_system_info(): if 'Family' in entries: rec['system_family'] = entries['Family'] - chassisinfo = search_dmidecode("Chassis Information") + chassisinfo = search_dmidecode(session, "Chassis Information") if chassisinfo: entries = _get_type_and_value(chassisinfo[0]) if 'Type' in entries: @@ -2256,14 +2044,6 @@ def get_system_info(): return rec -def get_master_ifaces(session): - devices = get_master_network_devices(session) - ifaces = [] - for device in devices: - ifaces.append(device['Kernel_name']) - return ifaces - - def set_dict_attributes(node, config): """Take a dict object, and set xmlnode attributes accordingly""" for k, v in config.iteritems(): @@ -2278,14 +2058,6 @@ def get_xml_attributes(node): return attr -def get_text_from_node_list(nlist, tag): - for node in nlist: - if node.nodeType == node.ELEMENT_NODE and node.tagName == tag: - for subnode in node.childNodes: - if subnode.nodeType == node.TEXT_NODE: - return subnode.data.strip() - - def to_bool(string): """Convert string value of true/false to bool""" return string.upper() == "TRUE" @@ -2487,30 +2259,25 @@ def valid_ping_response(ping_response, max_loss=0): return False -dmidecode_output = None - - @log_exceptions -def get_dmidecode_output(): +def get_dmidecode_output(session): """ Build dmidecode information data structure from output of dmidecode. """ - global dmidecode_output - if not dmidecode_output: - binfo = make_local_call(['dmidecode']) - buf = '' - dmidecode_output = [] - for line in binfo.split(os.linesep): - if len(line.strip()) == 0: - dmidecode_output.append(buf) - buf = '' - else: - buf += line + os.linesep + binfo = call_ack_plugin(session, 'get_dmidecode_output') + buf = '' + dmidecode_output = [] + for line in binfo.split(os.linesep): + if len(line.strip()) == 0: + dmidecode_output.append(buf) + buf = '' + else: + buf += line + os.linesep return dmidecode_output @log_exceptions -def search_dmidecode(keyword): +def search_dmidecode(session, keyword): """ Search ttype or busid from ds """ - ds = get_dmidecode_output() + ds = get_dmidecode_output(session) found = [] for info in ds: if keyword in info: diff --git a/plugins/autocertkit b/plugins/autocertkit index 44e0ab5e..0d59eb46 100755 --- a/plugins/autocertkit +++ b/plugins/autocertkit @@ -94,20 +94,21 @@ UNAME = "/bin/uname" PGREP = "/usr/bin/pgrep" # Logging setup - +LOG_NAME = "auto-cert-kit-plugin" LOG_LOC = '/var/log/auto-cert-kit-plugin.log' -log = None +def configure_logging(): + global log + log = acktools.log.configure_log(LOG_NAME, LOG_LOC, False) + +configure_logging() -def configure_logging(name): + +def release_logging(): global log if log: acktools.log.release_log(log) - log = acktools.log.configure_log(name, LOG_LOC, False) - return log - -configure_logging('autocertkit') # Exceptions @@ -388,6 +389,19 @@ def get_vm_ips(session, vm_ref): return res +@log_exceptions +def set_nic_device_status(session, arg): + """Set an ifconfig ethX interface up or down.""" + device = validate_exists(arg, 'device', None, True) + status = validate_exists(arg, 'status', None, True) + res = make_local_call([IFCONFIG, device, status]) + if res['returncode'] != 0: + msg = "ERR: Failed to set device status. %s" % res['stderr'] + log.error(msg) + return json_dumps(msg) + return json_dumps("OK") + + @log_exceptions def get_local_device_linkstate(session, arg): """ Return current operstate of network device.""" @@ -429,20 +443,16 @@ def save_bugtool(): def run_ack_logrotate(session, args): """Run logrotate for ACK logs""" + release_logging() ack_logrotate_dconf = '/etc/logrotate.d/autocertkit' - global log - - # This method should not log before logrotate execution to avoid os file - # handle error try: shutil.copyfile(LOGROTATE_CONF_LOC, ack_logrotate_dconf) call = ['/usr/sbin/logrotate', '-f', ack_logrotate_dconf] res = make_local_call(call, False) except Exception, e: return json_dumps(str(e)) - - # Restart logging and leave results of logrotate in the log. - log = configure_logging('autocertkit') + finally: + configure_logging() if res['returncode'] != 0: msg = "ERR: Failed to run logrotate." log.error("%s: %s" % (msg, res['stderr'])) @@ -1927,6 +1937,13 @@ def get_ack_version(session, args): return json_dumps(ver[0].strip()) raise Exception("Unable to parse ack version") + +@log_exceptions +def get_dmidecode_output(session, args): + """Returns output of dmidecode call""" + return json_dumps(make_local_call(['dmidecode'])["stdout"]) + + ##################################################### if __name__ == '__main__': @@ -1952,6 +1969,7 @@ if __name__ == '__main__': 'get_local_storage_devices': get_local_storage_devices, 'get_iface_stats': get_iface_stats, 'get_host_routes': get_host_routes, + 'set_nic_device_status': set_nic_device_status, 'get_local_device_linkstate': get_local_device_linkstate, 'create_output_package': create_output_package, 'start_iperf_server': start_iperf_server, @@ -1964,6 +1982,7 @@ if __name__ == '__main__': 'get_local_device_info': get_local_device_info, 'inject_ssh_key': inject_ssh_key, 'get_kernel_version': get_kernel_version, + 'get_dmidecode_output': get_dmidecode_output, 'get_ack_version': get_ack_version, 'run_ack_logrotate': run_ack_logrotate, 'retrieve_crashdumps': retrieve_crashdumps,