def login(interactive_login): """ Login to APIC-EM northbound APIs in shell. Returns: Client (NbClientManager) which is already logged in. """ if interactive_login : print("\nEnter APIC-EM hostname or IP") server = input("Server: ") print("\nEnter APIC-EM Username") username = input("Username: "******"\nEnter APIC-EM password") password = getpass(prompt='Your password: '******'Authentication Failed. Please provide valid username/password.') else: print('HTTP Status Code {code}. Reason: {reason}'.format( code=exc_info.response.status_code, reason=exc_info.response.reason)) exit(1) except requests.exceptions.ConnectionError: print('Connection aborted. Please check if the host {host} is available.'.format(host=server)) exit(1)
def login(): """ Login to APIC-EM northbound APIs in shell. Returns: Client (NbClientManager) which is already logged in. """ try: client = NbClientManager(server=DNAC, username=DNAC_USER, password=DNAC_PASSWORD, port=DNAC_PORT, connect=True) return client except requests.exceptions.HTTPError as exc_info: if exc_info.response.status_code == 401: print( 'Authentication Failed. Please provide valid username/password.' ) else: print('HTTP Status Code {code}. Reason: {reason}'.format( code=exc_info.response.status_code, reason=exc_info.response.reason)) exit(1) except requests.exceptions.ConnectionError: print( 'Connection aborted. Please check if the host {host} is available.' .format(host=DNAC)) exit(1)
def login(): """ Login to APIC-EM northbound APIs in shell. Returns: Client (NbClientManager) which is already logged in. """ parser = argparser() args = parser.parse_args() using_parser = False if args.cluster or args.username or args.password: using_parser = True host = args.cluster or None username = args.username or None password = args.password or None client = None while not client: host_prompt = 'Host Address[{}]: '.format( host) if host else 'Host Address: ' username_prompt = 'Username[{}]: '.format( username) if username else 'Username: '******'Password: '******'Authentication Failed. Please provide valid username/password.' ) continue else: print('HTTP Status Code {code}. Reason: {reason}'.format( code=exc_info.response.status_code, reason=exc_info.response.reason)) exit(1) except requests.exceptions.ConnectionError: print( 'Connection aborted. Please check if the host {} is available.' .format(host)) exit(1) return client
def login(): apic = os.getenv("APIC_SERVER") or "sandboxapic.cisco.com" username = os.getenv("APIC_USERNAME") or "devnetuser" password = os.getenv("APIC_PASSWORD") or "Cisco123!" try: client = NbClientManager(server=apic, username=username, password=password, connect=True) return client except: return None
def login(): apic = "sandboxapic.cisco.com" username = "******" password = "******" try: client = NbClientManager(server=apic, username=username, password=password, connect=True) return client except: return None
result = wait.until( query_discovery_status, timeout=timeout, interval=polling_interval, message="Timeout while waiting discovery complete.") except UniqException: print("Discovery job did not Complete in {0} seconds.".format(timeout)) if result == "Complete": print("Discovery job successfully completed.") elif result == "Failed": print("Discovery job failed to complete.") client = NbClientManager(server="1.1.1.1", username="******", password="******", connect=True) wait = Wait() request = { "name": "example_job", "discoveryType": "single", "protocolOrder": "ssh,telnet", "ipAddressList": "1.1.1.2", "retry": "3", "timeout": "60", "userNameList": ["******"], "passwordList": ["******"], "enablePasswordList": ["******"], "snmpROCommunity": "******", "snmpRWCommunity": "******",
def setup_nb_client(self): """ Returns faked NbClientManager nb. """ nb = NbClientManager('1.2.3.4', 'username', 'password', connect=False) return nb