Closed phantium closed 7 years ago
We will look into this issue as discussed:), Regards, Marc
Is this example usefull? https://github.com/nuagenetworks/vspk-examples/blob/master/fip_overview.py
Of course the example works, but this comes down to my complaint again that is it VERY slow. Listing just 38 FIPs will take around 12-13 seconds.
For now I have worked around this with the following code, it effectively puts the FIPs in a dictionary. As this is slow, you don't want to generate it too often. Would still like to see a solution for this from Nuage.
fiplist = {}
from vspk.v3_2 import NUVSDSession
session = NUVSDSession(username=u'csproot', password=u'csproot', enterprise=u'csp', api_url=u'https://my.vsd.ip')
session.start()
user = session.user
for fip in user.floating_ips.get():
try:
vport = fip.vports.get()[0]
except IndexError:
vport = None
if vport:
interface = vport.vm_interfaces.get()[0]
else:
interface = None
if interface:
vm = vport.vms.get()[0]
if fip.address and interface:
fiplist[interface.vmuuid] = {}
fiplist[interface.vmuuid]['fip'] = fip.address
And then also using the nova API to get all the desired data.
from novaclient import client
nova = client.Client("2", "admin", "password", "admin", "https://cloud_address:13000/v2.0")
for i in nova.servers.list(search_opts={'all_tenants': 1}):
if i.id in fiplist:
print i.id, i.name, i.addresses.values()[-1:][0][0]['addr'], fiplist[i.id]['fip'], getattr(i, 'OS-EXT-AZ:availability_zone'), getattr(i, 'OS-EXT-SRV-ATTR:instance_name').replace('inst', 'instance')
else:
print i.id, i.name, i.addresses.values()[-1:][0][0]['addr'], getattr(i, 'OS-EXT-AZ:availability_zone'), getattr(i, 'OS-EXT-SRV-ATTR:instance_name').replace('inst', 'instance')
Result:
5dd9c820-f1a6-4e84-b80a-d94b0bc8f21f cfme076 10.114.93.5 AMS6 instance-00000562
38d0c079-5384-40da-92cc-9bd6c15e5d3b test-ams6 10.99.100.35 10.6.1.159 AMS6 instance-0000020e
ceba8162-eaa2-4563-9790-e9dd1e428995 test-ams5 10.99.100.34 10.5.1.39 AMS5 instance-0000020b
I hope this helps someone.
But would still like to see a vm uuid in user.floating_ips.get()
, it would make my life easier, and the script not as slow.
This looks like an API issue to me.
I'm not very knowledgeable about it, but basically you'd like floating ip objects to have have the ID or the vm interface to which it is assigned? This or the other way around: each vm interface to have the ID of the floating ip assigned to it.
I'm just trying to formulate the problem as clearly as possible to ask the devs.
Hi @little-dude, this is correct. There is also an AR for this which is 1-6476303. Problem is that there is no VMUUID visible from user.floating_ips.get(), and also no way to see the normal IP address. However I personally believe it is bad practice to use something other than an ID to match data. Using an ID of some sort would be the best way, as I have done in my code.
However I personally believe it is bad practice to use something other than an ID to match data.
:+1:
There is also an AR for this which is 1-6476303.
What is an AR? Is it some ticket system?
It's the nuage ticketing system, it's the ticket number.
Hi @phantium, @marcowenwolf,
I understand your issue and understand that there is a slowness on the current approach. However, this kind of change is not an easy one as it means changing our API behaviour and product design, which is in itself a complex task and requires significant QA validation, as i'm sure you can appreciate.
First of all, let me ask if it is possible to do the whole process using the Openstack API's, as you seem to be using OpenStack as well? Openstack is aware of both the IP and the Floating IP, potentially, getting the required information is faster from there?
If not, have you tried the vspk-go (if that is a possibility at all)? It can be faster than the python vspk, in my experience.
Finally, if none of these will help, can you contact me directly on philippe.dellaert@nuagenetworks.net to take this offline, i'm interested in a more detailed description what your end-goal is (if it is different from getting just a FIP to VM IP List) and in what environment/customer this is being attempted. (I don't have easy access at the AR's right now, sorry).
Regards, Philippe Dellaert
Hi,
I would like to know how I can fetch both the floating and normal IP of a VM, assuming there is already an associated floating IP. Otherwise I'd like to return False.
I am looking for the best method in terms of performance. Is there direct approach? Or am stuck with looping through vms/enterprises and pulling the data from each vport?
For example I can get floating IPs with:
And VM ips:
But there is no mapping between the two, which is a shame. As there should be at least a VM id to which you can refer.
Any help is greatly appreciated!
Thanks in advance.
Edit: I am using the v3.2 API