-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_demo_prod.py
103 lines (93 loc) · 5.94 KB
/
deploy_demo_prod.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import json
import requests
session = requests.session()
# 应用工厂登录
def factoryLogin(account, password):
print("登录应用工厂")
posturl = "https://sso.cloudtogo.cn/api/user/login"
postdata = {
"account": account,
"password": password,
"type": "pwd"
}
# 使用session直接post请求
responseres = session.post(posturl, json=postdata)
print(responseres.status_code)
print(responseres.text)
token = json.loads(responseres.text)["data"]["token"]
print(token)
return token
# 发布应用
def deploy_app(session, token, payload):
url = "http://factory.cloudtogo.cn/api/factory/composer/deploy"
data = payload
deploy = session.post(
url,
data=json.dumps(data),
headers={
"token": token,
"Content-Type": "application/json"})
print(deploy.text)
token = factoryLogin("13798955353", "123456")
payload = {"composerId": "ad23360b-35b5-11e9-ac72-00163e03ba33",
"projectId": "FP1902210849594400000165011319",
"deployMode": "strict",
"configs": [{"type": "domain",
"internal": "false",
"protocol": "HTTP",
"port": 8080,
"required": "true",
"description": "8080端口服务的子域名",
"initValue": "null",
"hidden": "false",
"keyData": "bp1_domain8080",
"valueData": "84a31f9c46eb.c.cloudtogo.cn",
"default": "null",
"labelData": "Python>8080端口访问域名",
"domain": "84a31f9c46eb",
"invalid": "false",
"domainSuffix": ".c.cloudtogo.cn"},
{"type": "string",
"internal": "false",
"protocol": "null",
"port": "null",
"required": "false",
"description": "请填入镜像地址",
"initValue": "null",
"hidden": "true",
"keyData": "bp1_image",
"valueData": "null",
"default": "null",
"labelData": "Python>镜像地址"},
{"type": "domain",
"internal": "false",
"protocol": "TCP",
"port": 6379,
"required": "true",
"description": "Redis port服务的子域名",
"initValue": "null",
"hidden": "true",
"keyData": "bp_domain6379",
"valueData": "undefined.c.cloudtogo.cn",
"default": "$domain.ignore$",
"labelData": "redis>Redis port访问域名",
"domainSuffix": ".c.cloudtogo.cn"},
{"paramType": "env",
"keyData": "env",
"valueData": "134324346fe442f8b5c00714e1c37157"},
{"labelData": "副本数",
"paramType": "copy",
"type": "string",
"keyData": ".bp",
"valueData": 1},
{"labelData": "副本数",
"paramType": "copy",
"type": "string",
"keyData": ".bp1",
"valueData": 1}],
"autoTestConfig": {},
"configDesc": "",
"scheduleDesc": "{\"replicasZeroBP\":[{\"bpId\":\"e8d29641-359d-11e9-9b2e-00505686c6ba\",\"label\":\"redis\",\"os\":\"Linux\",\"path\":\".bp\",\"api\":false,\"buildpackSupport\":false,\"ports\":[{\"domain\":null,\"port\":6379,\"protocol\":\"TCP\"}],\"replica_support\":true,\"sessionpersist_required\":false,\"replicas\":1},{\"bpId\":\"e8d97a83-359d-11e9-9b2e-00505686c6ba\",\"label\":\"Python\",\"os\":\"Linux\",\"path\":\".bp1\",\"api\":false,\"buildpackSupport\":true,\"ports\":[{\"domain\":null,\"port\":8080,\"protocol\":\"HTTP\"}],\"replica_support\":true,\"sessionpersist_required\":false,\"replicas\":1}],\"apiZeroBP\":[{\"bpId\":\"e8d97a83-359d-11e9-9b2e-00505686c6ba\",\"label\":\"Python\",\"os\":\"Linux\",\"path\":\".bp1\",\"api\":false,\"buildpackSupport\":true,\"ports\":[{\"domain\":null,\"port\":8080,\"protocol\":\"HTTP\"}],\"replica_support\":true,\"sessionpersist_required\":false}],\"autoTest\":{\"projectId\":\"\"},\"env\":\"134324346fe442f8b5c00714e1c37157\",\"applyConfigs\":[{\"type\":\"domain\",\"internal\":false,\"protocol\":\"HTTP\",\"port\":8080,\"required\":true,\"description\":\"8080端口服务的子域名\",\"initValue\":null,\"hidden\":false,\"keyData\":\"bp1_domain8080\",\"valueData\":\"84a31f9c46eb.play.cloudtogo.cn\",\"default\":null,\"labelData\":\"Python>8080端口访问域名\",\"domain\":\"84a31f9c46eb\",\"invalid\":false,\"domainSuffix\":\".play.cloudtogo.cn\"},{\"type\":\"string\",\"internal\":false,\"protocol\":null,\"port\":null,\"required\":false,\"description\":\"请填入镜像地址\",\"initValue\":null,\"hidden\":true,\"keyData\":\"bp1_image\",\"valueData\":null,\"default\":null,\"labelData\":\"Python>镜像地址\"},{\"type\":\"domain\",\"internal\":false,\"protocol\":\"TCP\",\"port\":6379,\"required\":true,\"description\":\"Redis port服务的子域名\",\"initValue\":null,\"hidden\":true,\"keyData\":\"bp_domain6379\",\"valueData\":\"undefined.play.cloudtogo.cn\",\"default\":\"$domain.ignore$\",\"labelData\":\"redis>Redis port访问域名\",\"domainSuffix\":\".play.cloudtogo.cn\"}],\"schedule\":{\"replicas\":1,\"scheduleType\":\"auto\",\"customFormConfigs\":[]},\"buildpack\":{\"buildpackType\":\"auto\",\"customFormConfigs\":[]}}",
"deployDesc": "jenkins test on prod",
"flowId": "null"}
deploy_app(session, token, payload)