Example #1
0
    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: Controller access failure, reason: %s"
                  % result.brief)
            print ("\n").strip()
            break
        elif(result.status == http.OK):
            print("  '%s' is already mounted" % node_id)
            print ("\n").strip()
        elif(result.status == http.NOT_FOUND):
            nc_device = NETCONFDevice(item['name'],
                                      item['ip_addr'], item['port'],
                                      item['admin_name'], item['admin_pswd'])
            result = ctrl.netconf_node_mount(nc_device)
            if(result.status == http.OK):
                print ("  Mounted '%s' device" % nc_device.node_id)
                print ("\n").strip()
            else:
                print("!!!Error, reason: %s" % result.brief)
                print ("\n").strip()
        else:
            print("!!!Error, reason: %s" % result.brief)
            print ("\n").strip()