cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
291
Views
0
Helpful
1
Replies
Highlighted
Cisco Employee

[ISSUE} YDK-PY CRUD service with Python flask microframework

Hello Experts,

 

I'd like some guidance on a script that gets operational data from xr router, then certain key/values are extracted from the json output, with the goal to display it on a webpage (using YDK-PY with FLASK microframework to display data on to the webpage.

 

when I call the flask app.router(/interfaceStats) decorater, my script seems to hang at the CRUD operation.  During the crud -

intPropObj1=crud.read(provider, intPropObj)

the script hangs, and so does the flask web server.

 

Regards,

RK

 

Code Snippet -

 

@app.route('/interfaceStats')

def interfaceStats():

  _init_logging()

 

  dir_path = os.path.dirname(os.path.realpath(__file__))

 

  private = "%s/id_rsa" % dir_path

  public = "%s/id_rsa.pub" % dir_path

  print(dir_path, private, public)

 

 

  provider = NetconfServiceProvider(address='192.168.253.144',

                                    username='rkotwani',

                                    protocol='ssh',

                                    timeout=0,

                                    port=22,

                                    private_key_path=private,

                                    public_key_path=public)

 

  codec = CodecService()

  provider1 = CodecServiceProvider(type="json")

  print("past codec provider1")

  crud = CRUDService()

  print("past crud instantiation")

  intPropObj=ifmgr_oper.InterfaceProperties()

  print("here")

# Getting stuck below.

  intPropObj1=crud.read(provider, intPropObj)

# Getting stuck at the above line

  print("here 2")

  jsonIntPropObj = codec.encode(provider1, intPropObj1)

  print(jsonIntPropObj)

  return render_template('index.html')

1 REPLY 1
Highlighted
Cisco Employee

Re: [ISSUE} YDK-PY CRUD service with Python flask microframework

were you able to sort out the problem?

This widget could not be displayed.