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