-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowgandipaasinfo.py
44 lines (33 loc) · 1.07 KB
/
showgandipaasinfo.py
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
44
# -*- coding: utf-8 -*-
"""
此範例程式碼用途為透過API金鑰,取得Gandi IaaS相關資訊
"""
import xmlrpclib
import sys
# 連接API伺服器
API = xmlrpclib.ServerProxy('https://rpc.gandi.net/xmlrpc/')
if len(sys.argv) != 2:
print "%s %s" % (sys.argv[0], "<YOUR API KEY>")
exit(1)
APIKEY = sys.argv[1]
# 您可以呼叫API方法
# 您必須經由API金鑰作為第一個方法的參數進行驗證
VERSION = API.version.info(APIKEY)
print "gandi api version: " + VERSION['api_version']
# Count your Gandi PaaS instances
# 計算Gandi Paas 實體的數量
GANDIPAASNUMS = API.paas.count(APIKEY)
GANDIPAAS_COUNT_MSG = "You have %s Gandi PaaS instances" % GANDIPAASNUMS
if GANDIPAASNUMS > 1:
GANDIPAAS_COUNT_MSG += "s"
print GANDIPAAS_COUNT_MSG
# Get all site id
# 取得所有site 編號
PAASID_LIST = []
for eachpaas in API.paas.list(APIKEY):
PAASID_LIST.append(eachpaas['id'])
print "Gandi PaaS IDs:", PAASID_LIST
# Get info on each Gandi Site
# 取得所有Gandi Site 的相關資訊
if len(PAASID_LIST) > 0:
pprint(API.paas.list(APIKEY))