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