Beispiel #1
0
def validate(config, topo, layout, pf):
    """ validate module of linchpin cli : currenly validates only topologies,
        need to implement PinFile, layouts too"""
    lpcli = LinchpinCli()
    topo = os.path.abspath(topo)
    output = lpcli.lp_validate(topo, layout, pf)
    pprint.pprint(output)
Beispiel #2
0
def layouts_get(config, layout, upstream):
    """
    needs implementation if layout folder is not found raise error
    """
    lpcli = LinchpinCli()
    output = lpcli.lp_layout_get(layout, upstream)
    pprint.pprint(output)
Beispiel #3
0
def topology_get(config, topo, upstream):
    """
    needs implementation if topology folder is not found raise error
    """
    lpcli = LinchpinCli()
    d = lpcli.lp_topo_get(topo)
    pprint.pprint(d)
Beispiel #4
0
def layouts_get(config, layout, upstream):
    """
    Get layout by name
    """
    lpcli = LinchpinCli()
    output = lpcli.lp_layout_get(layout, upstream)
    pprint.pprint(output)
Beispiel #5
0
def topology_get(config, topo, upstream):
    """
    Get topology by name
    """
    lpcli = LinchpinCli()
    d = lpcli.lp_topo_get(topo)
    pprint.pprint(d)
Beispiel #6
0
 def test_lp_validate_topology(self):
     lp = LinchpinCli()
     base_path = os.path.realpath(__file__)
     base_path = "/".join(base_path.split("/")[0:-2])
     topo = base_path+"/tests/mockdata/ex_all.yml"
     topo = os.path.abspath(topo)
     lp = lp.lp_validate(topo)
     assert_equal(lp, 0)
Beispiel #7
0
def invgen(config, topoout, layout, invout, invtype):
    """ invgen module of linchpin cli """
    topoout = os.path.abspath(topoout)
    layout = os.path.abspath(layout)
    invout = os.path.abspath(invout)
    lpcli = LinchpinCli()
    result = lpcli.lp_invgen(topoout, layout, invout, invtype)
    pprint.pprint(result)
Beispiel #8
0
def validate(config, topo, layout, pf):
    """ validate module of linchpin cli : 
        validates only topologies for now
    """
    lpcli = LinchpinCli()
    topo = os.path.abspath(topo)
    output = lpcli.lp_validate(topo, layout, pf)
    pprint.pprint(output)
Beispiel #9
0
def invgen(config, topoout, layout, invout, invtype):
    """ invgen module of linchpin cli """
    topoout = os.path.abspath(topoout)
    layout = os.path.abspath(layout)
    invout = os.path.abspath(invout)
    lpcli = LinchpinCli()
    result = lpcli.lp_invgen(topoout, layout, invout, invtype)
    pprint.pprint(result)
Beispiel #10
0
 def test_lp_invgen_with_params(self):
     lp = LinchpinCli()
     of = im.get_mock_outputfile()
     lf = im.get_mock_layoutfile()
     io = os.getcwd()+"/testoutput.txt"
     lp.lp_invgen(of, lf, io, "generic")
     filegenerated = os.path.exists(io)
     os.remove(io)
     assert_equal(filegenerated, True)
Beispiel #11
0
def layouts_list(config, upstream):
    lpcli = LinchpinCli()
    click.echo(": LAYOUTS LIST :")
    files = lpcli.lp_layout_list(upstream)
    t_files = []
    for i in range(0, len(files)):
        t_files.append((i + 1, files[i]["name"]))
    headers = ["Sno", "Name"]
    print tabulate(t_files, headers, tablefmt="fancy_grid")
Beispiel #12
0
def layouts_list(config, upstream):
    lpcli = LinchpinCli()
    click.echo(": LAYOUTS LIST :")
    files = lpcli.lp_layout_list(upstream)
    t_files = []
    for i in range(0, len(files)):
        t_files.append((i+1, files[i]["name"]))
    headers = ["Sno", "Name"]
    print tabulate(t_files, headers, tablefmt="fancy_grid")
Beispiel #13
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)
Beispiel #14
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)
Beispiel #15
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)
Beispiel #16
0
 def test_get_config(self):
     lp = LinchpinCli()
     cfg = lp.get_config()
     keys = ['inventory_layouts_path',
             'inventory_outputs_path',
             'no_output',
             'async_timeout',
             'check_mode',
             'inventory_playbooks',
             'inventory_types',
             'outputfolder_path',
             'async',
             'keystore_path',
             'inventoryfolder_path',
             'schema']
     assert_equal(cfg.keys(), keys)
Beispiel #17
0
 def test_lp_invgen_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_invgen()
Beispiel #18
0
 def test_object_create(self):
     lp = LinchpinCli()
     assert_equal(isinstance(lp, LinchpinCli), True)
Beispiel #19
0
 def test_lp_validate_topology_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_validate()
Beispiel #20
0
 def test_lp_rise_with_wrong_target(self):
     lp = LinchpinCli()
     target = "dosenotexists"
     pf = im.get_mock_pf_path()
     lp.lp_rise(pf, target)
Beispiel #21
0
 def test_lp_rise_wthout_params(self):
     lp = LinchpinCli()
     lp.lp_rise()
Beispiel #22
0
 def test_lp_drop_with_wrong_target(self):
     lp = LinchpinCli()
     target = "doesnotexists"
     pf = im.get_mock_pf_path()
     lp.lp_drop(pf, target)
Beispiel #23
0
 def test_get_evars(self):
     lp = LinchpinCli()
     pf = im.get_mock_pf()
     lp.get_evars(pf)
Beispiel #24
0
 def test_lp_layout_list_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_layout_list()
     assert_equal(isinstance(lp, list), True)
Beispiel #25
0
 def test_get_config_path(self):
     lp = LinchpinCli()
     config_path = lp.get_config_path().split("/")[-1]
     assert_equal("linchpin_config.yml", config_path)
Beispiel #26
0
 def test_lp_topo_get_with_wrong_input_topo(self):
     lp = LinchpinCli()
     topo = "thisdoesnotexists"
     lp = lp.lp_topo_get(topo)
Beispiel #27
0
 def test_get_evars_without_pf(self):
     lp = LinchpinCli()
     evars = lp.get_evars()
Beispiel #28
0
 def test_lp_topo_get_with_wrong_upstream(self):
     lp = LinchpinCli()
     topo = "thisdoesnotexists"
     upstream = "www.example.com"
     lp = lp.lp_topo_get(topo, upstream)
Beispiel #29
0
 def test_lp_list_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_list()
Beispiel #30
0
 def test_lp_layout_get_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_topo_get()
Beispiel #31
0
 def test_lp_layout_list_with_wrong_upstream(self):
     lp = LinchpinCli()
     upstream = "www.example.com"
     lp = lp.lp_alyout_list(upstream)
Beispiel #32
0
 def test_lp_drop_without_params(self):
     lp = LinchpinCli()
     lp.lp_drop()