Exemple #1
0
def get_schema():
    # Generate the connection and get the schema
    SCHEMA = devnet_connection.get_schema(YANG_MODEL)
    ROOT = ET.fromstring(SCHEMA.xml)
    YANG_TREE = list(ROOT)[0].text
    F = open("YANG/{}.yang".format(YANG_MODEL), "w")
    F.write(YANG_TREE)
    F.close()

    devnet_connection.close_session()
def delete_device_config():
    # Open XML template
    config_template = open("XML/delete_config.xml").read()
    for loopback in loopbacks:    
        # Input items into template
        config_delete = config_template.format(INTERFACE=loopback)
        # Edit configuration
        devnet_connection.edit_config(target="running", config=config_delete)
        print("\n*** The interface {} was deleted ***".format(loopback))
        #print(device_reply)

    devnet_connection.close_session()
Exemple #3
0
def view_device_config():
    # Open XML template
    config_template = open("XML/filter_config.xml").read()
    for loopback in loopbacks:
        # Input items into template
        config_filter = config_template.format(INTERFACE=loopback)
        # View item
        item_config = devnet_connection.get(config_filter)
        xmlDom = xmlparser.parseString(str(item_config))
        print("+"*25 + " " + loopback + " " + "+"*25 )
        print(xmlDom.toprettyxml(indent="    "))

    devnet_connection.close_session()
Exemple #4
0
def edit_device_config():
    # Open XML template
    config_template = open("XML/edit_config.xml").read()
    for loopback in loopbacks:
        # Input items into template
        config_new = config_template.format(
            INTERFACE=loopback, DESCRIPTION="DevNet test interface")
        devnet_connection.edit_config(target="running", config=config_new)
        print(
            "\n*** The interface {} has been configured ***".format(loopback))
        #print(device_reply)

    devnet_connection.close_session()
Exemple #5
0
from devnet_connection import devnet_connection


# Write a function to establish the remote connection and get device capabilities
def get_capabilities():
    for capability in devnet_connection.server_capabilities:
        print("-" * 50)
        print(capability)


devnet_connection.close_session()

# Call function
if __name__ == '__main__':
    get_capabilities()