mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
More robust IOUVM support
This commit is contained in:
parent
386b311755
commit
6330e99ff1
@ -23,6 +23,7 @@ import asyncio
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from ..utils.asyncio import wait_run_in_executor
|
from ..utils.asyncio import wait_run_in_executor
|
||||||
|
from .vm_error import VMError
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -132,7 +133,10 @@ class BaseVM:
|
|||||||
@property
|
@property
|
||||||
def temporary_directory(self):
|
def temporary_directory(self):
|
||||||
if self._temporary_directory is None:
|
if self._temporary_directory is None:
|
||||||
|
try:
|
||||||
self._temporary_directory = tempfile.mkdtemp()
|
self._temporary_directory = tempfile.mkdtemp()
|
||||||
|
except OSError as e:
|
||||||
|
raise VMError("Can't create temporary directory: {}".format(e))
|
||||||
return self._temporary_directory
|
return self._temporary_directory
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
|
@ -332,14 +332,21 @@ class IOUVM(BaseVM):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def iourc_content(self):
|
def iourc_content(self):
|
||||||
|
try:
|
||||||
with open(os.path.join(self.temporary_directory, "iourc")) as f:
|
with open(os.path.join(self.temporary_directory, "iourc")) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
except OSError:
|
||||||
|
return None
|
||||||
|
|
||||||
@iourc_content.setter
|
@iourc_content.setter
|
||||||
def iourc_content(self, value):
|
def iourc_content(self, value):
|
||||||
if value is not None:
|
if value is not None:
|
||||||
with open(os.path.join(self.temporary_directory, "iourc"), "w+") as f:
|
path = os.path.join(self.temporary_directory, "iourc")
|
||||||
|
try:
|
||||||
|
with open(path, "w+") as f:
|
||||||
f.write(value)
|
f.write(value)
|
||||||
|
except OSError as e:
|
||||||
|
raise IOUError("Could not write iourc file {}: {}".format(path, e))
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _library_check(self):
|
def _library_check(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user