示例#1
0
def install(hubs,
            clients,
            *,
            bootstrap=None,
            package=None,
            hub_package=None,
            client_package=None,
            version=None,
            demo=False,
            call_collect=False,
            edition=None):
    assert hubs or clients
    assert not (hubs and clients and package)
    # These assertions are checked in main.py

    if not hub_package:
        hub_package = package
    if not client_package:
        client_package = package
    if bootstrap:
        if type(bootstrap) is str:
            bootstrap = [bootstrap]
        save_file(os.path.join(cf_remote_dir(), "policy_server.dat"),
                  "\n".join(bootstrap + [""]))
    errors = 0
    if hubs:
        if type(hubs) is str:
            hubs = [hubs]
        for index, hub in enumerate(hubs):
            log.debug("Installing {} hub package on '{}'".format(edition, hub))
            errors += install_host(
                hub,
                hub=True,
                package=hub_package,
                bootstrap=bootstrap[index %
                                    len(bootstrap)] if bootstrap else None,
                version=version,
                demo=demo,
                call_collect=call_collect,
                edition=edition)
    for index, host in enumerate(clients or []):
        log.debug("Installing {} client package on '{}'".format(edition, host))
        errors += install_host(
            host,
            hub=False,
            package=client_package,
            bootstrap=bootstrap[index % len(bootstrap)] if bootstrap else None,
            version=version,
            demo=demo,
            edition=edition)
    if demo and hubs:
        for hub in hubs:
            print(
                "Your demo hub is ready: https://{}/ (Username: admin, Password: password)"
                .format(strip_user(hub)))
    return errors
示例#2
0
文件: commands.py 项目: cfengine/core
def install(
        hubs,
        clients,
        *,
        bootstrap=None,
        package=None,
        hub_package=None,
        client_package=None,
        version=None,
        demo=False,
        call_collect=False):
    assert hubs or clients
    assert not (hubs and clients and package)
    # These assertions are checked in main.py

    if not hub_package:
        hub_package = package
    if not client_package:
        client_package = package
    if bootstrap:
        if type(bootstrap) is str:
            bootstrap = [bootstrap]
        save_file(os.path.join(cf_remote_dir(), "policy_server.dat"), "\n".join(bootstrap + [""]))
    if hubs:
        if type(hubs) is str:
            hubs = [hubs]
        for index, hub in enumerate(hubs):
            log.debug("Installing hub package on '{}'".format(hub))
            install_host(
                hub,
                hub=True,
                package=hub_package,
                bootstrap=bootstrap[index % len(bootstrap)] if bootstrap else None,
                version=version,
                demo=demo,
                call_collect=call_collect)
    for index, host in enumerate(clients or []):
        log.debug("Installing client package on '{}'".format(host))
        install_host(
            host,
            hub=False,
            package=client_package,
            bootstrap=bootstrap[index % len(bootstrap)] if bootstrap else None,
            version=version,
            demo=demo)
    if demo and hubs:
        for hub in hubs:
            print(
                "Your demo hub is ready: https://{}/ (Username: admin, Password: password)".
                format(strip_user(hub)))
示例#3
0
def install(hub,
            clients,
            *,
            bootstrap=None,
            package=None,
            hub_package=None,
            client_package=None,
            version=None,
            demo=False):
    assert hub or clients
    assert not (hub and clients and package)
    # These assertions are checked in main.py

    if not hub_package:
        hub_package = package
    if not client_package:
        client_package = package
    if bootstrap:
        save_file(os.path.join(cf_remote_dir(), "policy_server.dat"),
                  bootstrap + "\n")
    if hub:
        log.debug("Installing hub package on '{}'".format(hub))
        install_host(hub,
                     hub=True,
                     package=hub_package,
                     bootstrap=bootstrap,
                     version=version,
                     demo=demo)
    for host in (clients or []):
        log.debug("Installing client package on '{}'".format(host))
        install_host(host,
                     hub=False,
                     package=client_package,
                     bootstrap=bootstrap,
                     version=version,
                     demo=demo)
    if demo and hub:
        print(
            "Your demo hub is ready: https://{}/ (Username: admin, Password: password)"
            .format(hub))