Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 4
0
def layouts_get(config, layout, upstream):
    """
    Get layout by name
    """
    lpcli = LinchpinCli()
    output = lpcli.lp_layout_get(layout, upstream)
    pprint.pprint(output)
Ejemplo n.º 5
0
def topology_get(config, topo, upstream):
    """
    Get topology by name
    """
    lpcli = LinchpinCli()
    d = lpcli.lp_topo_get(topo)
    pprint.pprint(d)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 17
0
 def test_lp_invgen_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_invgen()
Ejemplo n.º 18
0
 def test_object_create(self):
     lp = LinchpinCli()
     assert_equal(isinstance(lp, LinchpinCli), True)
Ejemplo n.º 19
0
 def test_lp_validate_topology_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_validate()
Ejemplo n.º 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)
Ejemplo n.º 21
0
 def test_lp_rise_wthout_params(self):
     lp = LinchpinCli()
     lp.lp_rise()
Ejemplo n.º 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)
Ejemplo n.º 23
0
 def test_get_evars(self):
     lp = LinchpinCli()
     pf = im.get_mock_pf()
     lp.get_evars(pf)
Ejemplo n.º 24
0
 def test_lp_layout_list_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_layout_list()
     assert_equal(isinstance(lp, list), True)
Ejemplo n.º 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)
Ejemplo n.º 26
0
 def test_lp_topo_get_with_wrong_input_topo(self):
     lp = LinchpinCli()
     topo = "thisdoesnotexists"
     lp = lp.lp_topo_get(topo)
Ejemplo n.º 27
0
 def test_get_evars_without_pf(self):
     lp = LinchpinCli()
     evars = lp.get_evars()
Ejemplo n.º 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)
Ejemplo n.º 29
0
 def test_lp_list_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_list()
Ejemplo n.º 30
0
 def test_lp_layout_get_without_params(self):
     lp = LinchpinCli()
     lp = lp.lp_topo_get()
Ejemplo n.º 31
0
 def test_lp_layout_list_with_wrong_upstream(self):
     lp = LinchpinCli()
     upstream = "www.example.com"
     lp = lp.lp_alyout_list(upstream)
Ejemplo n.º 32
0
 def test_lp_drop_without_params(self):
     lp = LinchpinCli()
     lp.lp_drop()