Example #1
0
    if(nc_dev_cfg is None):
        print("!!!Error, reason: failed to get NETCONF devices configuration")
        exit(1)

    # Allocate object instance that represents the Controller
    ctrl = ODLController(ctrl_cfg['ip_addr'], ctrl_cfg['http_port'],
                         ctrl_cfg['admin_name'], ctrl_cfg['admin_pswd'])

    print("\n").strip()
    print("Controller: '%s:%s'" % (ctrl.ip_addr, ctrl.port))
    print("\n").strip()

    # Communicate to the Controller and display the result of communication
    for item in nc_dev_cfg:
        node_id = item['name']
        result = ctrl.netconf_node_is_mounted(node_id)
        if(result.status == http.SERVICE_UNAVAILABLE or
           result.status == http.UNAUTHORIZED):
            print("!!!Error, reason: %s" % result.brief)
            print ("\n").strip()
            break
        elif(result.status == http.NOT_FOUND):
            print("  '%s' is not mounted" % node_id)
            print("\n").strip()
        elif(result.status == http.OK):
            result = ctrl.netconf_node_unmount(node_id)
            if(result.status == http.OK):
                print ("  Unmounted '%s' device" % node_id)
                print("\n").strip()
            else:
                print("!!!Error, reason: %s" % result.brief)