Beispiel #1
0
    def init(self):
        if self.__seabios_out == "on":
            self.__chardev_for_so = CCharDev({
                "backend":
                "file",
                "path":
                os.path.join(config.infrasim_log_dir, self.__node_name,
                             "seabios.log"),
            })
            self.__chardev_for_so.set_id("seabios")
            self.__chardev_for_so.init()

        if self.__guest_out == "on":
            self.__chardev_for_go = CCharDev({
                "backend":
                "file",
                "path":
                os.path.join(config.infrasim_log_dir, self.__node_name,
                             "guest.log")
            })

            self.__chardev_for_go.set_id("guest")
            self.__chardev_for_go.init()

            self.__serial_for_go = CSerial(self.__chardev_for_go,
                                           {"index": "0"})
            self.__serial_for_go.init()
Beispiel #2
0
    def init(self):
        self.__interface = self.__ipmi.get('interface')

        if 'chardev' in self.__ipmi:
            self.__chardev_obj = CCharDev(self.__ipmi['chardev'])
            self.__chardev_obj.logger = self.logger
            self.__chardev_obj.set_id("ipmi0")
            self.__chardev_obj.host = self.__host
            self.__chardev_obj.port = self.__bmc_connection_port
            self.__chardev_obj.init()

        self.__ioport = self.__ipmi.get('ioport')
        self.__irq = self.__ipmi.get('irq')
Beispiel #3
0
class CIPMI(CElement):
    def __init__(self, ipmi_info):
        super(CIPMI, self).__init__()
        self.__ipmi = ipmi_info
        self.__interface = None
        self.__host = None
        self.__bmc_connection_port = None
        self.__chardev_obj = None
        self.__ioport = None
        self.__irq = None

    def set_bmc_conn_host(self, host):
        self.__host = host

    def set_bmc_conn_port(self, port):
        self.__bmc_connection_port = port

    def precheck(self):
        """
        Check if internal socket port is used.
        """
        if self.__chardev_obj is None:
            raise ArgsNotCorrect("[IPMI] -chardev should set.")

    def init(self):
        self.__interface = self.__ipmi.get('interface')

        if 'chardev' in self.__ipmi:
            self.__chardev_obj = CCharDev(self.__ipmi['chardev'])
            self.__chardev_obj.logger = self.logger
            self.__chardev_obj.set_id("ipmi0")
            self.__chardev_obj.host = self.__host
            self.__chardev_obj.port = self.__bmc_connection_port
            self.__chardev_obj.init()

        self.__ioport = self.__ipmi.get('ioport')
        self.__irq = self.__ipmi.get('irq')

    def handle_parms(self):
        self.__chardev_obj.handle_parms()
        chardev_option = self.__chardev_obj.get_option()
        bmc_option = ','.join([
            'ipmi-bmc-extern',
            'chardev={}'.format(self.__chardev_obj.get_id()), 'id=bmc0'
        ])
        interface_option = ','.join(['isa-ipmi-kcs', 'bmc=bmc0'])
        if self.__ioport:
            interface_option = ','.join(
                [interface_option, "ioport={}".format(self.__ioport)])

        if self.__irq:
            interface_option = ','.join(
                [interface_option, "irq={}".format(self.__irq)])

        ipmi_option = " ".join([
            chardev_option, "-device {}".format(bmc_option),
            "-device {}".format(interface_option)
        ])
        self.add_option(ipmi_option)
Beispiel #4
0
    def init(self):
        self.__chardev = CCharDev({
            "backend":
            "socket",
            "path":
            os.path.join(self.__workspace, "guest.agt"),
            "server":
            "on",
            "wait":
            False
        })
        self.__chardev.set_id("guest-agent")
        self.__chardev.init()

        self.__serial = CSerial(self.__chardev, {"index": 3})
        self.__serial.init()
class GuestAgent(CElement):
    def __init__(self, workspace):
        super(GuestAgent, self).__init__()
        self.__chardev = None
        self.__workspace = workspace
        self.__serial = None

    def precheck(self):
        if self.__chardev:
            self.__chardev.precheck()

        if self.__serial:
            self.__serial.precheck()

    def init(self):
        self.__chardev = CCharDev({
            "backend": "socket",
            "path": os.path.join(self.__workspace, "guest.agt"),
            "server": "on",
            "wait": False
        })
        self.__chardev.set_id("guest-agent")
        self.__chardev.init()

        self.__serial = CSerial(self.__chardev,
                                {"index": 3})
        self.__serial.init()

    def handle_parms(self):
        self.__chardev.handle_parms()
        self.__serial.handle_parms()
        self.add_option(self.__chardev.get_option())
        self.add_option(self.__serial.get_option())
Beispiel #6
0
class CIPMI(CElement):
    def __init__(self, ipmi_info):
        super(CIPMI, self).__init__()
        self.__ipmi = ipmi_info
        self.__interface = None
        self.__host = None
        self.__bmc_connection_port = None
        self.__chardev_obj = None
        self.__ioport = None
        self.__irq = None

    def set_bmc_conn_host(self, host):
        self.__host = host

    def set_bmc_conn_port(self, port):
        self.__bmc_connection_port = port

    def precheck(self):
        """
        Check if internal socket port is used.
        """
        if self.__chardev_obj is None:
            raise ArgsNotCorrect("[IPMI] -chardev should set.")

    def init(self):
        self.__interface = self.__ipmi.get('interface')

        if 'chardev' in self.__ipmi:
            self.__chardev_obj = CCharDev(self.__ipmi['chardev'])
            self.__chardev_obj.logger = self.logger
            self.__chardev_obj.set_id("ipmi0")
            self.__chardev_obj.host = self.__host
            self.__chardev_obj.port = self.__bmc_connection_port
            self.__chardev_obj.init()

        self.__ioport = self.__ipmi.get('ioport')
        self.__irq = self.__ipmi.get('irq')

    def handle_parms(self):
        self.__chardev_obj.handle_parms()
        chardev_option = self.__chardev_obj.get_option()
        bmc_option = ','.join(['ipmi-bmc-extern', 'chardev={}'.format(self.__chardev_obj.get_id()), 'id=bmc0'])
        interface_option = ','.join(['isa-ipmi-kcs', 'bmc=bmc0'])
        if self.__ioport:
            interface_option = ','.join([interface_option, "ioport={}".format(self.__ioport)])

        if self.__irq:
            interface_option = ','.join([interface_option, "irq={}".format(self.__irq)])

        ipmi_option = " ".join([chardev_option,
                                "-device {}".format(bmc_option),
                                "-device {}".format(interface_option)])
        self.add_option(ipmi_option)
Beispiel #7
0
    def init(self):
        if self.__seabios_out == "on":
            self.__chardev_for_so = CCharDev({
                "backend": "file",
                "path": os.path.join(config.infrasim_log_dir, self.__node_name, "seabios.log"),
            })
            self.__chardev_for_so.set_id("seabios")
            self.__chardev_for_so.init()

        if self.__guest_out == "on":
            self.__chardev_for_go = CCharDev({
                "backend": "file",
                "path": os.path.join(config.infrasim_log_dir, self.__node_name, "guest.log")
            })

            self.__chardev_for_go.set_id("guest")
            self.__chardev_for_go.init()

            self.__serial_for_go = CSerial(self.__chardev_for_go, {"index": "0"})
            self.__serial_for_go.init()
Beispiel #8
0
    def init(self):
        self.__mode = self.__monitor.get("mode", "readline")
        chardev_info = {}
        if self.__mode == "readline":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "host" not in chardev_info:
                chardev_info["host"] = "127.0.0.1"
            if "port" not in chardev_info:
                chardev_info["port"] = 2345
        elif self.__mode == "control":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "path" not in chardev_info:
                if self.get_workspace():
                    chardev_path = os.path.join(self.get_workspace(),
                                                ".monitor")
                else:
                    chardev_path = os.path.join(config.infrasim_etc,
                                                ".monitor")
                chardev_info["path"] = chardev_path
        else:
            pass

        self.__monitor["chardev"] = chardev_info
        self.__chardev = CCharDev(chardev_info)
        self.__chardev.logger = self.logger
        self.__chardev.set_id("monitorchardev")
        self.__chardev.init()
Beispiel #9
0
    def init(self):
        self.__interface = self.__ipmi.get('interface')

        if 'chardev' in self.__ipmi:
            self.__chardev_obj = CCharDev(self.__ipmi['chardev'])
            self.__chardev_obj.logger = self.logger
            self.__chardev_obj.set_id("ipmi0")
            self.__chardev_obj.host = self.__host
            self.__chardev_obj.port = self.__bmc_connection_port
            self.__chardev_obj.init()

        self.__ioport = self.__ipmi.get('ioport')
        self.__irq = self.__ipmi.get('irq')
    def init(self):
        self.__chardev = CCharDev({
            "backend": "socket",
            "path": os.path.join(self.__workspace, "guest.agt"),
            "server": "on",
            "wait": False
        })
        self.__chardev.set_id("guest-agent")
        self.__chardev.init()

        self.__serial = CSerial(self.__chardev,
                                {"index": 3})
        self.__serial.init()
Beispiel #11
0
    def init(self):
        self.__mode = self.__monitor.get("mode", "readline")
        chardev_info = {}
        if self.__mode == "readline":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "host" not in chardev_info:
                chardev_info["host"] = "127.0.0.1"
            if "port" not in chardev_info:
                chardev_info["port"] = 2345
        elif self.__mode == "control":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "path" not in chardev_info:
                if self.get_workspace():
                    chardev_path = os.path.join(self.get_workspace(), ".monitor")
                else:
                    chardev_path = os.path.join(config.infrasim_etc, ".monitor")
                chardev_info["path"] = chardev_path
        else:
            pass

        self.__monitor["chardev"] = chardev_info
        self.__chardev = CCharDev(chardev_info)
        self.__chardev.logger = self.logger
        self.__chardev.set_id("monitorchardev")
        self.__chardev.init()
Beispiel #12
0
class GuestAgent(CElement):
    def __init__(self, workspace):
        super(GuestAgent, self).__init__()
        self.__chardev = None
        self.__workspace = workspace
        self.__serial = None

    def precheck(self):
        if self.__chardev:
            self.__chardev.precheck()

        if self.__serial:
            self.__serial.precheck()

    def init(self):
        self.__chardev = CCharDev({
            "backend":
            "socket",
            "path":
            os.path.join(self.__workspace, "guest.agt"),
            "server":
            "on",
            "wait":
            False
        })
        self.__chardev.set_id("guest-agent")
        self.__chardev.init()

        self.__serial = CSerial(self.__chardev, {"index": 3})
        self.__serial.init()

    def handle_parms(self):
        self.__chardev.handle_parms()
        self.__serial.handle_parms()
        self.add_option(self.__chardev.get_option())
        self.add_option(self.__serial.get_option())
Beispiel #13
0
class CMonitor(CElement):
    def __init__(self, monitor_info):
        super(CMonitor, self).__init__()
        self.__monitor = monitor_info
        self.__chardev = None
        self.__mode = "readline"
        self.__workspace = ""
        self.__monitor_handle = None

    def get_workspace(self):
        return self.__workspace

    def set_workspace(self, ws):
        self.__workspace = ws

    def precheck(self):
        if self.__mode not in ["readline", "control"]:
            raise ArgsNotCorrect("[Monitor] Invalid monitor mode: {}".format(
                self.__mode))

        self.__chardev.precheck()

        # Monitor specific chardev attribution
        if self.__monitor["chardev"]["backend"] != "socket":
            raise ArgsNotCorrect(
                "[Monitor] Invalid monitor chardev backend: {}".format(
                    self.__monitor["chardev"]["backend"]))
        if self.__monitor["chardev"]["server"] is not True:
            raise ArgsNotCorrect(
                "[Monitor] Invalid monitor chardev server: {}".format(
                    self.__monitor["chardev"]["server"]))
        if self.__monitor["chardev"]["wait"] is not False:
            raise ArgsNotCorrect(
                "[Monitor] Invalid monitor chardev wait: {}".format(
                    self.__monitor["chardev"]["wait"]))

    def init(self):
        self.__mode = self.__monitor.get("mode", "readline")
        chardev_info = {}
        if self.__mode == "readline":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "host" not in chardev_info:
                chardev_info["host"] = "127.0.0.1"
            if "port" not in chardev_info:
                chardev_info["port"] = 2345
        elif self.__mode == "control":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "path" not in chardev_info:
                if self.get_workspace():
                    chardev_path = os.path.join(self.get_workspace(),
                                                ".monitor")
                else:
                    chardev_path = os.path.join(config.infrasim_etc,
                                                ".monitor")
                chardev_info["path"] = chardev_path
        else:
            pass

        self.__monitor["chardev"] = chardev_info
        self.__chardev = CCharDev(chardev_info)
        self.__chardev.logger = self.logger
        self.__chardev.set_id("monitorchardev")
        self.__chardev.init()

    def handle_parms(self):
        self.__chardev.handle_parms()
        self.add_option(self.__chardev.get_option())
        self.add_option("-mon chardev={},mode={}".format(
            self.__chardev.get_id(), self.__mode))

    def get_mode(self):
        return self.__mode

    def open(self):
        if self.__mode == "readline":
            self.__monitor_handle = Telnet(self.__chardev.host,
                                           self.__chardev.port)
        elif self.__mode == "control":
            self.__monitor_handle = socket.socket(socket.AF_UNIX,
                                                  socket.SOCK_STREAM)
            self.__monitor_handle.connect(self.__chardev.get_path())

            # enable qmp capabilities
            qmp_payload = {"execute": "qmp_capabilities"}
            self.send(qmp_payload)
        else:
            raise ArgsNotCorrect(
                "[Monitor] Monitor mode {} is unknown.".format(self.__mode))
        self.logger.info("[Monitor] monitor opened({}).".format(
            self.__monitor_handle))

    def send(self, command):
        if self.__monitor_handle:
            self.logger.info("[Monitor] send command {}".format(command))
            if self.__mode == "readline":
                self.__monitor_handle.write(command)
            else:
                self.__monitor_handle.send(json.dumps(command))

    def close(self):
        if self.__monitor_handle:
            self.__monitor_handle.close()
            self.logger.info("[Monitor] monitor closed.")
Beispiel #14
0
class QTrace(CElement):
    def __init__(self, trace_settings, workspace):
        super(QTrace, self).__init__()
        self.__seabios_out = trace_settings.get("seabios")
        self.__guest_out = trace_settings.get("guest")

        self.__chardev_for_so = None

        self.__chardev_for_go = None
        self.__serial_for_go = None
        self.__node_name = workspace.split('/')[-1]

    def precheck(self):
        pass

    def init(self):
        if self.__seabios_out == "on":
            self.__chardev_for_so = CCharDev({
                "backend": "file",
                "path": os.path.join(config.infrasim_log_dir, self.__node_name, "seabios.log"),
            })
            self.__chardev_for_so.set_id("seabios")
            self.__chardev_for_so.init()

        if self.__guest_out == "on":
            self.__chardev_for_go = CCharDev({
                "backend": "file",
                "path": os.path.join(config.infrasim_log_dir, self.__node_name, "guest.log")
            })

            self.__chardev_for_go.set_id("guest")
            self.__chardev_for_go.init()

            self.__serial_for_go = CSerial(self.__chardev_for_go, {"index": "0"})
            self.__serial_for_go.init()

    def handle_parms(self):
        if self.__chardev_for_so:
            self.__chardev_for_so.handle_parms()
            self.add_option("{} -device isa-debugcon,iobase=0x402,chardev=seabios".format(
                self.__chardev_for_so.get_option()))

        if self.__chardev_for_go and self.__serial_for_go:
            self.__chardev_for_go.handle_parms()
            self.__serial_for_go.handle_parms()
            self.add_option(self.__chardev_for_go.get_option())
            self.add_option(self.__serial_for_go.get_option())
Beispiel #15
0
    def handle_parms(self):
        self.add_option("-vnc :{}".format(self.__display))
        self.add_option("-name {}".format(self.get_task_name()))
        self.add_option("-device sga")

        if self.__enable_kvm:
            self.add_option("--enable-kvm")

        if self.__smbios:
            self.add_option("-smbios file={}".format(self.__smbios))

        if self.__bios:
            self.add_option("-bios {}".format(self.__bios))

        if self.__mem_path:
            self.add_option("-mem-path {}".format(self.__mem_path))

        if self.__extra_option:
            self.add_option(self.__extra_option)

        boot_param = []
        if self.__boot_order:
            bootdev_path = self.get_workspace() + '/bootdev'
            if os.path.exists(bootdev_path) is True:
                with open(bootdev_path, "r") as f:
                    boot_param = f.readlines()
                boot_param[0] = boot_param[0].strip()
                if boot_param[0] == "default":
                    self.__boot_order = "c"
                elif boot_param[0] == "pxe":
                    self.__boot_order = "n"
                elif boot_param[0] == "cdrom":
                    self.__boot_order = "d"
                else:
                    self.__boot_order = "ncd"
                boot_param.append("order={}".format(self.__boot_order))
            else:
                boot_param.append("order={}".format(self.__boot_order))
        if self.__boot_menu:
            boot_param.append("menu={}".format(self.__boot_menu))
        if self.__boot_splash_name:
            boot_param.append("splash={}".format(self.__boot_splash_name))
        if self.__boot_splash_time:
            boot_param.append("splash-time={}".format(self.__boot_splash_time))
        tmp = ","
        self.add_option("-boot {}".format(tmp.join(boot_param)))

        machine_option = "-machine q35,usb=off,vmport=off"
        if self.__iommu:
            machine_option = ",".join([machine_option, "iommu=on"])
        self.add_option(machine_option)

        if self.__cdrom_file:
            self.add_option("-cdrom {}".format(self.__cdrom_file))

        if self.__socket_serial and self.__sol_enabled:
            chardev = CCharDev({
                "backend": "socket",
                "path": self.__socket_serial,
                "wait": "off"
            })
            chardev.logger = self.logger
            chardev.set_id("serial0")
            chardev.init()
            chardev.handle_parms()

            self.add_option(chardev.get_option())
            self.add_option("-device isa-serial,chardev={}".format(chardev.get_id()))

        self.add_option("-uuid {}".format(str(uuid.uuid4())))

        if self.__kernel and self.__initrd:
            self.add_option("-kernel {} -initrd {}".format(self.__kernel, self.__initrd))

        if self.__cmdline:
            self.add_option("--append \"{}\"".format(self.__cmdline))

        for element_obj in self.__element_list:
            element_obj.handle_parms()
Beispiel #16
0
class CMonitor(CElement):
    def __init__(self, monitor_info):
        super(CMonitor, self).__init__()
        self.__monitor = monitor_info
        self.__chardev = None
        self.__mode = "readline"
        self.__workspace = ""
        self.__monitor_handle = None

    def get_workspace(self):
        return self.__workspace

    def set_workspace(self, ws):
        self.__workspace = ws

    def precheck(self):
        if self.__mode not in ["readline", "control"]:
            raise ArgsNotCorrect("[Monitor] Invalid monitor mode: {}".format(self.__mode))

        self.__chardev.precheck()

        # Monitor specific chardev attribution
        if self.__monitor["chardev"]["backend"] != "socket":
            raise ArgsNotCorrect("[Monitor] Invalid monitor chardev backend: {}".
                                 format(self.__monitor["chardev"]["backend"]))
        if self.__monitor["chardev"]["server"] is not True:
            raise ArgsNotCorrect("[Monitor] Invalid monitor chardev server: {}".
                                 format(self.__monitor["chardev"]["server"]))
        if self.__monitor["chardev"]["wait"] is not False:
            raise ArgsNotCorrect("[Monitor] Invalid monitor chardev wait: {}".
                                 format(self.__monitor["chardev"]["wait"]))


    def init(self):
        self.__mode = self.__monitor.get("mode", "readline")
        chardev_info = {}
        if self.__mode == "readline":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "host" not in chardev_info:
                chardev_info["host"] = "127.0.0.1"
            if "port" not in chardev_info:
                chardev_info["port"] = 2345
        elif self.__mode == "control":
            chardev_info = self.__monitor.get("chardev", {})
            if "backend" not in chardev_info:
                chardev_info["backend"] = "socket"
            if "server" not in chardev_info:
                chardev_info["server"] = True
            if "wait" not in chardev_info:
                chardev_info["wait"] = False
            if "path" not in chardev_info:
                if self.get_workspace():
                    chardev_path = os.path.join(self.get_workspace(), ".monitor")
                else:
                    chardev_path = os.path.join(config.infrasim_etc, ".monitor")
                chardev_info["path"] = chardev_path
        else:
            pass

        self.__monitor["chardev"] = chardev_info
        self.__chardev = CCharDev(chardev_info)
        self.__chardev.logger = self.logger
        self.__chardev.set_id("monitorchardev")
        self.__chardev.init()

    def handle_parms(self):
        self.__chardev.handle_parms()
        self.add_option(self.__chardev.get_option())
        self.add_option("-mon chardev={},mode={}".format(self.__chardev.get_id(), self.__mode))

    def get_mode(self):
        return self.__mode

    def open(self):
        if self.__mode == "readline":
            self.__monitor_handle = Telnet(self.__chardev.host, self.__chardev.port)
        elif self.__mode == "control":
            self.__monitor_handle = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            self.__monitor_handle.connect(self.__chardev.get_path())

            # enable qmp capabilities
            qmp_payload = {
                "execute": "qmp_capabilities"
            }
            self.send(qmp_payload)
        else:
            raise ArgsNotCorrect("[Monitor] Monitor mode {} is unknown.".format(self.__mode))
        self.logger.info("[Monitor] monitor opened({}).".format(self.__monitor_handle))

    def send(self, command):
        if self.__monitor_handle:
            self.logger.info("[Monitor] send command {}".format(command))
            if self.__mode == "readline":
                self.__monitor_handle.write(command)
            else:
                self.__monitor_handle.send(json.dumps(command))

    def close(self):
        if self.__monitor_handle:
            self.__monitor_handle.close()
            self.logger.info("[Monitor] monitor closed.")
Beispiel #17
0
class QTrace(CElement):
    def __init__(self, trace_settings, workspace):
        super(QTrace, self).__init__()
        self.__seabios_out = trace_settings.get("seabios")
        self.__guest_out = trace_settings.get("guest")

        self.__chardev_for_so = None

        self.__chardev_for_go = None
        self.__serial_for_go = None
        self.__node_name = workspace.split('/')[-1]

    def precheck(self):
        pass

    def init(self):
        if self.__seabios_out == "on":
            self.__chardev_for_so = CCharDev({
                "backend":
                "file",
                "path":
                os.path.join(config.infrasim_log_dir, self.__node_name,
                             "seabios.log"),
            })
            self.__chardev_for_so.set_id("seabios")
            self.__chardev_for_so.init()

        if self.__guest_out == "on":
            self.__chardev_for_go = CCharDev({
                "backend":
                "file",
                "path":
                os.path.join(config.infrasim_log_dir, self.__node_name,
                             "guest.log")
            })

            self.__chardev_for_go.set_id("guest")
            self.__chardev_for_go.init()

            self.__serial_for_go = CSerial(self.__chardev_for_go,
                                           {"index": "0"})
            self.__serial_for_go.init()

    def handle_parms(self):
        if self.__chardev_for_so:
            self.__chardev_for_so.handle_parms()
            self.add_option(
                "{} -device isa-debugcon,iobase=0x402,chardev=seabios".format(
                    self.__chardev_for_so.get_option()))

        if self.__chardev_for_go and self.__serial_for_go:
            self.__chardev_for_go.handle_parms()
            self.__serial_for_go.handle_parms()
            self.add_option(self.__chardev_for_go.get_option())
            self.add_option(self.__serial_for_go.get_option())
Beispiel #18
0
    def handle_parms(self):
        self.add_option("-vnc :{}".format(self.__display))
        self.add_option("-name {}".format(self.get_task_name()))
        if self.__sol_enabled:
            self.add_option("-device sga")

        if self.__enable_kvm:
            self.add_option("--enable-kvm")

        if self.__smbios:
            self.add_option("-smbios file={}".format(self.__smbios))

        if self.__bios:
            self.add_option("-bios {}".format(self.__bios))

        if self.__mem_path:
            self.add_option("-mem-path {}".format(self.__mem_path))

        if self.__extra_option:
            self.add_option(self.__extra_option)

        boot_param = []
        if self.__boot_order:
            bootdev_path = self.get_workspace() + '/bootdev'
            if os.path.exists(bootdev_path) is True:
                with open(bootdev_path, "r") as f:
                    boot_param = f.readlines()
                boot_param[0] = boot_param[0].strip()
                if boot_param[0] == "default":
                    self.__boot_order = "c"
                elif boot_param[0] == "pxe":
                    self.__boot_order = "n"
                elif boot_param[0] == "cdrom":
                    self.__boot_order = "d"
                else:
                    self.__boot_order = "ncd"
                boot_param.append("order={}".format(self.__boot_order))
            else:
                boot_param.append("order={}".format(self.__boot_order))
        if self.__boot_menu:
            boot_param.append("menu={}".format(self.__boot_menu))
        if self.__boot_splash_name:
            boot_param.append("splash={}".format(self.__boot_splash_name))
        if self.__boot_splash_time:
            boot_param.append("splash-time={}".format(self.__boot_splash_time))
        tmp = ","
        self.add_option("-boot {}".format(tmp.join(boot_param)))

        if self.__cdrom_file:
            self.add_option("-cdrom {}".format(self.__cdrom_file))

        if self.__socket_serial and self.__sol_enabled:
            chardev = CCharDev({
                "backend": "socket",
                "path": self.__socket_serial,
                "wait": "off"
            })
            chardev.logger = self.logger
            chardev.set_id("serial0")
            chardev.init()
            chardev.handle_parms()

            self.add_option(chardev.get_option())
            self.add_option("-device isa-serial,chardev={}".format(
                chardev.get_id()))

        self.add_option("-uuid {}".format(str(uuid.uuid4())))

        if self.__kernel and self.__initrd:
            self.add_option("-kernel {} -initrd {}".format(
                self.__kernel, self.__initrd))

        if self.__cmdline:
            self.add_option("--append \"{}\"".format(self.__cmdline))

        if self.__shm_key:
            self.add_option("-communicate shmkey={}".format(self.__shm_key))

        for element_obj in self.__element_list:
            element_obj.handle_parms()
Beispiel #19
0
    def handle_parms(self):
        self.add_option("-vnc :{}".format(self.__display))
        self.add_option("-name {}".format(self.get_task_name()))
        if self.__sol_enabled:
            self.add_option("-device sga")

        if self.__enable_kvm:
            self.add_option("--enable-kvm")

        self.add_option("-uuid {}".format(self.__uuid))

        if self.__smbios:
            self.add_option("-smbios file={}".format(self.__smbios))

        if self.__bios:
            self.add_option("-bios {}".format(self.__bios))

        if self.__mem_path:
            self.add_option("-mem-path {}".format(self.__mem_path))

        if self.__extra_option:
            self.add_option(self.__extra_option)

        boot_param = []
        if self.__boot_order:
            bootdev_path = self.get_workspace() + '/bootdev'
            if os.path.exists(bootdev_path) is True:
                with open(bootdev_path, "r") as f:
                    boot_param = f.readlines()
                boot_param[0] = boot_param[0].strip()
                if boot_param[0] == "default":
                    self.__boot_order = "c"
                elif boot_param[0] == "pxe":
                    self.__boot_order = "n"
                elif boot_param[0] == "cdrom":
                    self.__boot_order = "d"
                else:
                    self.__boot_order = "ncd"
                boot_param.append("order={}".format(self.__boot_order))
            else:
                boot_param.append("order={}".format(self.__boot_order))
        if self.__boot_menu:
            boot_param.append("menu={}".format(self.__boot_menu))
        if self.__boot_splash_name:
            boot_param.append("splash={}".format(self.__boot_splash_name))
        if self.__boot_splash_time:
            boot_param.append("splash-time={}".format(self.__boot_splash_time))
        tmp = ","
        self.add_option("-boot {}".format(tmp.join(boot_param)))

        if self.__socket_serial and self.__sol_enabled:
            chardev = CCharDev({
                "backend": "socket",
                "path": self.__socket_serial,
                "wait": "off"
            })
            chardev.logger = self.logger
            chardev.set_id("serial0")
            chardev.init()
            chardev.precheck()
            chardev.handle_parms()
            self.add_option(chardev.get_option())

            # serial index 0 must be used for SOL
            serial_obj = CSerial(chardev, {"index": 0})
            serial_obj.init()
            serial_obj.precheck()
            serial_obj.handle_parms()
            self.add_option(serial_obj.get_option())

        if self.__kernel and self.__initrd:
            self.add_option("-kernel {} -initrd {}".format(self.__kernel, self.__initrd))

        if self.__cmdline:
            self.add_option("--append \"{}\"".format(self.__cmdline))

        if self.__shm_key:
            self.add_option("-communicate shmkey={}".format(self.__shm_key))

        for element_obj in self.__element_list:
            element_obj.handle_parms()