gnetclisdk 1.0.55__tar.gz → 1.0.56__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/PKG-INFO +14 -4
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/README.md +3 -2
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk/client.py +8 -3
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk.egg-info/PKG-INFO +14 -4
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/MANIFEST.in +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk/auth.py +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk/exceptions.py +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk/interceptors.py +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk/proto/server_pb2.py +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk/proto/server_pb2.pyi +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk/proto/server_pb2_grpc.py +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk.egg-info/SOURCES.txt +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk.egg-info/dependency_links.txt +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk.egg-info/requires.txt +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/gnetclisdk.egg-info/top_level.txt +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/pyproject.toml +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/requirements.txt +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/setup.cfg +0 -0
- {gnetclisdk-1.0.55 → gnetclisdk-1.0.56}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: gnetclisdk
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.56
|
4
4
|
Summary: Client for Gnetcli GRPC-server
|
5
5
|
Home-page: https://github.com/annetutil/gnetcli
|
6
6
|
Author: Alexander Balezin
|
@@ -16,6 +16,15 @@ Description-Content-Type: text/markdown
|
|
16
16
|
Requires-Dist: protobuf>=4.24.4
|
17
17
|
Requires-Dist: grpcio>=1.59.2
|
18
18
|
Requires-Dist: googleapis-common-protos>=1.61.0
|
19
|
+
Dynamic: author
|
20
|
+
Dynamic: author-email
|
21
|
+
Dynamic: classifier
|
22
|
+
Dynamic: description
|
23
|
+
Dynamic: description-content-type
|
24
|
+
Dynamic: home-page
|
25
|
+
Dynamic: license
|
26
|
+
Dynamic: requires-dist
|
27
|
+
Dynamic: summary
|
19
28
|
|
20
29
|
## Python client for Gnetcli GRPC server
|
21
30
|
|
@@ -27,13 +36,14 @@ See documentation on [gnetcli server](https://annetutil.github.io/gnetcli/).
|
|
27
36
|
Example:
|
28
37
|
|
29
38
|
```python
|
30
|
-
from gnetclisdk.client import Credentials, Gnetcli
|
39
|
+
from gnetclisdk.client import Credentials, Gnetcli, HostParams
|
31
40
|
import os, asyncio
|
32
41
|
|
33
42
|
async def example():
|
34
43
|
api = Gnetcli(insecure_grpc=True)
|
44
|
+
# api = Gnetcli(insecure_grpc=True, auth_token="Basic " + base64.b64encode(f"{username}:{password}".encode('utf-8')).decode("ascii")
|
35
45
|
dev_creds = Credentials(os.environ.get("LOGIN"), os.environ.get("PASSWORD"))
|
36
|
-
res = await api.cmd(hostname="myhost",
|
46
|
+
res = await api.cmd(hostname="myhost", cmd="dis clock", host_params=HostParams(device="huawei", credentials=dev_creds))
|
37
47
|
print("err=%s status=%s out=%s" % (res.error, res.status, res.out))
|
38
48
|
|
39
49
|
asyncio.run(example())
|
@@ -8,13 +8,14 @@ See documentation on [gnetcli server](https://annetutil.github.io/gnetcli/).
|
|
8
8
|
Example:
|
9
9
|
|
10
10
|
```python
|
11
|
-
from gnetclisdk.client import Credentials, Gnetcli
|
11
|
+
from gnetclisdk.client import Credentials, Gnetcli, HostParams
|
12
12
|
import os, asyncio
|
13
13
|
|
14
14
|
async def example():
|
15
15
|
api = Gnetcli(insecure_grpc=True)
|
16
|
+
# api = Gnetcli(insecure_grpc=True, auth_token="Basic " + base64.b64encode(f"{username}:{password}".encode('utf-8')).decode("ascii")
|
16
17
|
dev_creds = Credentials(os.environ.get("LOGIN"), os.environ.get("PASSWORD"))
|
17
|
-
res = await api.cmd(hostname="myhost",
|
18
|
+
res = await api.cmd(hostname="myhost", cmd="dis clock", host_params=HostParams(device="huawei", credentials=dev_creds))
|
18
19
|
print("err=%s status=%s out=%s" % (res.error, res.status, res.out))
|
19
20
|
|
20
21
|
asyncio.run(example())
|
@@ -2,6 +2,7 @@ import asyncio
|
|
2
2
|
import logging
|
3
3
|
import os.path
|
4
4
|
import uuid
|
5
|
+
import re
|
5
6
|
from abc import ABC, abstractmethod
|
6
7
|
from contextlib import asynccontextmanager
|
7
8
|
from dataclasses import dataclass, field
|
@@ -190,7 +191,7 @@ class Gnetcli:
|
|
190
191
|
_logger.debug("connect to %s", self._server)
|
191
192
|
async with self._grpc_channel_fn(self._server, options=self._options) as channel:
|
192
193
|
stub = server_pb2_grpc.GnetcliStub(channel)
|
193
|
-
_logger.debug("executing netconf cmd: %r", pbcmd)
|
194
|
+
_logger.debug("executing netconf cmd: %r", mask_password(repr(pbcmd)))
|
194
195
|
try:
|
195
196
|
response = await grpc_call_wrapper(stub.ExecNetconf, pbcmd)
|
196
197
|
except Exception as e:
|
@@ -344,7 +345,7 @@ class GnetcliSession(ABC):
|
|
344
345
|
if not self._stream:
|
345
346
|
raise Exception("empty self._stream")
|
346
347
|
try:
|
347
|
-
_logger.debug("cmd %r on %r", str(cmdpb).replace("\n", ""), self._stream)
|
348
|
+
_logger.debug("cmd %r on %r", mask_password(str(cmdpb)).replace("\n", ""), self._stream)
|
348
349
|
await self._stream.write(cmdpb)
|
349
350
|
response: Message = await self._stream.read()
|
350
351
|
except grpc.aio.AioRpcError as e:
|
@@ -420,7 +421,7 @@ async def grpc_call_wrapper(stub: grpc.UnaryUnaryMultiCallable, request: Any) ->
|
|
420
421
|
metadata = [
|
421
422
|
(HEADER_REQUEST_ID, req_id),
|
422
423
|
]
|
423
|
-
_logger.debug("executing %s: %r, req_id=%s", type(request), repr(request), req_id)
|
424
|
+
_logger.debug("executing %s: %r, req_id=%s", type(request), mask_password(repr(request)), req_id)
|
424
425
|
await asyncio.sleep(i * 2)
|
425
426
|
try:
|
426
427
|
response = await stub(request=request, metadata=metadata)
|
@@ -494,6 +495,10 @@ def make_cmd(
|
|
494
495
|
return res
|
495
496
|
|
496
497
|
|
498
|
+
def mask_password(line: str) -> str:
|
499
|
+
return re.sub(r'password: ".+?"', "password: ...", line)
|
500
|
+
|
501
|
+
|
497
502
|
def make_files_request(files: Dict[str, File]) -> List[server_pb2.FileData]:
|
498
503
|
res: List[server_pb2.FileData] = []
|
499
504
|
for path, file in files.items():
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: gnetclisdk
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.56
|
4
4
|
Summary: Client for Gnetcli GRPC-server
|
5
5
|
Home-page: https://github.com/annetutil/gnetcli
|
6
6
|
Author: Alexander Balezin
|
@@ -16,6 +16,15 @@ Description-Content-Type: text/markdown
|
|
16
16
|
Requires-Dist: protobuf>=4.24.4
|
17
17
|
Requires-Dist: grpcio>=1.59.2
|
18
18
|
Requires-Dist: googleapis-common-protos>=1.61.0
|
19
|
+
Dynamic: author
|
20
|
+
Dynamic: author-email
|
21
|
+
Dynamic: classifier
|
22
|
+
Dynamic: description
|
23
|
+
Dynamic: description-content-type
|
24
|
+
Dynamic: home-page
|
25
|
+
Dynamic: license
|
26
|
+
Dynamic: requires-dist
|
27
|
+
Dynamic: summary
|
19
28
|
|
20
29
|
## Python client for Gnetcli GRPC server
|
21
30
|
|
@@ -27,13 +36,14 @@ See documentation on [gnetcli server](https://annetutil.github.io/gnetcli/).
|
|
27
36
|
Example:
|
28
37
|
|
29
38
|
```python
|
30
|
-
from gnetclisdk.client import Credentials, Gnetcli
|
39
|
+
from gnetclisdk.client import Credentials, Gnetcli, HostParams
|
31
40
|
import os, asyncio
|
32
41
|
|
33
42
|
async def example():
|
34
43
|
api = Gnetcli(insecure_grpc=True)
|
44
|
+
# api = Gnetcli(insecure_grpc=True, auth_token="Basic " + base64.b64encode(f"{username}:{password}".encode('utf-8')).decode("ascii")
|
35
45
|
dev_creds = Credentials(os.environ.get("LOGIN"), os.environ.get("PASSWORD"))
|
36
|
-
res = await api.cmd(hostname="myhost",
|
46
|
+
res = await api.cmd(hostname="myhost", cmd="dis clock", host_params=HostParams(device="huawei", credentials=dev_creds))
|
37
47
|
print("err=%s status=%s out=%s" % (res.error, res.status, res.out))
|
38
48
|
|
39
49
|
asyncio.run(example())
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|