2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-15 04:07:48 +00:00

Relay errors on invalid licenses

License errors are now raised to the caller.

Change-Id: I0fc107525b4d009dfd6c7ad52ab356a9dcaac5c0
This commit is contained in:
Jarrod Johnson 2019-07-22 11:12:19 -04:00
parent 64b6c078d6
commit b6fb57dfa5
2 changed files with 23 additions and 3 deletions

View File

@ -1836,14 +1836,24 @@ class XCCClient(IMMClient):
break
def apply_license(self, filename, progress=None):
license_errors = {
310: "License is for a different model of system",
311: "License is for a different system serial number",
312: "License is invalid",
313: "License is expired",
314: "License usage limit reached",
}
uploadthread = webclient.FileUploader(self.wc, '/upload', filename)
uploadthread.start()
uploadthread.join()
rsp = json.loads(uploadthread.rsp)
licpath = rsp.get('items', [{}])[0].get('path', None)
if licpath:
self.wc.grab_json_response('/api/providers/imm_fod',
rsp = self.wc.grab_json_response('/api/providers/imm_fod',
{'FOD_LicenseKeyInstall': licpath})
if rsp.get('return', 0) in license_errors:
raise pygexc.InvalidParameterValue(
license_errors[rsp['return']])
return self.get_licenses()
def get_user_expiration(self, uid):

View File

@ -740,14 +740,24 @@ class OEMHandler(generic.OEMHandler):
yield savefile
def apply_license(self, filename, progress=None):
license_errors = {
310: "License is for a different model of system",
311: "License is for a different system serial number",
312: "License is invalid",
313: "License is expired",
314: "License usage limit reached",
}
uploadthread = webclient.FileUploader(self.wc, '/upload', filename)
uploadthread.start()
uploadthread.join()
rsp = json.loads(uploadthread.rsp)
licpath = rsp.get('items', [{}])[0].get('path', None)
if licpath:
self.wc.grab_json_response('/api/providers/imm_fod',
{'FOD_LicenseKeyInstall': licpath})
rsp = self.wc.grab_json_response('/api/providers/imm_fod',
{'FOD_LicenseKeyInstall': licpath})
if rsp.get('return', 0) in license_errors:
raise pygexc.InvalidParameterValue(
license_errors[rsp['return']])
return self.get_licenses()
def get_user_expiration(self, uid):