|
48 | 48 | from hpecp.cli.k8sworker import K8sWorkerProxy
|
49 | 49 | from hpecp.cli.k8scluster import K8sClusterProxy
|
50 | 50 | from hpecp.cli.tenant import TenantProxy
|
| 51 | +from hpecp.cli.license import LicenseProxy |
| 52 | + |
51 | 53 | from hpecp import ContainerPlatformClient
|
52 | 54 |
|
53 | 55 |
|
|
57 | 59 | _log = Logger.get_logger()
|
58 | 60 |
|
59 | 61 |
|
60 |
| -# @wrapt.decorator |
61 |
| -# def intercept_exception(wrapped, instance, args, kwargs): |
62 |
| -# """Handle Exceptions.""" # noqa: D202 |
63 |
| - |
64 |
| -# def _unknown_exception_handler(ex): |
65 |
| -# """Handle unknown exceptions.""" |
66 |
| -# if _log.level == 10: # "DEBUG" |
67 |
| -# print( |
68 |
| -# "Unknown error.", file=sys.stderr, |
69 |
| -# ) |
70 |
| -# else: |
71 |
| -# print( |
72 |
| -# "Unknown error. To debug run with env var LOG_LEVEL=DEBUG", |
73 |
| -# file=sys.stderr, |
74 |
| -# ) |
75 |
| -# tb = traceback.format_exc() |
76 |
| -# _log.debug(tb) |
77 |
| -# _log.debug(ex) |
78 |
| -# sys.exit(1) |
79 |
| - |
80 |
| -# try: |
81 |
| -# return wrapped(*args, **kwargs) |
82 |
| -# except SystemExit as se: |
83 |
| -# sys.exit(se.code) |
84 |
| -# except AssertionError as ae: |
85 |
| -# print(ae, file=sys.stderr) |
86 |
| -# sys.exit(1) |
87 |
| -# except APIUnknownException as ue: |
88 |
| -# _unknown_exception_handler(ue) |
89 |
| -# except ( |
90 |
| -# APIException, |
91 |
| -# APIItemNotFoundException, |
92 |
| -# APIItemConflictException, |
93 |
| -# APIForbiddenException, |
94 |
| -# ContainerPlatformClientException, |
95 |
| -# ) as e: |
96 |
| -# print(e.message, file=sys.stderr) |
97 |
| -# sys.exit(1) |
98 |
| -# except Exception as ex: |
99 |
| -# _unknown_exception_handler(ex) |
100 |
| - |
101 |
| - |
102 | 62 | class LockProxy(object):
|
103 | 63 | """Proxy object to :py:attr:`<hpecp.client.lock>`."""
|
104 | 64 |
|
@@ -160,122 +120,6 @@ def delete_all(
|
160 | 120 | sys.exit(1)
|
161 | 121 |
|
162 | 122 |
|
163 |
| -class LicenseProxy(object): |
164 |
| - """Proxy object to :py:attr:`<hpecp.client.license>`.""" |
165 |
| - |
166 |
| - def __dir__(self): |
167 |
| - """Return the CLI method names.""" |
168 |
| - return ["delete", "delete_all", "list", "platform_id", "register"] |
169 |
| - |
170 |
| - @base.intercept_exception |
171 |
| - def platform_id(self,): |
172 |
| - """Get the platform ID.""" |
173 |
| - print(base.get_client().license.platform_id()) |
174 |
| - |
175 |
| - def list( |
176 |
| - self, output="yaml", license_key_only=False, |
177 |
| - ): |
178 |
| - """Retrieve the list of licenses. |
179 |
| -
|
180 |
| - :param output: how to display the output ['yaml'|'json'] |
181 |
| - """ |
182 |
| - response = base.get_client().license.list() |
183 |
| - if license_key_only: |
184 |
| - response = [ |
185 |
| - str(unicode(li["LicenseKey"])) for li in response["Licenses"] |
186 |
| - ] |
187 |
| - print("\n".join(response)) |
188 |
| - else: |
189 |
| - if output == "yaml": |
190 |
| - print( |
191 |
| - yaml.dump( |
192 |
| - yaml.load( |
193 |
| - json.dumps(response), Loader=yaml.FullLoader, |
194 |
| - ) |
195 |
| - ) |
196 |
| - ) |
197 |
| - else: |
198 |
| - print(json.dumps(response)) |
199 |
| - |
200 |
| - @base.intercept_exception |
201 |
| - def register( |
202 |
| - self, server_filename, |
203 |
| - ): |
204 |
| - """Register a license. |
205 |
| -
|
206 |
| - :param server_filename: Filepath to the license on the server, e.g. |
207 |
| - '/srv/bluedata/license/LICENSE-1.txt' |
208 |
| - """ |
209 |
| - print( |
210 |
| - base.get_client().license.register(server_filename=server_filename) |
211 |
| - ) |
212 |
| - |
213 |
| - # TODO implement me! |
214 |
| - # def upload_with_ssh_key( |
215 |
| - # self, |
216 |
| - # server_filename, |
217 |
| - # ssh_key_file=None, |
218 |
| - # ssh_key_data=None, |
219 |
| - # license_file=None, |
220 |
| - # base64enc_license_data=None, |
221 |
| - # ): |
222 |
| - # """Not implemented yet. |
223 |
| - |
224 |
| - # Workaround: |
225 |
| - # ----------- |
226 |
| - # - scp your license to '/srv/bluedata/license/' on the controller |
227 |
| - # - run client.license.register(server_filename) to register |
228 |
| - # the license |
229 |
| - # """ |
230 |
| - # raise Exception( |
231 |
| - # "Not implemented yet! Workaround: scp your license to" |
232 |
| - # "'/srv/bluedata/license/'" |
233 |
| - # ) |
234 |
| - |
235 |
| - # TODO implement me! |
236 |
| - # def upload_with_ssh_pass( |
237 |
| - # self, |
238 |
| - # server_filename, |
239 |
| - # ssh_username, |
240 |
| - # ssh_password, |
241 |
| - # license_file=None, |
242 |
| - # base64enc_license_data=None, |
243 |
| - # ): |
244 |
| - # """Not implemented yet. |
245 |
| - |
246 |
| - # Workaround: |
247 |
| - # ----------- |
248 |
| - # - scp your license to '/srv/bluedata/license/' on the controller |
249 |
| - # - run client.license.register(server_filename) to register |
250 |
| - # the license |
251 |
| - # """ |
252 |
| - # raise Exception( |
253 |
| - # "Not implemented yet! Workaround: scp your license to" |
254 |
| - # "'/srv/bluedata/license/'" |
255 |
| - # ) |
256 |
| - |
257 |
| - @base.intercept_exception |
258 |
| - def delete( |
259 |
| - self, license_key, |
260 |
| - ): |
261 |
| - """Delete a license by LicenseKey. |
262 |
| -
|
263 |
| - :param license_key: The license key, e.g. '1234 1234 ... 1234 |
264 |
| - "SOMETEXT"' |
265 |
| - """ |
266 |
| - base.get_client().license.delete(license_key=license_key) |
267 |
| - |
268 |
| - @base.intercept_exception |
269 |
| - def delete_all(self,): |
270 |
| - """Delete all licenses.""" |
271 |
| - response = base.get_client().license.list() |
272 |
| - all_license_keys = [ |
273 |
| - str(unicode(li["LicenseKey"])) for li in response["Licenses"] |
274 |
| - ] |
275 |
| - for licence_key in all_license_keys: |
276 |
| - base.get_client().license.delete(license_key=licence_key) |
277 |
| - |
278 |
| - |
279 | 123 | class HttpClientProxy(object):
|
280 | 124 | """Proxy object to :py:attr:`<hpecp.client._request>`."""
|
281 | 125 |
|
|
0 commit comments