Advertisement
krishnanvenku

KVM OpenStack VM IP List

Mar 11th, 2016
9,644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from novaclient import client
  2. #NOVA
  3. VERSION="2"
  4. USER="admin"
  5. PASSWORD="Password"
  6. TENANT="admin"
  7. AUTH_URL="http://X.X.X.X:5000/v2.0"
  8.  
  9. tup=(UserID,DisplayName) #Get Tuple of UserID, Display name from Nova DB
  10.  
  11. nt = client.Client(VERSION, USER, PASSWORD, TENANT, AUTH_URL)
  12. if nt is not None:
  13.     search_opts = { 'all_tenants': "1" } # List Vms of all Tenants
  14.     for i in nt.servers.list(search_opts=search_opts):
  15.         if( i.user_id == tup[0] and i.name== tup[1]):#Compare User ID, Display Name of API with UserID, Display Name @ DB
  16.             print i.addresses
  17.             vm_ip=i.addresses # Got the IP Address , hooray !
  18.             break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement