예제 #1
0
def run_from_report(input_file, config_file, log_file, report_file, autoload):
    """Create and autoload CloudShell resources from the generated report"""
    input_data_parser = get_input_data_parser(input_file)
    input_data_model = input_data_parser.parse(input_file)
    logger = get_logger(log_file)

    if config_file is None:
        additional_vendors_data = []
    else:
        config_data_parser = get_config_data_parser(config_file)
        additional_vendors_data = config_data_parser.parse(config_file)

    report = reports.discovery.get_report(report_file=report_file)
    parsed_entries = report.parse_entries_from_file(report_file)

    cs_session_manager = CloudShellSessionManager(
        cs_ip=input_data_model.cs_ip,
        cs_user=input_data_model.cs_user,
        cs_password=input_data_model.cs_password,
        logger=logger)

    command = commands.RunFromReportCommand(
        data_processor=JsonDataProcessor(logger=logger),
        report=reports.discovery.get_report(
            report_file=report_file,
            report_type=reports.discovery.DEFAULT_REPORT_TYPE),
        logger=logger,
        cs_session_manager=cs_session_manager,
        output=ConsoleOutput(),
        autoload=autoload)

    command.execute(parsed_entries=parsed_entries,
                    additional_vendors_data=additional_vendors_data)
예제 #2
0
def connect_ports_from_report(input_file, connections_report_file, log_file):
    """Create connections between CloudShell Port resources specified in the connection file"""
    input_data_parser = get_input_data_parser(input_file)
    input_data_model = input_data_parser.parse(input_file)
    logger = get_logger(log_file)

    report = reports.connections.get_report(
        report_file=connections_report_file)
    parsed_entries = report.parse_entries_from_file(connections_report_file)

    cs_session_manager = CloudShellSessionManager(
        cs_ip=input_data_model.cs_ip,
        cs_user=input_data_model.cs_user,
        cs_password=input_data_model.cs_password,
        logger=logger)

    command = commands.ConnectPortsFromReportCommand(
        cs_session_manager=cs_session_manager,
        report=reports.connections.get_report(
            report_file=connections_report_file),
        logger=logger,
        output=ConsoleOutput())

    command.execute(parsed_entries=parsed_entries)
예제 #3
0
def connect_ports(input_file, resources_names, domain, offline,
                  connections_report_file, connections_report_type, log_file):
    """Create connections between CloudShell Port resources based on the "Adjacent" attributes"""
    input_data_parser = get_input_data_parser(input_file)
    input_data_model = input_data_parser.parse(input_file)
    logger = get_logger(log_file)

    cs_session_manager = CloudShellSessionManager(
        cs_ip=input_data_model.cs_ip,
        cs_user=input_data_model.cs_user,
        cs_password=input_data_model.cs_password,
        logger=logger)

    command = commands.ConnectPortsCommand(
        cs_session_manager=cs_session_manager,
        report=reports.connections.get_report(
            report_file=connections_report_file,
            report_type=connections_report_type),
        offline=offline,
        logger=logger,
        output=ConsoleOutput())

    resources_names = [name.strip() for name in resources_names.split(",")]
    command.execute(resources_names=resources_names, domain=domain)
예제 #4
0
def run(input_file, config_file, log_file, report_file, report_type, offline,
        autoload):
    """Run Auto discovery command with given arguments from the input file"""
    input_data_parser = get_input_data_parser(input_file)
    input_data_model = input_data_parser.parse(input_file)
    logger = get_logger(log_file)

    if config_file is None:
        additional_vendors_data = []
    else:
        config_data_parser = get_config_data_parser(config_file)
        additional_vendors_data = config_data_parser.parse(config_file)

    report = reports.discovery.get_report(report_file=report_file,
                                          report_type=report_type)

    cs_session_manager = CloudShellSessionManager(
        cs_ip=input_data_model.cs_ip,
        cs_user=input_data_model.cs_user,
        cs_password=input_data_model.cs_password,
        logger=logger)

    auto_discover_command = commands.RunCommand(
        data_processor=JsonDataProcessor(logger=logger),
        report=report,
        logger=logger,
        cs_session_manager=cs_session_manager,
        output=ConsoleOutput(),
        offline=offline,
        autoload=autoload)

    auto_discover_command.execute(
        devices_ips=input_data_model.devices_ips,
        snmp_comunity_strings=input_data_model.snmp_community_strings,
        vendor_settings=input_data_model.vendor_settings,
        additional_vendors_data=additional_vendors_data)