Advertisement
Guest User

Untitled

a guest
Mar 8th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. from keystoneauth1 import loading
  2. from keystoneauth1 import session
  3. from neutronclient.v2_0 import client
  4. import pymysql
  5.  
  6.  
  7. loader = loading.get_plugin_loader('password')
  8. auth = loader.load_from_options(auth_url='http://10.10.33.140:35357/v3',username='admin',password='k3st0ne2017ZEtka', project_id= 'e241d7f5fae342048589cc0c3387dac0', user_domain_name='default')
  9. sess = session.Session(auth=auth)
  10. neutron = client.Client( session=sess)
  11.  
  12.  
  13.  
  14. #########Database Connection##########################
  15.  
  16.  
  17.  
  18. connection = pymysql.connect(host='localhost', user='root', password='Ro3118086', db='billing', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
  19.  
  20.  
  21.  
  22.  
  23. ################function to execute in SQL#################################
  24.  
  25. project_list=[]
  26.  
  27. def upsert_db():
  28.  
  29.     with connection.cursor() as cur:
  30.  
  31.         cur.execute("SELECT id FROM project")
  32.         rows=cur.fetchall()
  33.         for row in rows:
  34.             project_list.append(row["id"])
  35.  
  36. upsert_db()
  37.  
  38.  
  39. for this_project_id in project_list:
  40.     loader = loading.get_plugin_loader('password')
  41.     auth = loader.load_from_options(auth_url='http://10.10.33.140:35357/v3',username='admin',password='k3st0ne2017ZEtka', project_id= this_project_id, user_domain_name='default')
  42.     sess = session.Session(auth=auth)
  43.     neutron = client.Client( session=sess)
  44.  
  45.     print(neutron.list_floatingips(retrieve_all=True))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement