Пример #1
0
def deploy(options: argparse.Namespace) -> None:
    module.Project.get(options.main_file)
    from inmanta import deploy as deploy_module

    run = deploy_module.Deploy(options)
    try:
        if not run.setup():
            raise Exception("Failed to setup an embedded Inmanta orchestrator.")
        run.run()
    finally:
        run.stop()
Пример #2
0
def deploy(options: argparse.Namespace) -> None:
    module.Project.get(options.main_file)
    from inmanta import deploy

    run = deploy.Deploy(options)
    try:
        if not run.setup():
            LOGGER.error("Failed to setup the orchestrator.")
            return
        run.run()
    finally:
        run.stop()
Пример #3
0
def deploy(options):
    module.Project.get(options.main_file)
    from inmanta import deploy

    io_loop = IOLoop.current()
    run = deploy.Deploy(io_loop)
    run.run(options)

    try:
        io_loop.start()
    except (KeyboardInterrupt, deploy.FinishedException):
        IOLoop.current().stop()
        run.stop()
Пример #4
0
def test_embedded_inmanta_server(tmpdir, postgres_db):
    """Test starting an embedded server"""
    project_dir = tmpdir.mkdir("project")
    os.chdir(project_dir)
    main_cf_file = project_dir.join("main.cf")
    project_yml_file = project_dir.join("project.yml")
    with open(project_yml_file, "w", encoding="utf-8") as f:
        f.write("name: test\n")
        f.write("modulepath: " + str(project_dir.join("libs")) + "\n")
        f.write("downloadpath: " + str(project_dir.join("libs")) + "\n")
        f.write("repo: https://github.com/inmanta/\n")
        f.write("description: Test\n")
    with open(main_cf_file, "w", encoding="utf-8") as f:
        f.write("")

    Options = collections.namedtuple("Options", ["dryrun", "dashboard"])
    options = Options(dryrun=False, dashboard=False)
    depl = deploy.Deploy(options, postgresport=postgres_db.port)
    assert depl.setup()
    depl.stop()
Пример #5
0
def test_deploy(io_loop, snippetcompiler, tmpdir, mongo_db, motor):
    file_name = tmpdir.join("test_file")
    snippetcompiler.setup_for_snippet("""
    host = std::Host(name="test", os=std::linux)
    file = std::Symlink(host=host, source="/dev/null", target="%s")
    """ % file_name)

    os.chdir(snippetcompiler.project_dir)
    Options = collections.namedtuple(
        "Options", ["no_agent_log", "dryrun", "map", "agent"])
    options = Options(no_agent_log=False, dryrun=False, map="", agent="")

    run = deploy.Deploy(io_loop, mongoport=mongo_db.port)
    try:
        run.run(options, only_setup=True)
        yield run.do_deploy(False, "")
        assert file_name.exists()
    except (KeyboardInterrupt, deploy.FinishedException):
        # This is how the deploy command ends
        pass

    finally:
        run.stop()
Пример #6
0
def test_deploy(snippetcompiler, tmpdir, postgres_db):
    file_name = tmpdir.join("test_file")
    # TODO: when agentconfig deploys no longer require an agent restart, define a new agent. Currently this makes the
    # test to slow.
    snippetcompiler.setup_for_snippet("""
    host = std::Host(name="internal", os=std::linux)
    file = std::Symlink(host=host, source="/dev/null", target="%s")
    """ % file_name)

    os.chdir(snippetcompiler.project_dir)
    Options = collections.namedtuple("Options", ["dryrun", "dashboard"])
    options = Options(dryrun=False, dashboard=False)

    assert not file_name.exists()

    run = deploy.Deploy(options, postgresport=postgres_db.port)
    try:
        if not run.setup():
            raise Exception("Failed to setup server")
        run.run()
    finally:
        run.stop()

    assert file_name.exists()