appmesh 1.2.9__py3-none-any.whl → 1.3.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 +22 -17
- {appmesh-1.2.9.dist-info → appmesh-1.3.1.dist-info}/METADATA +3 -3
- appmesh-1.3.1.dist-info/RECORD +6 -0
- {appmesh-1.2.9.dist-info → appmesh-1.3.1.dist-info}/WHEEL +1 -1
- appmesh-1.2.9.dist-info/RECORD +0 -6
- {appmesh-1.2.9.dist-info → appmesh-1.3.1.dist-info}/top_level.txt +0 -0
appmesh/appmesh_client.py
CHANGED
@@ -32,6 +32,10 @@ _SSL_CLIENT_PEM_FILE = "/opt/appmesh/ssl/client.pem"
|
|
32
32
|
_SSL_CLIENT_PEM_KEY_FILE = "/opt/appmesh/ssl/client-key.pem"
|
33
33
|
HTTP_USER_AGENT_HEADER_NAME = "User-Agent"
|
34
34
|
HTTP_USER_AGENT = "appmesh/python"
|
35
|
+
HTTP_USER_AGENT_TCP = "appmesh/python/tcp"
|
36
|
+
HTTP_HEADER_KEY_X_SEND_FILE_SOCKET = "X-Send-File-Socket"
|
37
|
+
HTTP_HEADER_KEY_X_RECV_FILE_SOCKET = "X-Recv-File-Socket"
|
38
|
+
HTTP_HEADER_KEY_X_TARGET_HOST = "X-Target-Host"
|
35
39
|
|
36
40
|
|
37
41
|
def _get_str_item(data: dict, key):
|
@@ -1333,9 +1337,9 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
1333
1337
|
header["Authorization"] = "Bearer " + self.jwt_token
|
1334
1338
|
if self.delegate_host and len(self.delegate_host) > 0:
|
1335
1339
|
if ":" in self.delegate_host:
|
1336
|
-
header[
|
1340
|
+
header[HTTP_HEADER_KEY_X_TARGET_HOST] = self.delegate_host
|
1337
1341
|
else:
|
1338
|
-
header[
|
1342
|
+
header[HTTP_HEADER_KEY_X_TARGET_HOST] = self.delegate_host + ":" + str(parse.urlsplit(self.server_url).port)
|
1339
1343
|
header[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT
|
1340
1344
|
|
1341
1345
|
if method is AppMeshClient.Method.GET:
|
@@ -1500,11 +1504,8 @@ class AppMeshClientTCP(AppMeshClient):
|
|
1500
1504
|
if super().jwt_token:
|
1501
1505
|
appmesh_requst.headers["Authorization"] = "Bearer " + super().jwt_token
|
1502
1506
|
if super().delegate_host and len(super().delegate_host) > 0:
|
1503
|
-
|
1504
|
-
|
1505
|
-
else:
|
1506
|
-
appmesh_requst.headers["X-Target-Host"] = super().delegate_host + ":" + str(parse.urlsplit(self.server_url).port)
|
1507
|
-
appmesh_requst.headers[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT
|
1507
|
+
raise Exception("Not support delegate request in TCP mode")
|
1508
|
+
appmesh_requst.headers[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT_TCP
|
1508
1509
|
appmesh_requst.uuid = str(uuid.uuid1())
|
1509
1510
|
appmesh_requst.http_method = method.value
|
1510
1511
|
appmesh_requst.request_uri = path
|
@@ -1525,13 +1526,13 @@ class AppMeshClientTCP(AppMeshClient):
|
|
1525
1526
|
for k, v in query.items():
|
1526
1527
|
appmesh_requst.querys[k] = v
|
1527
1528
|
data = appmesh_requst.serialize()
|
1528
|
-
self.__socket_client.sendall(len(data).to_bytes(TCP_MESSAGE_HEADER_LENGTH, "big", signed=False))
|
1529
|
+
self.__socket_client.sendall(len(data).to_bytes(TCP_MESSAGE_HEADER_LENGTH, byteorder="big", signed=False))
|
1529
1530
|
self.__socket_client.sendall(data)
|
1530
1531
|
|
1531
1532
|
# https://developers.google.com/protocol-buffers/docs/pythontutorial
|
1532
1533
|
# https://stackoverflow.com/questions/33913308/socket-module-how-to-send-integer
|
1533
1534
|
resp_data = bytes()
|
1534
|
-
resp_data = self.__recvall(int.from_bytes(self.__recvall(TCP_MESSAGE_HEADER_LENGTH), "big", signed=False))
|
1535
|
+
resp_data = self.__recvall(int.from_bytes(self.__recvall(TCP_MESSAGE_HEADER_LENGTH), byteorder="big", signed=False))
|
1535
1536
|
if resp_data is None or len(resp_data) == 0:
|
1536
1537
|
self.__close_socket()
|
1537
1538
|
raise Exception("socket connection broken")
|
@@ -1558,18 +1559,21 @@ class AppMeshClientTCP(AppMeshClient):
|
|
1558
1559
|
Returns:
|
1559
1560
|
bool: success or failure.
|
1560
1561
|
"""
|
1561
|
-
|
1562
|
-
|
1562
|
+
header = {}
|
1563
|
+
header["File-Path"] = file_path
|
1564
|
+
header[HTTP_HEADER_KEY_X_RECV_FILE_SOCKET] = "true"
|
1565
|
+
resp = self._request_http(AppMeshClient.Method.GET, path="/appmesh/file/download", header=header)
|
1566
|
+
if resp.status_code == HTTPStatus.OK and HTTP_HEADER_KEY_X_RECV_FILE_SOCKET in resp.headers:
|
1563
1567
|
with open(local_file, "wb") as fp:
|
1564
1568
|
chunk_data = bytes()
|
1565
|
-
chunk_size = int.from_bytes(self.__recvall(TCP_MESSAGE_HEADER_LENGTH), "big", signed=False)
|
1569
|
+
chunk_size = int.from_bytes(self.__recvall(TCP_MESSAGE_HEADER_LENGTH), byteorder="big", signed=False)
|
1566
1570
|
while chunk_size > 0:
|
1567
1571
|
chunk_data = self.__recvall(chunk_size)
|
1568
1572
|
if chunk_data is None or len(chunk_data) == 0:
|
1569
1573
|
self.__close_socket()
|
1570
1574
|
raise Exception("socket connection broken")
|
1571
1575
|
fp.write(chunk_data)
|
1572
|
-
chunk_size = int.from_bytes(self.__recvall(TCP_MESSAGE_HEADER_LENGTH), "big", signed=False)
|
1576
|
+
chunk_size = int.from_bytes(self.__recvall(TCP_MESSAGE_HEADER_LENGTH), byteorder="big", signed=False)
|
1573
1577
|
if "File-Mode" in resp.headers:
|
1574
1578
|
os.chmod(path=local_file, mode=int(resp.headers["File-Mode"]))
|
1575
1579
|
if "File-User" in resp.headers and "File-Group" in resp.headers:
|
@@ -1605,15 +1609,16 @@ class AppMeshClientTCP(AppMeshClient):
|
|
1605
1609
|
header["File-User"] = str(file_stat.st_uid)
|
1606
1610
|
header["File-Group"] = str(file_stat.st_gid)
|
1607
1611
|
header["Content-Type"] = "text/plain"
|
1612
|
+
header[HTTP_HEADER_KEY_X_SEND_FILE_SOCKET] = "true"
|
1608
1613
|
# https://stackoverflow.com/questions/22567306/python-requests-file-upload
|
1609
1614
|
resp = self._request_http(AppMeshClient.Method.POST, path="/appmesh/file/upload", header=header)
|
1610
|
-
if resp.status_code == HTTPStatus.OK:
|
1611
|
-
chunk_size =
|
1615
|
+
if resp.status_code == HTTPStatus.OK and HTTP_HEADER_KEY_X_SEND_FILE_SOCKET in resp.headers:
|
1616
|
+
chunk_size = 8 * 1024 # (8 KB in bytes), 131072 bytes (128 KB) is default max ssl buffer size
|
1612
1617
|
chunk_data = fp.read(chunk_size)
|
1613
1618
|
while chunk_data:
|
1614
|
-
self.__socket_client.sendall(len(chunk_data).to_bytes(TCP_MESSAGE_HEADER_LENGTH, "big", signed=False))
|
1619
|
+
self.__socket_client.sendall(len(chunk_data).to_bytes(TCP_MESSAGE_HEADER_LENGTH, byteorder="big", signed=False))
|
1615
1620
|
self.__socket_client.sendall(chunk_data)
|
1616
1621
|
chunk_data = fp.read(chunk_size)
|
1617
|
-
self.__socket_client.sendall(int(0).to_bytes(TCP_MESSAGE_HEADER_LENGTH, "big", signed=False))
|
1622
|
+
self.__socket_client.sendall(int(0).to_bytes(TCP_MESSAGE_HEADER_LENGTH, byteorder="big", signed=False))
|
1618
1623
|
return True, ""
|
1619
1624
|
return False, resp.json()[REST_TEXT_MESSAGE_JSON_KEY]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: appmesh
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.3.1
|
4
4
|
Summary: Client SDK for App Mesh
|
5
5
|
Home-page: https://github.com/laoshanxi/app-mesh
|
6
6
|
Author: laoshanxi
|
@@ -31,7 +31,7 @@ App Mesh is a `Multi-Tenant`, `Cloud Native`, `Micro Service` application manage
|
|
31
31
|
|
32
32
|
App Mesh is similar to Kubernetes but is much more lightweight, supporting both containerized and native applications.
|
33
33
|
|
34
|
-
<div align=center><img src="https://github.com/laoshanxi/
|
34
|
+
<div align=center><img src="https://github.com/laoshanxi/picture/raw/master/appmesh/diagram.png" align=center /></div>
|
35
35
|
|
36
36
|
## Features
|
37
37
|
|
@@ -43,7 +43,7 @@ Cloud native | Schedule cloud-level applications to run on multiple hosts with r
|
|
43
43
|
Micro service application | ⚡️ [Consul micro-service cluster management](https://app-mesh.readthedocs.io/en/latest/CONSUL.html)
|
44
44
|
Extra Features | Collect host/app resource usage <br> Remote shell command execution <br> File upload/download interface <br> Hot-update support `systemctl reload appmesh` <br> Bash completion <br> Reverse proxy <br> [Web GUI](https://github.com/laoshanxi/app-mesh-ui)
|
45
45
|
Platform support | X86_64 <br> ARM32 <br> ARM64
|
46
|
-
SDK | [Python](https://app-mesh.readthedocs.io/en/latest/api/appmesh_client.html) <br> [Golang](https://github.com/laoshanxi/app-mesh/blob/main/src/sdk/go/appmesh_client.go) <br> [JavaScript](https://www.npmjs.com/package/appmesh) <br> [Java](https://github.com/laoshanxi/app-mesh/
|
46
|
+
SDK | [Python](https://app-mesh.readthedocs.io/en/latest/api/appmesh_client.html) <br> [Golang](https://github.com/laoshanxi/app-mesh/blob/main/src/sdk/go/appmesh_client.go) <br> [JavaScript](https://www.npmjs.com/package/appmesh) <br> [Java](https://github.com/laoshanxi/app-mesh/packages/2227502) <br> [Swagger OpenAPI Specification](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/laoshanxi/app-mesh/main/src/daemon/rest/openapi.yaml)
|
47
47
|
|
48
48
|
## Getting started
|
49
49
|
|
@@ -0,0 +1,6 @@
|
|
1
|
+
appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
|
2
|
+
appmesh/appmesh_client.py,sha256=BHgPST7m4vFbGCzHfg_kaqFZZyP9dW-h2M8mEurfyt0,62882
|
3
|
+
appmesh-1.3.1.dist-info/METADATA,sha256=qtqT4-GC1-PwliFwBHf-7Ixbt-UjgHiZ5DxO2JGkGfQ,11031
|
4
|
+
appmesh-1.3.1.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
5
|
+
appmesh-1.3.1.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
6
|
+
appmesh-1.3.1.dist-info/RECORD,,
|
appmesh-1.2.9.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
|
2
|
-
appmesh/appmesh_client.py,sha256=12PXzQY1MTh48XR5XaCLQ3Lvs1g7lLD2KE9QcrNhPgw,62480
|
3
|
-
appmesh-1.2.9.dist-info/METADATA,sha256=k4BdUChQq2Ts5YwEJwPGolTy1jpYpZdWnm6SmEtLrKo,11041
|
4
|
-
appmesh-1.2.9.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
5
|
-
appmesh-1.2.9.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
6
|
-
appmesh-1.2.9.dist-info/RECORD,,
|
File without changes
|