Example #1
0
def main(topo_data, cfg_data, fab, syntax, fab_id, pool_dict):
    import json
    dst_folder = None
    config_passed = False
    data = topo_data
    if cfg_data is not None:
    	cfg_data = {"device_profile": cfg_data}
        #Above is done so that we don't need to make change to other functions
        config_passed = True
    #Create JSOn from POAP json
    ank_data = createAnkJsonData(data, cfg_data)
    if ank_data['nodes'] is None:
        log.debug("json_converter.py...Error received in createAnkJsonData.")
        return None

    try:
    #Add config info onto nodes.
        if config_passed == True:
            applyConfig(data, ank_data, cfg_data, fab, fab_id, pool_dict)
            log.debug("json_converter.py...applyConfig completed")
        else:
            log.debug("json_converter.py...no seperate config info supplied")
    except:
        log.error("json_converter.py...applyConfig failed")
        return dst_folder

    options = test()
    #options = create_args()
    options.debug = True
    options.syntax = syntax

    #Since input is coming from poap we can assume that it will
    #be a dictionary. Otherwise it will be a file.
    #options.file = 'temp.json'
    options.file = 'dictionary'
    options.dictionary = ank_data

    try:
        dst_folder = console_script.main(options)
        log.debug("json_converter.py...call to ank completed.")
        log.debug(str(dst_folder))
        return dst_folder
    except:
        log.error("json_converter.py...call to ank failed.")
        return dst_folder
Example #2
0
def main(topo_data, cfg_data, fab, syntax, fab_id, pool_dict):
    import json
    dst_folder = None
    config_passed = False
    data = topo_data
    if cfg_data is not None:
        cfg_data = {"device_profile": cfg_data}
        #Above is done so that we don't need to make change to other functions
        config_passed = True
    #Create JSOn from POAP json
    ank_data = createAnkJsonData(data, cfg_data)
    if ank_data['nodes'] is None:
        log.debug("json_converter.py...Error received in createAnkJsonData.")
        return None

    try:
        #Add config info onto nodes.
        if config_passed == True:
            applyConfig(data, ank_data, cfg_data, fab, fab_id, pool_dict)
            log.debug("json_converter.py...applyConfig completed")
        else:
            log.debug("json_converter.py...no seperate config info supplied")
    except:
        log.error("json_converter.py...applyConfig failed")
        return dst_folder

    options = test()
    #options = create_args()
    options.debug = True
    options.syntax = syntax

    #Since input is coming from poap we can assume that it will
    #be a dictionary. Otherwise it will be a file.
    #options.file = 'temp.json'
    options.file = 'dictionary'
    options.dictionary = ank_data

    try:
        dst_folder = console_script.main(options)
        log.debug("json_converter.py...call to ank completed.")
        log.debug(str(dst_folder))
        return dst_folder
    except:
        log.error("json_converter.py...call to ank failed.")
        return dst_folder
Example #3
0
    try:
        pos = topo_file.rfind('/')
    except:
        pos = -1
    options.file = topo_file[:pos+1] + 'temp.json'

    try:
        with open(options.file, "w+") as fpc:
            fpc.write(json.dumps(ank_data))
    except:
        log.error("json_converter.py...Failed to create ank input json file.")
        return dst_folder

    try:
        dst_folder = console_script.main(options)
        return dst_folder
    except:
        log.error("json_converter.py...call to ank failed.")
        return dst_folder


def applyConfig(data, ank_data, cfg):

    if data.has_key('link_list'):
        configurePortChannel(data, ank_data)
        configureVirtualPortChannel(data, ank_data)
    ank_data = AddConfigInfo(ank_data, cfg)
    if ank_data is None:
        log.error("VPC id block is not correct")
        raise ValueError('Range not proper')