Example #1
0
def config(config, reset, init):
    """ config module of linchpin cli"""
    if reset:
        if os.path.isfile("./linchpin_config.yml"):
            display("WARNING:002", "prompt")
        config.lpconfig.stream(playbook_dir=config.clipath,
                               pwd=os.getcwd()).dump('linchpin_config.yml')
    if init:
        if not os.path.isfile("./linchpin_config.yml"):
            display("ERROR:004", "print")
        conf = yaml.load(open("linchpin_config.yml", "r").read())
        for key in conf:
            inp_str = raw_input("Enter value of " + key + ":(" +
                                str(conf[key]) + "):")
            if inp_str != "":
                conf[key] = inp_str
        config.lpconfig.stream(
            playbook_dir=config.clipath,
            keystore_path=conf["keystore_path"],
            outputfolder_path=conf["outputfolder_path"],
            inventoryfolder_path=conf["inventoryfolder_path"],
            async=conf["async"],
            async_timeout=conf["async_timeout"],
            no_output=conf["no_output"],
            schema=conf["schema"],
            inventory_layouts_path=conf["inventory_layouts_path"],
            inventory_outputs_path=conf["inventory_outputs_path"],
            check_mode=conf["check_mode"],
            pwd=os.getcwd()).dump('linchpin_config.yml')
Example #2
0
def config(config, reset, init):
    """ config module of linchpin cli"""
    if reset:
        if os.path.isfile("./linchpin_config.yml"):
            display("WARNING:002", "prompt")
        config.lpconfig.stream(playbook_dir=config.clipath,
                               pwd=os.getcwd()).dump('linchpin_config.yml')
    if init:
        if not os.path.isfile("./linchpin_config.yml"):
            display("ERROR:004", "print")
        conf = yaml.load(open("linchpin_config.yml", "r").read())
        for key in conf:
            inp_str = raw_input("Enter value of "+key+":("+str(conf[key])+"):")
            if inp_str != "":
                conf[key] = inp_str
        config.lpconfig.stream(
                         playbook_dir=config.clipath,
                         keystore_path=conf["keystore_path"],
                         outputfolder_path=conf["outputfolder_path"],
                         inventoryfolder_path=conf["inventoryfolder_path"],
                         async=conf["async"],
                         async_timeout=conf["async_timeout"],
                         no_output=conf["no_output"],
                         schema=conf["schema"],
                         inventory_layouts_path=conf["inventory_layouts_path"],
                         inventory_outputs_path=conf["inventory_outputs_path"],
                         check_mode=conf["check_mode"],
                         pwd=os.getcwd()).dump('linchpin_config.yml')
Example #3
0
def drop(config, pf, target):
    """ drop module of linchpin cli"""
    init_dir = os.getcwd()
    pfs = list_by_ext(init_dir, "PinFile")
    if len(pfs) == 0:
        display("ERROR:001")
    if len(pfs) > 1:
        display("ERROR:002")
    pf = pfs[0]
    lpcli = LinchpinCli()
    output = lpcli.lp_drop(pf, target)
Example #4
0
def drop(config, pf, target):
    """ drop module of linchpin cli"""
    init_dir = os.getcwd()
    pfs = list_by_ext(init_dir, "PinFile")
    if len(pfs) == 0:
        display("ERROR:001")
    if len(pfs) > 1:
        display("ERROR:002")
    pf = pfs[0]
    lpcli = LinchpinCli()
    output = lpcli.lp_drop(pf, target)
Example #5
0
def rise(config, lpf, target):
    """ rise module of linchpin cli """
    init_dir = os.getcwd()
    lpfs = list_by_ext(init_dir, "PinFile")
    if len(lpfs) == 0:
        display("ERROR:001")
    if len(lpfs) > 1:
        display("ERROR:002")
    lpf = lpfs[0]
    lpcli = LinchpinCli()
    output = lpcli.lp_rise(lpf, target)
Example #6
0
def init(config, path):
    """ init module of linchpin """
    click.echo('Initailising the templates for linchpin file !')
    if checkpaths():
        reply = display("WARNING:001", "prompt")
        if not reply:
            sys.exit(0)
    if config.verbose:
        click.echo("### verbose mode ###")
    if os.path.isdir(path):
        path = path.strip("/")
        config.linchpinfile.stream().dump(path + '/' + 'PinFile')
        mkdir(path + "/topologies")
        mkdir(path + "/layouts")
        mkdir(path + "/inventories")
        dir_list = ["topologies", "layouts"]
        copy_files(path, dir_list, config)
    else:
        click.echo("Invalid path to initialize !!")
Example #7
0
def init(config, path):
    """ init module of linchpin """
    click.echo('Initialising the templates for linchpin file !')
    if checkpaths():
        reply = display("WARNING:001", "prompt")
        if not reply:
            sys.exit(0)
    if config.verbose:
        click.echo("### verbose mode ###")
    if os.path.isdir(path):
        path = path.strip("/")
        config.linchpinfile.stream().dump(path+'/'+'PinFile')
        mkdir(path+"/topologies")
        mkdir(path+"/layouts")
        mkdir(path+"/inventories")
        dir_list = ["topologies", "layouts"]
        copy_files(path, dir_list, config)
    else:
        click.echo("Invalid path to initialise!!")