def main():
    """ Print documentation; Print configuration of each device."""
    print(cleandoc(__doc__))
    print()
    
    print('Loaded from:', getfile(config_module))
    print()
    
    if not inventory_config:
        print("There are no network devices configured.")
        return EX_TEMPFAIL

    print('Configured devices.')
    print_table(inventory_config)
    print()
    
    exit_code = EX_OK
    for device_config in inventory_config:
        try:
            http_session = connect(**device_config)
            print('Connected to', session_device_url(http_session))
            disconnect(http_session)
        except IOError:
            log(WARN, 'Unable to connect to Nexus device %s', str(device_config))
            exit_code = EX_TEMPFAIL
            continue
    return exit_code
예제 #2
0
def main():
    """ Oversee the sequence of tasks as per the documentation of this script. """
    print(cleandoc(__doc__))
    print()

    print('Select an appropriate device from those available.')
    print_table(inventory_config)
    print()
    for device_config in inventory_config:
        try:
            http_session = connect(**device_config)
            try:
                print('Connected to', session_device_url(http_session))
                print()
                demonstrate(http_session)
                return EX_OK if print_command_reference(
                    http_session, command) else EX_TEMPFAIL
            finally:
                disconnect(http_session)
        except IOError:
            log(WARN, 'Unable to connect to Nexus device %s',
                str(device_config))
            continue

    print("There are no suitable network devices. Demonstration cancelled.")
    return EX_TEMPFAIL
def main():
    """ Print documentation; Print configuration of each device."""
    print(cleandoc(__doc__))
    print()

    print('Loaded from:', getfile(config_module))
    print()

    if not inventory_config:
        print("There are no network devices configured.")
        return EX_TEMPFAIL

    print('Configured devices.')
    print_table(inventory_config)
    print()

    exit_code = EX_OK
    for device_config in inventory_config:
        try:
            http_session = connect(**device_config)
            print('Connected to', session_device_url(http_session))
            disconnect(http_session)
        except IOError:
            log(WARN, 'Unable to connect to Nexus device %s',
                str(device_config))
            exit_code = EX_TEMPFAIL
            continue
    return exit_code
def main():
    """ Oversee the sequence of tasks as per the documentation of this script. """
    print(cleandoc(__doc__))
    print()
    
    print('Select an appropriate device from those available.')
    print_table(inventory_config)
    print()
    for device_config in inventory_config:
        try:
            http_session = connect(**device_config)
            try:
                print('Connected to', session_device_url(http_session))
                print()
                demonstrate(http_session)
                return EX_OK if print_command_reference(http_session, command) else EX_TEMPFAIL        
            finally:
                disconnect(http_session)
        except IOError:
            log(WARN, 'Unable to connect to Nexus device %s', str(device_config))
            continue
    
    print("There are no suitable network devices. Demonstration cancelled.")
    return EX_TEMPFAIL