OpenIxia / IxNetwork

A central location for IxNetwork sample scripts and utilities. Please also visit http://openixia.com
MIT License
50 stars 59 forks source link

RestPy: lookup by Href not working as expected. #41

Closed muthvar1 closed 5 years ago

muthvar1 commented 5 years ago

Opening this issue as a continuation to issue#40 RestPy:Any example to retreive object using href? #40

Seems like the options provided do not work as expected, or I probably need to use a different set of procs to attain the same objective.

Has anyone tried this? I can't seem to get the ixnetwork object or any other object instance using this

session = testPlatform.Sessions.find(Id='17') 2019-03-05 00:04:34 [ixnetwork_restpy.connection] [DEBUG] GET https://10.23.239.233:443/api/v1/sessions None 2019-03-05 00:04:34 [ixnetwork_restpy.connection] [DEBUG] 200 OK ixNetwork = session.GetObjectFromHref('/api/v1/sessions/17/ixnetwork') ixNetwork ixNetwork = session.GetObjectFromHref(href = '/api/v1/sessions/17/ixnetwork') ixNetwork

r = session.GetObjectFromHref(href = '/api/v1/sessions/17/ixnetwork/topology') r

ajbalogh commented 5 years ago

handles are not supported - the class properties should be used ie session.Ixnetwork.

muthvar1 commented 5 years ago

So how else can I achieve this problem statement? I will describe the problem statement below. Can you please tell me how to achieve what I am looking for.

muthvar1 commented 5 years ago

handles are not supported - the class properties should be used ie session.Ixnetwork.

I am not sure I understood this? If the lookup is by href, then it should accept the href as a string right? Else this function does not seem useful to me. Like I mentioned in my problem statement in Issue#40. The href handle I have is retrieved from the api browser window.

ajbalogh commented 5 years ago

Every object that is multi instance supports a .find() command with options for finding specific objects. For example Sessions allows finding by Id. Vports, topologies can be found by name. IxNetwork is a single instance object so there is no need to find it - you just access the class property on sessions and you have the object.

muthvar1 commented 5 years ago

Just an update on this thread. Figured out one mistake I was doing here. The id in testPlatform.Sessions.find(Id='17') should be integer and not string. If string is provided it gives a random object and not the actual session you request.

ajbalogh commented 5 years ago

Thanks for that - i will coerce the id in the sessions class.

On Fri, Mar 8, 2019 at 3:09 PM varghese muthalaly notifications@github.com wrote:

Just an update on this thread. Figured out one mistake I was doing here. The id in testPlatform.Sessions.find(Id='17') should be integer and not string. If string is provided it gives a random object and not the actual session you request.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/OpenIxia/IxNetwork/issues/41#issuecomment-471108188, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac5ZltfGJt_wRQlFVpvi8LyvbkBhq_ATks5vUu2dgaJpZM4bdfSj .