SOLIDserverRest 2.3.10__tar.gz → 2.3.11__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 (33) hide show
  1. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/PKG-INFO +156 -153
  2. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/README.md +0 -1
  3. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/SOLIDserverRest.py +0 -0
  4. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/dns_record.py +5 -7
  5. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/validators.py +3 -3
  6. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest.egg-info/PKG-INFO +156 -153
  7. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest.egg-info/SOURCES.txt +3 -1
  8. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest.egg-info/entry_points.txt +0 -1
  9. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest.egg-info/not-zip-safe +1 -1
  10. SOLIDserverRest-2.3.11/SOLIDserverRest.egg-info/requires.txt +7 -0
  11. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/setup.cfg +4 -4
  12. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/setup.py +6 -6
  13. SOLIDserverRest-2.3.11/tests/test_simple.py +104 -0
  14. SOLIDserverRest-2.3.11/tests/tests.py +287 -0
  15. SOLIDserverRest-2.3.10/SOLIDserverRest.egg-info/requires.txt +0 -7
  16. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/LICENSE +0 -0
  17. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/Exception.py +0 -0
  18. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/__init__.py +0 -0
  19. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/__init__.py +0 -0
  20. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/base.py +0 -0
  21. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/class_params.py +0 -0
  22. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/device.py +0 -0
  23. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/device_tools.py +0 -0
  24. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/devif.py +0 -0
  25. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/dns.py +0 -0
  26. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/dns_zone.py +0 -0
  27. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/ipaddress.py +0 -0
  28. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/network.py +0 -0
  29. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/sds.py +0 -0
  30. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/adv/space.py +0 -0
  31. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest/mapper.py +0 -0
  32. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest.egg-info/dependency_links.txt +0 -0
  33. {SOLIDserverRest-2.3.10 → SOLIDserverRest-2.3.11}/SOLIDserverRest.egg-info/top_level.txt +0 -0
@@ -1,153 +1,156 @@
1
- Metadata-Version: 2.1
2
- Name: SOLIDserverRest
3
- Version: 2.3.10
4
- Summary: The SOLIDserverRest is a library to drive EfficientIP API
5
- Home-page: https://gitlab.com/efficientip/solidserverrest
6
- Author: Gregory CUGAT / Alex Chauvin
7
- Author-email: gregory.cugat@efficientip.com, ach@efficientip.com
8
- License: BSD 2
9
- Platform: UNKNOWN
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Requires-Python: >=3.7
16
- Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
-
19
- [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
20
-
21
- [![pipeline status](https://gitlab.com/efficientip/solidserverrest/badges/master/pipeline.svg)](https://gitlab.com/efficientip/solidserverrest/commits/master)
22
- [![coverage report](https://gitlab.com/efficientip/solidserverrest/badges/master/coverage.svg)](https://codecov.io/gl/efficientip/solidserverrest)
23
-
24
- # SOLIDserverRest
25
-
26
- This 'SOLIDserverRest' allows to easily interact with [SOLIDserver](https://www.efficientip.com/products/solidserver/)'s REST API.
27
- It allows managing all IPAM objects through CRUD operations.
28
-
29
- * ***Free software***: BSD2 License
30
-
31
- This 'SOLIDserverRest' is compatible with [SOLIDserver](https://www.efficientip.com/products/solidserver/) version 7 and ownward.
32
-
33
- # Install
34
- Install 'SOLIDserverRest' using pip in your virtualenv:
35
-
36
- ```
37
- pip install SOLIDserverRest
38
- ```
39
-
40
- # Usage
41
-
42
- ## Using the SOLIDserverRest advanced object (recommended)
43
-
44
- 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:
45
- ```
46
- from SOLIDserverRest import *
47
- from SOLIDserverRest import adv as sdsadv
48
-
49
- SDS_HOST = "192.168.254.254"
50
- SDS_LOGIN = "foo"
51
- SDS_PWD = "bar"
52
-
53
- sds = sdsadv.SDS(ip_address=SDS_HOST,
54
- user=SDS_LOGIN,
55
- pwd=SDS_PWD)
56
- try:
57
- sds.connect(method="native")
58
- except SDSError as e:
59
- logging.error(e)
60
- exit(1)
61
-
62
- print(adv)
63
-
64
- ```
65
-
66
- More examples in the example directory.
67
-
68
- ## Using the SOLIDserverRest object
69
-
70
- The raw API is mapped using the SOLIDserverRest object which handle the connection, prepare the formating and handle some errors. It can be usefull twhen the advanced library is not yet implementing an object that you require in your code.
71
-
72
- ### 1. Declare endpoint API point
73
- Set the API endpoint you want to talk with through API. Could use an IP address
74
- (v4 or v6) or a host name
75
- * host = IP address of the SOLIDserver server
76
- ```
77
- con = SOLIDserverRest("fqdn_host.org")
78
- ```
79
-
80
- ### 2. Specify connection method
81
- You can use native connection mode using SOLIDserver default method which provide
82
- authentication through headers in the requests with information
83
- encoded in base64
84
-
85
- * user = user who want to use
86
- * password = password of the user
87
-
88
- ```python
89
- con.use_native_sds(user="apiuser", password="apipwd")
90
- ```
91
-
92
- You can also use the basic authentication method for connecting the SOLIDserver.
93
-
94
- * user = user who want to use
95
- * password = password of the user
96
-
97
- ```python
98
- con.use_basicauth_sds(user="apiuser", password="apipwd")
99
- ```
100
-
101
- ### 3. Set TLS security
102
- SSL certificate chain is validated by default, to disable it, use the set_ssl_verify method
103
-
104
- ```python
105
- con.set_ssl_verify(False) # True by default
106
- rest_answer = con.query("method", "parameters")
107
- ```
108
-
109
- Otherwise, you have to provide the certificate file:
110
- ```python
111
- con = SOLIDserverRest(SERVER)
112
- ```
113
- If the certificate file is not valide, an exception ```SDSInitError``` is raised.
114
-
115
- ### 4. Request to SOLIDserver API
116
-
117
- You need parameters:
118
- * method = choose your method in the list below
119
- * parameters = Python dictionary with parameters you want to use
120
-
121
- ```python
122
- rest_answer = con.query("method", "parameters")
123
- ```
124
-
125
- ### 5. Analyze answer
126
-
127
- * rest_answer => object name
128
- * rest_answer.status_code => current http answer code set in the object
129
- * rest_answer.content => Answer core from SOLIDserver API set in the object
130
-
131
- Example:
132
- ```python
133
- print(rest_answer)
134
- print(rest_answer.status_code)
135
- print(rest_answer.content)
136
- ```
137
-
138
- # Methods that could be used
139
- Methods are organized to match the ontology used in SOLIDServer, you will find:
140
- * Sites - address spaces
141
- * Subnets (v4 and v6)
142
- * Pools (v4 and v6)
143
- * Addresses (v4 and v6)
144
- * Aliases (v4 and v6)
145
- * DNS servers, views, zones, RR, acl, key
146
- * application manager
147
- * DHCP server, scope, shared net, range, static, group
148
- * device manager
149
- * VLAN manager
150
-
151
- More information about supported methods in the [specific document](docs/METHODS.md)
152
-
153
-
1
+ Metadata-Version: 2.1
2
+ Name: SOLIDserverRest
3
+ Version: 2.3.11
4
+ Summary: The SOLIDserverRest is a library to drive EfficientIP API
5
+ Home-page: https://gitlab.com/efficientip/solidserverrest
6
+ Author: Gregory CUGAT / Alex Chauvin
7
+ Author-email: gregory.cugat@efficientip.com, ach@efficientip.com
8
+ License: BSD 2
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3.7
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: requests~=2.31
18
+ Requires-Dist: PySocks~=1.7
19
+ Requires-Dist: urllib3~=1.26
20
+ Requires-Dist: idna~=3.6
21
+ Requires-Dist: chardet~=5.2
22
+ Requires-Dist: pyopenssl~=24.0
23
+ Requires-Dist: packaging~=23.2
24
+
25
+ [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
26
+
27
+ [![pipeline status](https://gitlab.com/efficientip/solidserverrest/badges/master/pipeline.svg)](https://gitlab.com/efficientip/solidserverrest/commits/master)
28
+
29
+ # SOLIDserverRest
30
+
31
+ This 'SOLIDserverRest' allows to easily interact with [SOLIDserver](https://www.efficientip.com/products/solidserver/)'s REST API.
32
+ It allows managing all IPAM objects through CRUD operations.
33
+
34
+ * ***Free software***: BSD2 License
35
+
36
+ This 'SOLIDserverRest' is compatible with [SOLIDserver](https://www.efficientip.com/products/solidserver/) version 7 and ownward.
37
+
38
+ # Install
39
+ Install 'SOLIDserverRest' using pip in your virtualenv:
40
+
41
+ ```
42
+ pip install SOLIDserverRest
43
+ ```
44
+
45
+ # Usage
46
+
47
+ ## Using the SOLIDserverRest advanced object (recommended)
48
+
49
+ 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
+ ```
51
+ from SOLIDserverRest import *
52
+ from SOLIDserverRest import adv as sdsadv
53
+
54
+ SDS_HOST = "192.168.254.254"
55
+ SDS_LOGIN = "foo"
56
+ SDS_PWD = "bar"
57
+
58
+ sds = sdsadv.SDS(ip_address=SDS_HOST,
59
+ user=SDS_LOGIN,
60
+ pwd=SDS_PWD)
61
+ try:
62
+ sds.connect(method="native")
63
+ except SDSError as e:
64
+ logging.error(e)
65
+ exit(1)
66
+
67
+ print(adv)
68
+
69
+ ```
70
+
71
+ More examples in the example directory.
72
+
73
+ ## Using the SOLIDserverRest object
74
+
75
+ The raw API is mapped using the SOLIDserverRest object which handle the connection, prepare the formating and handle some errors. It can be usefull twhen the advanced library is not yet implementing an object that you require in your code.
76
+
77
+ ### 1. Declare endpoint API point
78
+ Set the API endpoint you want to talk with through API. Could use an IP address
79
+ (v4 or v6) or a host name
80
+ * host = IP address of the SOLIDserver server
81
+ ```
82
+ con = SOLIDserverRest("fqdn_host.org")
83
+ ```
84
+
85
+ ### 2. Specify connection method
86
+ You can use native connection mode using SOLIDserver default method which provide
87
+ authentication through headers in the requests with information
88
+ encoded in base64
89
+
90
+ * user = user who want to use
91
+ * password = password of the user
92
+
93
+ ```python
94
+ con.use_native_sds(user="apiuser", password="apipwd")
95
+ ```
96
+
97
+ You can also use the basic authentication method for connecting the SOLIDserver.
98
+
99
+ * user = user who want to use
100
+ * password = password of the user
101
+
102
+ ```python
103
+ con.use_basicauth_sds(user="apiuser", password="apipwd")
104
+ ```
105
+
106
+ ### 3. Set TLS security
107
+ SSL certificate chain is validated by default, to disable it, use the set_ssl_verify method
108
+
109
+ ```python
110
+ con.set_ssl_verify(False) # True by default
111
+ rest_answer = con.query("method", "parameters")
112
+ ```
113
+
114
+ Otherwise, you have to provide the certificate file:
115
+ ```python
116
+ con = SOLIDserverRest(SERVER)
117
+ ```
118
+ If the certificate file is not valide, an exception ```SDSInitError``` is raised.
119
+
120
+ ### 4. Request to SOLIDserver API
121
+
122
+ You need parameters:
123
+ * method = choose your method in the list below
124
+ * parameters = Python dictionary with parameters you want to use
125
+
126
+ ```python
127
+ rest_answer = con.query("method", "parameters")
128
+ ```
129
+
130
+ ### 5. Analyze answer
131
+
132
+ * rest_answer => object name
133
+ * rest_answer.status_code => current http answer code set in the object
134
+ * rest_answer.content => Answer core from SOLIDserver API set in the object
135
+
136
+ Example:
137
+ ```python
138
+ print(rest_answer)
139
+ print(rest_answer.status_code)
140
+ print(rest_answer.content)
141
+ ```
142
+
143
+ # Methods that could be used
144
+ Methods are organized to match the ontology used in SOLIDServer, you will find:
145
+ * Sites - address spaces
146
+ * Subnets (v4 and v6)
147
+ * Pools (v4 and v6)
148
+ * Addresses (v4 and v6)
149
+ * Aliases (v4 and v6)
150
+ * DNS servers, views, zones, RR, acl, key
151
+ * application manager
152
+ * DHCP server, scope, shared net, range, static, group
153
+ * device manager
154
+ * VLAN manager
155
+
156
+ More information about supported methods in the [specific document](docs/METHODS.md)
@@ -1,7 +1,6 @@
1
1
  [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
2
2
 
3
3
  [![pipeline status](https://gitlab.com/efficientip/solidserverrest/badges/master/pipeline.svg)](https://gitlab.com/efficientip/solidserverrest/commits/master)
4
- [![coverage report](https://gitlab.com/efficientip/solidserverrest/badges/master/coverage.svg)](https://codecov.io/gl/efficientip/solidserverrest)
5
4
 
6
5
  # SOLIDserverRest
7
6
 
@@ -463,7 +463,11 @@ class ExtendedDNSRecord(DNS_record):
463
463
 
464
464
  if name is not None:
465
465
  if _zone.name not in name:
466
- name = "{}.{}".format(name, _zone.name)
466
+ if name == "":
467
+ name = _zone.name
468
+ else:
469
+ name = f"{name}.{_zone.name}"
470
+
467
471
  super().__init__(sds, name)
468
472
  self.set_zone(_zone)
469
473
  self.mapping_dict = mapping_dict
@@ -503,12 +507,6 @@ class ExtendedDNSRecord(DNS_record):
503
507
  self.set_additional_where_params(**add_param)
504
508
  with_params_statement = with_params_statement[:-2] + " "
505
509
 
506
- for _key, _value in self.additional_where_params.items():
507
- if isinstance(_value, str):
508
- params['WHERE'] += f" and {_key}='{_value}'"
509
- elif isinstance(_value, int):
510
- params['WHERE'] += f" and {_key}={_value}"
511
-
512
510
  try:
513
511
  duplicate_check = self.sds.query("dns_rr_list",
514
512
  params=params)
@@ -16,7 +16,7 @@ class INTValidator:
16
16
  try:
17
17
  other_int = int(other)
18
18
  except Exception:
19
- raise SDSError("{} must be of type int".format(name))
19
+ raise SDSError(f"{name} must be of type int")
20
20
 
21
21
  _range = range(self.min_val, self.max_val)
22
22
 
@@ -38,7 +38,7 @@ class STRValidator:
38
38
  def validate(self, other, name):
39
39
  is_string = isinstance(other, str)
40
40
  if not is_string:
41
- raise SDSError("{} must be of type string".format(other))
41
+ raise SDSError(f"{name} must be of type string")
42
42
 
43
43
  _len = len(other)
44
44
 
@@ -46,5 +46,5 @@ class STRValidator:
46
46
  raise SDSError(
47
47
  f"{name} must be a string with a max"
48
48
  f" length of {self.max_len}, provided string"
49
- f" is of length {str_len}"
49
+ f" is of length {_len}"
50
50
  )
@@ -1,153 +1,156 @@
1
- Metadata-Version: 2.1
2
- Name: SOLIDserverRest
3
- Version: 2.3.10
4
- Summary: The SOLIDserverRest is a library to drive EfficientIP API
5
- Home-page: https://gitlab.com/efficientip/solidserverrest
6
- Author: Gregory CUGAT / Alex Chauvin
7
- Author-email: gregory.cugat@efficientip.com, ach@efficientip.com
8
- License: BSD 2
9
- Platform: UNKNOWN
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Requires-Python: >=3.7
16
- Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
-
19
- [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
20
-
21
- [![pipeline status](https://gitlab.com/efficientip/solidserverrest/badges/master/pipeline.svg)](https://gitlab.com/efficientip/solidserverrest/commits/master)
22
- [![coverage report](https://gitlab.com/efficientip/solidserverrest/badges/master/coverage.svg)](https://codecov.io/gl/efficientip/solidserverrest)
23
-
24
- # SOLIDserverRest
25
-
26
- This 'SOLIDserverRest' allows to easily interact with [SOLIDserver](https://www.efficientip.com/products/solidserver/)'s REST API.
27
- It allows managing all IPAM objects through CRUD operations.
28
-
29
- * ***Free software***: BSD2 License
30
-
31
- This 'SOLIDserverRest' is compatible with [SOLIDserver](https://www.efficientip.com/products/solidserver/) version 7 and ownward.
32
-
33
- # Install
34
- Install 'SOLIDserverRest' using pip in your virtualenv:
35
-
36
- ```
37
- pip install SOLIDserverRest
38
- ```
39
-
40
- # Usage
41
-
42
- ## Using the SOLIDserverRest advanced object (recommended)
43
-
44
- 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:
45
- ```
46
- from SOLIDserverRest import *
47
- from SOLIDserverRest import adv as sdsadv
48
-
49
- SDS_HOST = "192.168.254.254"
50
- SDS_LOGIN = "foo"
51
- SDS_PWD = "bar"
52
-
53
- sds = sdsadv.SDS(ip_address=SDS_HOST,
54
- user=SDS_LOGIN,
55
- pwd=SDS_PWD)
56
- try:
57
- sds.connect(method="native")
58
- except SDSError as e:
59
- logging.error(e)
60
- exit(1)
61
-
62
- print(adv)
63
-
64
- ```
65
-
66
- More examples in the example directory.
67
-
68
- ## Using the SOLIDserverRest object
69
-
70
- The raw API is mapped using the SOLIDserverRest object which handle the connection, prepare the formating and handle some errors. It can be usefull twhen the advanced library is not yet implementing an object that you require in your code.
71
-
72
- ### 1. Declare endpoint API point
73
- Set the API endpoint you want to talk with through API. Could use an IP address
74
- (v4 or v6) or a host name
75
- * host = IP address of the SOLIDserver server
76
- ```
77
- con = SOLIDserverRest("fqdn_host.org")
78
- ```
79
-
80
- ### 2. Specify connection method
81
- You can use native connection mode using SOLIDserver default method which provide
82
- authentication through headers in the requests with information
83
- encoded in base64
84
-
85
- * user = user who want to use
86
- * password = password of the user
87
-
88
- ```python
89
- con.use_native_sds(user="apiuser", password="apipwd")
90
- ```
91
-
92
- You can also use the basic authentication method for connecting the SOLIDserver.
93
-
94
- * user = user who want to use
95
- * password = password of the user
96
-
97
- ```python
98
- con.use_basicauth_sds(user="apiuser", password="apipwd")
99
- ```
100
-
101
- ### 3. Set TLS security
102
- SSL certificate chain is validated by default, to disable it, use the set_ssl_verify method
103
-
104
- ```python
105
- con.set_ssl_verify(False) # True by default
106
- rest_answer = con.query("method", "parameters")
107
- ```
108
-
109
- Otherwise, you have to provide the certificate file:
110
- ```python
111
- con = SOLIDserverRest(SERVER)
112
- ```
113
- If the certificate file is not valide, an exception ```SDSInitError``` is raised.
114
-
115
- ### 4. Request to SOLIDserver API
116
-
117
- You need parameters:
118
- * method = choose your method in the list below
119
- * parameters = Python dictionary with parameters you want to use
120
-
121
- ```python
122
- rest_answer = con.query("method", "parameters")
123
- ```
124
-
125
- ### 5. Analyze answer
126
-
127
- * rest_answer => object name
128
- * rest_answer.status_code => current http answer code set in the object
129
- * rest_answer.content => Answer core from SOLIDserver API set in the object
130
-
131
- Example:
132
- ```python
133
- print(rest_answer)
134
- print(rest_answer.status_code)
135
- print(rest_answer.content)
136
- ```
137
-
138
- # Methods that could be used
139
- Methods are organized to match the ontology used in SOLIDServer, you will find:
140
- * Sites - address spaces
141
- * Subnets (v4 and v6)
142
- * Pools (v4 and v6)
143
- * Addresses (v4 and v6)
144
- * Aliases (v4 and v6)
145
- * DNS servers, views, zones, RR, acl, key
146
- * application manager
147
- * DHCP server, scope, shared net, range, static, group
148
- * device manager
149
- * VLAN manager
150
-
151
- More information about supported methods in the [specific document](docs/METHODS.md)
152
-
153
-
1
+ Metadata-Version: 2.1
2
+ Name: SOLIDserverRest
3
+ Version: 2.3.11
4
+ Summary: The SOLIDserverRest is a library to drive EfficientIP API
5
+ Home-page: https://gitlab.com/efficientip/solidserverrest
6
+ Author: Gregory CUGAT / Alex Chauvin
7
+ Author-email: gregory.cugat@efficientip.com, ach@efficientip.com
8
+ License: BSD 2
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3.7
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: requests~=2.31
18
+ Requires-Dist: PySocks~=1.7
19
+ Requires-Dist: urllib3~=1.26
20
+ Requires-Dist: idna~=3.6
21
+ Requires-Dist: chardet~=5.2
22
+ Requires-Dist: pyopenssl~=24.0
23
+ Requires-Dist: packaging~=23.2
24
+
25
+ [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
26
+
27
+ [![pipeline status](https://gitlab.com/efficientip/solidserverrest/badges/master/pipeline.svg)](https://gitlab.com/efficientip/solidserverrest/commits/master)
28
+
29
+ # SOLIDserverRest
30
+
31
+ This 'SOLIDserverRest' allows to easily interact with [SOLIDserver](https://www.efficientip.com/products/solidserver/)'s REST API.
32
+ It allows managing all IPAM objects through CRUD operations.
33
+
34
+ * ***Free software***: BSD2 License
35
+
36
+ This 'SOLIDserverRest' is compatible with [SOLIDserver](https://www.efficientip.com/products/solidserver/) version 7 and ownward.
37
+
38
+ # Install
39
+ Install 'SOLIDserverRest' using pip in your virtualenv:
40
+
41
+ ```
42
+ pip install SOLIDserverRest
43
+ ```
44
+
45
+ # Usage
46
+
47
+ ## Using the SOLIDserverRest advanced object (recommended)
48
+
49
+ 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
+ ```
51
+ from SOLIDserverRest import *
52
+ from SOLIDserverRest import adv as sdsadv
53
+
54
+ SDS_HOST = "192.168.254.254"
55
+ SDS_LOGIN = "foo"
56
+ SDS_PWD = "bar"
57
+
58
+ sds = sdsadv.SDS(ip_address=SDS_HOST,
59
+ user=SDS_LOGIN,
60
+ pwd=SDS_PWD)
61
+ try:
62
+ sds.connect(method="native")
63
+ except SDSError as e:
64
+ logging.error(e)
65
+ exit(1)
66
+
67
+ print(adv)
68
+
69
+ ```
70
+
71
+ More examples in the example directory.
72
+
73
+ ## Using the SOLIDserverRest object
74
+
75
+ The raw API is mapped using the SOLIDserverRest object which handle the connection, prepare the formating and handle some errors. It can be usefull twhen the advanced library is not yet implementing an object that you require in your code.
76
+
77
+ ### 1. Declare endpoint API point
78
+ Set the API endpoint you want to talk with through API. Could use an IP address
79
+ (v4 or v6) or a host name
80
+ * host = IP address of the SOLIDserver server
81
+ ```
82
+ con = SOLIDserverRest("fqdn_host.org")
83
+ ```
84
+
85
+ ### 2. Specify connection method
86
+ You can use native connection mode using SOLIDserver default method which provide
87
+ authentication through headers in the requests with information
88
+ encoded in base64
89
+
90
+ * user = user who want to use
91
+ * password = password of the user
92
+
93
+ ```python
94
+ con.use_native_sds(user="apiuser", password="apipwd")
95
+ ```
96
+
97
+ You can also use the basic authentication method for connecting the SOLIDserver.
98
+
99
+ * user = user who want to use
100
+ * password = password of the user
101
+
102
+ ```python
103
+ con.use_basicauth_sds(user="apiuser", password="apipwd")
104
+ ```
105
+
106
+ ### 3. Set TLS security
107
+ SSL certificate chain is validated by default, to disable it, use the set_ssl_verify method
108
+
109
+ ```python
110
+ con.set_ssl_verify(False) # True by default
111
+ rest_answer = con.query("method", "parameters")
112
+ ```
113
+
114
+ Otherwise, you have to provide the certificate file:
115
+ ```python
116
+ con = SOLIDserverRest(SERVER)
117
+ ```
118
+ If the certificate file is not valide, an exception ```SDSInitError``` is raised.
119
+
120
+ ### 4. Request to SOLIDserver API
121
+
122
+ You need parameters:
123
+ * method = choose your method in the list below
124
+ * parameters = Python dictionary with parameters you want to use
125
+
126
+ ```python
127
+ rest_answer = con.query("method", "parameters")
128
+ ```
129
+
130
+ ### 5. Analyze answer
131
+
132
+ * rest_answer => object name
133
+ * rest_answer.status_code => current http answer code set in the object
134
+ * rest_answer.content => Answer core from SOLIDserver API set in the object
135
+
136
+ Example:
137
+ ```python
138
+ print(rest_answer)
139
+ print(rest_answer.status_code)
140
+ print(rest_answer.content)
141
+ ```
142
+
143
+ # Methods that could be used
144
+ Methods are organized to match the ontology used in SOLIDServer, you will find:
145
+ * Sites - address spaces
146
+ * Subnets (v4 and v6)
147
+ * Pools (v4 and v6)
148
+ * Addresses (v4 and v6)
149
+ * Aliases (v4 and v6)
150
+ * DNS servers, views, zones, RR, acl, key
151
+ * application manager
152
+ * DHCP server, scope, shared net, range, static, group
153
+ * device manager
154
+ * VLAN manager
155
+
156
+ More information about supported methods in the [specific document](docs/METHODS.md)
@@ -25,4 +25,6 @@ SOLIDserverRest/adv/ipaddress.py
25
25
  SOLIDserverRest/adv/network.py
26
26
  SOLIDserverRest/adv/sds.py
27
27
  SOLIDserverRest/adv/space.py
28
- SOLIDserverRest/adv/validators.py
28
+ SOLIDserverRest/adv/validators.py
29
+ tests/test_simple.py
30
+ tests/tests.py
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  check-python-versions = check_python_versions:main
3
-
@@ -0,0 +1,7 @@
1
+ requests~=2.31
2
+ PySocks~=1.7
3
+ urllib3~=1.26
4
+ idna~=3.6
5
+ chardet~=5.2
6
+ pyopenssl~=24.0
7
+ packaging~=23.2
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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.3.10',
13
+ version='2.3.11',
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',
@@ -24,13 +24,13 @@ setup(
24
24
  'Programming Language :: Python :: 3.9',
25
25
  'Programming Language :: Python :: 3.10',
26
26
  ],
27
- install_requires=['requests~=2.28',
27
+ install_requires=['requests~=2.31',
28
28
  'PySocks~=1.7',
29
29
  'urllib3~=1.26',
30
- 'idna~=3.4',
31
- 'chardet~=5.1',
32
- 'pyopenssl~=23.0',
33
- 'packaging~=23.0'],
30
+ 'idna~=3.6',
31
+ 'chardet~=5.2',
32
+ 'pyopenssl~=24.0',
33
+ 'packaging~=23.2'],
34
34
  license='BSD 2',
35
35
  packages=['SOLIDserverRest', 'SOLIDserverRest.adv'],
36
36
  zip_safe=False,
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/python
2
+ # -*-coding: utf-8 -*
3
+ ##########################################################
4
+
5
+ import sys
6
+ import os
7
+ import logging
8
+
9
+ sys.path.append(os.getcwd())
10
+
11
+ from SOLIDserverRest import *
12
+ from SOLIDserverRest.Exception import *
13
+
14
+ if sys.version_info[0] == 2:
15
+ try:
16
+ from data import *
17
+
18
+ except:
19
+ from data_sample import *
20
+
21
+ else:
22
+ try:
23
+ from .data import *
24
+
25
+ except:
26
+ from .data_sample import *
27
+
28
+ #SSD_HOST = "192.168.56.254"
29
+ #SSD_APIUSER = "api"
30
+ #SSD_APIPWD = "apiadmin"
31
+
32
+
33
+ def test_setup_init():
34
+ """ simple connection creation """
35
+ testR = SOLIDserverRest(SERVER)
36
+ testR.clean()
37
+
38
+
39
+ def test_setup_woinit():
40
+ """ set connection mode on unexisting connection """
41
+ con = SOLIDserverRest(SERVER)
42
+ con.clean()
43
+ try:
44
+ con.use_native_sds(user=USER, password=PWD)
45
+ except SDSInitError:
46
+ return
47
+
48
+ con.clean()
49
+ assert False, "set mode on non existant connection should fail"
50
+
51
+
52
+ def test_setup_simple():
53
+ """ simple setup of SDS native connection """
54
+ con = SOLIDserverRest(SERVER)
55
+ con.use_native_sds(user=USER, password=PWD)
56
+
57
+ s = con.get_status()
58
+ if 'python_version' not in s:
59
+ assert False, "python version not detected"
60
+
61
+ s = con.get_headers()
62
+ if 'X-IPM-Password' not in s:
63
+ assert False, "encoded credentials not detected"
64
+
65
+ con.clean()
66
+
67
+
68
+ def test_native_simple_call():
69
+ """ simple call with SDS native connection """
70
+ con = SOLIDserverRest(SERVER)
71
+ con.use_native_sds(user=USER, password=PWD)
72
+ con.set_ssl_verify(False)
73
+
74
+ try:
75
+ answer = con.query('ip_site_count',
76
+ timeout=1)
77
+
78
+ if answer.status_code != 200:
79
+ logging.error(answer.status_code)
80
+ assert False, "native call failed"
81
+
82
+ except SDSError:
83
+ None
84
+
85
+ # ---------------------------------------------
86
+
87
+
88
+ def do_all(b=True):
89
+ """ run all tests from the python """
90
+ if b:
91
+ test_native_simple_call()
92
+ else:
93
+ test_setup_init()
94
+ test_setup_woinit()
95
+ test_setup_simple()
96
+
97
+
98
+ if __name__ == '__main__':
99
+ import logging
100
+
101
+ _logFormat = '%(asctime)-15s [%(levelname)s] %(filename)s:%(lineno)d - %(message)s'
102
+ logging.basicConfig(format=_logFormat, level=logging.DEBUG)
103
+
104
+ do_all(True)
@@ -0,0 +1,287 @@
1
+ #!/usr/bin/python
2
+ # -*-coding:Utf-8 -*
3
+ ##########################################################
4
+ import sys
5
+ import os
6
+ import json
7
+ import re
8
+ import logging
9
+
10
+
11
+ _logFormat = '%(asctime)-15s [%(levelname)s] %(filename)s:%(lineno)d - %(message)s'
12
+ logging.basicConfig(format=_logFormat, level=logging.ERROR)
13
+
14
+ sys.path.append(os.getcwd())
15
+
16
+ from SOLIDserverRest import *
17
+ from SOLIDserverRest.Exception import *
18
+
19
+ import requests
20
+ from requests.packages.urllib3.exceptions import InsecureRequestWarning
21
+ requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
22
+
23
+ if sys.version_info[0] == 2:
24
+ try:
25
+ from data import *
26
+ except:
27
+ from data_sample import *
28
+ else:
29
+ try:
30
+ from tests.data_sample import *
31
+ except:
32
+ from .data_sample import *
33
+
34
+ logging.info('START => test.py')
35
+
36
+ def test_no_server():
37
+ logging.info('TEST: Test no server')
38
+ try:
39
+ testR = SOLIDserverRest(None)
40
+ testR.use_native_sds('soliduser', 'solidpass')
41
+ logging.info('Test = NO-OK')
42
+ assert None, "test without server, should have failed"
43
+ except SDSError as e:
44
+ logging.info('Test = OK {}'.format(str(e)))
45
+ None
46
+
47
+ def test_auto_dico_native_srv():
48
+ fct_auto_dico()
49
+
50
+ def test_auto_dico_native_no_srv():
51
+ fct_auto_dico(srv=None)
52
+
53
+ def test_auto_dico_basic_srv():
54
+ fct_auto_dico(SOLIDserverRest.CNX_BASIC)
55
+
56
+ def test_auto_dico_basic_nosrv():
57
+ fct_auto_dico(SOLIDserverRest.CNX_BASIC, None)
58
+
59
+ def fct_auto_dico(auth=SOLIDserverRest.CNX_NATIVE, srv=SERVER, options=False):
60
+ logging.info('================================')
61
+ logging.info('TESTS AUTO')
62
+ logging.info('================================')
63
+ testR = SOLIDserverRest(srv)
64
+ sds_str = str(testR)
65
+ testR.set_ssl_verify(False)
66
+
67
+ try:
68
+ if auth==SOLIDserverRest.CNX_NATIVE:
69
+ testR.use_native_sds(USER, PWD)
70
+ elif auth==SOLIDserverRest.CNX_BASIC:
71
+ testR.use_basicauth_sds(USER, PWD)
72
+ except SDSInitError as error:
73
+ logging.info(error)
74
+ if srv is not None:
75
+ assert None, "server connect error {}".format(srv)
76
+ return
77
+
78
+ logging.info('IP of th server: {}'.format(SERVER))
79
+ logging.info('User: {}'.format(USER))
80
+ logging.info('Password: {}'.format(PWD))
81
+
82
+ total_services = 0
83
+ check_services = 0
84
+ total_methods = len(set(METHOD_MAPPER.values()))
85
+ total_services = len(SERVICE_MAPPER)
86
+
87
+ method_tested = []
88
+
89
+ for cle in SERVICE_MAPPER:
90
+ serviceR = cle
91
+ parameters = PARAMETERS
92
+
93
+ method = None
94
+ for verb in METHOD_MAPPER:
95
+ _q = ".*_{}$".format(verb)
96
+ if re.match(_q, cle) is not None:
97
+ method = METHOD_MAPPER[verb]
98
+ break
99
+
100
+ logging.info('--------------------------------')
101
+ logging.info('Sub Test: {}'.format(serviceR))
102
+ logging.info('Parameters: {}'.format(parameters))
103
+ logging.info('method: {}'.format(method))
104
+
105
+ try:
106
+ answerR = testR.query(serviceR, parameters, option=options, timeout=0.2)
107
+ logging.info('Answer: {}'.format(answerR))
108
+ logging.info('Answer: {}'.format(answerR.status_code))
109
+ logging.info('Answer:')
110
+ logging.debug(answerR.content)
111
+ except SDSError as e:
112
+ logging.info("error on SDS query - {}".format(str()))
113
+ None
114
+
115
+ if method not in method_tested:
116
+ method_tested.append(method)
117
+
118
+ logging.info('--------------------------------')
119
+ check_services += 1
120
+
121
+ if len(method_tested) == total_methods:
122
+ break
123
+
124
+ logging.info('RESULTAT')
125
+ logging.info('{} services checked / {} total services'.format(check_services, total_services))
126
+
127
+ logging.info('END of TEST AUTO')
128
+
129
+
130
+ def test_ukn_svc(auth=SOLIDserverRest.CNX_NATIVE, srv=SERVER):
131
+ logging.info('================================')
132
+ logging.info('TEST UKN service')
133
+ logging.info('================================')
134
+ testR = SOLIDserverRest(srv)
135
+
136
+ if auth==SOLIDserverRest.CNX_NATIVE:
137
+ testR.use_native_sds(USER, PWD)
138
+ elif auth==SOLIDserverRest.CNX_BASIC:
139
+ testR.use_basicauth_sds(USER, PWD)
140
+
141
+ try:
142
+ answerR = testR.query('ukn_service_list', PARAMETERS, timeout=1)
143
+ logging.info('Answer: {}'.format(answerR))
144
+ logging.info('Answer: {}'.format(answerR.status_code))
145
+ logging.info('Answer:')
146
+ logging.info(answerR.content)
147
+ except SDSServiceError as e:
148
+ logging.info("unknown service - {}".format(str(e)))
149
+ return
150
+
151
+ assert None, "ukn service should have raised an error"
152
+
153
+ def test_no_params(auth=SOLIDserverRest.CNX_NATIVE, srv=SERVER):
154
+ logging.info('================================')
155
+ logging.info('TEST no params')
156
+ logging.info('================================')
157
+ testR = SOLIDserverRest(srv)
158
+
159
+ if auth==SOLIDserverRest.CNX_NATIVE:
160
+ testR.use_native_sds(USER, PWD)
161
+ elif auth==SOLIDserverRest.CNX_BASIC:
162
+ testR.use_basicauth_sds(USER, PWD)
163
+
164
+ try:
165
+ answerR = testR.query('ukn_service_list')
166
+ logging.info('Answer: {}'.format(answerR))
167
+ logging.info('Answer: {}'.format(answerR.status_code))
168
+ logging.info('Answer:')
169
+ logging.info(answerR.content)
170
+ except SDSServiceError:
171
+ logging.info("error on SDS query in test_no_params")
172
+ None
173
+
174
+ def test_method_none():
175
+ logging.info('================================')
176
+ logging.info('TEST method none')
177
+ logging.info('================================')
178
+ testR = SOLIDserverRest(SERVER)
179
+
180
+ testR.use_basicauth_sds(USER, PWD)
181
+
182
+ try:
183
+ answerR = testR.query('ukn_service_none', timeout=1)
184
+ logging.info('Answer: {}'.format(answerR))
185
+ logging.info('Answer: {}'.format(answerR.status_code))
186
+ logging.info('Answer:')
187
+ logging.info(answerR.content)
188
+ except SDSServiceError:
189
+ logging.info("error on SDS query in test_no_params")
190
+ None
191
+
192
+ def test_get_headers():
193
+ logging.info('================================')
194
+ logging.info('TEST get headers')
195
+ logging.info('================================')
196
+ testR = SOLIDserverRest(SERVER)
197
+ testR.use_basicauth_sds(USER, PWD)
198
+
199
+ testR.get_headers()
200
+
201
+ def test_get_status():
202
+ logging.info('================================')
203
+ logging.info('TEST get status')
204
+ logging.info('================================')
205
+ testR = SOLIDserverRest(SERVER)
206
+ testR.use_basicauth_sds(USER, PWD)
207
+
208
+ testR.get_status()
209
+
210
+ def test_get_string():
211
+ logging.info('================================')
212
+ logging.info('TEST get string')
213
+ logging.info('================================')
214
+ testR = SOLIDserverRest(SERVER)
215
+ testR.use_basicauth_sds(USER, PWD)
216
+ # print(testR)
217
+
218
+ def test_options():
219
+ fct_auto_dico(SOLIDserverRest.CNX_BASIC, SERVER, options=True)
220
+
221
+
222
+ def test_get_memberme():
223
+ logging.info('================================')
224
+ logging.info('TEST get memberme')
225
+ logging.info('================================')
226
+ testR = SOLIDserverRest(SERVER)
227
+ testR.use_basicauth_sds(USER, PWD)
228
+ parameters = {
229
+ 'WHERE': 'member_is_me=1',
230
+ }
231
+
232
+ j = None
233
+ try:
234
+ answerR = testR.query("member_list", params=parameters, option=False, timeout=1)
235
+ logging.info('Answer: {}'.format(answerR))
236
+ logging.info('Answer: {}'.format(answerR.status_code))
237
+ #logging.info('Answer:')
238
+ #logging.info(answerR.content)
239
+ j = json.loads(answerR.content)
240
+ except SDSError as e:
241
+ logging.info("error on SDS query - {}".format(str(e)))
242
+ return
243
+
244
+ if j is None:
245
+ assert None, "no json result from member_list request"
246
+ return
247
+
248
+ if j[0]['member_is_me'] != '1':
249
+ assert None, "member list should have a me item"
250
+ return
251
+
252
+ def test_use_validcert():
253
+ testR = SOLIDserverRest(SERVER)
254
+ testR.set_certificate_file("ca.crt")
255
+
256
+ def test_use_invalidcert():
257
+ testR = SOLIDserverRest(SERVER)
258
+ try:
259
+ testR.set_certificate_file("ca-invalid.crt")
260
+ except SDSInitError:
261
+ return
262
+
263
+ assert None, "no certificate file provided, should have failed"
264
+
265
+ def test_use_missingcert():
266
+ testR = SOLIDserverRest(SERVER)
267
+ try:
268
+ testR.set_certificate_file("ca-missing.crt")
269
+ except SDSInitError:
270
+ return
271
+
272
+ assert None, "no certificate file provided, should have failed"
273
+
274
+ def test_ssl_verify_bad_param():
275
+ testR = SOLIDserverRest(SERVER)
276
+ try:
277
+ testR.set_ssl_verify("test")
278
+ except SDSError:
279
+ return
280
+
281
+ assert None, "bool check to ssl_verify"
282
+
283
+ if __name__ == '__main__':
284
+ # test_get_string()
285
+ test_auto_dico_native_srv()
286
+
287
+ logging.info('END => test.py')
@@ -1,7 +0,0 @@
1
- requests~=2.28
2
- PySocks~=1.7
3
- urllib3~=1.26
4
- idna~=3.4
5
- chardet~=5.1
6
- pyopenssl~=23.0
7
- packaging~=23.0