slb.py 1.3 KB

1234567891011121314151617181920212223242526272829
  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. slbClient = s.create_client("slb", region, use_ssl=True)
  11. #kecClient = s.create_client("kec", region, use_ssl=True)
  12. #allInstances=kecClient.describe_instances()
  13. #allListeners=slbClient.describe_listeners(**{'Filter.1.Name':'load-balancer-id','Filter.1.Value.1':'89befb57-095a-4329-ae2a-fdfe81959f8c'})
  14. allListeners=slbClient.describe_listeners()
  15. #slbClient.register_instances_with_listener(**{'ListenerId':'9b465945-5214-4038-8436-c1764b8298f5','RealServerIp':'10.0.0.2','RealServerPort':'80','RealServerType':'host'})
  16. #givenListeners=slbClient.describe_listeners(**{'ListenerId.1':'d94b6af0-61bd-4b15-ab2c-c6758a3367bc'})
  17. prettyPrinter().pprint(allListeners)
  18. #slbClient.deregister_instances_from_listener(**{'RegisterId':'cf0245b2-b847-462a-a777-7f680f6e48b8'})
  19. #slbClient.delete_load_balancer(**{'LoadBalancerId':'b5a2fac6-7cd0-40ee-abb5-dbcc59cbb4b7'})
  20. #prettyPrinter().pprint(allInstances)
  21. for item in allListeners['ListenerSet']:
  22. print item['ListenerName']
  23. print item['ListenerId']