Пример #1
0
    def objs(self):
        if self.args.list_suites or self.args.list_tests:
            return

        # check to see if bmc_ip even pings to validate configuration parms
        try:
            self.util.PingFunc(
                self.args.bmc_ip, totalSleepTime=BMC_CONST.PING_RETRY_FOR_STABILITY)
        except Exception as e:
            # we are trying to catch sooner rather than later
            # if we have reservations that need cleaned up
            # otherwise we would have to try/except for cleanup
            # in lots of places
            # testcases.HelloWorld in CI fails if we throw this
            # raise only if we have reservations to cleanup
            if self.args.hostlocker is not None \
                    or self.args.aes is not None \
                    or self.args.aes_search_args is not None:
                self.util.cleanup()
                raise ParameterCheck(message="OpTestSystem PingFunc fails to "
                                     "ping '{}', check your configuration and setup, see "
                                     "Exception details: {}".format(self.args.bmc_ip, e))

        try:
            host = common.OpTestHost.OpTestHost(self.args.host_ip,
                                                self.args.host_user,
                                                self.args.host_password,
                                                self.args.bmc_ip,
                                                self.output,
                                                scratch_disk=self.args.host_scratch_disk,
                                                proxy=self.args.proxy,
                                                logfile=self.logfile,
                                                check_ssh_keys=self.args.check_ssh_keys,
                                                known_hosts_file=self.args.known_hosts_file,
                                                conf=self)
            if self.args.bmc_type in ['AMI', 'SMC']:
                web = OpTestWeb(self.args.bmc_ip,
                                self.args.bmc_usernameipmi,
                                self.args.bmc_passwordipmi)
                bmc = None
                if self.args.bmc_type in ['AMI']:
                    ipmi = OpTestIPMI(self.args.bmc_ip,
                                      self.args.bmc_usernameipmi,
                                      self.args.bmc_passwordipmi,
                                      host=host,
                                      host_console_command=self.args.host_serial_console_command,
                                      logfile=self.logfile,
                                      )

                    bmc = OpTestBMC(ip=self.args.bmc_ip,
                                    username=self.args.bmc_username,
                                    password=self.args.bmc_password,
                                    logfile=self.logfile,
                                    ipmi=ipmi,
                                    web=web,
                                    check_ssh_keys=self.args.check_ssh_keys,
                                    known_hosts_file=self.args.known_hosts_file
                                    )
                elif self.args.bmc_type in ['SMC']:
                    ipmi = OpTestSMCIPMI(self.args.bmc_ip,
                                         self.args.bmc_usernameipmi,
                                         self.args.bmc_passwordipmi,
                                         logfile=self.logfile,
                                         host=host,
                                         )
                    bmc = OpTestSMC(ip=self.args.bmc_ip,
                                    username=self.args.bmc_username,
                                    password=self.args.bmc_password,
                                    ipmi=ipmi,
                                    web=web,
                                    check_ssh_keys=self.args.check_ssh_keys,
                                    known_hosts_file=self.args.known_hosts_file
                                    )
                self.op_system = common.OpTestSystem.OpTestSystem(
                    state=self.startState,
                    bmc=bmc,
                    host=host,
                    conf=self,
                )
                ipmi.set_system(self.op_system)
                bmc.set_system(self.op_system)
            elif self.args.bmc_type in ['FSP']:
                ipmi = OpTestIPMI(self.args.bmc_ip,
                                  None,  # FSP does not use UID
                                  self.args.bmc_passwordipmi,
                                  host=host,
                                  logfile=self.logfile)
                bmc = OpTestFSP(self.args.bmc_ip,
                                self.args.bmc_username,
                                self.args.bmc_password,
                                ipmi=ipmi,
                                )
                self.op_system = common.OpTestSystem.OpTestFSPSystem(
                    state=self.startState,
                    bmc=bmc,
                    host=host,
                    conf=self,
                )
                ipmi.set_system(self.op_system)
            elif self.args.bmc_type in ['FSP_PHYP']:
                hmc = None
                if all(v is not None for v in [self.args.hmc_ip, self.args.hmc_username, self.args.hmc_password]):
                    hmc = OpTestHMC(self.args.hmc_ip,
                                    self.args.hmc_username,
                                    self.args.hmc_password,
                                    managed_system=self.args.system_name,
                                    lpar_name=self.args.lpar_name,
                                    lpar_vios=self.args.lpar_vios,
                                    lpar_prof=self.args.lpar_prof,
                                    lpar_user=self.args.host_user,
                                    lpar_password=self.args.host_password,
                                    logfile=self.logfile
                                    )
                else:
                    raise Exception(
                        "HMC IP, username and password is required")
                bmc = OpTestFSP(self.args.bmc_ip,
                                self.args.bmc_username,
                                self.args.bmc_password,
                                )
                self.op_system = common.OpTestSystem.OpTestFSPSystem(
                    state=self.startState,
                    bmc=bmc,
                    host=host,
                    hmc=hmc,
                    conf=self,
                )
                hmc.set_system(self.op_system)
            elif self.args.bmc_type in ['OpenBMC']:
                ipmi = OpTestIPMI(self.args.bmc_ip,
                                  self.args.bmc_usernameipmi,
                                  self.args.bmc_passwordipmi,
                                  host=host,
                                  logfile=self.logfile)
                rest_api = HostManagement(conf=self,
                                          ip=self.args.bmc_ip,
                                          username=self.args.bmc_username,
                                          password=self.args.bmc_password)
                bmc = OpTestOpenBMC(ip=self.args.bmc_ip,
                                    username=self.args.bmc_username,
                                    password=self.args.bmc_password,
                                    ipmi=ipmi,
                                    rest_api=rest_api,
                                    logfile=self.logfile,
                                    check_ssh_keys=self.args.check_ssh_keys,
                                    known_hosts_file=self.args.known_hosts_file)
                self.op_system = common.OpTestSystem.OpTestOpenBMCSystem(
                    host=host,
                    bmc=bmc,
                    state=self.startState,
                    conf=self,
                )
                bmc.set_system(self.op_system)
            elif self.args.bmc_type in ['qemu']:
                print((repr(self.args)))
                bmc = OpTestQemu(conf=self,
                                 qemu_binary=self.args.qemu_binary,
                                 pnor=self.args.host_pnor,
                                 skiboot=self.args.flash_skiboot,
                                 kernel=self.args.flash_kernel,
                                 initramfs=self.args.flash_initramfs,
                                 cdrom=self.args.os_cdrom,
                                 logfile=self.logfile)
                self.op_system = common.OpTestSystem.OpTestQemuSystem(host=host,
                                                                      bmc=bmc,
                                                                      state=self.startState,
                                                                      conf=self,
                                                                      )
                bmc.set_system(self.op_system)
            elif self.args.bmc_type in ['mambo']:
                if not (os.stat(self.args.mambo_binary).st_mode & stat.S_IXOTH):
                    raise ParameterCheck(message="Check that the file exists with X permissions mambo-binary={}"
                                         .format(self.args.mambo_binary))
                if self.args.flash_skiboot is None \
                        or not os.access(self.args.flash_skiboot, os.R_OK):
                    raise ParameterCheck(message="Check that the file exists with R permissions flash-skiboot={}"
                                         .format(self.args.flash_skiboot))
                if self.args.flash_kernel is None \
                        or not os.access(self.args.flash_kernel, os.R_OK):
                    raise ParameterCheck(message="Check that the file exists with R permissions flash-kernel={}"
                                         .format(self.args.flash_kernel))
                bmc = OpTestMambo(mambo_binary=self.args.mambo_binary,
                                  mambo_initial_run_script=self.args.mambo_initial_run_script,
                                  mambo_autorun=self.args.mambo_autorun,
                                  skiboot=self.args.flash_skiboot,
                                  kernel=self.args.flash_kernel,
                                  initramfs=self.args.flash_initramfs,
                                  timeout_factor=self.args.mambo_timeout_factor,
                                  logfile=self.logfile)
                self.op_system = common.OpTestSystem.OpTestMamboSystem(host=host,
                                                                       bmc=bmc,
                                                                       state=self.startState,
                                                                       conf=self,
                                                                       )
                bmc.set_system(self.op_system)

            # Check that the bmc_type exists in our loaded addons then create our objects
            elif self.args.bmc_type in optAddons:
                (bmc, self.op_system) = optAddons[self.args.bmc_type].createSystem(
                    self, host)
            else:
                self.util.cleanup()
                raise Exception("Unsupported BMC Type '{}', check your "
                                "upper/lower cases for bmc_type and verify "
                                "any credentials used from HostLocker or "
                                "AES Version (see aes_get_creds "
                                "version_mappings)".format(self.args.bmc_type))

            host.set_system(self.op_system)
            return
        except Exception as e:
            traceback.print_exc()
            self.util.cleanup()
            raise e
    def objs(self):
        host = OpTestHost(self.args.host_ip,
                          self.args.host_user,
                          self.args.host_password,
                          self.args.bmc_ip,
                          self.output,
                          scratch_disk=self.args.host_scratch_disk,
                          proxy=self.args.proxy,
                          logfile=self.logfile,
                          check_ssh_keys=self.args.check_ssh_keys,
                          known_hosts_file=self.args.known_hosts_file)
        if self.args.bmc_type in ['AMI', 'SMC']:
            web = OpTestWeb(self.args.bmc_ip, self.args.bmc_usernameipmi,
                            self.args.bmc_passwordipmi)
            bmc = None
            if self.args.bmc_type in ['AMI']:
                ipmi = OpTestIPMI(
                    self.args.bmc_ip,
                    self.args.bmc_usernameipmi,
                    self.args.bmc_passwordipmi,
                    host=host,
                    logfile=self.logfile,
                )

                bmc = OpTestBMC(ip=self.args.bmc_ip,
                                username=self.args.bmc_username,
                                password=self.args.bmc_password,
                                logfile=self.logfile,
                                ipmi=ipmi,
                                web=web,
                                check_ssh_keys=self.args.check_ssh_keys,
                                known_hosts_file=self.args.known_hosts_file)
            elif self.args.bmc_type in ['SMC']:
                ipmi = OpTestSMCIPMI(
                    self.args.bmc_ip,
                    self.args.bmc_usernameipmi,
                    self.args.bmc_passwordipmi,
                    logfile=self.logfile,
                    host=host,
                )
                bmc = OpTestSMC(ip=self.args.bmc_ip,
                                username=self.args.bmc_username,
                                password=self.args.bmc_password,
                                ipmi=ipmi,
                                web=web,
                                check_ssh_keys=self.args.check_ssh_keys,
                                known_hosts_file=self.args.known_hosts_file)
            self.op_system = OpTestSystem(
                state=self.startState,
                bmc=bmc,
                host=host,
            )
            ipmi.set_system(self.op_system)
        elif self.args.bmc_type in ['FSP']:
            ipmi = OpTestIPMI(self.args.bmc_ip,
                              self.args.bmc_usernameipmi,
                              self.args.bmc_passwordipmi,
                              host=host,
                              logfile=self.logfile)
            bmc = OpTestFSP(
                self.args.bmc_ip,
                self.args.bmc_username,
                self.args.bmc_password,
                ipmi=ipmi,
            )
            self.op_system = OpTestFSPSystem(
                state=self.startState,
                bmc=bmc,
                host=host,
            )
            ipmi.set_system(self.op_system)
        elif self.args.bmc_type in ['OpenBMC']:
            ipmi = OpTestIPMI(self.args.bmc_ip,
                              self.args.bmc_usernameipmi,
                              self.args.bmc_passwordipmi,
                              host=host,
                              logfile=self.logfile)
            rest_api = HostManagement(self.args.bmc_ip, self.args.bmc_username,
                                      self.args.bmc_password)
            bmc = OpTestOpenBMC(self.args.bmc_ip,
                                self.args.bmc_username,
                                self.args.bmc_password,
                                logfile=self.logfile,
                                ipmi=ipmi,
                                rest_api=rest_api,
                                check_ssh_keys=self.args.check_ssh_keys,
                                known_hosts_file=self.args.known_hosts_file)
            self.op_system = OpTestOpenBMCSystem(
                host=host,
                bmc=bmc,
                state=self.startState,
            )
            bmc.set_system(self.op_system)
        elif self.args.bmc_type in ['qemu']:
            print repr(self.args)
            bmc = OpTestQemu(self.args.qemu_binary,
                             self.args.flash_skiboot,
                             self.args.flash_kernel,
                             self.args.flash_initramfs,
                             cdrom=self.args.os_cdrom,
                             logfile=self.logfile,
                             hda=self.args.host_scratch_disk)
            self.op_system = OpTestQemuSystem(host=host, bmc=bmc)
        # Check that the bmc_type exists in our loaded addons then create our objects
        elif self.args.bmc_type in optAddons:
            (bmc, self.op_system) = optAddons[self.args.bmc_type].createSystem(
                self, host)
        else:
            raise Exception("Unsupported BMC Type")

        host.set_system(self.op_system)
        return