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:Fastest way to get ipv4 object associated with a specific Ip? #55

Closed muthvar1 closed 5 years ago

muthvar1 commented 5 years ago

Hi Folks, Is there a short and fast way to get the ipv4 object associated with an ipv4 or ipv6 address if we have the address? I am looking to see if you have something below. IxNetwork.Topology.DeviceGroup.Ethernet.Ipv4.find(Value = '2.2.2.2')

Note: there could be an iterator so it could be a list of ips also and not a single value.

whandjr commented 5 years ago

Hi Varghese,

Others can chime in here. But I don’t think we have anything like that today. We are considering some ideas, but haven’t figured out how to make this work as yet.

The issue is in most cases the “address” is a multi-value pattern, and not a simple address. It could be a range of values. The pattern used to create the list of addresses doesn’t have to be contiguous, and can even be random. So there is no single “object” with that specific address. This is how IxNetwork is able to scale greatly. There may be an object associated with the address, but finding it is not as easy as “find()”. The find may be a very slow process as it would have to explode the pattern of addresses to the complete list represented by the pattern, and then search, which could take a very long time to execute, as there could be thousands or more of addresses.

What is the use case for finding an object with a specific address?

Thanks, Wes

Wesley Hand m: 818-312-6752

From: varghese muthalaly notifications@github.com Sent: Tuesday, April 23, 2019 7:49 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [OpenIxia/IxNetwork] RestPy:Fastest way to get ipv4 object associated with a specific Ip? (#55)

[EXTERNAL]

Hi Folks, Is there a short and fast way to get the ipv4 object associated with an ipv4 or ipv6 address if we have the address? I am looking to see if you have something below. IxNetwork.Topology.DeviceGroup.Ethernet.Ipv4.find(Value = '2.2.2.2')

Note: there could be an iterator so it could be a list of ips also and not a single value.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F55&data=02%7C01%7C%7C18842d25f3f245f6a19608d6c8464d25%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636916601610046512&sdata=y1LaGHc9LABV1Toz9QiB3VTKMQDSZ9Fz5pE8asO2rN4%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGJXMDGIHYP2AUX7ASX7JTDPR6N73ANCNFSM4HH7HTMQ&data=02%7C01%7C%7C18842d25f3f245f6a19608d6c8464d25%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636916601610046512&sdata=9nQxSLa7%2FPTp9RremM9PEMX%2FcoYb6Afea6L68GhOlsA%3D&reserved=0.

muthvar1 commented 5 years ago

Hi Wes, The use case in my scenario is that I within our test scripts for certain triggers, we would need to find the object(s) associated with an ip(s) to start or stop that specific device or send an arp/ns etc. Thsi is basically mimicking what we have available and perform routinely on the IxNetwork GUI client.

Secondly, You do have the Values under the iterator(multivalue Object) assigned to a specific attribute under the Address reference Object right? So should'nt there be a way to get this implemented then?

ipObject.href u'/api/v1/sessions/11/ixnetwork/topology/5/deviceGroup/2/ethernet/1/ipv4/1' ipObject.Address.Values [u'56.28.0.12', u'56.28.0.13', u'56.28.0.14', u'56.28.0.15', u'56.28.0.16', u'56.28.0.17', u'56.28.0.18', u'56.28.0.19', u'56.28.0.20', u'56.28.0.21']

whandjr commented 5 years ago

Hi Vargese,

This may be possible for the example given, as this use case is using the list pattern where each address is explicitly called out.

However, there are other patterns where the list is implied.

The solution would need to be built around a general case that supports all available patterns.

We are working on possible solutions for the general case. Will let you know if we come up with something.

Thanks for your inputs.

Thanks, Wes

Sent via the Samsung Galaxy S8+, please excuse typos.

-------- Original message -------- From: varghese muthalaly notifications@github.com Date: 4/24/19 5:09 PM (GMT-05:00) To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Wesley Hand wesley.hand@keysight.com, Comment comment@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] RestPy:Fastest way to get ipv4 object associated with a specific Ip? (#55)

[EXTERNAL]

Hi Wes, The use case in my scenario is that I within our test scripts for certain triggers, we would need to find the object(s) associated with an ip(s) to start or stop that specific device or send an arp/ns etc. Thsi is basically mimicking what we have available and perform routinely on the IxNetwork GUI client.

Secondly, You do have the Values under the iterator(multivalue Object) assigned to a specific attribute under the Address reference Object right? So should'nt there be a way to get this implemented then?

ipObject.href u'/api/v1/sessions/11/ixnetwork/topology/5/deviceGroup/2/ethernet/1/ipv4/1' ipObject.Address.Values [u'56.28.0.12', u'56.28.0.13', u'56.28.0.14', u'56.28.0.15', u'56.28.0.16', u'56.28.0.17', u'56.28.0.18', u'56.28.0.19', u'56.28.0.20', u'56.28.0.21']

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F55%23issuecomment-486427210&data=02%7C01%7C%7C79af6bd5147f45697a2008d6c8f91849%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636917369515210993&sdata=Abr8c5uRUzDnWV8AiIkI%2BoL4EPrs9gNYOSg4FZzqCyA%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGJXMDE3ASXO4NZYR3FLLWLPSDD7LANCNFSM4HH7HTMQ&data=02%7C01%7C%7C79af6bd5147f45697a2008d6c8f91849%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636917369515220993&sdata=J0f7mDjnlPwwKuCIgkfinOb%2Bc2%2F4jJgCEKm8EsSta4Y%3D&reserved=0.

ajbalogh commented 5 years ago

We currently do not support this methodology for finding instances as parent instances are required at this time. We are looking at implementing a solution that does not require parent instances.

muthvar1 commented 5 years ago

Thanks Wes,Andy. Is there a way we can document and track this request? This is something that we were really looking forward to in the RestPy SDK since it is an operation that was lacking in the earlier HLT sdk. This meant that we had to store numerous handles for every single ip we configured in some global data structure and maintain this through our tests. I was hoping with the query(find) functionality in the RestPy SDK that this would have been solved. At least this was my assumption.

Secondly. Is there any other way we can get this object? Seems like without having a reference parent object stored in some data structure that is maintained throughout the script life cycle, we can't query individual objects? Would the only way to retrieve this object (assuming we only use list patterns) is to retrieve all topologies, all devices under topologies, all ethernet devices under topologies and then do a nested search within that to get the related ipv4Object?

ajbalogh commented 5 years ago

You can get this object by specifying the find for all parent objects. A, B, C, D below would be replaced with the names of those objects.

ipv4 = Topology.find(Name='A'),DeviceGroup.find(Name='B').Ethernet.find(Name='C').Ipv4.find(Name='D')

muthvar1 commented 5 years ago

Hi Andy, The issue is that I would'nt know the name of the parent objects here. All that the consumer for this function would have is the ip address.