Esempio n. 1
0
def main():
    async_scrapli = True
    if not async_scrapli:
        conn = NXOSDriver(**n9kv_ssh)
        conn.open()
        response = conn.send_command("show run")
        print(response.result)
    else:
        asyncio.get_event_loop().run_until_complete(get_config())
Esempio n. 2
0
def connectToDevice(deviceconfig):
    """
    Parse device config data & open SSH connection
    """
    print("Loading device configuration...")
    device = {}
    device["host"] = deviceconfig["address"]
    device["auth_username"] = deviceconfig["username"]
    device["auth_password"] = deviceconfig["password"]
    device["auth_strict_key"] = False
    device["timeout_socket"] = 10
    device["timeout_ops"] = 10
    try:
        device["port"] = deviceconfig["port"]
    except KeyError:
        pass
    if deviceconfig["type"] == "ios-xe":
        conn = IOSXEDriver(**device)
    elif deviceconfig["type"] == "nx-os":
        conn = NXOSDriver(**device)
    try:
        print(f"Attempting connection to {device['host']}")
        conn.open()
        print(f"Successfully connected to {device['host']}")
    except Exception as e:
        print(f"Failed connection to {device['host']}")
        print("Error message is: %s" % e)
        return None
    return conn
Esempio n. 3
0
def test_nxos_driver_init_telnet():
    conn = NXOSDriver(host="myhost", transport="telnet")
    assert conn.transport.username_prompt == "login:"
Esempio n. 4
0
import logging
from pathlib import Path

from device_info import nxos_device

from scrapli.driver.core import NXOSDriver

logging.basicConfig(
    filename=f"{Path(__file__).resolve().parents[0]}/nxos_driver.log", level=logging.DEBUG
)
logger = logging.getLogger("scrapli")

conn = NXOSDriver(**nxos_device)
conn.open()

print("***** Get Prompt:")
prompt = conn.get_prompt()
print(prompt)

print("***** Show run | i hostname:")
result = conn.send_command("show run | i hostname")
print(result, result.result)

print("***** Disable Paging:")
result = conn.send_command("term length 0")
print(result, result.result)

print("***** Show run:")
result = conn.send_command("show run")
print(result, result.result)