def print_output(dev):
    device = {}
    device["hostname"] = srx_device().facts['hostname']
    device["connected_user"] = dev.user
    device["connected_port"] = dev.port
    device["route_table"] = route.items()
    device["arp_table"] = arp.items()
    pprint(device)
             format="set",
             merge=True)
    cfg.load("delete routing-options static route 203.0.113.200/32",
             format="set",
             merge=True)
    print("deleting the routes")
    if cfg.diff() is not None:
        cfg.commit()
    cfg.unlock()


def Compare_routes(routes, updated_routes):
    new_routes = []
    for route in updated_routes.keys():
        if route not in routes.keys():
            new_routes.append(route)
    return new_routes


if __name__ == "__main__":
    a_device = srx_device()
    a_device.timeout = 60
    cfg = Config(a_device)
    route = gather_routes(a_device)
    Config_from_file(path="static_routes.conf", a_device=a_device, merge=True)
    updated_routes = gather_routes(a_device)
    new_routes = Compare_routes(route, updated_routes)

    print("The new routes are", new_routes)
    Del_routes(a_device)
from getpass import getpass
from jnpr_devices import srx_device

a_device = {}
if a_device == True:
    a_device = Device(host="srx2.lasthop.io",
                      user="******",
                      password=getpass())
    a_device.open()
    a_device.timeout = 60
    cfg = Config(a_device)
    cfg.lock()

#### Class 8 exercise 3a  importing srx_device###
else:
    srx_device().timeout = 60
    cfg = Config(srx_device())

    ## Gracefully handle the LockError
    try:
        cfg.lock()
        print("locking the configuration")
    except LockError:
        print("Already locked")

cfg.load("set system host-name python4life", format="set", merge=True)
#cfg.rollback(0)
print(cfg.diff())
#cfg.commit(comment =" Making hostname change")
### Rollback the configuration ###
print("Making hostname change")
def gather_arp_table(device):
    arp = ArpTable(srx_device())
    arp.get()
    return arp
def gather_routes(device):
    route = RouteTable(srx_device())
    route.get()
    return route
from jnpr.junos import Device
from getpass import getpass
from pprint import pprint
from jnpr_devices import srx_device

a = srx_device()
print(a.facts)