How to use the autonetkit.config.settings 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 sk2 / autonetkit / autonetkit / workflow.py View on Github external
def compile_network(anm):
    # log.info("Creating base network model")
    nidb = create_nidb(anm)
    g_phy = anm['phy']
    # log.info("Compiling to targets")

    for target_data in config.settings['Compile Targets'].values():
        host = target_data['host']
        platform = target_data['platform']
        if platform == 'netkit':
            import autonetkit.compilers.platform.netkit as pl_netkit
            platform_compiler = pl_netkit.NetkitCompiler(nidb, anm,
                                                         host)
        elif platform == 'VIRL':
            try:
                import autonetkit_cisco.compilers.platform.cisco as pl_cisco
                platform_compiler = pl_cisco.CiscoCompiler(nidb, anm,
                                                           host)
            except ImportError:
                log.debug('Unable to load VIRL platform compiler')
        elif platform == 'dynagen':
            import autonetkit.compilers.platform.dynagen as pl_dynagen
            platform_compiler = pl_dynagen.DynagenCompiler(nidb, anm,
github sk2 / autonetkit / autonetkit / compilers / platform / netkit.py View on Github external
def allocate_tap_ips(self):
        """Allocates TAP IPs"""
        settings = autonetkit.config.settings
        lab_topology = self.nidb.topology(self.host)
        from netaddr import IPNetwork
        address_block = IPNetwork(settings.get("tapsn")
                                  or "172.16.0.0/16").iter_hosts()  # added for backwards compatibility
        lab_topology.tap_host = address_block.next()
        lab_topology.tap_vm = address_block.next()  # for tunnel host
        for node in sorted(self.nidb.l3devices(host=self.host)):
            node.tap.ip = address_block.next()
github datacenter / ignite-DEPRECATED / autonetkit / build_network.py View on Github external
"""Module to build overlay graphs for network design"""

import autonetkit
import autonetkit.ank as ank_utils
import autonetkit.anm
import autonetkit.config
import autonetkit.exception
import autonetkit.log as log
import networkx as nx

from pool.pool import allocate_pool_entry

SETTINGS = autonetkit.config.settings

# TODO: revisit phy_neighbors for eg ASN and use layer3 instead

__all__ = ['build']


def load(input_graph_string, defaults = True):

    # TODO: look at XML header for file type
    import autonetkit.load.graphml as graphml
    import autonetkit.load.load_json as load_json
    try:
        input_graph = graphml.load_graphml(input_graph_string, defaults=defaults)
    except autonetkit.exception.AnkIncorrectFileFormat:
        try:
            input_graph = load_json.load_json(input_graph_string, defaults=defaults)
github sk2 / autonetkit / autonetkit / design / ip.py View on Github external
#!/usr/bin/python
# -*- coding: utf-8 -*-
import autonetkit.ank as ank_utils
import autonetkit.config
import autonetkit.log as log

SETTINGS = autonetkit.config.settings


# TODO: refactor to go in chronological workflow order




#@call_log
def build_ip(anm):
    g_ip = anm.add_overlay('ip')
    g_l2 = anm['layer2']
    g_phy = anm['phy']
    # Retain arbitrary ASN allocation for IP addressing
    g_ip.add_nodes_from(g_l2, retain=["asn", "broadcast_domain"])
    g_ip.add_edges_from(g_l2.edges())
github datacenter / ignite-DEPRECATED / ank / autonetkit / autonetkit / compilers / platform / cisco.py View on Github external
def _parameters(self):
        g_phy = self.anm['phy']
        settings = autonetkit.config.settings
        to_memory = settings['Compiler']['Cisco']['to memory']
        use_mgmt_interfaces = g_phy.data.mgmt_interfaces_enabled

        now = datetime.now()
        if settings['Compiler']['Cisco']['timestamp']:
            timestamp = now.strftime("%Y%m%d_%H%M%S_%f")
            dst_folder = os.path.join(
                "rendered", self.host, timestamp, "cisco")
        else:
            dst_folder = os.path.join("rendered", self.host, "cisco")

        # TODO: use a namedtuple
        return to_memory, use_mgmt_interfaces, dst_folder
github sk2 / autonetkit / autonetkit / ank_messaging.py View on Github external
def __init__(self, host = None):
        if use_http_post:
            host = config.settings['Http Post']['server']
            port = config.settings['Http Post']['port']
            self.http_url = "http://%s:%s/publish" % (host, port)
            self.publish = self.publish_http_post
            self.publish_compressed = self.publish_http_post
github sk2 / autonetkit / autonetkit / ank_messaging.py View on Github external
def format_http_url(host=None, port=None, route='publish'):
    if not host and not port:
        host = config.settings['Http Post']['server']
        port = config.settings['Http Post']['port']
    return 'http://%s:%s/%s' % (host, port, route)
github sk2 / autonetkit / autonetkit / rabbitmq_watch.py View on Github external
import pika
import autonetkit.config
import os
settings = autonetkit.config.settings
rabbitmq_server = settings['Rabbitmq']['server']


connection = pika.BlockingConnection(pika.ConnectionParameters(
        host = rabbitmq_server))
channel = connection.channel()

channel.exchange_declare(exchange='www',
        type='direct')

result = channel.queue_declare(exclusive=True)
queue_name = result.method.queue

channel.queue_bind(exchange='www',
                    queue=queue_name,
                    routing_key = "client")
github sk2 / autonetkit / autonetkit / design / ip_addressing / ipv6.py View on Github external
import autonetkit.ank as ank_utils
import autonetkit.config
import autonetkit.log as log
from autonetkit.ank import sn_preflen_to_network
from netaddr import IPAddress

SETTINGS = autonetkit.config.settings

#@call_log


def manual_ipv6_loopback_allocation(anm):
    """Applies manual IPv6 allocation"""

    import netaddr
    g_ipv6 = anm['ipv6']
    g_in = anm['input']

    for l3_device in g_ipv6.l3devices():
        try:
            l3_device.loopback = IPAddress(l3_device['input'].loopback_v6)
        except netaddr.AddrFormatError:
            log.debug("Unable to parse IP address %s on %s",
github sk2 / autonetkit / autonetkit / measure_client.py View on Github external
def main():
    import argparse
    usage = "ank_measure_client"
    parser = argparse.ArgumentParser(description = usage)
    parser.add_argument('--hostname',  default= "measure_client", help="Hostname for messaging")   
    parser.add_argument('--server', '-s',  default= None, help="RabbitMQ server")   
    arguments = parser.parse_args()

    server = arguments.hostname
    try:
        pika_host = arguments.server # test if manually specified
    except IndexError:
        import autonetkit.config as config
        pika_host = config.settings['Rabbitmq']['server']

    connection = pika.BlockingConnection(pika.ConnectionParameters(
            host = pika_host))
    channel = connection.channel()

    channel.exchange_declare(exchange='measure',
            type='direct')

    result = channel.queue_declare(exclusive=True)
    queue_name = result.method.queue

    channel.queue_bind(exchange='measure',
                       queue=queue_name,
                       routing_key = server)

    print ' [*] Waiting for messages. To exit press CTRL+C'