2
0

eip.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/python
  2. # -*- encoding:utf-8 -*-
  3. import json,pprint
  4. from prettyprinter import prettyPrinter
  5. from kscore.session import get_session
  6. if __name__ == "__main__":
  7. s = get_session()
  8. region='cn-beijing-6'
  9. #region='cn-shanghai-2'
  10. eipClient = s.create_client("eip", region, use_ssl=True)
  11. #allInstances=kecClient.describe_instances()
  12. #allNics=vpcClient.describe_network_interfaces()
  13. #allEips=eipClient.describe_addresses(MaxResults=7,NextToken='OA==')
  14. allEips=eipClient.describe_addresses(MaxResults=7)
  15. #allEips=eipClient.describe_addresses(**{'Filter.1.Name':'instance-type','Filter.1.Value.1':'Ipfwd'})
  16. #allEips=eipClient.describe_addresses(**{'Filter.1.Name':'instance-type','Filter.1.Value.1':'Slb'})
  17. #pprint.pprint(allEips)
  18. #prettyPrinter().pprint(allEips)
  19. #prettyPrinter().pprint(allNics)
  20. #prettyPrinter().pprint(allInstances)
  21. for item in allEips['AddressesSet']:
  22. print item['PublicIp']
  23. print item['AllocationId']
  24. #eipClient.associate_address(**{'AllocationId':'1cd0da05-8a3e-4c8e-8230-e6d39b85331e','InstanceType':'Ipfwd','InstanceId':'bede9a1c-d3a7-4b31-82e6-6699790ad1a3', 'NetworkInterfaceId':'fec81567-a4c7-4460-a998-54f407e77c0a'})
  25. #eipClient.disassociate_address(**{'AllocationId':'1cd0da05-8a3e-4c8e-8230-e6d39b85331e'})
  26. #eipClient.modify_address(**{'AllocationId':'c054f87a-4508-4db2-bc10-f594b34a2ef3','BandWidth':1})
  27. #eipClient.modify_address(**{'AllocationId':'070a4af5-90ff-4953-a388-01a694ebdae5','BandWidth':1})