How to use the autonetkit.log.debug 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 / ank / autonetkit / autonetkit / console_script.py View on Github external
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 None

    try:
        dst_folder = workflow.manage_network(input_string, timestamp,
                       grid=options.grid, **build_options)
        log.debug("Generated network configurations: %s" % dst_folder)
    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:
                time.sleep(1)
                rebuild = False
github datacenter / ignite-DEPRECATED / autonetkit / json_converter.py View on Github external
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
github sk2 / autonetkit / autonetkit / compilers / device / cisco.py View on Github external
# Could occur for VRFs
                log.debug("No ISIS connections for interface %s" % interface)
                continue

            # TODO: change this to be is_bound and is_multipoint
            if isis_int.multipoint:
                log.warning('Extended IOS config support not valid for multipoint ISIS connections on %s'
                            % interface)
                continue

                # TODO multipoint handling?

            edge = edges[0]
            dst = edge.dst
            if not dst.is_router():
                log.debug('Connection to non-router host not added to IGP'
                          )
                continue

            src_type = node.device_subtype
            dst_type = dst['phy'].device_subtype
            if src_type == 'IOS XRv':
                if dst_type == 'IOSv':
                    interface.isis.hello_padding_disable = True
                elif dst_type == 'CSR1000v':
                    interface.isis.hello_padding_disable = True
                elif dst_type == 'NX-OSv':
                    interface.isis.hello_padding_disable = True

            if src_type == 'IOSv':
                if dst_type == 'IOS XRv':
                    interface.isis.mtu = 1430
github sk2 / autonetkit / autonetkit / render.py View on Github external
except KeyError, error:
                    log.warning("Unable to render %s:"
                                " %s not set" % (node, error))
                    from mako import exceptions
                    log.debug(exceptions.text_error_template().render())
                except AttributeError, error:
                    log.warning("Unable to render %s: %s " % (node, error))
                    from mako import exceptions
                    log.debug(exceptions.text_error_template().render())
                except NameError, error:
                    log.warning("Unable to render %s: %s. "
                                "Check all variables used are defined" % (node, error))
                except TypeError, error:
                    log.warning("Unable to render %s: %s." % (node, error))
                    from mako import exceptions
                    log.debug(exceptions.text_error_template().render())

        if node.render.to_memory:
            # Render directly to DeviceModel
            node.render.render_output = render_template.render(
                node=node,
                version_banner=version_banner,
                date=date,
            )

    if render_base:
        # TODO: revert to shutil copy
        if render_base:
            render_base = resource_path(render_base)
            fs_mako_templates = []
            for root, _, filenames in os.walk(render_base):
                for filename in fnmatch.filter(filenames, '*.mako'):
github sk2 / autonetkit / autonetkit / anm / graph.py View on Github external
def _copy_interfaces(self, nbunch):
        """Copies ports from one overlay to another"""

        nbunch = [n.node_id if isinstance(n, NmNode) else n
                  for n in nbunch]

        if self._overlay_id == "phy":
            # note: this will auto copy data from input if present - by default
            # TODO: provide an option to add_nodes to skip this
            # or would it be better to just provide a function in ank_utils to
            # wipe interfaces in the rare case it's needed?
            input_graph = self._anm.overlay_nx_graphs['input']
            for node_id in nbunch:
                if node_id not in input_graph:
                    log.debug("Not copying interfaces for %s: ",
                              "not in input graph %s" % node_id)
                    self._graph.node[node_id]['_ports'] = {
                        0: {'description': 'loopback', 'category': 'loopback'}}
                    continue

                try:
                    input_interfaces = input_graph.node[node_id]['_ports']
                except KeyError:
                    #Node not in input
                    # Just do base initialisation of loopback zero
                    self._graph.node[node_id]['_ports'] = {
                        0: {'description': 'loopback', 'category': 'loopback'}}
                else:
                    interface_data = {'description': None,
                                      'category': 'physical'}
                    # need to do dict() to copy, otherwise all point to same memory
github datacenter / ignite-DEPRECATED / ank / autonetkit / autonetkit / compilers / device / cisco.py View on Github external
# Could occur for VRFs
                log.debug("No ISIS connections for interface %s" % interface)
                continue

            # TODO: change this to be is_bound and is_multipoint
            if isis_int.multipoint:
                log.warning('Extended IOS config support not valid for multipoint ISIS connections on %s'
                            % interface)
                continue

                # TODO multipoint handling?

            edge = edges[0]
            dst = edge.dst
            if not dst.is_router():
                log.debug('Connection to non-router host not added to IGP'
                          )
                continue

            src_type = node.device_subtype
            dst_type = dst['phy'].device_subtype
            if src_type == 'IOS XRv':
                if dst_type == 'IOSv':
                    interface.isis.hello_padding_disable = True
                elif dst_type == 'CSR1000v':
                    interface.isis.hello_padding_disable = True
                elif dst_type == 'NX-OSv':
                    interface.isis.hello_padding_disable = True

            if src_type == 'IOSv':
                if dst_type == 'IOS XRv':
                    interface.isis.mtu = 1430
github sk2 / autonetkit / autonetkit / anm / graph.py View on Github external
def _copy_interfaces(self, node):
        """Copies ports from one overlay to another"""

        if self._overlay_id == "phy":
            # note: this will auto copy data from input if present - by default
            # TODO: provide an option to add_nodes to skip this
            # or would it be better to just provide a function in ank_utils to
            # wipe interfaces in the rare case it's needed?
            input_graph = self._anm.overlay_nx_graphs['input']
            if node not in input_graph:
                log.debug("Not copying interfaces for %s: ",
                          "not in input graph %s" % node)
                self._graph.node[node]['_ports'] = {
                    0: {'description': 'loopback', 'category': 'loopback'}}
                return

            try:
                input_interfaces = input_graph.node[node]['_ports']
            except KeyError:
                # Node not in input
                # Just do base initialisation of loopback zero
                self._graph.node[node]['_ports'] = {
                    0: {'description': 'loopback', 'category': 'loopback'}}
            else:
                interface_data = {'description': None,
                                  'category': 'physical'}
                # need to do dict() to copy, otherwise all point to same memory
github sk2 / autonetkit / autonetkit / ank_validate.py View on Github external
def validate(anm):
    log.debug("Validating overlay topologies")
    tests_passed = True
    tests_passed = validate_ipv4(anm) and tests_passed

    try:
        from autonetkit_cisco import ank_validate as cisco_validate
    except ImportError, e:
        log.debug("Unable to load autonetkit_cisco %s" % e)
    else:
        cisco_validate.validate(anm)

    validate_ibgp(anm)
    validate_igp(anm)
    check_for_selfloops(anm)
    all_nodes_have_asn(anm)

    if tests_passed:
        log.debug("All validation tests passed.")
    else:
        log.warning("Some validation tests failed.")
github datacenter / ignite-DEPRECATED / ank / autonetkit / autonetkit / build_network.py View on Github external
from autonetkit.design.mpls import mpls_te, mpls_oam
    mpls_te(anm)
    mpls_oam(anm)

# post-processing
    if anm['phy'].data.enable_routing:
        from autonetkit.design.mpls import (mark_ebgp_vrf,
                                            build_ibgp_vpn_v4)
        mark_ebgp_vrf(anm)
        build_ibgp_vpn_v4(anm)  # build after bgp as is based on
    # autonetkit.update_vis(anm)

    try:
        from autonetkit_cisco import build_network as cisco_build_network
    except ImportError, error:
        log.debug("Unable to load autonetkit_cisco %s", error)
    else:
        cisco_build_network.post_design(anm)

    # log.info("Finished building network")
    return anm