mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-20 13:23:10 +00:00
Fixes hostid retrieval.
This commit is contained in:
parent
5637b7be86
commit
f7d3af4a59
@ -339,6 +339,7 @@ class IOUVM(BaseVM):
|
||||
raise IOUError("The following shared library dependencies cannot be found for IOU image {}: {}".format(self._path,
|
||||
", ".join(missing_libs)))
|
||||
|
||||
@asyncio.coroutine
|
||||
def _check_iou_licence(self):
|
||||
"""
|
||||
Checks for a valid IOU key in the iourc file (paranoid mode).
|
||||
@ -358,16 +359,17 @@ class IOUVM(BaseVM):
|
||||
if hostname not in config["license"]:
|
||||
raise IOUError("Hostname key not found in iourc file {}".format(self.iourc_path))
|
||||
user_ioukey = config["license"][hostname]
|
||||
print(user_ioukey[-1:])
|
||||
if user_ioukey[-1:] != ';':
|
||||
raise IOUError("IOU key not ending with ; in iourc file".format(self.iourc_path))
|
||||
if len(user_ioukey) != 17:
|
||||
raise IOUError("IOU key length is not 16 characters in iourc file".format(self.iourc_path))
|
||||
user_ioukey = user_ioukey[:16]
|
||||
try:
|
||||
hostid = os.popen("hostid").read().strip()
|
||||
except OSError as e:
|
||||
raise IOUError("Could not read the hostid: {}".format(e))
|
||||
hostid = (yield from gns3server.utils.asyncio.subprocess_check_output("hostid")).strip()
|
||||
except FileNotFoundError as e:
|
||||
raise IOUError("Could not find hostid: {}".format(e))
|
||||
except subprocess.SubprocessError as e:
|
||||
raise IOUError("Could not execute hostid: {}".format(e))
|
||||
try:
|
||||
ioukey = int(hostid, 16)
|
||||
except ValueError:
|
||||
@ -401,7 +403,7 @@ class IOUVM(BaseVM):
|
||||
|
||||
license_check = self._manager.config.get_section_config("IOU").getboolean("license_check", True)
|
||||
if license_check:
|
||||
self._check_iou_licence()
|
||||
yield from self._check_iou_licence()
|
||||
|
||||
iouyap_path = self.iouyap_path
|
||||
if not iouyap_path or not os.path.isfile(iouyap_path):
|
||||
|
Loading…
Reference in New Issue
Block a user