DirectConnect.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #coding:utf-8
  2. #!/usr/bin/python
  3. # -*- encoding:utf-8 -*-
  4. import json,pprint
  5. from prettyprinter import prettyPrinter
  6. from kscore.session import get_session
  7. if __name__ == "__main__":
  8. s = get_session()
  9. vpcClient = s.create_client("vpc", "cn-beijing-6", use_ssl=True)
  10. # 获取物理专线列表,创建,修改和删除物理专线请联系售前或者销售
  11. vpcClient.describe_direct_connects()
  12. #创建专线通道 这里只是最简单参数,其他请按需添加
  13. param_dict = {
  14. "DirectConnectId": "物理专线ID",
  15. "DirectConnectInterfaceName": "ceshi"
  16. }
  17. #vpcClient.create_direct_connect_interface(**param_dict)
  18. #创建专线网关
  19. param_dict = {
  20. "VpcId": "虚拟私有网络id",
  21. "DirectConnectGatewayName": "ceshi-gw"
  22. }
  23. #vpcClient.create_direct_connect_gateway(**param_dict)
  24. #绑定专线网关
  25. param_dict = {
  26. "DirectConnectGatewayId": "专线网关id",
  27. "DirectConnectInterfaceId": "专线通道id"
  28. }
  29. #vpcClient.attach_direct_connect_gateway(**param_dict)
  30. #解绑专线网关
  31. param_dict = {
  32. "DirectConnectGatewayId": "专线网关id",
  33. "DirectConnectInterfaceId": "专线通道id"
  34. }
  35. #vpcClient.detach_direct_connect_gateway(**param_dict)
  36. #专线网关列表
  37. vpcClient.describe_direct_connect_gateways()
  38. #专线通道列表
  39. vpcClient.describe_direct_connect_interfaces()
  40. #删除专线网关
  41. param_dict={
  42. "DirectConnectGatewayId": "专线网关id"
  43. }
  44. #vpcClient.delete_direct_connect_gateway(**param_dict)
  45. #删除专线通道
  46. param_dict = {
  47. "DirectConnectInterfaceId": "专线通道id"
  48. }
  49. vpcClient.delete_direct_connect_interface(**param_dict)