def test_get_handler(self):
     osutil.get_osutil()
     protocol.get_protocol_util()
     dhcp.get_dhcp_handler()
     provision.get_provision_handler()
     deprovision.get_deprovision_handler()
     daemon.get_daemon_handler()
     resourcedisk.get_resourcedisk_handler()
     scvmm.get_scvmm_handler()
     monitor.get_monitor_handler()
     update.get_update_handler()
     exthandlers.get_exthandlers_handler()
 def test_get_handler(self):
     osutil.get_osutil()
     protocol.get_protocol_util()
     dhcp.get_dhcp_handler()
     provision.get_provision_handler()
     deprovision.get_deprovision_handler()
     daemon.get_daemon_handler()
     resourcedisk.get_resourcedisk_handler()
     scvmm.get_scvmm_handler()
     monitor.get_monitor_handler()
     update.get_update_handler()
     exthandlers.get_exthandlers_handler()
Exemple #3
0
    def daemon(self, child_args=None):
        logger.info("Run daemon")

        self.protocol_util = get_protocol_util() # pylint: disable=W0201
        self.scvmm_handler = get_scvmm_handler() # pylint: disable=W0201
        self.resourcedisk_handler = get_resourcedisk_handler() # pylint: disable=W0201
        self.rdma_handler = get_rdma_handler() # pylint: disable=W0201
        self.provision_handler = get_provision_handler() # pylint: disable=W0201
        self.update_handler = get_update_handler() # pylint: disable=W0201

        if conf.get_detect_scvmm_env():
            self.scvmm_handler.run()

        if conf.get_resourcedisk_format():
            self.resourcedisk_handler.run()

        # Always redetermine the protocol start (e.g., wireserver vs.
        # on-premise) since a VHD can move between environments
        self.protocol_util.clear_protocol()

        self.provision_handler.run()

        # Once we have the protocol, complete initialization of the telemetry fields
        # that require the goal state and IMDS
        self._initialize_telemetry()

        # Enable RDMA, continue in errors
        if conf.enable_rdma():
            nd_version = self.rdma_handler.get_rdma_version()
            self.rdma_handler.install_driver_if_needed()

            logger.info("RDMA capabilities are enabled in configuration")
            try:
                # Ensure the most recent SharedConfig is available
                # - Changes to RDMA state may not increment the goal state
                #   incarnation number. A forced update ensures the most
                #   current values.
                protocol = self.protocol_util.get_protocol()
                if type(protocol) is not WireProtocol: # pylint: disable=C0123
                    raise Exception("Attempt to setup RDMA without Wireserver")

                protocol.client.update_goal_state(forced=True)

                setup_rdma_device(nd_version, protocol.client.get_shared_conf())
            except Exception as e: # pylint: disable=C0103
                logger.error("Error setting up rdma device: %s" % e)
        else:
            logger.info("RDMA capabilities are not enabled, skipping")

        self.sleep_if_disabled()

        # Disable output to /dev/console once provisioning has completed
        if logger.console_output_enabled():
            logger.info("End of log to /dev/console. The agent will now check for updates and then will process extensions.")
            logger.disable_console_output()

        while self.running:
            self.update_handler.run_latest(child_args=child_args)
    def test_scvmm_detection_with_file(self):
        # setup
        conf.get_dvd_mount_point = Mock(return_value=self.tmp_dir)
        conf.get_detect_scvmm_env = Mock(return_value=True)
        scvmm_file = os.path.join(self.tmp_dir, scvmm.VMM_CONF_FILE_NAME)
        fileutil.write_file(scvmm_file, "")

        with patch.object(scvmm.ScvmmHandler, 'start_scvmm_agent') as po:
            with patch('os.listdir', return_value=["sr0", "sr1", "sr2"]):
                with patch('time.sleep', return_value=0):
                    # execute
                    failed = False
                    try:
                        scvmm.get_scvmm_handler().run()
                    except:
                        failed = True
                    # assert
                    self.assertTrue(failed)
                    self.assertTrue(po.call_count == 1)
                    # cleanup
                    os.remove(scvmm_file)
Exemple #5
0
    def test_scvmm_detection_with_file(self):
        # setup
        conf.get_dvd_mount_point = Mock(return_value=self.tmp_dir)
        conf.get_detect_scvmm_env = Mock(return_value=True)
        scvmm_file = os.path.join(self.tmp_dir, scvmm.VMM_CONF_FILE_NAME)
        fileutil.write_file(scvmm_file, "")

        with patch.object(scvmm.ScvmmHandler, 'start_scvmm_agent') as po:
            with patch('os.listdir', return_value=["sr0", "sr1", "sr2"]):
                with patch('time.sleep', return_value=0):
                    # execute
                    failed = False
                    try:
                        scvmm.get_scvmm_handler().run()
                    except:
                        failed = True
                    # assert
                    self.assertTrue(failed)
                    self.assertTrue(po.call_count == 1)
                    # cleanup
                    os.remove(scvmm_file)
Exemple #6
0
    def daemon(self, child_args=None):
        logger.info("Run daemon")

        self.protocol_util = get_protocol_util()
        self.scvmm_handler = get_scvmm_handler()
        self.resourcedisk_handler = get_resourcedisk_handler()
        self.rdma_handler = get_rdma_handler()
        self.provision_handler = get_provision_handler()
        self.update_handler = get_update_handler()

        # Create lib dir
        if not os.path.isdir(conf.get_lib_dir()):
            fileutil.mkdir(conf.get_lib_dir(), mode=0o700)
            os.chdir(conf.get_lib_dir())

        if conf.get_detect_scvmm_env():
            self.scvmm_handler.run()

        if conf.get_resourcedisk_format():
            self.resourcedisk_handler.run()

        # Always redetermine the protocol start (e.g., wireserver vs.
        # on-premise) since a VHD can move between environments        
        self.protocol_util.clear_protocol()

        self.provision_handler.run()

        # Enable RDMA, continue in errors
        if conf.enable_rdma():
            self.rdma_handler.install_driver()

            logger.info("RDMA capabilities are enabled in configuration")
            try:
                # Ensure the most recent SharedConfig is available
                # - Changes to RDMA state may not increment the goal state
                #   incarnation number. A forced update ensures the most
                #   current values.
                protocol = self.protocol_util.get_protocol()
                client = protocol.client
                if client is None or type(client) is not WireClient:
                    raise Exception("Attempt to setup RDMA without Wireserver")
                client.update_goal_state(forced=True)

                setup_rdma_device()
            except Exception as e:
                logger.error("Error setting up rdma device: %s" % e)
        else:
            logger.info("RDMA capabilities are not enabled, skipping")

        while self.running:
            self.update_handler.run_latest(child_args=child_args)
Exemple #7
0
    def daemon(self, child_args=None):
        logger.info("Run daemon")

        self.protocol_util = get_protocol_util()
        self.scvmm_handler = get_scvmm_handler()
        self.resourcedisk_handler = get_resourcedisk_handler()
        self.rdma_handler = get_rdma_handler()
        self.provision_handler = get_provision_handler()
        self.update_handler = get_update_handler()

        # Create lib dir
        if not os.path.isdir(conf.get_lib_dir()):
            fileutil.mkdir(conf.get_lib_dir(), mode=0o700)
            os.chdir(conf.get_lib_dir())

        if conf.get_detect_scvmm_env():
            self.scvmm_handler.run()

        if conf.get_resourcedisk_format():
            self.resourcedisk_handler.run()

        # Always redetermine the protocol start (e.g., wireserver vs.
        # on-premise) since a VHD can move between environments        
        self.protocol_util.clear_protocol()

        self.provision_handler.run()

        # Enable RDMA, continue in errors
        if conf.enable_rdma():
            self.rdma_handler.install_driver()

            logger.info("RDMA capabilities are enabled in configuration")
            try:
                # Ensure the most recent SharedConfig is available
                # - Changes to RDMA state may not increment the goal state
                #   incarnation number. A forced update ensures the most
                #   current values.
                protocol = self.protocol_util.get_protocol()
                client = protocol.client
                if client is None or type(client) is not WireClient:
                    raise Exception("Attempt to setup RDMA without Wireserver")
                client.update_goal_state(forced=True)

                setup_rdma_device()
            except Exception as e:
                logger.error("Error setting up rdma device: %s" % e)
        else:
            logger.info("RDMA capabilities are not enabled, skipping")

        while self.running:
            self.update_handler.run_latest(child_args=child_args)
Exemple #8
0
    def daemon(self):
        logger.info("Run daemon")

        self.protocol_util = get_protocol_util()
        self.scvmm_handler = get_scvmm_handler()
        self.resourcedisk_handler = get_resourcedisk_handler()
        self.rdma_handler = get_rdma_handler()
        self.provision_handler = get_provision_handler()
        self.update_handler = get_update_handler()

        # Create lib dir
        if not os.path.isdir(conf.get_lib_dir()):
            fileutil.mkdir(conf.get_lib_dir(), mode=0o700)
            os.chdir(conf.get_lib_dir())

        if conf.get_detect_scvmm_env():
            self.scvmm_handler.run()

        if conf.get_resourcedisk_format():
            self.resourcedisk_handler.run()

        # Always redetermine the protocol start (e.g., wireserver vs.
        # on-premise) since a VHD can move between environments
        self.protocol_util.clear_protocol()

        self.provision_handler.run()

        # Enable RDMA, continue in errors
        if conf.enable_rdma():
            self.rdma_handler.install_driver()

            logger.info("RDMA capabilities are enabled in configuration")
            try:
                setup_rdma_device()
            except Exception as e:
                logger.error("Error setting up rdma device: %s" % e)
        else:
            logger.info("RDMA capabilities are not enabled, skipping")

        while self.running:
            self.update_handler.run_latest()
Exemple #9
0
    def daemon(self):
        logger.info("Run daemon")

        self.protocol_util = get_protocol_util()
        self.scvmm_handler = get_scvmm_handler()
        self.resourcedisk_handler = get_resourcedisk_handler()
        self.rdma_handler = get_rdma_handler()
        self.provision_handler = get_provision_handler()
        self.update_handler = get_update_handler()

        # Create lib dir
        if not os.path.isdir(conf.get_lib_dir()):
            fileutil.mkdir(conf.get_lib_dir(), mode=0o700)
            os.chdir(conf.get_lib_dir())

        if conf.get_detect_scvmm_env():
            self.scvmm_handler.run()

        if conf.get_resourcedisk_format():
            self.resourcedisk_handler.run()

        # Always redetermine the protocol start (e.g., wireserver vs.
        # on-premise) since a VHD can move between environments        
        self.protocol_util.clear_protocol()

        self.provision_handler.run()

        # Enable RDMA, continue in errors
        if conf.enable_rdma():
            self.rdma_handler.install_driver()

            logger.info("RDMA capabilities are enabled in configuration")
            try:
                setup_rdma_device()
            except Exception as e:
                logger.error("Error setting up rdma device: %s" % e)
        else:
            logger.info("RDMA capabilities are not enabled, skipping")

        while self.running:
            self.update_handler.run_latest()