コード例 #1
0
def collect_info():
    """
    read inventory.yml as input information, out_templates.yml as information about textfsm templates and return dic of
    collected info
    :return:
    """
    parsed_yaml_inventory = read_yaml(path="inventory.yml")
    parsed_yaml_template = read_yaml(path="out_templates.yml")
    # pprint(parsed_yaml_template)
    connection_params = form_connection_params_from_yaml(parsed_yaml_inventory)
    # pprint(connection_params)

    # check wrong names in inventory file
    wrong_names = []
    for device_type in connection_params.keys():
        if device_type not in parsed_yaml_template.keys():
            print(
                'device type {type} does not have OUT template in out_templates.yml\nDelete it'.format(
                    type=device_type))
            wrong_names.append(device_type)
    for name in wrong_names:
        del (connection_params[name])

    total_result = {}
    for device_type, device_list in connection_params.items():
        device_count = len(device_list)
        type_result_list = collect_info_device_type(
            device_list, parsed_yaml_template[device_type], device_count, parsed_yaml_template['command_list'])
        total_result.update({device_type: type_result_list})
    return total_result
コード例 #2
0
def main():
    parsed_yaml = read_yaml()
    loop = asyncio.get_event_loop()
    tasks = [
        loop.create_task(collect_outputs(device, COMMANDS_LIST))
        for device in form_connection_params_from_yaml(parsed_yaml, site=SITE_NAME)
    ]
    loop.run_until_complete(asyncio.wait(tasks))
    for task in tasks:
        print(task.result())
def main():
    start_time = time.time()

    parsed_yaml = read_yaml()
    devices_params_gen = form_connection_params_from_yaml(parsed_yaml,
                                                          site_name='sjc')

    loop = asyncio.get_event_loop()

    tasks = [
        loop.create_task(configure_device_from_netbox(device_params))
        for device_params in devices_params_gen
    ]

    loop.run_until_complete(asyncio.wait(tasks))

    # for task in tasks:
    #     print(task.result())

    print('It took {} seconds to run'.format(time.time() - start_time))
def add_devices():
    parsed_yaml = read_yaml()
    devices_params_gen = form_device_params_from_yaml(parsed_yaml)
    for device_params in devices_params_gen:
        add_device(**device_params)
    print('All devices have been imported')
コード例 #5
0
    print('Confusion Matrix')
    print(confusion_matrix(y_true, y_pred))
    print('Classification Report')
    target_names = ['B', 'C']
    print(classification_report(y_true, y_pred, target_names=target_names))
    f1 = f1_score(y_true, y_pred, average=None)
    acc = accuracy_score(y_true, y_pred)
    return acc, f1


if __name__ == '__main__':

    YAML_FILE = sys.argv[1]
    # YAML_FILE = 'train'

    CONFIG = read_yaml(YAML_FILE)

    TRAINING_PARAMS = CONFIG['Training']['Params']
    OUTPUT_TRAIN_FILES = CONFIG['Training']['Output']
    IMG_ROWS = CONFIG['ImageData']['Rows']
    IMG_COLS = CONFIG['ImageData']['Cols']

    METHODS = CONFIG['Augmentation']['Methods']

    AUG_SCALE_FACTOR = CONFIG['Augmentation']['ScalingFactor']

    MODEL = CONFIG['Model']['Name']

    us_images_dir = CONFIG['DataPartition']['USImagesDir']
    pat_images_dir = CONFIG['DataPartition']['PATImagesDir']
コード例 #6
0
def main():
    parsed_yaml = read_yaml()
    connection_params = form_connection_params_from_yaml(parsed_yaml,
                                                         site=SITE_NAME)
    for device_result in collect_outputs(connection_params, COMMANDS_LIST):
        print(device_result)
コード例 #7
0
def index():
    devices = read_yaml('devices.yaml')
    return render_template('index.html', routers=devices)