Advertisement
Guest User

Untitled

a guest
Mar 8th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 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. #########Database Connection##########################
  8.  
  9.  
  10. connection = pymysql.connect(host='localhost', user='root', password='Ro3118086', db='billing', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
  11.  
  12.  
  13. ################function to execute in SQL#################################
  14.  
  15. project_list=[]
  16.  
  17. def upsert_db():
  18.  
  19.     with connection.cursor() as cur:
  20.  
  21.         cur.execute("SELECT id FROM project")
  22.         rows=cur.fetchall()
  23.         for row in rows:
  24.             project_list.append(row["id"])
  25.  
  26. upsert_db()
  27.  
  28.  
  29.  
  30. for this_project_id in project_list:
  31.  
  32.     #print(this_project_id)
  33.  
  34.     loader = loading.get_plugin_loader('password')
  35.     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')
  36.     sess = session.Session(auth=auth)
  37.     neutron = client.Client( session=sess)
  38.  
  39.     print(neutron.list_floatingips(retrieve_all=True))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement