SOLIDserverRest 2.4.0__tar.gz → 2.5.0__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.
Files changed (34) hide show
  1. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/PKG-INFO +45 -10
  2. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/README.md +27 -2
  3. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/SOLIDserverRest.py +69 -5
  4. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/network.py +58 -1
  5. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/sds.py +33 -6
  6. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/mapper.py +22 -0
  7. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest.egg-info/PKG-INFO +45 -10
  8. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest.egg-info/SOURCES.txt +0 -1
  9. solidserverrest-2.5.0/SOLIDserverRest.egg-info/requires.txt +7 -0
  10. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/setup.py +8 -7
  11. SOLIDserverRest-2.4.0/SOLIDserverRest.egg-info/requires.txt +0 -7
  12. SOLIDserverRest-2.4.0/tests/test_dhcp_option_legacy.py +0 -231
  13. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/LICENSE +0 -0
  14. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/Exception.py +0 -0
  15. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/__init__.py +0 -0
  16. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/__init__.py +0 -0
  17. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/base.py +0 -0
  18. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/class_params.py +0 -0
  19. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/device.py +0 -0
  20. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/device_tools.py +0 -0
  21. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/devif.py +0 -0
  22. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/dns.py +0 -0
  23. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/dns_record.py +0 -0
  24. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/dns_zone.py +0 -0
  25. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/ipaddress.py +0 -0
  26. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/space.py +0 -0
  27. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest/adv/validators.py +0 -0
  28. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest.egg-info/dependency_links.txt +0 -0
  29. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest.egg-info/entry_points.txt +0 -0
  30. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest.egg-info/not-zip-safe +0 -0
  31. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/SOLIDserverRest.egg-info/top_level.txt +0 -0
  32. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/setup.cfg +0 -0
  33. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/tests/test_simple.py +0 -0
  34. {SOLIDserverRest-2.4.0 → solidserverrest-2.5.0}/tests/tests.py +0 -0
@@ -1,26 +1,36 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: SOLIDserverRest
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: The SOLIDserverRest is a library to drive EfficientIP API
5
5
  Home-page: https://gitlab.com/efficientip/solidserverrest
6
6
  Author: Gregory CUGAT / Alex Chauvin
7
7
  Author-email: gregory.cugat@efficientip.com, ach@efficientip.com
8
8
  License: BSD 2
9
9
  Classifier: Intended Audience :: Developers
10
- Classifier: Programming Language :: Python :: 3.7
11
10
  Classifier: Programming Language :: Python :: 3.8
12
11
  Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
14
  Requires-Python: >=3.7
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Requires-Dist: requests~=2.0
18
- Requires-Dist: PySocks~=1.0
19
- Requires-Dist: urllib3~=1.0
18
+ Requires-Dist: urllib3~=2.0
20
19
  Requires-Dist: idna~=3.0
21
- Requires-Dist: chardet~=5.0
22
- Requires-Dist: pyopenssl~=24.0
23
- Requires-Dist: packaging~=23.0
20
+ Requires-Dist: PySocks~=1.0
21
+ Requires-Dist: chardet~=5.2
22
+ Requires-Dist: pyopenssl~=25.0
23
+ Requires-Dist: packaging~=24.0
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
24
34
 
25
35
  [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
26
36
 
@@ -46,6 +56,8 @@ Install 'SOLIDserverRest' using pip in your virtualenv:
46
56
 
47
57
  ## Using the SOLIDserverRest advanced object (recommended)
48
58
 
59
+ ### With basic authentication
60
+
49
61
  All commands and object manipulation are going through a SOLIDserver main object, handling the connection to the manager and pushing API calls. The creation of a SOLIDserver object is done like that:
50
62
  ```
51
63
  from SOLIDserverRest import *
@@ -59,12 +71,35 @@ sds = sdsadv.SDS(ip_address=SDS_HOST,
59
71
  user=SDS_LOGIN,
60
72
  pwd=SDS_PWD)
61
73
  try:
62
- sds.connect(method="native")
74
+ sds.connect()
75
+ except SDSError as e:
76
+ logging.error(e)
77
+ exit(1)
78
+
79
+ print(sds)
80
+
81
+ ```
82
+
83
+ ## With token authentication (SDS release >= 8.4.0)
84
+
85
+ ```
86
+ from SOLIDserverRest import *
87
+ from SOLIDserverRest import adv as sdsadv
88
+
89
+ SDS_HOST = "192.168.254.254"
90
+ SDS_TOKEN_ID = "8628f88cbd40df99903d6f385caa0462"
91
+ SDS_TOKEN_SEC = "ca8ec3c0f07b380c4723349230901d40a84ba4b4987c12863b66b0b5297ad922"
92
+
93
+ sds = sdsadv.SDS(ip_address=SDS_HOST)
94
+ sds.set_token_creds(keyid=SDS_TOKEN_ID,
95
+ keysecret=SDS_TOKEN_SEC)
96
+ try:
97
+ sds.connect(method="token")
63
98
  except SDSError as e:
64
99
  logging.error(e)
65
100
  exit(1)
66
101
 
67
- print(adv)
102
+ print(sds)
68
103
 
69
104
  ```
70
105
 
@@ -22,6 +22,8 @@ Install 'SOLIDserverRest' using pip in your virtualenv:
22
22
 
23
23
  ## Using the SOLIDserverRest advanced object (recommended)
24
24
 
25
+ ### With basic authentication
26
+
25
27
  All commands and object manipulation are going through a SOLIDserver main object, handling the connection to the manager and pushing API calls. The creation of a SOLIDserver object is done like that:
26
28
  ```
27
29
  from SOLIDserverRest import *
@@ -35,12 +37,35 @@ sds = sdsadv.SDS(ip_address=SDS_HOST,
35
37
  user=SDS_LOGIN,
36
38
  pwd=SDS_PWD)
37
39
  try:
38
- sds.connect(method="native")
40
+ sds.connect()
41
+ except SDSError as e:
42
+ logging.error(e)
43
+ exit(1)
44
+
45
+ print(sds)
46
+
47
+ ```
48
+
49
+ ## With token authentication (SDS release >= 8.4.0)
50
+
51
+ ```
52
+ from SOLIDserverRest import *
53
+ from SOLIDserverRest import adv as sdsadv
54
+
55
+ SDS_HOST = "192.168.254.254"
56
+ SDS_TOKEN_ID = "8628f88cbd40df99903d6f385caa0462"
57
+ SDS_TOKEN_SEC = "ca8ec3c0f07b380c4723349230901d40a84ba4b4987c12863b66b0b5297ad922"
58
+
59
+ sds = sdsadv.SDS(ip_address=SDS_HOST)
60
+ sds.set_token_creds(keyid=SDS_TOKEN_ID,
61
+ keysecret=SDS_TOKEN_SEC)
62
+ try:
63
+ sds.connect(method="token")
39
64
  except SDSError as e:
40
65
  logging.error(e)
41
66
  exit(1)
42
67
 
43
- print(adv)
68
+ print(sds)
44
69
 
45
70
  ```
46
71
 
@@ -21,6 +21,8 @@ import base64
21
21
  import re
22
22
  import logging
23
23
  import urllib
24
+ import time
25
+ import hashlib
24
26
  import requests
25
27
 
26
28
 
@@ -55,6 +57,7 @@ class SOLIDserverRest:
55
57
  CNX_NATIVE = 1
56
58
  CNX_APIKEY = 2
57
59
  CNX_BASIC = 3
60
+ CNX_TOKEN = 4
58
61
 
59
62
  # -------------------------------------
60
63
  def __init__(self, host, debug=False):
@@ -81,6 +84,10 @@ class SOLIDserverRest:
81
84
  self.ssl_verify = True
82
85
  self.proxies = None
83
86
 
87
+ # token authentication
88
+ self.cred_token_keyid = None
89
+ self.cred_token_keysecret = None
90
+
84
91
  # set specific features for python v2 (<=2020, not supported after)
85
92
  if sys.version_info[0] == 2: # pragma: no cover
86
93
  # pylint: disable=E1101
@@ -145,6 +152,30 @@ class SOLIDserverRest:
145
152
  'content-type': 'application/json'
146
153
  }
147
154
 
155
+ # -------------------------------------
156
+ def use_token_sds(self, keyid=None, keysecret=None):
157
+ """ propose to use the basic auth implementation on the SDS
158
+ """
159
+ logging.debug("useTokenAuthSDS")
160
+
161
+ # check if SDS connection is established
162
+ if self.host is None:
163
+ raise SDSInitError()
164
+
165
+ if keyid is None or keysecret is None:
166
+ msg = "missing token information in credentials"
167
+ raise SDSInitError(message=msg)
168
+
169
+ self.cred_token_keyid = keyid
170
+ self.cred_token_keysecret = keysecret
171
+
172
+ self.cnx_type = self.CNX_TOKEN
173
+ # self.session.auth = requests.auth.HTTPBasicAuth(user, password)
174
+
175
+ self.headers = {
176
+ 'content-type': 'application/json'
177
+ }
178
+
148
179
  # -------------------------------------
149
180
  def set_certificate_file(self, file_path):
150
181
  """set the certificate that will be used to authenticate the server"""
@@ -157,7 +188,6 @@ class SOLIDserverRest:
157
188
  logging.warning("cannot load CA file")
158
189
  raise SDSInitError(f"cannot load CA file {file_path}") from ioe
159
190
  except crypto.Error as error:
160
- logging.warning(error)
161
191
  raise SDSInitError(f"invalid CA file {file_path}") from error
162
192
 
163
193
  self.session.verify = file_path
@@ -232,9 +262,11 @@ class SOLIDserverRest:
232
262
  self.last_url = f"{svc_mapped}{params}".strip()
233
263
 
234
264
  if re.match('.*_find_free$', service) is not None:
235
- url = f"{self.prefix_url}/rpc/{self.last_url}"
265
+ url_path = f"/rpc/{self.last_url}"
266
+ url = f"{self.prefix_url}{url_path}"
236
267
  else:
237
- url = f"{self.prefix_url}/{self.default_method}/{self.last_url}"
268
+ url_path = f"/{self.default_method}/{self.last_url}"
269
+ url = f"{self.prefix_url}{url_path}"
238
270
 
239
271
  try:
240
272
  logging.debug("m=%s u=%s h=%s v=%s a=%s",
@@ -244,6 +276,29 @@ class SOLIDserverRest:
244
276
  self.ssl_verify,
245
277
  self.auth)
246
278
 
279
+ if self.cnx_type == self.CNX_TOKEN:
280
+ _string_to_sign = self.cred_token_keysecret
281
+ _sign_time = int(time.time())
282
+ _string_to_sign += f"\n{_sign_time}"
283
+ _string_to_sign += f"\n{method}"
284
+ _string_to_sign += f"\n{url}"
285
+
286
+ _signature = hashlib.sha3_256(
287
+ _string_to_sign.encode()).hexdigest()
288
+
289
+ _headers = self.headers.copy()
290
+ _headers['Authorization'] = (f"SDS {self.cred_token_keyid}:"
291
+ f"{_signature}")
292
+ _headers['X-SDS-TS'] = str(_sign_time)
293
+
294
+ return self.session.request(
295
+ method,
296
+ url,
297
+ headers=_headers,
298
+ proxies=self.proxies,
299
+ verify=self.ssl_verify,
300
+ timeout=timeout)
301
+
247
302
  return self.session.request(
248
303
  method,
249
304
  url,
@@ -252,6 +307,7 @@ class SOLIDserverRest:
252
307
  verify=self.ssl_verify,
253
308
  timeout=timeout,
254
309
  auth=self.auth)
310
+
255
311
  except requests.exceptions.SSLError as error:
256
312
  raise SDSRequestError(method,
257
313
  url,
@@ -299,11 +355,19 @@ class SOLIDserverRest:
299
355
  self.session = None
300
356
  self.ssl_verify = True
301
357
  self.proxies = None
358
+ self.cred_token_keyid = None
359
+ self.cred_token_keysecret = None
302
360
 
303
361
  # -------------------------------------
304
362
  def __str__(self): # pragma: no cover
305
- _s = "SOLIDserverRest: API={}, user={}"
306
- return _s.format(self.prefix_url, self.user)
363
+ _s = f"SOLIDserverRest: API={self.prefix_url}"
364
+
365
+ if self.user:
366
+ _s += f", user={self.user}"
367
+ elif self.cred_token_keyid:
368
+ _s += f" token={self.cred_token_keyid[:8]}"
369
+
370
+ return _s
307
371
 
308
372
  # deprecated method to be suppressed
309
373
 
@@ -312,7 +312,8 @@ class Network(ClassParams):
312
312
  if self.parent_network is not None:
313
313
  params['parent_subnet_id'] = self.parent_network.myid
314
314
  else: # pragma: no cover
315
- assert None, "TODO - not a block and no parent set, abort"
315
+ # assert None, "TODO - not a block and no parent set, abort"
316
+ pass
316
317
 
317
318
  if self.is_terminal:
318
319
  params['is_terminal'] = '1'
@@ -379,6 +380,62 @@ class Network(ClassParams):
379
380
 
380
381
  self.clean_params()
381
382
 
383
+ # -------------------------------------
384
+ def get_id_by_ipaddr(self):
385
+ """get the ID from its ip addr, return None if non existant"""
386
+
387
+ params = {
388
+ "limit": 1,
389
+ **self.additional_params
390
+ }
391
+ params.update(
392
+ {
393
+ "WHERE": ("start_hostaddr='{}'".format(self.subnet_addr)
394
+ + f" and subnet_size={1 << (32 - self.subnet_prefix)}")
395
+ }
396
+ )
397
+
398
+ if hasattr(self, 'space'):
399
+ if self.space:
400
+ params['WHERE'] += f" and site_id={self.space.myid}"
401
+
402
+ print(params)
403
+
404
+ try:
405
+ rjson = self.sds.query('ip_subnet_list',
406
+ params=params)
407
+ print(rjson)
408
+ except SDSError as err_descr:
409
+ msg = f"cannot found object by ip addr {self.subnet_addr}"
410
+ msg += " / "+str(err_descr)
411
+ raise SDSIpAddressNotFoundError(msg) from err_descr
412
+
413
+ if rjson[0]['errno'] != '0': # pragma: no cover
414
+ raise SDSError("errno raised on get id by addr")
415
+
416
+ return rjson[0]['subnet_id']
417
+
418
+ # -------------------------------------
419
+ def _get_id(self, query, key):
420
+ """get the ID for the current object based
421
+ on its current name
422
+ """
423
+
424
+ if self.myid >= 0:
425
+ return self.myid
426
+
427
+ if self.params[f'{key}_id'] is None:
428
+ if self.name:
429
+ _id = self._get_id_by_name(query=query,
430
+ key=key,
431
+ name=self.name)
432
+ else:
433
+ _id = self.get_id_by_ipaddr()
434
+
435
+ self.myid = int(_id)
436
+
437
+ return self.myid
438
+
382
439
  # -------------------------------------
383
440
  def refresh(self):
384
441
  """refresh content of the network from the SDS"""
@@ -54,6 +54,10 @@ class SDS(ClassParams):
54
54
  self.auth_method = None
55
55
  self.check_certificate = False
56
56
 
57
+ # token authentication
58
+ self.cred_token_keyid = None
59
+ self.cred_token_keysecret = None
60
+
57
61
  self.sds = None
58
62
  self.timeout = 1
59
63
 
@@ -66,7 +70,7 @@ class SDS(ClassParams):
66
70
  ipaddress.IPv4Address(ip_address)
67
71
  except ipaddress.AddressValueError as error:
68
72
  raise SDSInitError(message=f"IPv4 address of"
69
- " server error: {error}") from error
73
+ f" server error: {error}") from error
70
74
 
71
75
  self.sds_ip = ip_address
72
76
 
@@ -96,6 +100,14 @@ class SDS(ClassParams):
96
100
  self.user = user
97
101
  self.pwd = pwd
98
102
 
103
+ def set_token_creds(self, keyid=None, keysecret=None):
104
+ """add token credentials to this session"""
105
+ if keyid is None or keysecret is None:
106
+ msg = "missing token information in credentials"
107
+ raise SDSInitError(message=msg)
108
+ self.cred_token_keyid = keyid
109
+ self.cred_token_keysecret = keysecret
110
+
99
111
  # ---------------------------
100
112
  def set_check_cert(self, check=True):
101
113
  """whether we have to check the certificate, even if not provided"""
@@ -106,24 +118,37 @@ class SDS(ClassParams):
106
118
  """connects to SOLIDserver and check everything is OK by
107
119
  querying the version of the admin node in the member list
108
120
 
109
- method -- basicauth (default) or native (header based)
121
+ method -- basicauth (default) or native (header based) or token
110
122
  cert_file_path -- disable SSL check if None (default)
111
123
  file with cert if check enabled
112
124
  """
113
- if self.user is None or self.pwd is None:
114
- msg = "missing user or password in credentials for connect"
115
- raise SDSInitError(message=msg)
125
+
116
126
  if self.sds_ip is None:
117
127
  raise SDSInitError(message="missing ip for server for connect")
118
128
 
119
129
  self.sds = SOLIDserverRest(self.sds_ip)
120
130
 
121
131
  if method == "basicauth":
132
+ if self.user is None or self.pwd is None:
133
+ msg = "missing user or password in credentials for connect"
134
+ raise SDSInitError(message=msg)
122
135
  self.sds.use_basicauth_sds(self.user, self.pwd)
123
136
  self.auth_method = "basic auth"
124
137
  elif method == "native":
138
+ if self.user is None or self.pwd is None:
139
+ msg = "missing user or password in credentials for connect"
140
+ raise SDSInitError(message=msg)
125
141
  self.sds.use_native_sds(self.user, self.pwd)
126
142
  self.auth_method = "native"
143
+ elif method == "token":
144
+ if (self.cred_token_keyid is None
145
+ or self.cred_token_keysecret is None):
146
+ msg = "missing token in credentials for connect"
147
+ raise SDSInitError(message=msg)
148
+
149
+ self.sds.use_token_sds(keyid=self.cred_token_keyid,
150
+ keysecret=self.cred_token_keysecret)
151
+ self.auth_method = "token"
127
152
 
128
153
  # certificate & SSL check
129
154
  if cert_file_path is not None:
@@ -155,6 +180,8 @@ class SDS(ClassParams):
155
180
  self.auth_method = None
156
181
  self.check_certificate = False
157
182
  self.timeout = 1
183
+ self.cred_token_keyid = None
184
+ self.cred_token_keysecret = None
158
185
 
159
186
  # ---------------------------
160
187
  def get_version(self):
@@ -242,7 +269,7 @@ class SDS(ClassParams):
242
269
  j = json.loads(f'[{answer_req.content.decode()}]')
243
270
  if isinstance(j, list):
244
271
  return j[0]
245
- except Error:
272
+ except ValueError:
246
273
  pass
247
274
 
248
275
  logging.error("no json in return")
@@ -277,6 +277,28 @@ SERVICE_MAPPER.update({
277
277
  'dhcp_static6_info': 'dhcp6_static6_info',
278
278
  'dhcp_static6_count': 'dhcp6_static6_count',
279
279
  'dhcp_static6_delete': 'dhcp6_static6_delete',
280
+
281
+ 'dhcp_prefix6_create': 'dhcp6_prefix6_add',
282
+ 'dhcp_prefix6_update': 'dhcp6_prefix6_add',
283
+ 'dhcp_prefix6_list': 'dhcp6_prefix6_list',
284
+ 'dhcp_prefix6_info': 'dhcp6_prefix6_info',
285
+ 'dhcp_prefix6_count': 'dhcp6_prefix6_count',
286
+ 'dhcp_prefix6_delete': 'dhcp6_prefix6_delete',
287
+
288
+ 'dhcp_delegated_prefix6_create': 'dhcp6_delegated_prefix6_add',
289
+ 'dhcp_delegated_prefix6_update': 'dhcp6_delegated_prefix6_add',
290
+ 'dhcp_delegated_prefix6_list': 'dhcp6_delegatedprefix6_list',
291
+ 'dhcp_delegated_prefix6_info': 'dhcp6_delegatedprefix6_info',
292
+ 'dhcp_delegated_prefix6_count': 'dhcp6_delegatedprefix6_count',
293
+ 'dhcp_delegated_prefix6_delete': 'dhcp6_delegated_prefix6_delete',
294
+
295
+ 'dhcp_shared_network6_create': 'dhcp6_sn6_add',
296
+ 'dhcp_shared_network6_update': 'dhcp6_sn6_add',
297
+ 'dhcp_shared_network6_list': 'dhcp6_shared_network6v2_list',
298
+ 'dhcp_shared_network6_info': 'dhcp6_shared_network6v2_info',
299
+ 'dhcp_shared_network6_count': 'dhcp6_shared_network6v2_count',
300
+ 'dhcp_shared_network6_delete': 'dhcp6_sn6_delete',
301
+
280
302
  })
281
303
 
282
304
  SERVICE_MAPPER.update({
@@ -1,26 +1,36 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: SOLIDserverRest
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: The SOLIDserverRest is a library to drive EfficientIP API
5
5
  Home-page: https://gitlab.com/efficientip/solidserverrest
6
6
  Author: Gregory CUGAT / Alex Chauvin
7
7
  Author-email: gregory.cugat@efficientip.com, ach@efficientip.com
8
8
  License: BSD 2
9
9
  Classifier: Intended Audience :: Developers
10
- Classifier: Programming Language :: Python :: 3.7
11
10
  Classifier: Programming Language :: Python :: 3.8
12
11
  Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
14
  Requires-Python: >=3.7
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Requires-Dist: requests~=2.0
18
- Requires-Dist: PySocks~=1.0
19
- Requires-Dist: urllib3~=1.0
18
+ Requires-Dist: urllib3~=2.0
20
19
  Requires-Dist: idna~=3.0
21
- Requires-Dist: chardet~=5.0
22
- Requires-Dist: pyopenssl~=24.0
23
- Requires-Dist: packaging~=23.0
20
+ Requires-Dist: PySocks~=1.0
21
+ Requires-Dist: chardet~=5.2
22
+ Requires-Dist: pyopenssl~=25.0
23
+ Requires-Dist: packaging~=24.0
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
24
34
 
25
35
  [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
26
36
 
@@ -46,6 +56,8 @@ Install 'SOLIDserverRest' using pip in your virtualenv:
46
56
 
47
57
  ## Using the SOLIDserverRest advanced object (recommended)
48
58
 
59
+ ### With basic authentication
60
+
49
61
  All commands and object manipulation are going through a SOLIDserver main object, handling the connection to the manager and pushing API calls. The creation of a SOLIDserver object is done like that:
50
62
  ```
51
63
  from SOLIDserverRest import *
@@ -59,12 +71,35 @@ sds = sdsadv.SDS(ip_address=SDS_HOST,
59
71
  user=SDS_LOGIN,
60
72
  pwd=SDS_PWD)
61
73
  try:
62
- sds.connect(method="native")
74
+ sds.connect()
75
+ except SDSError as e:
76
+ logging.error(e)
77
+ exit(1)
78
+
79
+ print(sds)
80
+
81
+ ```
82
+
83
+ ## With token authentication (SDS release >= 8.4.0)
84
+
85
+ ```
86
+ from SOLIDserverRest import *
87
+ from SOLIDserverRest import adv as sdsadv
88
+
89
+ SDS_HOST = "192.168.254.254"
90
+ SDS_TOKEN_ID = "8628f88cbd40df99903d6f385caa0462"
91
+ SDS_TOKEN_SEC = "ca8ec3c0f07b380c4723349230901d40a84ba4b4987c12863b66b0b5297ad922"
92
+
93
+ sds = sdsadv.SDS(ip_address=SDS_HOST)
94
+ sds.set_token_creds(keyid=SDS_TOKEN_ID,
95
+ keysecret=SDS_TOKEN_SEC)
96
+ try:
97
+ sds.connect(method="token")
63
98
  except SDSError as e:
64
99
  logging.error(e)
65
100
  exit(1)
66
101
 
67
- print(adv)
102
+ print(sds)
68
103
 
69
104
  ```
70
105
 
@@ -26,6 +26,5 @@ SOLIDserverRest/adv/network.py
26
26
  SOLIDserverRest/adv/sds.py
27
27
  SOLIDserverRest/adv/space.py
28
28
  SOLIDserverRest/adv/validators.py
29
- tests/test_dhcp_option_legacy.py
30
29
  tests/test_simple.py
31
30
  tests/tests.py
@@ -0,0 +1,7 @@
1
+ requests~=2.0
2
+ urllib3~=2.0
3
+ idna~=3.0
4
+ PySocks~=1.0
5
+ chardet~=5.2
6
+ pyopenssl~=25.0
7
+ packaging~=24.0
@@ -10,7 +10,7 @@ with open(os.path.join(here, 'README.md')) as f:
10
10
 
11
11
  setup(
12
12
  name='SOLIDserverRest',
13
- version='2.4.0',
13
+ version='2.5.0',
14
14
  author='Gregory CUGAT / Alex Chauvin',
15
15
  url='https://gitlab.com/efficientip/solidserverrest',
16
16
  description='The SOLIDserverRest is a library to drive EfficientIP API',
@@ -19,18 +19,19 @@ setup(
19
19
  author_email='gregory.cugat@efficientip.com, ach@efficientip.com',
20
20
  classifiers=[
21
21
  'Intended Audience :: Developers',
22
- 'Programming Language :: Python :: 3.7',
23
22
  'Programming Language :: Python :: 3.8',
24
23
  'Programming Language :: Python :: 3.9',
25
24
  'Programming Language :: Python :: 3.10',
25
+ 'Programming Language :: Python :: 3.11',
26
26
  ],
27
27
  install_requires=['requests~=2.0',
28
- 'PySocks~=1.0',
29
- 'urllib3~=1.0',
28
+ 'urllib3~=2.0',
30
29
  'idna~=3.0',
31
- 'chardet~=5.0',
32
- 'pyopenssl~=24.0',
33
- 'packaging~=23.0'],
30
+ 'PySocks~=1.0',
31
+ 'chardet~=5.2',
32
+ 'pyopenssl~=25.0',
33
+ 'packaging~=24.0'
34
+ ],
34
35
  license='BSD 2',
35
36
  packages=['SOLIDserverRest', 'SOLIDserverRest.adv'],
36
37
  zip_safe=False,
@@ -1,7 +0,0 @@
1
- requests~=2.0
2
- PySocks~=1.0
3
- urllib3~=1.0
4
- idna~=3.0
5
- chardet~=5.0
6
- pyopenssl~=24.0
7
- packaging~=23.0
@@ -1,231 +0,0 @@
1
- #
2
- #
3
- # Time-stamp: <2022-05-09 13:26:07 alex>
4
- #
5
-
6
- """test file for DHCP options using simple lib
7
-
8
- * test_device_new_object
9
-
10
- """
11
-
12
- import logging
13
- import sys
14
- import uuid
15
- import datetime
16
-
17
- from SOLIDserverRest.Exception import SDSInitError, SDSRequestError
18
- from SOLIDserverRest.Exception import SDSAuthError, SDSError
19
- from SOLIDserverRest.Exception import SDSEmptyError, SDSSpaceError
20
-
21
- from .context import sdsadv
22
- from .context import _connect_to_sds
23
- from .adv_basic import *
24
-
25
- DHCP_ID = 3
26
- DHCP_SCOPE_ID = 8
27
- DHCP_RANGE_ID = 13
28
- DHCP_STATIC_ID = 35
29
-
30
- # -------------------------------------------------------
31
-
32
-
33
- def test_list_dhcp_server():
34
- """
35
- """
36
-
37
- sds = _connect_to_sds()
38
-
39
- r = sds.query("dhcp_server_list",
40
- params={
41
- # 'hostdev_name': device_name
42
- })
43
-
44
- for _server in r:
45
- logging.info(
46
- f"id={_server['dhcp_id']}"
47
- f" {_server['dhcp_name']}"
48
- f" {_server['hostaddr']}"
49
- f" {_server['dhcp_type']}"
50
- f" {_server['vdhcp_arch']}"
51
- )
52
-
53
- # -------------------------------------------------------
54
-
55
-
56
- def test_list_dhcp_scope():
57
- """
58
- """
59
-
60
- sds = _connect_to_sds()
61
-
62
- r = sds.query("dhcp_scope_list",
63
- params={
64
- 'WHERE': f'dhcp_id={DHCP_ID}'
65
- })
66
-
67
- for _server in r:
68
- logging.info(
69
- f"id={_server['dhcpscope_id']}"
70
- f" {_server['dhcpscope_name']}"
71
- f" {_server['dhcpsn_name']}"
72
- )
73
-
74
-
75
- def test_list_dhcp_range():
76
- """
77
- """
78
-
79
- sds = _connect_to_sds()
80
-
81
- r = sds.query("dhcp_range_list",
82
- params={
83
- 'WHERE': f'dhcpscope_id={DHCP_SCOPE_ID}'
84
- })
85
-
86
- for _range in r:
87
- logging.info(
88
- f"id={_range['dhcprange_id']}"
89
- f" {_range['dhcprange_name']}"
90
- f" {_range['dhcprange_start_addr']}"
91
- f"-{_range['dhcprange_end_addr']}"
92
- )
93
-
94
-
95
- def test_list_dhcp_static():
96
- """
97
- """
98
-
99
- sds = _connect_to_sds()
100
-
101
- r = sds.query("dhcp_static_list",
102
- params={
103
- 'WHERE': f'dhcpscope_id={DHCP_SCOPE_ID}'
104
- })
105
-
106
- for _static in r:
107
- logging.info(
108
- f"id={_static['dhcphost_id']}"
109
- f" {_static['dhcphost_name']}"
110
- f" {_static['dhcphost_addr']}"
111
- f"-{_static['dhcphost_mac_addr']}"
112
- )
113
-
114
- # -------------------------------------------------------
115
-
116
-
117
- def test_list_options_server():
118
- """
119
- """
120
-
121
- sds = _connect_to_sds()
122
-
123
- r = sds.query("dhcp_options_server_list",
124
- params={
125
- 'dhcp_id': DHCP_ID
126
- })
127
-
128
- for _server in r:
129
- logging.info(
130
- f"id={_server['dhcpoption_id']}"
131
- f" {_server['dhcpoption_name']} = "
132
- f" {_server['dhcpoption_value']}"
133
- )
134
-
135
-
136
- def test_list_options_scope():
137
- """
138
- """
139
-
140
- sds = _connect_to_sds()
141
-
142
- r = sds.query("dhcp_options_scope_list",
143
- params={
144
- 'dhcpscope_id': DHCP_SCOPE_ID
145
- })
146
-
147
- for _scope in r:
148
- logging.info(
149
- f"id={_scope['dhcpscopeoption_id']}"
150
- f" {_scope['dhcpoption_name']} = "
151
- f" {_scope['dhcpoption_value']}"
152
- )
153
-
154
-
155
- def test_list_options_range():
156
- """
157
- """
158
-
159
- sds = _connect_to_sds()
160
-
161
- r = sds.query("dhcp_options_range_list",
162
- params={
163
- 'dhcprange_id': DHCP_RANGE_ID
164
- })
165
-
166
- for _option in r:
167
- logging.info(
168
- f"id={_option['dhcprangeoption_id']}"
169
- f" {_option['dhcpoption_name']} = "
170
- f" {_option['dhcpoption_value']}"
171
- )
172
-
173
-
174
- def test_list_options_static():
175
- """
176
- """
177
-
178
- sds = _connect_to_sds()
179
-
180
- r = sds.query("dhcp_options_static_list",
181
- params={
182
- 'dhcpstatic_id': DHCP_STATIC_ID
183
- })
184
-
185
- for _option in r:
186
- logging.info(
187
- f"id={_option['dhcphostoption_id']}"
188
- f" {_option['dhcpoption_name']} = "
189
- f" {_option['dhcpoption_value']}"
190
- )
191
-
192
- # -------------------------------------------------------
193
-
194
-
195
- def test_create_options_static():
196
- """
197
- """
198
-
199
- sds = _connect_to_sds()
200
-
201
- # add
202
- r = sds.query("dhcp_option_create",
203
- params={
204
- 'dhcphost_id': DHCP_STATIC_ID,
205
- 'dhcpoption_type': 'host',
206
- 'dhcpoption_name': 'option routers',
207
- 'dhcpoption_value': '10.1.2.3',
208
- 'add_flag': 'add_only'
209
- })
210
-
211
- # update
212
- r = sds.query("dhcp_option_update",
213
- params={
214
- 'dhcphost_id': DHCP_STATIC_ID,
215
- 'dhcpoption_type': 'host',
216
- 'dhcpoption_name': 'option routers',
217
- 'dhcpoption_value': '10.1.2.5',
218
- 'add_flag': 'edit_only'
219
- })
220
-
221
- # delete
222
- r = sds.query("dhcp_option_update",
223
- params={
224
- 'dhcphost_id': DHCP_STATIC_ID,
225
- 'dhcpoption_type': 'host',
226
- 'dhcpoption_name': 'option routers',
227
- 'dhcpoption_value': '',
228
- 'add_flag': 'edit_only'
229
- })
230
-
231
- logging.info(r)
File without changes