-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy patheip_demo.py
More file actions
43 lines (32 loc) · 802 Bytes
/
eip_demo.py
File metadata and controls
43 lines (32 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python
#-*- encoding: utf-8 -*-
from sdk import UcloudApiClient
from config import *
import sys
import json
ApiClient = UcloudApiClient(base_url, public_key, private_key, 1, 1)
#获取当前用户主机列表
response = ApiClient.get('/instances',
offset = 0,
max_count = 100
)
if response['ret_code'] == 0:
print response
#获取EIP列表
response = ApiClient.get('/uip/list')
if response['ret_code'] == 0:
print response
#绑定EIP到主机
response = ApiClient.post('/uip/associate',
vm_id = "$VM_INSTANCE_UUID",
eip_id = "$EIP_UUID"
)
if response['ret_code'] == 0:
print response
#从主机解绑EIP
response = ApiClient.post('/uip/disassociate',
vm_id = "$VM_INSTANCE_UUID",
eip_id = "$EIP_UUID"
)
if response['ret_code'] == 0:
print response