appmesh 1.2.0__py3-none-any.whl → 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- appmesh/appmesh_client.py +72 -31
- {appmesh-1.2.0.dist-info → appmesh-1.2.1.dist-info}/METADATA +1 -1
- appmesh-1.2.1.dist-info/RECORD +6 -0
- appmesh-1.2.0.dist-info/RECORD +0 -6
- {appmesh-1.2.0.dist-info → appmesh-1.2.1.dist-info}/WHEEL +0 -0
- {appmesh-1.2.0.dist-info → appmesh-1.2.1.dist-info}/top_level.txt +0 -0
appmesh/appmesh_client.py
CHANGED
@@ -53,14 +53,18 @@ class AppOutput(object):
|
|
53
53
|
"""App output object for app_output() method"""
|
54
54
|
|
55
55
|
def __init__(self, status_code: HTTPStatus, output: str, out_position: Optional[int], exit_code: Optional[int]) -> None:
|
56
|
-
|
56
|
+
|
57
57
|
self.status_code = status_code
|
58
|
-
|
58
|
+
"""HTTP status code"""
|
59
|
+
|
59
60
|
self.output = output
|
60
|
-
|
61
|
+
"""HTTP response text"""
|
62
|
+
|
61
63
|
self.out_position = out_position
|
62
|
-
|
64
|
+
"""Current read position (int or None)"""
|
65
|
+
|
63
66
|
self.exit_code = exit_code
|
67
|
+
"""Process exit code (int or None)"""
|
64
68
|
|
65
69
|
|
66
70
|
class App(object):
|
@@ -93,10 +97,12 @@ class App(object):
|
|
93
97
|
def __init__(self, data=None) -> None:
|
94
98
|
if isinstance(data, (str, bytes, bytearray)):
|
95
99
|
data = json.loads(data)
|
96
|
-
|
100
|
+
|
97
101
|
self.exit = _get_str_item(data, "exit")
|
98
|
-
|
102
|
+
"""default exit behavior [restart,standby,keepalive,remove]"""
|
103
|
+
|
99
104
|
self.control = _get_native_item(data, "control") if _get_native_item(data, "control") else dict()
|
105
|
+
"""exit code behavior (e.g, --control 0:restart --control 1:standby), higher priority than default exit behavior"""
|
100
106
|
|
101
107
|
def set_exit_behavior(self, a: Action) -> None:
|
102
108
|
"""Set error handling behavior while application exit"""
|
@@ -114,10 +120,12 @@ class App(object):
|
|
114
120
|
def __init__(self, data=None) -> None:
|
115
121
|
if isinstance(data, (str, bytes, bytearray)):
|
116
122
|
data = json.loads(data)
|
117
|
-
|
123
|
+
|
118
124
|
self.daily_start = _get_int_item(data, "daily_start")
|
119
|
-
|
125
|
+
"""daily start time (e.g., '09:00:00+08')"""
|
126
|
+
|
120
127
|
self.daily_end = _get_int_item(data, "daily_end")
|
128
|
+
"""daily end time (e.g., '20:00:00+08')"""
|
121
129
|
|
122
130
|
def set_daily_range(self, start: datetime, end: datetime) -> None:
|
123
131
|
"""Set valid day hour range"""
|
@@ -132,12 +140,15 @@ class App(object):
|
|
132
140
|
def __init__(self, data=None) -> None:
|
133
141
|
if isinstance(data, (str, bytes, bytearray)):
|
134
142
|
data = json.loads(data)
|
135
|
-
|
143
|
+
|
136
144
|
self.cpu_shares = _get_int_item(data, "cpu_shares")
|
137
|
-
|
145
|
+
"""CPU shares (relative weight)"""
|
146
|
+
|
138
147
|
self.memory_mb = _get_int_item(data, "memory_mb")
|
139
|
-
|
148
|
+
"""physical memory limit in MByte"""
|
149
|
+
|
140
150
|
self.memory_virt_mb = _get_int_item(data, "memory_virt_mb")
|
151
|
+
"""virtual memory limit in MByte"""
|
141
152
|
|
142
153
|
def __init__(self, data=None):
|
143
154
|
"""Construct an App Mesh Application object
|
@@ -149,73 +160,99 @@ class App(object):
|
|
149
160
|
if isinstance(data, (str, bytes, bytearray)):
|
150
161
|
data = json.loads(data)
|
151
162
|
|
152
|
-
# application name
|
153
163
|
self.name = _get_str_item(data, "name")
|
154
|
-
|
164
|
+
"""application name (unique)"""
|
165
|
+
|
155
166
|
self.command = _get_str_item(data, "command")
|
167
|
+
"""full command line with arguments"""
|
156
168
|
|
157
|
-
# use shell mode, cmd can be more shell commands with string format
|
158
169
|
self.shell = _get_bool_item(data, "shell")
|
159
|
-
|
170
|
+
"""use shell mode, cmd can be more shell commands with string format"""
|
171
|
+
|
160
172
|
self.session_login = _get_bool_item(data, "session_login")
|
161
|
-
|
173
|
+
"""app run in session login mode"""
|
174
|
+
|
162
175
|
self.description = _get_str_item(data, "description")
|
163
|
-
|
176
|
+
"""application description string"""
|
177
|
+
|
164
178
|
self.metadata = _get_native_item(data, "metadata")
|
165
|
-
|
179
|
+
"""metadata string/JSON (input for application, pass to process stdin)"""
|
180
|
+
|
166
181
|
self.working_dir = _get_str_item(data, "working_dir")
|
167
|
-
|
182
|
+
"""working directory"""
|
183
|
+
|
168
184
|
self.status = _get_int_item(data, "status")
|
169
|
-
|
185
|
+
"""initial application status (true is enable, false is disabled)"""
|
186
|
+
|
170
187
|
self.docker_image = _get_str_item(data, "docker_image")
|
171
|
-
|
188
|
+
"""docker image which used to run command line (for docker container application)"""
|
189
|
+
|
172
190
|
self.stdout_cache_num = _get_int_item(data, "stdout_cache_num")
|
191
|
+
"""stdout file cache number"""
|
173
192
|
|
174
|
-
# start date time for app (ISO8601 time format, e.g., '2020-10-11T09:22:05')
|
175
193
|
self.start_time = _get_int_item(data, "start_time")
|
176
|
-
|
194
|
+
"""start date time for app (ISO8601 time format, e.g., '2020-10-11T09:22:05')"""
|
195
|
+
|
177
196
|
self.end_time = _get_int_item(data, "end_time")
|
178
|
-
|
197
|
+
"""end date time for app (ISO8601 time format, e.g., '2020-10-11T10:22:05')"""
|
198
|
+
|
179
199
|
self.interval = _get_int_item(data, "interval")
|
180
|
-
|
200
|
+
"""start interval seconds for short running app, support ISO 8601 durations and cron expression (e.g., 'P1Y2M3DT4H5M6S' 'P5W' '* */5 * * * *')"""
|
201
|
+
|
181
202
|
self.cron = _get_bool_item(data, "cron")
|
203
|
+
"""indicate interval parameter use cron expression or not"""
|
204
|
+
|
182
205
|
self.daily_limitation = App.DailyLimitation(_get_native_item(data, "daily_limitation"))
|
183
206
|
|
184
|
-
# extra timeout seconds for stopping current process, support ISO 8601 durations (e.g., 'P1Y2M3DT4H5M6S' 'P5W').
|
185
207
|
self.retention = _get_str_item(data, "retention")
|
208
|
+
"""extra timeout seconds for stopping current process, support ISO 8601 durations (e.g., 'P1Y2M3DT4H5M6S' 'P5W')."""
|
186
209
|
|
187
|
-
# health check script command (e.g., sh -x 'curl host:port/health', return 0 is health)
|
188
210
|
self.health_check_cmd = _get_str_item(data, "health_check_cmd")
|
189
|
-
|
211
|
+
"""health check script command (e.g., sh -x 'curl host:port/health', return 0 is health)"""
|
212
|
+
|
190
213
|
self.permission = _get_int_item(data, "permission")
|
214
|
+
"""application user permission, value is 2 bit integer: [group & other], each bit can be deny:1, read:2, write: 3."""
|
191
215
|
self.behavior = App.Behavior(_get_native_item(data, "behavior"))
|
192
216
|
|
193
|
-
# environment variables (e.g., -e env1=value1 -e env2=value2, APP_DOCKER_OPTS is used to input docker run parameters)
|
194
217
|
self.env = dict()
|
218
|
+
"""environment variables (e.g., -e env1=value1 -e env2=value2, APP_DOCKER_OPTS is used to input docker run parameters)"""
|
195
219
|
if data and "env" in data:
|
196
220
|
for k, v in data["env"].items():
|
197
221
|
self.env[k] = v
|
198
|
-
|
222
|
+
|
199
223
|
self.sec_env = dict()
|
224
|
+
"""security environment variables, encrypt in server side with application owner's cipher"""
|
200
225
|
if data and "sec_env" in data:
|
201
226
|
for k, v in data["sec_env"].items():
|
202
227
|
self.sec_env[k] = v
|
203
|
-
|
228
|
+
|
204
229
|
self.pid = _get_int_item(data, "pid")
|
230
|
+
"""process id used to attach to the running process"""
|
205
231
|
self.resource_limit = App.ResourceLimitation(_get_native_item(data, "resource_limit"))
|
206
232
|
|
207
233
|
# readonly attributes
|
208
234
|
self.owner = _get_str_item(data, "owner")
|
235
|
+
"""owner name"""
|
209
236
|
self.pstree = _get_str_item(data, "pstree")
|
237
|
+
"""process tree"""
|
210
238
|
self.container_id = _get_str_item(data, "container_id")
|
239
|
+
"""container id"""
|
211
240
|
self.memory = _get_int_item(data, "memory")
|
241
|
+
"""memory usage"""
|
212
242
|
self.cpu = _get_int_item(data, "cpu")
|
243
|
+
"""cpu usage"""
|
213
244
|
self.fd = _get_int_item(data, "fd")
|
245
|
+
"""file descriptor usage"""
|
214
246
|
self.last_start_time = _get_int_item(data, "last_start_time")
|
247
|
+
"""last start time"""
|
215
248
|
self.last_exit_time = _get_int_item(data, "last_exit_time")
|
249
|
+
"""last exit time"""
|
216
250
|
self.health = _get_int_item(data, "health")
|
251
|
+
"""health status"""
|
217
252
|
self.version = _get_int_item(data, "version")
|
253
|
+
"""version number"""
|
218
254
|
self.return_code = _get_int_item(data, "return_code")
|
255
|
+
"""last exit code"""
|
219
256
|
|
220
257
|
def set_valid_time(self, start: datetime, end: datetime) -> None:
|
221
258
|
"""Set avialable time window"""
|
@@ -265,8 +302,11 @@ class Run(object):
|
|
265
302
|
|
266
303
|
def __init__(self, client, app_name: str, process_id: str):
|
267
304
|
self.app_name = app_name
|
305
|
+
"""application name"""
|
268
306
|
self.proc_uid = process_id
|
307
|
+
"""process_uuid from run_async()"""
|
269
308
|
self.__client = client
|
309
|
+
"""AppMeshClient object"""
|
270
310
|
|
271
311
|
def wait(self, stdout_print: bool = True, timeout: int = 0) -> int:
|
272
312
|
"""Wait for an async run to be finished
|
@@ -317,6 +357,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
317
357
|
rest_timeout (tuple, optional): HTTP timeout, Defaults to 60 seconds for connect timeout and 300 seconds for read timeout
|
318
358
|
jwt_token (str, optional): JWT token, provide correct token is same with login() & authenticate().
|
319
359
|
"""
|
360
|
+
|
320
361
|
self.server_url = rest_url
|
321
362
|
self.__jwt_token = jwt_token
|
322
363
|
self.ssl_verify = rest_ssl_verify
|
@@ -0,0 +1,6 @@
|
|
1
|
+
appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
|
2
|
+
appmesh/appmesh_client.py,sha256=b1UOMQm8GUy6WAl3385YGMbs4qyZqKukZn9vx8RRswU,60702
|
3
|
+
appmesh-1.2.1.dist-info/METADATA,sha256=l4ZxoKiK0ftZ8HqGi7A7wbm77-1shEFyFCsNYR1tzzs,10928
|
4
|
+
appmesh-1.2.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
5
|
+
appmesh-1.2.1.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
6
|
+
appmesh-1.2.1.dist-info/RECORD,,
|
appmesh-1.2.0.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
|
2
|
-
appmesh/appmesh_client.py,sha256=Gpf7pdqijTThDQQWH3gDPSZO7Wfjpdp4h4yUpkdk_aQ,60075
|
3
|
-
appmesh-1.2.0.dist-info/METADATA,sha256=aOLMvUjWhjrg3DzFdUs6luSMZlHo4ZVsksqgYO3Xr20,10928
|
4
|
-
appmesh-1.2.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
5
|
-
appmesh-1.2.0.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
6
|
-
appmesh-1.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|