2
0

kcrs.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- encoding:utf-8 -*-
  2. from kscore.session import get_session
  3. import json
  4. if __name__ == "__main__":
  5. s = get_session()
  6. client = s.create_client("kcrs", "cn-beijing-6", use_ssl=True)
  7. # 查询镜像实例列表
  8. param = {
  9. "ProjectId.1": "0",
  10. "MaxResults": 20,
  11. "Marker": 0,
  12. }
  13. m = client.describe_instance(**param)
  14. print json.dumps(m, sort_keys=True, indent=4)
  15. '''
  16. # 创建镜像实例
  17. param = {
  18. "InstanceName": "xxxxx2",
  19. "ChargeType": "HourlyInstantSettlement",
  20. "InstanceType": "basic",
  21. "PurchaseTime": "1",
  22. "ProjectId": "0",
  23. }
  24. m = client.create_instance(**param)
  25. print json.dumps(m, sort_keys=True, indent=4)
  26. '''
  27. '''
  28. m = client.delete_instance(InstanceId="d11bbbc9-xxx")
  29. print json.dumps(m, sort_keys=True, indent=4)
  30. '''
  31. '''
  32. # 创建镜像实例访问凭证
  33. param = {
  34. "InstanceId": "c3fdd2ac-xxxx",
  35. "TokenType": "Hour",
  36. "TokenTime": "24",
  37. }
  38. m = client.create_instance_token(**param)
  39. print json.dumps(m, sort_keys=True, indent=4)
  40. '''