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)
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)
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)
def layouts_get(config, layout, upstream): """ Get layout by name """ lpcli = LinchpinCli() output = lpcli.lp_layout_get(layout, upstream) pprint.pprint(output)
def topology_get(config, topo, upstream): """ Get topology by name """ lpcli = LinchpinCli() d = lpcli.lp_topo_get(topo) pprint.pprint(d)
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)
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)
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)
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)
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)
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")
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")
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)
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)
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)
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)
def test_lp_invgen_without_params(self): lp = LinchpinCli() lp = lp.lp_invgen()
def test_object_create(self): lp = LinchpinCli() assert_equal(isinstance(lp, LinchpinCli), True)
def test_lp_validate_topology_without_params(self): lp = LinchpinCli() lp = lp.lp_validate()
def test_lp_rise_with_wrong_target(self): lp = LinchpinCli() target = "dosenotexists" pf = im.get_mock_pf_path() lp.lp_rise(pf, target)
def test_lp_rise_wthout_params(self): lp = LinchpinCli() lp.lp_rise()
def test_lp_drop_with_wrong_target(self): lp = LinchpinCli() target = "doesnotexists" pf = im.get_mock_pf_path() lp.lp_drop(pf, target)
def test_get_evars(self): lp = LinchpinCli() pf = im.get_mock_pf() lp.get_evars(pf)
def test_lp_layout_list_without_params(self): lp = LinchpinCli() lp = lp.lp_layout_list() assert_equal(isinstance(lp, list), True)
def test_get_config_path(self): lp = LinchpinCli() config_path = lp.get_config_path().split("/")[-1] assert_equal("linchpin_config.yml", config_path)
def test_lp_topo_get_with_wrong_input_topo(self): lp = LinchpinCli() topo = "thisdoesnotexists" lp = lp.lp_topo_get(topo)
def test_get_evars_without_pf(self): lp = LinchpinCli() evars = lp.get_evars()
def test_lp_topo_get_with_wrong_upstream(self): lp = LinchpinCli() topo = "thisdoesnotexists" upstream = "www.example.com" lp = lp.lp_topo_get(topo, upstream)
def test_lp_list_without_params(self): lp = LinchpinCli() lp = lp.lp_list()
def test_lp_layout_get_without_params(self): lp = LinchpinCli() lp = lp.lp_topo_get()
def test_lp_layout_list_with_wrong_upstream(self): lp = LinchpinCli() upstream = "www.example.com" lp = lp.lp_alyout_list(upstream)
def test_lp_drop_without_params(self): lp = LinchpinCli() lp.lp_drop()