def main(config, test_run_file): """Main routine - assess which tests should be run, and create output 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(): res = session.xenapi.host.call_plugin(host_ref, 'autocertkit', 'run_ack_logrotate', {}) utils.configure_logging('auto-cert-kit') pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() if 'generate' in config: #Generate config file only utils.log.info("Test file generated") return "OK" #Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
def check_host_compatibility(himn, username): xcp_version = utils.get_xcp_version(himn, username) if LooseVersion(xcp_version) < LooseVersion(MIN_XCP_VERSION): utils.reportError('Platform version %s should equal or greater than %s' % (xcp_version, MIN_XCP_VERSION)) return version_hotfixes = json.loads(VERSION_HOTFIXES) ver = utils.ssh(himn, username, ('xe host-param-get uuid=$(xe host-list --minimal) ' 'param-name=software-version param-key=product_version')) hotfixes = version_hotfixes.get(ver) if not hotfixes: return for hotfix in hotfixes: if not hotfix: continue installed = utils.ssh(himn, username, 'xe patch-list name-label=%s --minimal' % hotfix) if not installed: utils.reportError('Hotfix %s has not been installed ' % ver)
def main(config, test_run_file): """Main routine - assess which tests should be run, and create output 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') pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() if 'generate' in config: # Generate config file only utils.log.info("Test file generated") return "OK" # Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
def main(config, test_run_file): """Main routine - assess which tests should be run, and create output file""" session = get_xapi_session(config) # Ensure that all hosts in the pool have booted up. utils.wait_for_hosts(session) # Start Logger utils.init_ack_logging(session) utils.log.info("Options: %s" % config) # Pre checks before running tests pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) if 'generate' in config: # Generate config file only utils.log.info("Test file generated") session.logout() return "OK" # cleanup in case previous run did not complete entirely if utils.pool_wide_cleanup(session): utils.reboot_normally(session) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() # Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
def main(config, test_run_file): """Main routine - assess which tests should be run, and create output file""" session = get_xapi_session(config) # Start Logger utils.init_ack_logging(session) utils.log.info("Options: %s" % config) # Pre checks before running tests pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) if 'generate' in config: # Generate config file only utils.log.info("Test file generated") session.logout() return "OK" # cleanup in case previous run did not complete entirely if utils.pool_wide_cleanup(session): utils.reboot_normally(session) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() # Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
if __name__ == '__main__': install_xenapi_sdk() astute = utils.get_astute() if astute: username, password, install_xapi = utils.get_options(astute) endpoints = get_endpoints(astute) himn_eth, himn_local = utils.init_eth() public_ip = utils.astute_get( astute, ('network_metadata', 'vips', 'public', 'ipaddr')) services_ssl = utils.astute_get(astute, ('public_ssl', 'services')) if username and password and endpoints and himn_local: route_to_compute(endpoints, HIMN_IP, himn_local, username) xcp_version = utils.get_xcp_version(HIMN_IP, username) if install_xapi: install_suppack(HIMN_IP, username, XS_PLUGIN_ISO, xcp_version) enable_linux_bridge(HIMN_IP, username) forward_from_himn(himn_eth) # port forwarding for novnc forward_port('br-mgmt', himn_eth, HIMN_IP, '80') create_novacompute_conf(HIMN_IP, username, password, public_ip, services_ssl) patch_compute_xenapi() restart_services('nova-compute') install_logrotate_script(HIMN_IP, username)
def append_xml_config(self, doc, xml_node): """Append xml config for running the tests. xml_node should be the devices xml tag under which each device to be certified hangs.""" device_node = doc.createElement("device") device_config = self.get_device_config() if device_config: for k, v in device_config.iteritems(): device_node.setAttribute(k, v) # Set the unique device id device_node.setAttribute("udid", str(self.get_uid())) # Set the device type device_node.setAttribute("tag", self.TAG) cts_node = doc.createElement("certification_tests") device_node.appendChild(cts_node) test_classes = self.get_test_classes() for test_class_name, test_class in test_classes: skipthis = False xcp_version = utils.get_xcp_version(self.session) if test_class.REQUIRED_FOR: if utils.eval_expr(test_class.REQUIRED_FOR, xcp_version): if not utils.REQ_CAP in test_class.caps: test_class.caps.append(utils.REQ_CAP) else: if utils.REQ_CAP in test_class.caps: test_class.caps.remove(utils.REQ_CAP) skipthis = True class_node = doc.createElement("test_class") class_node.setAttribute("name", test_class_name) class_node.setAttribute("caps", str(test_class(self.session, self.config).caps)) class_node.setAttribute("order", str(test_class(self.session, self.config).order)) test_methods = test_class(self.session, self.config).list_tests() for method in test_methods: method_node = doc.createElement("test_method") method_node.setAttribute("name", str(method)) # Result/Info fields result_node = doc.createElement("result") info_node = doc.createElement("info") if skipthis: result_node.appendChild(doc.createTextNode("skip")) reason_node = doc.createElement("reason") reason_node.appendChild( doc.createTextNode("%s is not required for XCP %s." % (test_class_name, xcp_version)) ) method_node.appendChild(reason_node) else: result_node.appendChild(doc.createTextNode("NULL")) method_node.appendChild(result_node) method_node.appendChild(info_node) testname_node = doc.createElement("test_name") testname_node.appendChild(doc.createTextNode("%s.%s" % (test_class_name.split(".")[1], str(method)))) method_node.appendChild(testname_node) class_node.appendChild(method_node) cts_node.appendChild(class_node) xml_node.appendChild(device_node)
def append_xml_config(self, doc, xml_node): """Append xml config for running the tests. xml_node should be the devices xml tag under which each device to be certified hangs.""" device_node = doc.createElement('device') device_config = self.get_device_config() if device_config: for k, v in device_config.iteritems(): device_node.setAttribute(k, v) # Set the unique device id device_node.setAttribute('udid', str(self.get_uid())) # Set the device type device_node.setAttribute('tag', self.TAG) cts_node = doc.createElement('certification_tests') device_node.appendChild(cts_node) test_classes = self.get_test_classes() for test_class_name, test_class in test_classes: skipthis = False xcp_version = utils.get_xcp_version(self.session) if test_class.REQUIRED_FOR: if utils.eval_expr(test_class.REQUIRED_FOR, xcp_version): if not utils.REQ_CAP in test_class.caps: test_class.caps.append(utils.REQ_CAP) else: if utils.REQ_CAP in test_class.caps: test_class.caps.remove(utils.REQ_CAP) skipthis = True class_node = doc.createElement('test_class') class_node.setAttribute('name', test_class_name) class_node.setAttribute('caps', str( test_class(self.session, self.config).caps)) class_node.setAttribute('order', str( test_class(self.session, self.config).order)) test_methods = test_class(self.session, self.config).list_tests() for method in test_methods: method_node = doc.createElement('test_method') method_node.setAttribute('name', str(method)) # Result/Info fields result_node = doc.createElement('result') info_node = doc.createElement('info') if skipthis: result_node.appendChild(doc.createTextNode('skip')) reason_node = doc.createElement('reason') reason_node.appendChild(doc.createTextNode('%s is not required for XCP %s.' % (test_class_name, xcp_version))) method_node.appendChild(reason_node) else: result_node.appendChild(doc.createTextNode('NULL')) method_node.appendChild(result_node) method_node.appendChild(info_node) testname_node = doc.createElement('test_name') testname_node.appendChild(doc.createTextNode('%s.%s' % (test_class_name.split('.')[1], str(method)))) method_node.appendChild(testname_node) status_node = doc.createElement('status') if skipthis: status_node.appendChild(doc.createTextNode('done')) else: status_node.appendChild(doc.createTextNode('init')) control_node = doc.createElement('control') method_node.appendChild(status_node) method_node.appendChild(control_node) class_node.appendChild(method_node) cts_node.appendChild(class_node) xml_node.appendChild(device_node)