Esempio n. 1
0
    def __init__(self, name, *args, **kwargs):

        # get the VPCS location
        config = Config.instance()
        vpcs_config = config.get_section_config(name.upper())
        self._vpcs = vpcs_config.get("vpcs_path")
        if not self._vpcs or not os.path.isfile(self._vpcs):
            paths = [os.getcwd()] + os.environ["PATH"].split(os.pathsep)
            # look for VPCS in the current working directory and $PATH
            for path in paths:
                try:
                    if "vpcs" in os.listdir(path) and os.access(os.path.join(path, "vpcs"), os.X_OK):
                        self._vpcs = os.path.join(path, "vpcs")
                        break
                except OSError:
                    continue

        if not self._vpcs:
            log.warning("VPCS binary couldn't be found!")
        elif not os.access(self._vpcs, os.X_OK):
            log.warning("VPCS is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._vpcs_instances = {}
        self._console_start_port_range = vpcs_config.get("console_start_port_range", 4501)
        self._console_end_port_range = vpcs_config.get("console_end_port_range", 5000)
        self._allocated_udp_ports = []
        self._udp_start_port_range = vpcs_config.get("udp_start_port_range", 20501)
        self._udp_end_port_range = vpcs_config.get("udp_end_port_range", 21000)
        self._host = vpcs_config.get("host", kwargs["host"])
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
Esempio n. 2
0
    def __init__(self, name, *args, **kwargs):
        config = Config.instance()

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._host = kwargs["host"]
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._heartbeat_file = "%s/heartbeat_file_for_gnsdms" % (
            self._tempdir)

        if 'heartbeat_file' in kwargs:
            self._heartbeat_file = kwargs['heartbeat_file']

        self._is_enabled = False
        try:
            cloud_config = Config.instance().get_section_config("CLOUD_SERVER")
            instance_id = cloud_config["instance_id"]
            cloud_user_name = cloud_config["cloud_user_name"]
            cloud_api_key = cloud_config["cloud_api_key"]
            self._is_enabled = True
        except KeyError:
            log.critical("Missing cloud.conf - disabling Deadman Switch")

        self._deadman_process = None
        self.heartbeat()
        self.start()
Esempio n. 3
0
    def __init__(self, name, *args, **kwargs):

        # get the VPCS location
        config = Config.instance()
        vpcs_config = config.get_section_config(name.upper())
        self._vpcs = vpcs_config.get("vpcs_path")
        if not self._vpcs or not os.path.isfile(self._vpcs):
            paths = [os.getcwd()] + os.environ["PATH"].split(os.pathsep)
            # look for VPCS in the current working directory and $PATH
            for path in paths:
                try:
                    if "vpcs" in os.listdir(path) and os.access(os.path.join(path, "vpcs"), os.X_OK):
                        self._vpcs = os.path.join(path, "vpcs")
                        break
                except OSError:
                    continue

        if not self._vpcs:
            log.warning("VPCS binary couldn't be found!")
        elif not os.access(self._vpcs, os.X_OK):
            log.warning("VPCS is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._vpcs_instances = {}
        self._console_start_port_range = vpcs_config.get("console_start_port_range", 4501)
        self._console_end_port_range = vpcs_config.get("console_end_port_range", 5000)
        self._allocated_udp_ports = []
        self._udp_start_port_range = vpcs_config.get("udp_start_port_range", 20501)
        self._udp_end_port_range = vpcs_config.get("udp_end_port_range", 21000)
        self._host = vpcs_config.get("host", kwargs["host"])
        self._console_host = vpcs_config.get("console_host", kwargs["console_host"])
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
Esempio n. 4
0
    def __init__(self, name, *args, **kwargs):
        config = Config.instance()

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._host = kwargs["host"]
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._heartbeat_file = "%s/heartbeat_file_for_gnsdms" % (self._tempdir)

        if 'heartbeat_file' in kwargs:
            self._heartbeat_file = kwargs['heartbeat_file']

        self._is_enabled = False
        try:
            cloud_config = Config.instance().get_section_config("CLOUD_SERVER")
            instance_id = cloud_config["instance_id"]
            cloud_user_name = cloud_config["cloud_user_name"]
            cloud_api_key = cloud_config["cloud_api_key"]
            self._is_enabled = True
        except KeyError:
            log.critical("Missing cloud.conf - disabling Deadman Switch")

        self._deadman_process = None
        self.heartbeat()
        self.start()
Esempio n. 5
0
    def stop(self):
        """
        Properly stops the module.
        """

        #if not sys.platform.startswith("win32"):
        #    self._callback.stop()
        if self._hypervisor_manager:
            self._hypervisor_manager.stop_all_hypervisors()
        IModule.stop(self)  # this will stop the I/O loop
Esempio n. 6
0
    def stop(self):
        """
        Properly stops the module.
        """

        # delete all IOU instances
        for iou_id in self._iou_instances:
            iou_instance = self._iou_instances[iou_id]
            iou_instance.delete()

        IModule.stop(self)  # this will stop the I/O loop
Esempio n. 7
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        # delete all QEMU instances
        for qemu_id in self._qemu_instances:
            qemu_instance = self._qemu_instances[qemu_id]
            qemu_instance.delete()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 8
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        # delete all QEMU instances
        for qemu_id in self._qemu_instances:
            qemu_instance = self._qemu_instances[qemu_id]
            qemu_instance.delete()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 9
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        # delete all VPCS instances
        for vpcs_id in self._vpcs_instances:
            vpcs_instance = self._vpcs_instances[vpcs_id]
            vpcs_instance.delete()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 10
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        # delete all VPCS instances
        for vpcs_id in self._vpcs_instances:
            vpcs_instance = self._vpcs_instances[vpcs_id]
            vpcs_instance.delete()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 11
0
    def __init__(self, name, *args, **kwargs):

        # get the vboxmanage location
        self._vboxmanage_path = None
        if sys.platform.startswith("win"):
            if "VBOX_INSTALL_PATH" in os.environ:
                self._vboxmanage_path = os.path.join(os.environ["VBOX_INSTALL_PATH"], "VBoxManage.exe")
            elif "VBOX_MSI_INSTALL_PATH" in os.environ:
                self._vboxmanage_path = os.path.join(os.environ["VBOX_MSI_INSTALL_PATH"], "VBoxManage.exe")
        elif sys.platform.startswith("darwin"):
            self._vboxmanage_path = "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
        else:
            config = Config.instance()
            vbox_config = config.get_section_config(name.upper())
            self._vboxmanage_path = vbox_config.get("vboxmanage_path")
            if not self._vboxmanage_path or not os.path.isfile(self._vboxmanage_path):
                paths = [os.getcwd()] + os.environ["PATH"].split(os.pathsep)
                # look for vboxmanage in the current working directory and $PATH
                for path in paths:
                    try:
                        if "vboxmanage" in [s.lower() for s in os.listdir(path)] and os.access(
                            os.path.join(path, "vboxmanage"), os.X_OK
                        ):
                            self._vboxmanage_path = os.path.join(path, "vboxmanage")
                            break
                    except OSError:
                        continue

        if not self._vboxmanage_path:
            log.warning("vboxmanage couldn't be found!")
        elif not os.access(self._vboxmanage_path, os.X_OK):
            log.warning("vboxmanage is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._vbox_instances = {}

        config = Config.instance()
        vbox_config = config.get_section_config(name.upper())
        self._console_start_port_range = vbox_config.get("console_start_port_range", 3501)
        self._console_end_port_range = vbox_config.get("console_end_port_range", 4000)
        self._allocated_udp_ports = []
        self._udp_start_port_range = vbox_config.get("udp_start_port_range", 35001)
        self._udp_end_port_range = vbox_config.get("udp_end_port_range", 35500)
        self._host = vbox_config.get("host", kwargs["host"])
        self._console_host = vbox_config.get("console_host", kwargs["console_host"])
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
Esempio n. 12
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        # delete all VirtualBox instances
        for vbox_id in self._vbox_instances:
            vbox_instance = self._vbox_instances[vbox_id]
            vbox_instance.delete()

        if self._vboxwrapper and self._vboxwrapper.started:
            self._vboxwrapper.stop()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 13
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        # delete all VirtualBox instances
        for vbox_id in self._vbox_instances:
            vbox_instance = self._vbox_instances[vbox_id]
            vbox_instance.delete()

        if self._vboxwrapper and self._vboxwrapper.started:
            self._vboxwrapper.stop()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 14
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        # delete all VirtualBox instances
        for vbox_id in self._vbox_instances:
            vbox_instance = self._vbox_instances[vbox_id]
            try:
                vbox_instance.delete()
            except VirtualBoxError:
                continue

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 15
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        if not sys.platform.startswith("win32"):
            self._callback.stop()

        # stop all Dynamips hypervisors
        if self._hypervisor_manager:
            self._hypervisor_manager.stop_all_hypervisors()

        self.delete_dynamips_files()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 16
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        if self._deadman_process == None:
            log.info("Deadman: Can't stop, is not currently running")

        log.debug("Deadman: Stopping process")

        self._deadman_process = self._stop_deadman_process()
        self._deadman_process = None
        #Jerry or Jeremy why do we do this? Won't this stop the I/O loop for
        #for everyone?
        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 17
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        self._iou_callback.stop()

        # delete all IOU instances
        for iou_id in self._iou_instances:
            iou_instance = self._iou_instances[iou_id]
            iou_instance.delete()

        self.delete_iourc_file()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 18
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        if self._deadman_process == None:
            log.info("Deadman: Can't stop, is not currently running")

        log.debug("Deadman: Stopping process")

        self._deadman_process = self._stop_deadman_process()
        self._deadman_process = None
        #Jerry or Jeremy why do we do this? Won't this stop the I/O loop for
        #for everyone?
        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 19
0
    def __init__(self, name, *args, **kwargs):

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._qemu_instances = {}

        config = Config.instance()
        qemu_config = config.get_section_config(name.upper())
        self._console_start_port_range = qemu_config.get("console_start_port_range", 5001)
        self._console_end_port_range = qemu_config.get("console_end_port_range", 5500)
        self._allocated_udp_ports = []
        self._udp_start_port_range = qemu_config.get("udp_start_port_range", 40001)
        self._udp_end_port_range = qemu_config.get("udp_end_port_range", 45500)
        self._host = qemu_config.get("host", kwargs["host"])
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
Esempio n. 20
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        self._iou_callback.stop()

        # delete all IOU instances
        for iou_id in self._iou_instances:
            iou_instance = self._iou_instances[iou_id]
            iou_instance.delete()

        self.delete_iourc_file()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 21
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        if not sys.platform.startswith("win32"):
            self._callback.stop()

        # stop all Dynamips hypervisors
        if self._hypervisor_manager:
            self._hypervisor_manager.stop_all_hypervisors()

        self.delete_dynamips_files()

        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 22
0
    def __init__(self, name, *args, **kwargs):

        # get the iouyap location
        config = Config.instance()
        iou_config = config.get_section_config(name.upper())
        self._iouyap = iou_config.get("iouyap_path")
        if not self._iouyap or not os.path.isfile(self._iouyap):
            paths = [os.getcwd()] + os.environ["PATH"].split(os.pathsep)
            # look for iouyap in the current working directory and $PATH
            for path in paths:
                try:
                    if "iouyap" in os.listdir(path) and os.access(
                            os.path.join(path, "iouyap"), os.X_OK):
                        self._iouyap = os.path.join(path, "iouyap")
                        break
                except OSError:
                    continue

        if not self._iouyap:
            log.warning("iouyap binary couldn't be found!")
        elif not os.access(self._iouyap, os.X_OK):
            log.warning("iouyap is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._iou_instances = {}
        self._console_start_port_range = iou_config.get(
            "console_start_port_range", 4001)
        self._console_end_port_range = iou_config.get("console_end_port_range",
                                                      4500)
        self._allocated_udp_ports = []
        self._udp_start_port_range = iou_config.get("udp_start_port_range",
                                                    30001)
        self._udp_end_port_range = iou_config.get("udp_end_port_range", 35000)
        self._host = iou_config.get("host", kwargs["host"])
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._iourc = ""

        # check every 5 seconds
        self._iou_callback = self.add_periodic_callback(
            self._check_iou_is_alive, 5000)
        self._iou_callback.start()
Esempio n. 23
0
    def __init__(self, name, *args, **kwargs):

        # get the iouyap location
        config = Config.instance()
        iou_config = config.get_section_config(name.upper())
        self._iouyap = iou_config.get("iouyap")
        if not self._iouyap or not os.path.isfile(self._iouyap):
            iouyap_in_cwd = os.path.join(os.getcwd(), "iouyap")
            if os.path.isfile(iouyap_in_cwd):
                self._iouyap = iouyap_in_cwd
            else:
                # look for iouyap if none is defined or accessible
                for path in os.environ["PATH"].split(":"):
                    try:
                        if "iouyap" in os.listdir(path) and os.access(os.path.join(path, "iouyap"), os.X_OK):
                            self._iouyap = os.path.join(path, "iouyap")
                            break
                    except OSError:
                        continue

        if not self._iouyap:
            log.warning("iouyap binary couldn't be found!")
        elif not os.access(self._iouyap, os.X_OK):
            log.warning("iouyap is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._iou_instances = {}
        self._console_start_port_range = 4001
        self._console_end_port_range = 4512
        self._allocated_udp_ports = []
        self._udp_start_port_range = 30001
        self._udp_end_port_range = 40001
        self._host = kwargs["host"]
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._iourc = ""

        # check every 5 seconds
        self._iou_callback = self.add_periodic_callback(self._check_iou_is_alive, 5000)
        self._iou_callback.start()
Esempio n. 24
0
    def __init__(self, name, *args, **kwargs):

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._qemu_instances = {}

        config = Config.instance()
        qemu_config = config.get_section_config(name.upper())
        self._console_start_port_range = qemu_config.get(
            "console_start_port_range", 5001)
        self._console_end_port_range = qemu_config.get(
            "console_end_port_range", 5500)
        self._allocated_udp_ports = []
        self._udp_start_port_range = qemu_config.get("udp_start_port_range",
                                                     40001)
        self._udp_end_port_range = qemu_config.get("udp_end_port_range", 45500)
        self._host = qemu_config.get("host", kwargs["host"])
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
Esempio n. 25
0
    def __init__(self, name, *args, **kwargs):

        # get the Dynamips location
        config = Config.instance()
        dynamips_config = config.get_section_config(name.upper())
        self._dynamips = dynamips_config.get("dynamips_path")
        if not self._dynamips or not os.path.isfile(self._dynamips):
            paths = [os.getcwd()] + os.environ["PATH"].split(os.pathsep)
            # look for Dynamips in the current working directory and $PATH
            for path in paths:
                try:
                    if "dynamips" in os.listdir(path) and os.access(
                            os.path.join(path, "dynamips"), os.X_OK):
                        self._dynamips = os.path.join(path, "dynamips")
                        break
                except OSError:
                    continue

        if not self._dynamips:
            log.warning("dynamips binary couldn't be found!")
        elif not os.access(self._dynamips, os.X_OK):
            log.warning("dynamips is not executable")

        IModule.__init__(self, name, *args, **kwargs)
        self._hypervisor_manager = None
        self._hypervisor_manager_settings = {}
        self._routers = {}
        self._ethernet_switches = {}
        self._frame_relay_switches = {}
        self._atm_switches = {}
        self._ethernet_hubs = {}
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._host = dynamips_config.get("host", kwargs["host"])

        if not sys.platform.startswith("win32"):
            #FIXME: pickle issues Windows
            self._callback = self.add_periodic_callback(
                self._check_hypervisors, 5000)
            self._callback.start()
Esempio n. 26
0
    def __init__(self, name, *args, **kwargs):

        IModule.__init__(self, name, *args, **kwargs)

        self._hypervisor_manager = None
        self._hypervisor_manager_settings = {}
        self._routers = {}
        self._ethernet_switches = {}
        self._frame_relay_switches = {}
        self._atm_switches = {}
        self._ethernet_hubs = {}
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._dynamips = ""
        self._host = kwargs["host"]

        if not sys.platform.startswith("win32"):
            #FIXME: pickle issues Windows
            self._callback = self.add_periodic_callback(self._check_hypervisors, 5000)
            self._callback.start()
Esempio n. 27
0
    def stop(self, signum=None):
        """
        Properly stops the module.

        :param signum: signal number (if called by the signal handler)
        """

        if not sys.platform.startswith("win32"):
            self._callback.stop()

        # automatically save configs for all router instances
        for router_id in self._routers:
            router = self._routers[router_id]
            router.save_configs()

        # stop all Dynamips hypervisors
        if self._hypervisor_manager:
            self._hypervisor_manager.stop_all_hypervisors()

        self.delete_dynamips_files()
        IModule.stop(self, signum)  # this will stop the I/O loop
Esempio n. 28
0
    def __init__(self, name, *args, **kwargs):

        # get the Dynamips location
        config = Config.instance()
        dynamips_config = config.get_section_config(name.upper())
        self._dynamips = dynamips_config.get("dynamips_path")
        if not self._dynamips or not os.path.isfile(self._dynamips):
            paths = [os.getcwd()] + os.environ["PATH"].split(os.pathsep)
            # look for Dynamips in the current working directory and $PATH
            for path in paths:
                try:
                    if "dynamips" in os.listdir(path) and os.access(os.path.join(path, "dynamips"), os.X_OK):
                        self._dynamips = os.path.join(path, "dynamips")
                        break
                except OSError:
                    continue

        if not self._dynamips:
            log.warning("dynamips binary couldn't be found!")
        elif not os.access(self._dynamips, os.X_OK):
            log.warning("dynamips is not executable")

        IModule.__init__(self, name, *args, **kwargs)
        self._hypervisor_manager = None
        self._hypervisor_manager_settings = {}
        self._routers = {}
        self._ethernet_switches = {}
        self._frame_relay_switches = {}
        self._atm_switches = {}
        self._ethernet_hubs = {}
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._host = dynamips_config.get("host", kwargs["host"])
        self._console_host = dynamips_config.get("console_host", kwargs["console_host"])

        if not sys.platform.startswith("win32"):
            #FIXME: pickle issues Windows
            self._callback = self.add_periodic_callback(self._check_hypervisors, 5000)
            self._callback.start()
Esempio n. 29
0
    def __init__(self, name, *args, **kwargs):

        # get the vboxwrapper location (only non-Windows platforms)
        if not sys.platform.startswith("win"):
            config = Config.instance()
            vbox_config = config.get_section_config(name.upper())
            self._vboxwrapper_path = vbox_config.get("vboxwrapper_path")
            if not self._vboxwrapper_path or not os.path.isfile(self._vboxwrapper_path):
                paths = [os.getcwd()] + os.environ["PATH"].split(":")
                # look for iouyap in the current working directory and $PATH
                for path in paths:
                    try:
                        if "vboxwrapper" in os.listdir(path) and os.access(os.path.join(path, "vboxwrapper"), os.X_OK):
                            self._vboxwrapper_path = os.path.join(path, "vboxwrapper")
                            break
                    except OSError:
                        continue

            if not self._vboxwrapper_path:
                log.warning("vboxwrapper couldn't be found!")
            elif not os.access(self._vboxwrapper_path, os.X_OK):
                log.warning("vboxwrapper is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._vbox_instances = {}

        config = Config.instance()
        vbox_config = config.get_section_config(name.upper())
        self._console_start_port_range = vbox_config.get("console_start_port_range", 3501)
        self._console_end_port_range = vbox_config.get("console_end_port_range", 4000)
        self._allocated_udp_ports = []
        self._udp_start_port_range = vbox_config.get("udp_start_port_range", 35001)
        self._udp_end_port_range = vbox_config.get("udp_end_port_range", 35500)
        self._host = kwargs["host"]
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._vboxmanager = None
        self._vboxwrapper = None
Esempio n. 30
0
    def __init__(self, name, *args, **kwargs):

        # get the vboxwrapper location (only non-Windows platforms)
        if not sys.platform.startswith("win"):
            config = Config.instance()
            vbox_config = config.get_section_config(name.upper())
            self._vboxwrapper_path = vbox_config.get("vboxwrapper_path")
            if not self._vboxwrapper_path or not os.path.isfile(self._vboxwrapper_path):
                paths = [os.getcwd()] + os.environ["PATH"].split(os.pathsep)
                # look for vboxwrapper in the current working directory and $PATH
                for path in paths:
                    try:
                        if "vboxwrapper" in os.listdir(path) and os.access(os.path.join(path, "vboxwrapper"), os.X_OK):
                            self._vboxwrapper_path = os.path.join(path, "vboxwrapper")
                            break
                    except OSError:
                        continue

            if not self._vboxwrapper_path:
                log.warning("vboxwrapper couldn't be found!")
            elif not os.access(self._vboxwrapper_path, os.X_OK):
                log.warning("vboxwrapper is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._vbox_instances = {}

        config = Config.instance()
        vbox_config = config.get_section_config(name.upper())
        self._console_start_port_range = vbox_config.get("console_start_port_range", 3501)
        self._console_end_port_range = vbox_config.get("console_end_port_range", 4000)
        self._allocated_udp_ports = []
        self._udp_start_port_range = vbox_config.get("udp_start_port_range", 35001)
        self._udp_end_port_range = vbox_config.get("udp_end_port_range", 35500)
        self._host = vbox_config.get("host", kwargs["host"])
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._vboxmanager = None
        self._vboxwrapper = None
Esempio n. 31
0
    def __init__(self, name, *args, **kwargs):

        # get the VPCS location
        config = Config.instance()
        vpcs_config = config.get_section_config(name.upper())
        self._vpcs = vpcs_config.get("vpcs")
        if not self._vpcs or not os.path.isfile(self._vpcs):
            vpcs_in_cwd = os.path.join(os.getcwd(), "vpcs")
            if os.path.isfile(vpcs_in_cwd):
                self._vpcs = vpcs_in_cwd
            else:
                # look for vpcs if none is defined or accessible
                for path in os.environ["PATH"].split(":"):
                    try:
                        if "vpcs" in os.listdir(path) and os.access(os.path.join(path, "vpcs"), os.X_OK):
                            self._vpcs = os.path.join(path, "vpcs")
                            break
                    except OSError:
                        continue

        if not self._vpcs:
            log.warning("VPCS binary couldn't be found!")
        elif not os.access(self._vpcs, os.X_OK):
            log.warning("VPCS is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._vpcs_instances = {}
        self._console_start_port_range = 4001
        self._console_end_port_range = 4512
        self._allocated_console_ports = []
        self._current_console_port = self._console_start_port_range
        self._udp_start_port_range = 30001
        self._udp_end_port_range = 40001
        self._current_udp_port = self._udp_start_port_range
        self._host = kwargs["host"]
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
Esempio n. 32
0
    def __init__(self, name, *args, **kwargs):

        # get the iouyap location
        config = Config.instance()
        iou_config = config.get_section_config(name.upper())
        self._iouyap = iou_config.get("iouyap")
        if not self._iouyap:
            for path in os.environ["PATH"].split(":"):
                if "iouyap" in os.listdir(path) and os.access("iouyap", os.X_OK):
                    self._iouyap = os.path.join(path, "iouyap")
                    break

        if not self._iouyap or not os.path.exists(self._iouyap):
            raise IOUError("iouyap binary couldn't be found!")

        if not os.access(self._iouyap, os.X_OK):
            raise IOUError("iouyap is not executable")

        # a new process start when calling IModule
        IModule.__init__(self, name, *args, **kwargs)
        self._remote_server = False
        self._iou_instances = {}
        self._console_start_port_range = 4001
        self._console_end_port_range = 4512
        self._current_console_port = self._console_start_port_range
        self._udp_start_port_range = 30001
        self._udp_end_port_range = 40001
        self._current_udp_port = self._udp_start_port_range
        self._host = "127.0.0.1"  # FIXME: used by ZeroMQ...
        self._projects_dir = kwargs["projects_dir"]
        self._tempdir = kwargs["temp_dir"]
        self._working_dir = self._projects_dir
        self._iourc = ""

        # check every 5 seconds
        self._iou_callback = self.add_periodic_callback(self._check_iou_is_alive, 5000)
        self._iou_callback.start()