Advertisement
Guest User

Untitled

a guest
Mar 31st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import json, urllib3, time, requests
  4. from abiquo.client import Abiquo
  5. from requests_oauthlib import OAuth1
  6.  
  7. urllib3.disable_warnings()
  8. requests.packages.urllib3.disable_warnings()
  9.  
  10. API_URL = 'https://chirauki40.bcn.abiquo.com/api'
  11. USER = 'admin'
  12. PASS = 'xabiquo'
  13.  
  14. api = Abiquo(API_URL, auth=(USER, PASS), verify=False)
  15.  
  16. code, datacenters =  api.admin.datacenters.get(
  17.     headers={'Accept':'application/vnd.abiquo.datacenters+json'})
  18.  
  19. for dc in datacenters:
  20.     print 'DC name is "%s"' % dc.name
  21.  
  22.     dc.name = 'testclient%s' % time.time()
  23.     print dc.__dict__
  24.     print dc.json
  25.  
  26.     code, dc = dc.put()
  27.     code, dc = dc.refresh()
  28.  
  29.     print 'DC name is "%s"' % dc.name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement