tccli 3.0.1151.1__py2.py3-none-any.whl → 3.0.1153.1__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- tccli/__init__.py +1 -1
- tccli/services/__init__.py +3 -0
- tccli/services/cdc/v20201214/api.json +101 -20
- tccli/services/cdc/v20201214/examples.json +1 -1
- tccli/services/cloudapp/__init__.py +4 -0
- tccli/services/cloudapp/cloudapp_client.py +195 -0
- tccli/services/cloudapp/v20220530/api.json +259 -0
- tccli/services/cloudapp/v20220530/examples.json +13 -0
- tccli/services/cvm/v20170312/api.json +10 -10
- tccli/services/dlc/v20210125/api.json +19 -1
- tccli/services/dlc/v20210125/examples.json +1 -1
- tccli/services/dsgc/v20190723/api.json +66 -3
- tccli/services/es/v20180416/api.json +19 -1
- tccli/services/es/v20180416/examples.json +1 -1
- tccli/services/ess/v20201111/api.json +1 -1
- tccli/services/essbasic/v20210526/api.json +23 -5
- tccli/services/essbasic/v20210526/examples.json +8 -2
- tccli/services/gaap/v20180529/api.json +22 -2
- tccli/services/gaap/v20180529/examples.json +1 -1
- tccli/services/hunyuan/v20230901/api.json +10 -0
- tccli/services/lcic/v20220817/api.json +19 -1
- tccli/services/lighthouse/v20200324/api.json +4 -4
- tccli/services/lke/v20231130/api.json +1 -1
- tccli/services/mongodb/v20190725/api.json +2 -2
- tccli/services/monitor/v20180724/api.json +136 -121
- tccli/services/monitor/v20180724/examples.json +30 -30
- tccli/services/tcr/v20190924/api.json +1 -1
- tccli/services/tcr/v20190924/examples.json +1 -1
- tccli/services/tdmq/tdmq_client.py +163 -4
- tccli/services/tdmq/v20200217/api.json +279 -0
- tccli/services/tdmq/v20200217/examples.json +24 -0
- tccli/services/tsi/v20210325/api.json +1 -1
- tccli/services/vpc/v20170312/api.json +171 -55
- tccli/services/waf/v20180125/examples.json +1 -1
- {tccli-3.0.1151.1.dist-info → tccli-3.0.1153.1.dist-info}/METADATA +2 -2
- {tccli-3.0.1151.1.dist-info → tccli-3.0.1153.1.dist-info}/RECORD +39 -35
- {tccli-3.0.1151.1.dist-info → tccli-3.0.1153.1.dist-info}/WHEEL +0 -0
- {tccli-3.0.1151.1.dist-info → tccli-3.0.1153.1.dist-info}/entry_points.txt +0 -0
- {tccli-3.0.1151.1.dist-info → tccli-3.0.1153.1.dist-info}/license_files/LICENSE +0 -0
tccli/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '3.0.
|
1
|
+
__version__ = '3.0.1153.1'
|
tccli/services/__init__.py
CHANGED
@@ -862,7 +862,7 @@
|
|
862
862
|
"example": "无",
|
863
863
|
"member": "string",
|
864
864
|
"name": "DedicatedClusterId",
|
865
|
-
"
|
865
|
+
"output_required": true,
|
866
866
|
"type": "string",
|
867
867
|
"value_allowed_null": false
|
868
868
|
},
|
@@ -872,7 +872,7 @@
|
|
872
872
|
"example": "无",
|
873
873
|
"member": "string",
|
874
874
|
"name": "DedicatedClusterTypeId",
|
875
|
-
"
|
875
|
+
"output_required": true,
|
876
876
|
"type": "string",
|
877
877
|
"value_allowed_null": false
|
878
878
|
},
|
@@ -882,7 +882,7 @@
|
|
882
882
|
"example": "无",
|
883
883
|
"member": "string",
|
884
884
|
"name": "SupportedStorageType",
|
885
|
-
"
|
885
|
+
"output_required": true,
|
886
886
|
"type": "list",
|
887
887
|
"value_allowed_null": false
|
888
888
|
},
|
@@ -892,7 +892,7 @@
|
|
892
892
|
"example": "无",
|
893
893
|
"member": "int64",
|
894
894
|
"name": "SupportedUplinkSpeed",
|
895
|
-
"
|
895
|
+
"output_required": true,
|
896
896
|
"type": "list",
|
897
897
|
"value_allowed_null": false
|
898
898
|
},
|
@@ -902,7 +902,7 @@
|
|
902
902
|
"example": "无",
|
903
903
|
"member": "string",
|
904
904
|
"name": "SupportedInstanceFamily",
|
905
|
-
"
|
905
|
+
"output_required": true,
|
906
906
|
"type": "list",
|
907
907
|
"value_allowed_null": false
|
908
908
|
},
|
@@ -912,7 +912,7 @@
|
|
912
912
|
"example": "无",
|
913
913
|
"member": "int64",
|
914
914
|
"name": "Weight",
|
915
|
-
"
|
915
|
+
"output_required": true,
|
916
916
|
"type": "int",
|
917
917
|
"value_allowed_null": false
|
918
918
|
},
|
@@ -922,7 +922,7 @@
|
|
922
922
|
"example": "无",
|
923
923
|
"member": "float",
|
924
924
|
"name": "PowerDraw",
|
925
|
-
"
|
925
|
+
"output_required": true,
|
926
926
|
"type": "float",
|
927
927
|
"value_allowed_null": false
|
928
928
|
},
|
@@ -932,7 +932,7 @@
|
|
932
932
|
"example": "无",
|
933
933
|
"member": "string",
|
934
934
|
"name": "OrderStatus",
|
935
|
-
"
|
935
|
+
"output_required": true,
|
936
936
|
"type": "string",
|
937
937
|
"value_allowed_null": false
|
938
938
|
},
|
@@ -942,7 +942,7 @@
|
|
942
942
|
"example": "无",
|
943
943
|
"member": "datetime_iso",
|
944
944
|
"name": "CreateTime",
|
945
|
-
"
|
945
|
+
"output_required": true,
|
946
946
|
"type": "string",
|
947
947
|
"value_allowed_null": false
|
948
948
|
},
|
@@ -952,7 +952,7 @@
|
|
952
952
|
"example": "ord-aijx4ets ",
|
953
953
|
"member": "string",
|
954
954
|
"name": "DedicatedClusterOrderId",
|
955
|
-
"
|
955
|
+
"output_required": true,
|
956
956
|
"type": "string",
|
957
957
|
"value_allowed_null": false
|
958
958
|
},
|
@@ -962,7 +962,7 @@
|
|
962
962
|
"example": "CREATE",
|
963
963
|
"member": "string",
|
964
964
|
"name": "Action",
|
965
|
-
"
|
965
|
+
"output_required": true,
|
966
966
|
"type": "string",
|
967
967
|
"value_allowed_null": false
|
968
968
|
},
|
@@ -972,7 +972,7 @@
|
|
972
972
|
"example": "无",
|
973
973
|
"member": "DedicatedClusterOrderItem",
|
974
974
|
"name": "DedicatedClusterOrderItems",
|
975
|
-
"
|
975
|
+
"output_required": true,
|
976
976
|
"type": "list",
|
977
977
|
"value_allowed_null": true
|
978
978
|
},
|
@@ -982,7 +982,7 @@
|
|
982
982
|
"example": "无",
|
983
983
|
"member": "int64",
|
984
984
|
"name": "Cpu",
|
985
|
-
"
|
985
|
+
"output_required": true,
|
986
986
|
"type": "int",
|
987
987
|
"value_allowed_null": true
|
988
988
|
},
|
@@ -992,7 +992,7 @@
|
|
992
992
|
"example": "无",
|
993
993
|
"member": "int64",
|
994
994
|
"name": "Mem",
|
995
|
-
"
|
995
|
+
"output_required": true,
|
996
996
|
"type": "int",
|
997
997
|
"value_allowed_null": true
|
998
998
|
},
|
@@ -1002,7 +1002,7 @@
|
|
1002
1002
|
"example": "无",
|
1003
1003
|
"member": "int64",
|
1004
1004
|
"name": "Gpu",
|
1005
|
-
"
|
1005
|
+
"output_required": true,
|
1006
1006
|
"type": "int",
|
1007
1007
|
"value_allowed_null": true
|
1008
1008
|
},
|
@@ -1012,7 +1012,7 @@
|
|
1012
1012
|
"example": "1",
|
1013
1013
|
"member": "int64",
|
1014
1014
|
"name": "PayStatus",
|
1015
|
-
"
|
1015
|
+
"output_required": true,
|
1016
1016
|
"type": "int",
|
1017
1017
|
"value_allowed_null": true
|
1018
1018
|
},
|
@@ -1022,7 +1022,7 @@
|
|
1022
1022
|
"example": "MONTHLY",
|
1023
1023
|
"member": "string",
|
1024
1024
|
"name": "PayType",
|
1025
|
-
"
|
1025
|
+
"output_required": true,
|
1026
1026
|
"type": "string",
|
1027
1027
|
"value_allowed_null": true
|
1028
1028
|
},
|
@@ -1032,7 +1032,7 @@
|
|
1032
1032
|
"example": "YEAR",
|
1033
1033
|
"member": "string",
|
1034
1034
|
"name": "TimeUnit",
|
1035
|
-
"
|
1035
|
+
"output_required": true,
|
1036
1036
|
"type": "string",
|
1037
1037
|
"value_allowed_null": true
|
1038
1038
|
},
|
@@ -1042,7 +1042,7 @@
|
|
1042
1042
|
"example": "1",
|
1043
1043
|
"member": "int64",
|
1044
1044
|
"name": "TimeSpan",
|
1045
|
-
"
|
1045
|
+
"output_required": true,
|
1046
1046
|
"type": "int",
|
1047
1047
|
"value_allowed_null": true
|
1048
1048
|
},
|
@@ -1052,7 +1052,77 @@
|
|
1052
1052
|
"example": "CUSTOM",
|
1053
1053
|
"member": "string",
|
1054
1054
|
"name": "OrderType",
|
1055
|
-
"
|
1055
|
+
"output_required": true,
|
1056
|
+
"type": "string",
|
1057
|
+
"value_allowed_null": true
|
1058
|
+
},
|
1059
|
+
{
|
1060
|
+
"disabled": false,
|
1061
|
+
"document": "验收状态\n注意:此字段可能返回 null,表示取不到有效值。",
|
1062
|
+
"example": "DELIVERING",
|
1063
|
+
"member": "string",
|
1064
|
+
"name": "CheckStatus",
|
1065
|
+
"output_required": false,
|
1066
|
+
"type": "string",
|
1067
|
+
"value_allowed_null": true
|
1068
|
+
},
|
1069
|
+
{
|
1070
|
+
"disabled": false,
|
1071
|
+
"document": "交付预期时间\n注意:此字段可能返回 null,表示取不到有效值。",
|
1072
|
+
"example": "2024-01-01 12:00:00",
|
1073
|
+
"member": "string",
|
1074
|
+
"name": "DeliverExpectTime",
|
1075
|
+
"output_required": false,
|
1076
|
+
"type": "string",
|
1077
|
+
"value_allowed_null": true
|
1078
|
+
},
|
1079
|
+
{
|
1080
|
+
"disabled": false,
|
1081
|
+
"document": "交付实际完成时间\n注意:此字段可能返回 null,表示取不到有效值。",
|
1082
|
+
"example": "2024-01-01 12:00:00",
|
1083
|
+
"member": "string",
|
1084
|
+
"name": "DeliverFinishTime",
|
1085
|
+
"output_required": false,
|
1086
|
+
"type": "string",
|
1087
|
+
"value_allowed_null": true
|
1088
|
+
},
|
1089
|
+
{
|
1090
|
+
"disabled": false,
|
1091
|
+
"document": "验收预期时间\n注意:此字段可能返回 null,表示取不到有效值。",
|
1092
|
+
"example": "2024-01-01 12:00:00",
|
1093
|
+
"member": "string",
|
1094
|
+
"name": "CheckExpectTime",
|
1095
|
+
"output_required": false,
|
1096
|
+
"type": "string",
|
1097
|
+
"value_allowed_null": true
|
1098
|
+
},
|
1099
|
+
{
|
1100
|
+
"disabled": false,
|
1101
|
+
"document": "验收实际完成时间\n注意:此字段可能返回 null,表示取不到有效值。",
|
1102
|
+
"example": "2024-01-01 12:00:00",
|
1103
|
+
"member": "string",
|
1104
|
+
"name": "CheckFinishTime",
|
1105
|
+
"output_required": false,
|
1106
|
+
"type": "string",
|
1107
|
+
"value_allowed_null": true
|
1108
|
+
},
|
1109
|
+
{
|
1110
|
+
"disabled": false,
|
1111
|
+
"document": "订单SLA\n注意:此字段可能返回 null,表示取不到有效值。",
|
1112
|
+
"example": "无",
|
1113
|
+
"member": "string",
|
1114
|
+
"name": "OrderSLA",
|
1115
|
+
"output_required": false,
|
1116
|
+
"type": "string",
|
1117
|
+
"value_allowed_null": true
|
1118
|
+
},
|
1119
|
+
{
|
1120
|
+
"disabled": false,
|
1121
|
+
"document": "订单支付计划\n注意:此字段可能返回 null,表示取不到有效值。",
|
1122
|
+
"example": "无",
|
1123
|
+
"member": "string",
|
1124
|
+
"name": "OrderPayPlan",
|
1125
|
+
"output_required": false,
|
1056
1126
|
"type": "string",
|
1057
1127
|
"value_allowed_null": true
|
1058
1128
|
}
|
@@ -1808,6 +1878,15 @@
|
|
1808
1878
|
"name": "ActionType",
|
1809
1879
|
"required": false,
|
1810
1880
|
"type": "string"
|
1881
|
+
},
|
1882
|
+
{
|
1883
|
+
"disabled": false,
|
1884
|
+
"document": "订单类型列表",
|
1885
|
+
"example": "无",
|
1886
|
+
"member": "string",
|
1887
|
+
"name": "OrderTypes",
|
1888
|
+
"required": false,
|
1889
|
+
"type": "list"
|
1811
1890
|
}
|
1812
1891
|
],
|
1813
1892
|
"type": "object"
|
@@ -1821,6 +1900,7 @@
|
|
1821
1900
|
"example": "无",
|
1822
1901
|
"member": "DedicatedClusterOrder",
|
1823
1902
|
"name": "DedicatedClusterOrderSet",
|
1903
|
+
"output_required": true,
|
1824
1904
|
"type": "list",
|
1825
1905
|
"value_allowed_null": false
|
1826
1906
|
},
|
@@ -1830,6 +1910,7 @@
|
|
1830
1910
|
"example": "20",
|
1831
1911
|
"member": "int64",
|
1832
1912
|
"name": "TotalCount",
|
1913
|
+
"output_required": true,
|
1833
1914
|
"type": "int",
|
1834
1915
|
"value_allowed_null": false
|
1835
1916
|
},
|
@@ -84,7 +84,7 @@
|
|
84
84
|
{
|
85
85
|
"document": "查询专用集群订单列表",
|
86
86
|
"input": "https://cdc.tencentcloudapi.com/?Action=DescribeDedicatedClusterOrders\n&<公共请求参数>",
|
87
|
-
"output": "{\n \"Response\": {\n \"DedicatedClusterOrderSet\": [\n {\n \"DedicatedClusterId\": \"
|
87
|
+
"output": "{\n \"Response\": {\n \"DedicatedClusterOrderSet\": [\n {\n \"DedicatedClusterId\": \"abc\",\n \"DedicatedClusterTypeId\": \"abc\",\n \"SupportedStorageType\": [\n \"abc\"\n ],\n \"SupportedUplinkSpeed\": [\n 0\n ],\n \"SupportedInstanceFamily\": [\n \"abc\"\n ],\n \"Weight\": 0,\n \"PowerDraw\": 0,\n \"OrderStatus\": \"abc\",\n \"CreateTime\": \"2020-09-22T00:00:00+00:00\",\n \"DedicatedClusterOrderId\": \"abc\",\n \"Action\": \"abc\",\n \"DedicatedClusterOrderItems\": [\n {\n \"DedicatedClusterTypeId\": \"abc\",\n \"SupportedStorageType\": [\n \"abc\"\n ],\n \"SupportedUplinkSpeed\": [\n 0\n ],\n \"SupportedInstanceFamily\": [\n \"abc\"\n ],\n \"Weight\": 0,\n \"PowerDraw\": 0,\n \"SubOrderStatus\": \"abc\",\n \"CreateTime\": \"2020-09-22T00:00:00+00:00\",\n \"SubOrderId\": \"abc\",\n \"Count\": 0,\n \"Name\": \"abc\",\n \"Description\": \"abc\",\n \"TotalCpu\": 0,\n \"TotalMem\": 0,\n \"TotalGpu\": 0,\n \"TypeName\": \"abc\",\n \"ComputeFormat\": \"abc\",\n \"TypeFamily\": \"abc\",\n \"SubOrderPayStatus\": 0\n }\n ],\n \"Cpu\": 0,\n \"Mem\": 0,\n \"Gpu\": 0,\n \"PayStatus\": 0,\n \"PayType\": \"abc\",\n \"TimeUnit\": \"abc\",\n \"TimeSpan\": 0,\n \"OrderType\": \"abc\",\n \"CheckStatus\": \"abc\",\n \"DeliverExpectTime\": \"abc\",\n \"DeliverFinishTime\": \"abc\",\n \"CheckExpectTime\": \"abc\",\n \"CheckFinishTime\": \"abc\",\n \"OrderSLA\": \"abc\",\n \"OrderPayPlan\": \"abc\"\n }\n ],\n \"TotalCount\": 0,\n \"RequestId\": \"abc\"\n }\n}",
|
88
88
|
"title": "查询专用集群订单列表"
|
89
89
|
}
|
90
90
|
],
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
import os
|
3
|
+
import sys
|
4
|
+
import six
|
5
|
+
import json
|
6
|
+
import tccli.options_define as OptionsDefine
|
7
|
+
import tccli.format_output as FormatOutput
|
8
|
+
from tccli import __version__
|
9
|
+
from tccli.utils import Utils
|
10
|
+
from tccli.exceptions import ConfigurationError, ClientError, ParamError
|
11
|
+
from tencentcloud.common import credential
|
12
|
+
from tencentcloud.common.profile.http_profile import HttpProfile
|
13
|
+
from tencentcloud.common.profile.client_profile import ClientProfile
|
14
|
+
from tencentcloud.cloudapp.v20220530 import cloudapp_client as cloudapp_client_v20220530
|
15
|
+
from tencentcloud.cloudapp.v20220530 import models as models_v20220530
|
16
|
+
|
17
|
+
from jmespath import search
|
18
|
+
import time
|
19
|
+
|
20
|
+
def doVerifyLicense(args, parsed_globals):
|
21
|
+
g_param = parse_global_arg(parsed_globals)
|
22
|
+
|
23
|
+
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
24
|
+
cred = credential.CVMRoleCredential()
|
25
|
+
elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
|
26
|
+
cred = credential.STSAssumeRoleCredential(
|
27
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
|
28
|
+
g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
29
|
+
)
|
30
|
+
elif os.getenv(OptionsDefine.ENV_TKE_REGION) and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
|
31
|
+
cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
|
32
|
+
else:
|
33
|
+
cred = credential.Credential(
|
34
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
|
35
|
+
)
|
36
|
+
http_profile = HttpProfile(
|
37
|
+
reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
|
38
|
+
reqMethod="POST",
|
39
|
+
endpoint=g_param[OptionsDefine.Endpoint],
|
40
|
+
proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
|
41
|
+
)
|
42
|
+
profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
|
43
|
+
if g_param[OptionsDefine.Language]:
|
44
|
+
profile.language = g_param[OptionsDefine.Language]
|
45
|
+
mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
|
46
|
+
client = mod.CloudappClient(cred, g_param[OptionsDefine.Region], profile)
|
47
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
48
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
49
|
+
model = models.VerifyLicenseRequest()
|
50
|
+
model.from_json_string(json.dumps(args))
|
51
|
+
start_time = time.time()
|
52
|
+
while True:
|
53
|
+
rsp = client.VerifyLicense(model)
|
54
|
+
result = rsp.to_json_string()
|
55
|
+
try:
|
56
|
+
json_obj = json.loads(result)
|
57
|
+
except TypeError as e:
|
58
|
+
json_obj = json.loads(result.decode('utf-8')) # python3.3
|
59
|
+
if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
|
60
|
+
break
|
61
|
+
cur_time = time.time()
|
62
|
+
if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
|
63
|
+
raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
|
64
|
+
(g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
|
65
|
+
search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
|
66
|
+
else:
|
67
|
+
print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
|
68
|
+
time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
|
69
|
+
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
70
|
+
|
71
|
+
|
72
|
+
CLIENT_MAP = {
|
73
|
+
"v20220530": cloudapp_client_v20220530,
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
MODELS_MAP = {
|
78
|
+
"v20220530": models_v20220530,
|
79
|
+
|
80
|
+
}
|
81
|
+
|
82
|
+
ACTION_MAP = {
|
83
|
+
"VerifyLicense": doVerifyLicense,
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
AVAILABLE_VERSION_LIST = [
|
88
|
+
"v20220530",
|
89
|
+
|
90
|
+
]
|
91
|
+
|
92
|
+
|
93
|
+
def action_caller():
|
94
|
+
return ACTION_MAP
|
95
|
+
|
96
|
+
|
97
|
+
def parse_global_arg(parsed_globals):
|
98
|
+
g_param = parsed_globals
|
99
|
+
|
100
|
+
is_exist_profile = True
|
101
|
+
if not parsed_globals["profile"]:
|
102
|
+
is_exist_profile = False
|
103
|
+
g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
|
104
|
+
|
105
|
+
configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
|
106
|
+
is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
|
107
|
+
is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
|
108
|
+
|
109
|
+
conf = {}
|
110
|
+
cred = {}
|
111
|
+
|
112
|
+
if is_conf_exist:
|
113
|
+
conf = Utils.load_json_msg(conf_path)
|
114
|
+
if is_cred_exist:
|
115
|
+
cred = Utils.load_json_msg(cred_path)
|
116
|
+
|
117
|
+
if not (isinstance(conf, dict) and isinstance(cred, dict)):
|
118
|
+
raise ConfigurationError(
|
119
|
+
"file: %s or %s is not json format"
|
120
|
+
% (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
|
121
|
+
|
122
|
+
if OptionsDefine.Token not in cred:
|
123
|
+
cred[OptionsDefine.Token] = None
|
124
|
+
|
125
|
+
if not is_exist_profile:
|
126
|
+
if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
|
127
|
+
cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
|
128
|
+
cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
|
129
|
+
cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
|
130
|
+
|
131
|
+
if os.environ.get(OptionsDefine.ENV_REGION):
|
132
|
+
conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
|
133
|
+
|
134
|
+
if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
|
135
|
+
cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
|
136
|
+
cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
|
137
|
+
|
138
|
+
for param in g_param.keys():
|
139
|
+
if g_param[param] is None:
|
140
|
+
if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
|
141
|
+
if param in cred:
|
142
|
+
g_param[param] = cred[param]
|
143
|
+
elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
|
144
|
+
or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
|
145
|
+
raise ConfigurationError("%s is invalid" % param)
|
146
|
+
elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
|
147
|
+
if param in conf[OptionsDefine.SysParam]:
|
148
|
+
g_param[param] = conf[OptionsDefine.SysParam][param]
|
149
|
+
elif param != OptionsDefine.Language:
|
150
|
+
raise ConfigurationError("%s is invalid" % param)
|
151
|
+
elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
|
152
|
+
if param.replace('_', '-') in cred:
|
153
|
+
g_param[param] = cred[param.replace('_', '-')]
|
154
|
+
|
155
|
+
try:
|
156
|
+
if g_param[OptionsDefine.ServiceVersion]:
|
157
|
+
g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
|
158
|
+
else:
|
159
|
+
version = conf["cloudapp"][OptionsDefine.Version]
|
160
|
+
g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
|
161
|
+
|
162
|
+
if g_param[OptionsDefine.Endpoint] is None:
|
163
|
+
g_param[OptionsDefine.Endpoint] = conf["cloudapp"][OptionsDefine.Endpoint]
|
164
|
+
g_param["sts_cred_endpoint"] = conf.get("sts", {}).get("endpoint")
|
165
|
+
except Exception as err:
|
166
|
+
raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
|
167
|
+
|
168
|
+
if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
|
169
|
+
raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
|
170
|
+
|
171
|
+
if g_param[OptionsDefine.Waiter]:
|
172
|
+
param = eval(g_param[OptionsDefine.Waiter])
|
173
|
+
if 'expr' not in param:
|
174
|
+
raise Exception('`expr` in `--waiter` must be defined')
|
175
|
+
if 'to' not in param:
|
176
|
+
raise Exception('`to` in `--waiter` must be defined')
|
177
|
+
if 'timeout' not in param:
|
178
|
+
if 'waiter' in conf and 'timeout' in conf['waiter']:
|
179
|
+
param['timeout'] = conf['waiter']['timeout']
|
180
|
+
else:
|
181
|
+
param['timeout'] = 180
|
182
|
+
if 'interval' not in param:
|
183
|
+
if 'waiter' in conf and 'interval' in conf['waiter']:
|
184
|
+
param['interval'] = conf['waiter']['interval']
|
185
|
+
else:
|
186
|
+
param['interval'] = 5
|
187
|
+
param['interval'] = min(param['interval'], param['timeout'])
|
188
|
+
g_param['OptionsDefine.WaiterInfo'] = param
|
189
|
+
|
190
|
+
if six.PY2:
|
191
|
+
for key, value in g_param.items():
|
192
|
+
if isinstance(value, six.text_type):
|
193
|
+
g_param[key] = value.encode('utf-8')
|
194
|
+
return g_param
|
195
|
+
|