How to use the autonetkit.log.error function in autonetkit

To help you get started, we’ve selected a few autonetkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datacenter / ignite-DEPRECATED / autonetkit / json_converter.py View on Github external
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.")
github sk2 / autonetkit / autonetkit / console_script.py View on Github external
input_string = sys.stdin
        now = datetime.now()
        timestamp = now.strftime("%Y%m%d_%H%M%S_%f")
    elif options.grid:
        input_string = ""
        now = datetime.now()
        timestamp = now.strftime("%Y%m%d_%H%M%S_%f")
    else:
        log.info("No input file specified. Exiting")
        return

    try:
        workflow.manage_network(input_string, timestamp,
                       grid=options.grid, **build_options)
    except Exception, err:
        log.error(
            "Error generating network configurations: %s" % err)
        log.debug("Error generating network configurations", exc_info=True)
        if settings['General']['stack_trace']:
            print traceback.print_exc()
        sys.exit("Unable to build configurations.")

# TODO: work out why build_options is being clobbered for monitor mode
    build_options['monitor'] = options.monitor or settings['General'][
        'monitor']

    if build_options['monitor']:
        try:
            log.info("Monitoring for updates...")
            input_filemonitor = workflow.file_monitor(options.file)
            #build_filemonitor = file_monitor("autonetkit/build_network.py")
            while True:
github datacenter / ignite-DEPRECATED / ank / autonetkit / autonetkit / json_converter.py View on Github external
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')

    '''
    By default ASN was set to 1. If BGP profile is applicable
    on the node then ASN may be different. We will be filling
    ASN info from BGP profile.
    '''
    ank_data = AddAsnInfo(ank_data, cfg)
github sk2 / autonetkit / autonetkit / plugins / ipv4.py View on Github external
# now allocate the IPs

        global_prefix_len = global_root.prefixlen

        # TODO: try/catch if the block is too small for prefix

        try:
            global_ip_block = \
                self.root_ip_block.subnet(global_prefix_len).next()
        except StopIteration:
            #message = ("Unable to allocate IPv4 subnets. ")
            formatted_prefixes = ", ".join(
                "AS%s: /%s" % (k, v) for k, v in sorted(prefixes_by_attr.items()))
            message = ("Cannot create requested number of /%s subnets from root block %s. Please specify a larger root IP block. (Requested subnet allocations are: %s)"
                       % (global_prefix_len, self.root_ip_block, formatted_prefixes))
            log.error(message)
            # TODO: throw ANK specific exception here
            raise AutoNetkitException(message)
        self.graph = global_graph

# add children of collision domains

        cd_nodes = [n for n in self if n.is_broadcast_domain()]
        for cd in sorted(cd_nodes):
            for edge in sorted(cd.host.edges()):

                # TODO: sort these

                child_id = self.next_node_id
                cd_id = cd.node
                global_graph.add_node(child_id, prefixlen=32,
                                      host=edge.dst_int)
github datacenter / ignite-DEPRECATED / ank / autonetkit / autonetkit / start_ank.py View on Github external
buff_ank = f_ank.read()
                            with open(file, "w+") as fpc:
                                fpc.write(line_ank)
                                fpc.write(buff_ank)
                                fpc.write(line_poap)
                                fpc.write(buff_poap)


            return 1

        else:
            log.error("start_ank.py...ank returned destination folder as None")
            return None

    except:
        log.error("start_ank.py...exception recieved in call to json_converter")
        return None
github datacenter / ignite-DEPRECATED / ank / autonetkit / autonetkit / json_converter.py View on Github external
import json

    dst_folder = None
    try:
        json_data=open(topo_file).read()
        log.debug("json_converter.py...opened topo_file")
    except:
        log.error("json_converter.py...file open failed for topo_file")
        return dst_folder

    try:
        data = json.loads(json_data)
        log.debug("json_converter.py...Loaded topology json")
    except ValueError, e:
        #Error in JSON format. Check JSON file
        log.error("json_converter.py...Error in JSON format. Loading of topology json failed")
        return dst_folder

    #Create JSOn from POAP json
    ank_data = createAnkJsonData(data)

    if ank_data['nodes'] is None:
        log.debug("json_converter.py...No nodes found in topology json.")
        return None

    try:
    #Add config info onto nodes.
        applyConfig(data, ank_data, cfg_file)
        log.debug("json_converter.py...applyConfig completed")
    except:
        log.error("json_converter.py...applyConfig failed")
        return dst_folder