Пример #1
0
def deploy_network(anm, nidb, input_graph_string=None):

    # TODO: make this driven from config file
    log.info("Deploying Network")

    # TODO: pick up platform, host, filenames from nidb (as set in there)
    deploy_hosts = config.settings['Deploy Hosts']
    for hostname, host_data in deploy_hosts.items():
        for platform, platform_data in host_data.items():
            if not any(nidb.nodes(host=hostname, platform=platform)):
                log.debug(
                    "No hosts for (host, platform) (%s, %s), skipping deployment"
                    % (hostname, platform))
                continue

            if not platform_data['deploy']:
                log.debug("Not deploying to %s on %s" % (platform, hostname))
                continue

            config_path = os.path.join("rendered", hostname, platform)

            if hostname == "internal":
                try:
                    from autonetkit_cisco import deploy as cisco_deploy
                except ImportError:
                    pass  # development module, may not be available
                if platform == "cisco":
                    create_new_xml = False
                    if not input_graph_string:
                        create_new_xml = True  # no input, eg if came from grid
                    elif anm['input'].data['file_type'] == "graphml":
                        create_new_xml = True  # input from graphml, create XML

                    if create_new_xml:
                        cisco_deploy.create_xml(anm, nidb, input_graph_string)
                    else:
                        cisco_deploy.package(nidb, config_path,
                                             input_graph_string)
                continue

            username = platform_data['username']
            key_file = platform_data['key file']
            host = platform_data['host']

            if platform == "netkit":
                import autonetkit.deploy.netkit as netkit_deploy
                tar_file = netkit_deploy.package(config_path, "nklab")
                netkit_deploy.transfer(host, username, tar_file, tar_file,
                                       key_file)
                netkit_deploy.extract(host,
                                      username,
                                      tar_file,
                                      config_path,
                                      timeout=60,
                                      key_filename=key_file)
            if platform == "cisco":
                #TODO: check why using nklab here
                cisco_deploy.package(config_path, "nklab")
Пример #2
0
def deploy_network(anm, nidb, input_graph_string=None):

    log.info("Deploying Network")

    deploy_hosts = config.settings['Deploy Hosts']
    for hostname, host_data in deploy_hosts.items():
        for platform, platform_data in host_data.items():
            if not any(nidb.nodes(host=hostname, platform=platform)):
                log.debug("No hosts for (host, platform) (%s, %s), skipping deployment"
                          % (hostname, platform))
                continue

            if not platform_data['deploy']:
                log.debug("Not deploying to %s on %s" % (platform, hostname))
                continue

            config_path = os.path.join("rendered", hostname, platform)

            if hostname == "internal":
                try:
                    from autonetkit_cisco import deploy as cisco_deploy
                except ImportError:
                    pass  # development module, may not be available
                if platform == "VIRL":
                    create_new_xml = False
                    if not input_graph_string:
                        create_new_xml = True  # no input, eg if came from grid
                    elif anm['input'].data['file_type'] == "graphml":
                        create_new_xml = True  # input from graphml, create XML

                    if create_new_xml:
                        cisco_deploy.create_xml(anm, nidb, input_graph_string)
                    else:
                        cisco_deploy.package(nidb, config_path,
                                             input_graph_string)
                continue

            username = platform_data['username']
            key_file = platform_data['key_file']
            host = platform_data['host']

            if platform == "netkit":
                import autonetkit.deploy.netkit as netkit_deploy
                tar_file = netkit_deploy.package(config_path, "nklab")
                netkit_deploy.transfer(
                    host, username, tar_file, tar_file, key_file)
                netkit_deploy.extract(host, username, tar_file,
                                      config_path, timeout=60, key_filename=key_file,
                                      parallel_count=10)
                if platform == "VIRL":
                    # TODO: check why using nklab here
                    cisco_deploy.package(config_path, "nklab")
Пример #3
0
def deploy_network(anm, nidb, input_graph_string):

    # TODO: make this driven from config file
    log.info("Deploying network")

# TODO: pick up platform, host, filenames from nidb (as set in there)
    deploy_hosts = config.settings['Deploy Hosts']
    for hostname, host_data in deploy_hosts.items():
        for platform, platform_data in host_data.items():
            if not any(nidb.nodes(host=hostname, platform=platform)):
                log.debug("No hosts for (host, platform) (%s, %s), skipping deployment"
                        % (hostname, platform))
                continue

            if not platform_data['deploy']:
                log.debug("Not deploying to %s on %s" % (platform, hostname))
                continue

            config_path = os.path.join("rendered", hostname, platform)

            if hostname == "internal":
                try:
                    from autonetkit_cisco import deploy as cisco_deploy
                except ImportError:
                    pass  # development module, may not be available
                if platform == "cisco":
                    if input_graph_string: # input xml file
                        cisco_deploy.package(nidb, config_path, input_graph_string)
                    else:
                        cisco_deploy.create_xml(anm, nidb, input_graph_string)
                continue

            username = platform_data['username']
            key_file = platform_data['key file']
            host = platform_data['host']

            if platform == "netkit":
                import autonetkit.deploy.netkit as netkit_deploy
                tar_file = netkit_deploy.package(config_path, "nklab")
                netkit_deploy.transfer(
                    host, username, tar_file, tar_file, key_file)
                netkit_deploy.extract(host, username, tar_file,
                                      config_path, timeout=60, key_filename=key_file)
            if platform == "cisco":
                cisco_deploy.package(config_path, "nklab")
Пример #4
0
def deploy_network(anm, nidb, input_graph_string, hosts):

    # TODO: make this driven from config file
    log.info("Deploying network")

    for target in hosts:
        try:
            target_data = config.settings['Hosts'][target]
        except KeyError:
            log.warning("Host %s not defined in configuration" % target)
            continue

        try:
            platform = target_data['platform']
        except KeyError:
            log.warning("no platform defined for %s" % target)
            continue

        config_path = os.path.join("rendered", "%s_%s" % (target, platform))
        
        if not target == "localhost":
            try:
                host = target_data['host']
            except KeyError:
                log.warning("Host %s has no address" % target)

            try: 
                username = target_data['username'] or ""
            except KeyError:
                username = ""
                
            try:
                key_file = target_data['keyfile'] or ""
                if not os.path.isfile(key_file):
                    raise KeyError 
                passwd = None 
            except KeyError:
                import getpass
                print "Please provide your password for the host", host
                passwd = getpass.getpass()
                key_file = None 

        if host == "internal":
            try:
                from autonetkit_cisco import deploy as cisco_deploy
            except ImportError:
                pass  # development module, may not be available
            if platform == "cisco":
                if input_graph_string: # input xml file
                    cisco_deploy.package(nidb, config_path, input_graph_string)
                else:
                    cisco_deploy.create_xml(anm, nidb, input_graph_string)
            continue

        if platform == "netkit":
            import autonetkit.deploy.netkit as netkit_deploy
            tar_file = netkit_deploy.package(config_path, "nklab")
            netkit_deploy.transfer(host, username, tar_file, tar_file, key_filename=key_file, password=passwd)
            netkit_deploy.extract(host, username, tar_file,
                                config_path, timeout=3600, key_filename=key_file, password=passwd)
        if platform == "cisco":
            cisco_deploy.package(config_path, "nklab")
Пример #5
0
def deploy_network(anm, nidb, input_graph_string=None):

    # log.info('Deploying Network')

    deploy_hosts = config.settings['Deploy Hosts']
    for (hostname, host_data) in deploy_hosts.items():
        for (platform, platform_data) in host_data.items():
            if not any(nidb.nodes(host=hostname, platform=platform)):
                log.debug(
                    'No hosts for (host, platform) (%s, %s), skipping deployment'
                    % (hostname, platform))
                continue

            if not platform_data['deploy']:
                log.debug('Not deploying to %s on %s' % (platform, hostname))
                continue

            config_path = os.path.join('rendered', hostname, platform)

            if hostname == 'internal':
                try:
                    from autonetkit_cisco import deploy as cisco_deploy
                except ImportError:
                    pass  # development module, may not be available
                if platform == 'VIRL':
                    create_new_xml = False
                    if not input_graph_string:
                        create_new_xml = True  # no input, eg if came from grid
                    elif anm['input'].data['file_type'] == 'graphml':
                        create_new_xml = True  # input from graphml, create XML

                    if create_new_xml:
                        cisco_deploy.create_xml(anm, nidb, input_graph_string)
                    else:
                        cisco_deploy.package(nidb, config_path,
                                             input_graph_string)
                continue

            username = platform_data['username']
            key_file = platform_data['key_file']
            host = platform_data['host']

            if platform == 'netkit':
                import autonetkit.deploy.netkit as netkit_deploy
                tar_file = netkit_deploy.package(config_path, 'nklab')
                netkit_deploy.transfer(host, username, tar_file, tar_file,
                                       key_file)
                netkit_deploy.extract(
                    host,
                    username,
                    tar_file,
                    config_path,
                    timeout=60,
                    key_filename=key_file,
                    parallel_count=10,
                )
                if platform == 'VIRL':

                    # TODO: check why using nklab here

                    cisco_deploy.package(config_path, 'nklab')