ga-api-client 0.2.16__tar.gz → 0.3.1__tar.gz
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.
- {ga-api-client-0.2.16/ga_api_client.egg-info → ga-api-client-0.3.1}/PKG-INFO +1 -1
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api/ga_api_client.py +233 -2
- {ga-api-client-0.2.16 → ga-api-client-0.3.1/ga_api_client.egg-info}/PKG-INFO +1 -1
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/setup.cfg +1 -1
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/LICENSE +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/README.md +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api/__init__.py +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api/field_tree.py +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api/hyper_log_log.py +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api_client.egg-info/SOURCES.txt +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api_client.egg-info/dependency_links.txt +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api_client.egg-info/requires.txt +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/ga_api_client.egg-info/top_level.txt +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/pyproject.toml +0 -0
- {ga-api-client-0.2.16 → ga-api-client-0.3.1}/setup.py +0 -0
|
@@ -8,7 +8,6 @@ import getpass
|
|
|
8
8
|
import json
|
|
9
9
|
import logging
|
|
10
10
|
import math
|
|
11
|
-
import http
|
|
12
11
|
from async_timeout import timeout
|
|
13
12
|
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes # 36.0.0
|
|
14
13
|
import aiohttp # 3.8.1
|
|
@@ -113,6 +112,8 @@ class Client:
|
|
|
113
112
|
# TODO: if url is wrong, the result might not be JSON
|
|
114
113
|
bringup = await resp.json()
|
|
115
114
|
# do captcha when enabled
|
|
115
|
+
if bringup['tenantID'] is not None:
|
|
116
|
+
self.tenantID = bringup['tenantID']
|
|
116
117
|
if bringup['captchaEnabled']:
|
|
117
118
|
logging.info(f'captcha')
|
|
118
119
|
key = os.urandom(24)
|
|
@@ -205,6 +206,9 @@ class Client:
|
|
|
205
206
|
else:
|
|
206
207
|
logging.error(f'{method} {path} - {e}, fail')
|
|
207
208
|
raise e
|
|
209
|
+
except Exception as e:
|
|
210
|
+
logging.error(f'{method} {path} - {e}, fail')
|
|
211
|
+
raise e
|
|
208
212
|
|
|
209
213
|
class System(Client):
|
|
210
214
|
def __init__(self, url, user=None, password=None, ssl=True, retry=0, conn_timeout=30, read_timeout=300):
|
|
@@ -390,7 +394,11 @@ class Tenant(Client):
|
|
|
390
394
|
status, rlt = await self._request('GET', '/cq/dataset', [200])
|
|
391
395
|
logging.info(f'status={status} rlt={rlt}')
|
|
392
396
|
return rlt
|
|
393
|
-
|
|
397
|
+
async def get_mgr_config(self, req):
|
|
398
|
+
# 200 - ok, return mgr configuration
|
|
399
|
+
status, rlt = await self._request('GET', f"/mgr/{req}", [200])
|
|
400
|
+
logging.info(f'status={status}')
|
|
401
|
+
return rlt
|
|
394
402
|
async def list_all_datasets(self):
|
|
395
403
|
dset_list = await self.get_all_datasets()
|
|
396
404
|
return desc_dataframe(dset_list)
|
|
@@ -627,6 +635,7 @@ class Adhoc:
|
|
|
627
635
|
try:
|
|
628
636
|
rlts = await asyncio.gather(*tasks)
|
|
629
637
|
except Exception as e:
|
|
638
|
+
logging.error(f'read range fail {e}')
|
|
630
639
|
for task in tasks:
|
|
631
640
|
task.cancel()
|
|
632
641
|
raise e
|
|
@@ -690,6 +699,7 @@ class Pipeline:
|
|
|
690
699
|
try:
|
|
691
700
|
rlts = await asyncio.gather(*tasks)
|
|
692
701
|
except Exception as e:
|
|
702
|
+
logging.error(f'read range fail {e}')
|
|
693
703
|
for task in tasks:
|
|
694
704
|
task.cancel()
|
|
695
705
|
raise e
|
|
@@ -769,6 +779,7 @@ class Dataset:
|
|
|
769
779
|
try:
|
|
770
780
|
rlts = await asyncio.gather(*tasks)
|
|
771
781
|
except Exception as e:
|
|
782
|
+
logging.error(f'patch fail {e}')
|
|
772
783
|
for task in tasks:
|
|
773
784
|
task.cancel()
|
|
774
785
|
raise e
|
|
@@ -796,6 +807,7 @@ class Dataset:
|
|
|
796
807
|
try:
|
|
797
808
|
rlts = await asyncio.gather(*tasks)
|
|
798
809
|
except Exception as e:
|
|
810
|
+
logging.error(f'poll fail {e}')
|
|
799
811
|
for task in tasks:
|
|
800
812
|
task.cancel()
|
|
801
813
|
raise e
|
|
@@ -835,7 +847,198 @@ class Dataset:
|
|
|
835
847
|
finally:
|
|
836
848
|
if add_delta:
|
|
837
849
|
next_ts += delta
|
|
850
|
+
class Controller:
|
|
851
|
+
def __init__(self, cid, tenant):
|
|
852
|
+
self.cid = cid
|
|
853
|
+
self._tenant = tenant
|
|
854
|
+
def desc_resource(self, rlt):
|
|
855
|
+
dict = {}
|
|
856
|
+
for i in rlt:
|
|
857
|
+
item = i.copy()
|
|
858
|
+
item.pop('tenant', None)
|
|
859
|
+
item.pop('rawConfig', None)
|
|
860
|
+
item.pop('devices', None)
|
|
861
|
+
dict[item["_id"]] = item
|
|
862
|
+
# item.pop('_id', group.None)
|
|
863
|
+
return pd.DataFrame.from_dict(dict, orient='index')
|
|
864
|
+
def desc_resource_group(self, rlt):
|
|
865
|
+
lst = []
|
|
866
|
+
for i in rlt:
|
|
867
|
+
for m in i["member"]:
|
|
868
|
+
lst.append([i["_id"], i["name"],m])
|
|
869
|
+
# item.pop('_id', None)
|
|
870
|
+
return pd.DataFrame(lst, columns =['_id', 'name', 'resource'])
|
|
871
|
+
|
|
872
|
+
async def list_interface(self):
|
|
873
|
+
"""List all interface of controller
|
|
874
|
+
|
|
875
|
+
Returns:
|
|
876
|
+
pandas.DataFrane: interface indexed by tag
|
|
877
|
+
"""
|
|
878
|
+
now = datetime.datetime.now().timestamp
|
|
879
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.interface'
|
|
880
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
881
|
+
return self.desc_resource(rlt)
|
|
882
|
+
async def list_home(self):
|
|
883
|
+
"""List all home of controller
|
|
884
|
+
|
|
885
|
+
Returns:
|
|
886
|
+
pandas.DataFrane: home indexed by tag
|
|
887
|
+
"""
|
|
888
|
+
now = datetime.datetime.now().timestamp
|
|
889
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.home'
|
|
890
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
891
|
+
return self.desc_resource(rlt)
|
|
892
|
+
async def list_router(self):
|
|
893
|
+
"""List all router of controller
|
|
894
|
+
|
|
895
|
+
Returns:
|
|
896
|
+
pandas.DataFrane: router indexed by tag
|
|
897
|
+
"""
|
|
898
|
+
now = datetime.datetime.now().timestamp
|
|
899
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.router'
|
|
900
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
901
|
+
return self.desc_resource(rlt)
|
|
902
|
+
async def list_boundary(self):
|
|
903
|
+
"""List all boundary of controller
|
|
904
|
+
|
|
905
|
+
Returns:
|
|
906
|
+
pandas.DataFrane: boundary indexed by tag
|
|
907
|
+
"""
|
|
908
|
+
now = datetime.datetime.now().timestamp
|
|
909
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.boundary'
|
|
910
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
911
|
+
return self.desc_resource(rlt)
|
|
912
|
+
async def list_neighbor(self):
|
|
913
|
+
"""List all neighbor of controller
|
|
914
|
+
|
|
915
|
+
Returns:
|
|
916
|
+
pandas.DataFrane: neighbor indexed by tag
|
|
917
|
+
"""
|
|
918
|
+
now = datetime.datetime.now().timestamp
|
|
919
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.neighbor'
|
|
920
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
921
|
+
return self.desc_resource(rlt)
|
|
922
|
+
async def list_subnetwork(self):
|
|
923
|
+
"""List all subnetwork of controller
|
|
924
|
+
|
|
925
|
+
Returns:
|
|
926
|
+
pandas.DataFrane: subnetwork indexed by tag
|
|
927
|
+
"""
|
|
928
|
+
now = datetime.datetime.now().timestamp
|
|
929
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.subnetwork'
|
|
930
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
931
|
+
return self.desc_resource(rlt)
|
|
932
|
+
async def list_serverfarm(self):
|
|
933
|
+
"""List all serverfarm of controller
|
|
934
|
+
|
|
935
|
+
Returns:
|
|
936
|
+
pandas.DataFrane: serverfarm indexed by tag
|
|
937
|
+
"""
|
|
938
|
+
now = datetime.datetime.now().timestamp
|
|
939
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.serverfarm'
|
|
940
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
941
|
+
return self.desc_resource(rlt)
|
|
942
|
+
async def list_vpn(self):
|
|
943
|
+
"""List all vpn of controller
|
|
944
|
+
|
|
945
|
+
Returns:
|
|
946
|
+
pandas.DataFrane: vpn indexed by tag
|
|
947
|
+
"""
|
|
948
|
+
now = datetime.datetime.now().timestamp
|
|
949
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.vpnCustomer'
|
|
950
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
951
|
+
return self.desc_resource(rlt)
|
|
952
|
+
async def list_pop(self):
|
|
953
|
+
"""List all pop of controller
|
|
954
|
+
|
|
955
|
+
Returns:
|
|
956
|
+
pandas.DataFrane: pop indexed by tag
|
|
957
|
+
"""
|
|
958
|
+
now = datetime.datetime.now().timestamp
|
|
959
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.pop'
|
|
960
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
961
|
+
return self.desc_resource(rlt)
|
|
962
|
+
async def list_interface_group(self):
|
|
963
|
+
"""List all interface_group of controller
|
|
838
964
|
|
|
965
|
+
Returns:
|
|
966
|
+
pandas.DataFrane: interface groups indexed by group ID
|
|
967
|
+
"""
|
|
968
|
+
now = datetime.datetime.now().timestamp
|
|
969
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.interface'
|
|
970
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
971
|
+
return self.desc_resource_group(rlt)
|
|
972
|
+
async def list_router_group(self):
|
|
973
|
+
"""List all router_group of controller
|
|
974
|
+
|
|
975
|
+
Returns:
|
|
976
|
+
pandas.DataFrane: router groups indexed by group ID
|
|
977
|
+
"""
|
|
978
|
+
now = datetime.datetime.now().timestamp
|
|
979
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.router'
|
|
980
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
981
|
+
return self.desc_resource_group(rlt)
|
|
982
|
+
async def list_boundary_group(self):
|
|
983
|
+
"""List all boundary_group of controller
|
|
984
|
+
|
|
985
|
+
Returns:
|
|
986
|
+
pandas.DataFrane: boundary groups indexed by group ID
|
|
987
|
+
"""
|
|
988
|
+
now = datetime.datetime.now().timestamp
|
|
989
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.boundary'
|
|
990
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
991
|
+
return self.desc_resource_group(rlt)
|
|
992
|
+
async def list_neighbor_group(self):
|
|
993
|
+
"""List all neighbor_group of controller
|
|
994
|
+
|
|
995
|
+
Returns:
|
|
996
|
+
pandas.DataFrane: neighbor groups indexed by group ID
|
|
997
|
+
"""
|
|
998
|
+
now = datetime.datetime.now().timestamp
|
|
999
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.neighbor'
|
|
1000
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
1001
|
+
return self.desc_resource_group(rlt)
|
|
1002
|
+
async def list_subnetwork_group(self):
|
|
1003
|
+
"""List all subnetwork_group of controller
|
|
1004
|
+
|
|
1005
|
+
Returns:
|
|
1006
|
+
pandas.DataFrane: subnetwork groups indexed by group ID
|
|
1007
|
+
"""
|
|
1008
|
+
now = datetime.datetime.now().timestamp
|
|
1009
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.subnetwork'
|
|
1010
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
1011
|
+
return self.desc_resource_group(rlt)
|
|
1012
|
+
async def list_serverfarm_group(self):
|
|
1013
|
+
"""List all serverfarm_group of controller
|
|
1014
|
+
|
|
1015
|
+
Returns:
|
|
1016
|
+
pandas.DataFrane: serverfarm groups indexed by group ID
|
|
1017
|
+
"""
|
|
1018
|
+
now = datetime.datetime.now().timestamp
|
|
1019
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.serverfarm'
|
|
1020
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
1021
|
+
return self.desc_resource_group(rlt)
|
|
1022
|
+
async def list_vpn_group(self):
|
|
1023
|
+
"""List all vpn_group of controller
|
|
1024
|
+
|
|
1025
|
+
Returns:
|
|
1026
|
+
pandas.DataFrane: vpn groups indexed by group ID
|
|
1027
|
+
"""
|
|
1028
|
+
now = datetime.datetime.now().timestamp
|
|
1029
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.vpnCustomer'
|
|
1030
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
1031
|
+
return self.desc_resource_group(rlt)
|
|
1032
|
+
async def list_pop_group(self):
|
|
1033
|
+
"""List all pop_group of controller
|
|
1034
|
+
|
|
1035
|
+
Returns:
|
|
1036
|
+
pandas.DataFrane: pop groups indexed by group ID
|
|
1037
|
+
"""
|
|
1038
|
+
now = datetime.datetime.now().timestamp
|
|
1039
|
+
req = f'tenant.{self._tenant.tenantID}.intern.atmC.{self.cid}.sync.group.pop'
|
|
1040
|
+
rlt = await self._tenant.get_mgr_config(req)
|
|
1041
|
+
return self.desc_resource_group(rlt)
|
|
839
1042
|
class Repository:
|
|
840
1043
|
def __init__(self, url, user=None, tenant=None, password=None, ssl=True, burst=1, retry=0, conn_timeout=30, read_timeout=300):
|
|
841
1044
|
"""Construct repository object to send tenant requests to API server
|
|
@@ -857,7 +1060,35 @@ class Repository:
|
|
|
857
1060
|
"""
|
|
858
1061
|
await self._tenant.close()
|
|
859
1062
|
await asyncio.sleep(0.250)
|
|
1063
|
+
async def list_controller(self):
|
|
1064
|
+
"""List all controllers
|
|
860
1065
|
|
|
1066
|
+
Returns:
|
|
1067
|
+
pandas.DataFrame: Dataset configurations indexed by id.
|
|
1068
|
+
"""
|
|
1069
|
+
now = datetime.datetime.now().timestamp()
|
|
1070
|
+
req_path = f'tenant.{self._tenant.tenantID}.intern.atmC?ts={now}'
|
|
1071
|
+
controller_list = await self._tenant.get_mgr_config(req_path)
|
|
1072
|
+
controller_dict = {}
|
|
1073
|
+
for controller in controller_list:
|
|
1074
|
+
item = controller.copy()
|
|
1075
|
+
item.pop('sync', None)
|
|
1076
|
+
item['version'] = item['setting']['version']
|
|
1077
|
+
item['host'] = item['setting']['rest']['host']
|
|
1078
|
+
item.pop('setting', None)
|
|
1079
|
+
item.pop('keepUnsync', None)
|
|
1080
|
+
controller_dict[item['_id']] = item
|
|
1081
|
+
item.pop('_id', None)
|
|
1082
|
+
return pd.DataFrame.from_dict(controller_dict, orient='index')
|
|
1083
|
+
async def controller(self, cid):
|
|
1084
|
+
"""List all controllers
|
|
1085
|
+
Args:
|
|
1086
|
+
cid: the controller ID
|
|
1087
|
+
|
|
1088
|
+
Returns:
|
|
1089
|
+
Controller object with the specified id.
|
|
1090
|
+
"""
|
|
1091
|
+
return Controller(cid, self._tenant)
|
|
861
1092
|
async def list(self):
|
|
862
1093
|
"""List all datasets
|
|
863
1094
|
|
|
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
|