Ejemplo n.º 1
0
    def test_orch_preparesite(self, input_files):
        objects.register_all()

        input_file = input_files.join("fullsite.yaml")

        design_state = statemgmt.DesignState()
        design_data = objects.SiteDesign()
        design_id = design_data.assign_id()
        design_state.post_design(design_data)

        ingester = Ingester()
        ingester.enable_plugins([drydock_provisioner.ingester.plugins.yaml.YamlIngester])
        ingester.ingest_data(plugin_name='yaml', design_state=design_state,
                             filenames=[str(input_file)], design_id=design_id)

        design_data = design_state.get_design(design_id)

        orchestrator = orch.Orchestrator(state_manager=design_state,
                                    enabled_drivers={'node': 'drydock_provisioner.drivers.node.maasdriver.driver.MaasNodeDriver'})

        orch_task = orchestrator.create_task(task.OrchestratorTask,
                                             site='sitename',
                                             design_id=design_id,
                                             action=hd_fields.OrchestratorAction.PrepareSite)

        orchestrator.execute_task(orch_task.get_id())

        orch_task = design_state.get_task(orch_task.get_id())

        assert orch_task.result == hd_fields.ActionResult.Success
Ejemplo n.º 2
0
    def test_client_verify(self):
        design_state = statemgmt.DesignState()
        orchestrator = orch.Orchestrator(state_manager=design_state,
                                    enabled_drivers={'node': 'drydock_provisioner.drivers.node.maasdriver.driver.MaasNodeDriver'})

        orch_task = orchestrator.create_task(task.OrchestratorTask,
                                             site='sitename',
                                             design_id=None,
                                             action=hd_fields.OrchestratorAction.VerifySite)

        orchestrator.execute_task(orch_task.get_id())

        orch_task = design_state.get_task(orch_task.get_id())

        assert orch_task.result == hd_fields.ActionResult.Success
Ejemplo n.º 3
0
    def test_task_complete(self):
        state_mgr = statemgmt.DesignState()
        orchestrator = orch.Orchestrator(state_manager=state_mgr)
        orch_task = orchestrator.create_task(
            task.OrchestratorTask,
            site='default',
            action=hd_fields.OrchestratorAction.Noop)

        orchestrator.execute_task(orch_task.get_id())

        orch_task = state_mgr.get_task(orch_task.get_id())

        assert orch_task.get_status() == hd_fields.TaskStatus.Complete

        for t_id in orch_task.subtasks:
            t = state_mgr.get_task(t_id)
            assert t.get_status() == hd_fields.TaskStatus.Complete
Ejemplo n.º 4
0
    def test_oob_verify_all_node(self, loaded_design):
        #mocker.patch('pyghmi.ipmi.private.session.Session')
        #mocker.patch.object('pyghmi.ipmi.command.Command','get_asset_tag')

        orchestrator = orch.Orchestrator(state_manager=loaded_design,
                                    enabled_drivers={'oob': 'drydock_provisioner.drivers.oob.pyghmi_driver.PyghmiDriver'})

        orch_task = orchestrator.create_task(task.OrchestratorTask,
                                             site='sitename',
                                             design_id=self.design_id,
                                             action=hd_fields.OrchestratorAction.VerifyNode)

        orchestrator.execute_task(orch_task.get_id())

        orch_task = loaded_design.get_task(orch_task.get_id())

        assert True
Ejemplo n.º 5
0
def start_drydock():
    objects.register_all()

    # Setup root logger
    logger = logging.getLogger('drydock')

    logger.setLevel(config.DrydockConfig.global_config.get('log_level'))
    ch = logging.StreamHandler()
    formatter = logging.Formatter(
        '%(asctime)s - %(levelname)s - %(filename)s:%(funcName)s - %(message)s'
    )
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    # Specalized format for API logging
    logger = logging.getLogger('drydock.control')
    logger.propagate = False
    formatter = logging.Formatter(
        '%(asctime)s - %(levelname)s - %(user)s - %(req_id)s - %(external_ctx)s - %(message)s'
    )

    ch = logging.StreamHandler()
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    state = statemgmt.DesignState()

    orchestrator = orch.Orchestrator(
        config.DrydockConfig.orchestrator_config.get('drivers', {}),
        state_manager=state)
    input_ingester = ingester.Ingester()
    input_ingester.enable_plugins(
        config.DrydockConfig.ingester_config.get('plugins', []))

    return api.start_api(state_manager=state,
                         ingester=input_ingester,
                         orchestrator=orchestrator)
Ejemplo n.º 6
0
    def test_task_termination(self):
        state_mgr = statemgmt.DesignState()
        orchestrator = orch.Orchestrator(state_manager=state_mgr)
        orch_task = orchestrator.create_task(
            task.OrchestratorTask,
            site='default',
            action=hd_fields.OrchestratorAction.Noop)

        orch_thread = threading.Thread(target=orchestrator.execute_task,
                                       args=(orch_task.get_id(), ))
        orch_thread.start()

        time.sleep(1)
        orchestrator.terminate_task(orch_task.get_id())

        while orch_thread.is_alive():
            time.sleep(1)

        orch_task = state_mgr.get_task(orch_task.get_id())
        assert orch_task.get_status() == hd_fields.TaskStatus.Terminated

        for t_id in orch_task.subtasks:
            t = state_mgr.get_task(t_id)
            assert t.get_status() == hd_fields.TaskStatus.Terminated
Ejemplo n.º 7
0
def start_drydock():
    objects.register_all()

    # Setup configuration parsing
    cli_options = [
        cfg.BoolOpt('debug',
                    short='d',
                    default=False,
                    help='Enable debug logging'),
    ]

    cfg.CONF.register_cli_opts(cli_options)
    config.config_mgr.register_options()
    cfg.CONF(sys.argv[1:])

    if cfg.CONF.debug:
        cfg.CONF.set_override(name='log_level',
                              override='DEBUG',
                              group='logging')

    # Setup root logger
    logger = logging.getLogger(cfg.CONF.logging.global_logger_name)

    logger.setLevel(cfg.CONF.logging.log_level)
    ch = logging.StreamHandler()
    formatter = logging.Formatter(
        '%(asctime)s - %(levelname)s - %(filename)s:%(funcName)s - %(message)s'
    )
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    # Specalized format for API logging
    logger = logging.getLogger(cfg.CONF.logging.control_logger_name)
    logger.propagate = False
    formatter = logging.Formatter(
        '%(asctime)s - %(levelname)s - %(user)s - %(req_id)s - %(external_ctx)s - %(message)s'
    )

    ch = logging.StreamHandler()
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    state = statemgmt.DesignState()

    orchestrator = orch.Orchestrator(cfg.CONF.plugins, state_manager=state)
    input_ingester = ingester.Ingester()
    input_ingester.enable_plugins(cfg.CONF.plugins.ingester)

    # Check if we have an API key in the environment
    # Hack around until we move MaaS configs to the YAML schema
    if 'MAAS_API_KEY' in os.environ:
        cfg.CONF.set_override(name='maas_api_key',
                              override=os.environ['MAAS_API_KEY'],
                              group='maasdriver')

    # Setup the RBAC policy enforcer
    policy.policy_engine = policy.DrydockPolicy()
    policy.policy_engine.register_policy()

    # Ensure that the policy_engine is initialized before starting the API
    wsgi_callable = api.start_api(state_manager=state,
                                  ingester=input_ingester,
                                  orchestrator=orchestrator)

    # Now that loggers are configured, log the effective config
    cfg.CONF.log_opt_values(
        logging.getLogger(cfg.CONF.logging.global_logger_name), logging.DEBUG)

    return wsgi_callable