Merge branch 'master' into unstable

This commit is contained in:
Julien Duponchelle 2015-04-20 19:26:27 +02:00
commit cf0adf56a8
8 changed files with 20 additions and 32 deletions

View File

@ -59,8 +59,6 @@ class IOUHandler:
for name, value in request.json.items():
if hasattr(vm, name) and getattr(vm, name) != value:
setattr(vm, name, value)
if "initial_config_content" in request.json:
vm.initial_config = request.json.get("initial_config_content")
response.set_status(201)
response.json(vm)
@ -108,8 +106,6 @@ class IOUHandler:
for name, value in request.json.items():
if hasattr(vm, name) and getattr(vm, name) != value:
setattr(vm, name, value)
if "initial_config_content" in request.json:
vm.initial_config = request.json.get("initial_config_content")
response.json(vm)
@classmethod
@ -309,4 +305,4 @@ class IOUHandler:
vm = iou_manager.get_vm(request.match_info["vm_id"],
project_id=request.match_info["project_id"])
response.set_status(200)
response.json({"content": vm.initial_config})
response.json({"content": vm.initial_config_content})

View File

@ -317,9 +317,9 @@ class IOUVM(BaseVM):
"""
if self.initial_config_file:
content = self.initial_config
content = self.initial_config_content
content = content.replace(self._name, new_name)
self.initial_config = content
self.initial_config_content = content
super(IOUVM, IOUVM).name.__set__(self, new_name)
@ -939,7 +939,7 @@ class IOUVM(BaseVM):
log.warn("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e))
@property
def initial_config(self):
def initial_config_content(self):
"""
Returns the content of the current initial-config file.
"""
@ -952,10 +952,10 @@ class IOUVM(BaseVM):
with open(config_file) as f:
return f.read()
except OSError as e:
raise IOUError("Can't read configuration file '{}'".format(config_file))
raise IOUError("Can't read configuration file '{}': {}".format(config_file, e))
@initial_config.setter
def initial_config(self, initial_config):
@initial_config_content.setter
def initial_config_content(self, initial_config):
"""
Update the initial config

View File

@ -67,7 +67,7 @@ class Qemu(BaseManager):
for path in paths:
try:
for f in os.listdir(path):
if (f.startswith("qemu-system") or f == "qemu" or f == "qemu.exe") and \
if (f.startswith("qemu-system") or f.startswith("qemu-kvm") or f == "qemu" or f == "qemu.exe") and \
os.access(os.path.join(path, f), os.X_OK) and \
os.path.isfile(os.path.join(path, f)):
qemu_path = os.path.join(path, f)

View File

@ -284,20 +284,10 @@ VM_UPDATE_SCHEMA = {
"type": "string",
"minLength": 1,
},
"startup_config": {
"description": "path to the IOS startup configuration file",
"type": "string",
"minLength": 1,
},
"startup_config_content": {
"description": "Content of IOS startup configuration file",
"type": "string",
},
"private_config": {
"description": "path to the IOS private configuration file",
"type": "string",
"minLength": 1,
},
"private_config_content": {
"description": "Content of IOS private configuration file",
"type": "string",

View File

@ -127,10 +127,6 @@ IOU_UPDATE_SCHEMA = {
"description": "Always up ethernet interface",
"type": ["boolean", "null"]
},
"initial_config": {
"description": "Path to the initial configuration of IOU",
"type": ["string", "null"]
},
"initial_config_content": {
"description": "Initial configuration of IOU",
"type": ["string", "null"]

View File

@ -225,6 +225,11 @@ class Server:
try:
self._loop.run_forever()
except OSError as e:
# This is to ignore OSError: [WinError 0] The operation completed successfully
# exception on Windows.
if not sys.platform.startswith("win") and not e.winerror == 0:
raise
except TypeError as e:
# This is to ignore an asyncio.windows_events exception
# on Windows when the process gets the SIGBREAK signal

View File

@ -81,11 +81,11 @@ def test_vm(project, manager):
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0f"
def test_vm_initial_config(project, manager):
def test_vm_initial_config_content(project, manager):
vm = IOUVM("test", "00010203-0405-0607-0808-0a0b0c0d0e0f", project, manager)
vm.initial_config = "hostname %h"
vm.initial_config_content = "hostname %h"
assert vm.name == "test"
assert vm.initial_config == "hostname test"
assert vm.initial_config_content == "hostname test"
assert vm.id == "00010203-0405-0607-0808-0a0b0c0d0e0f"
@ -287,10 +287,10 @@ def test_update_initial_config_empty(vm):
assert f.read() == content
def test_update_initial_config_h(vm):
def test_update_initial_config_content_hostname(vm):
content = "hostname %h\n"
vm.name = "pc1"
vm.initial_config = content
vm.initial_config_content = content
with open(vm.initial_config_file) as f:
assert f.read() == "hostname pc1\n"

View File

@ -32,7 +32,7 @@ def test_get_qemu_version(loop):
def test_binary_list(loop):
files_to_create = ["qemu-system-x86", "qemu-system-x42", "hello"]
files_to_create = ["qemu-system-x86", "qemu-system-x42", "qemu-kvm", "hello"]
for file_to_create in files_to_create:
path = os.path.join(os.environ["PATH"], file_to_create)
@ -44,6 +44,7 @@ def test_binary_list(loop):
qemus = loop.run_until_complete(asyncio.async(Qemu.binary_list()))
assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x86"), "version": "2.2.0"} in qemus
assert {"path": os.path.join(os.environ["PATH"], "qemu-kvm"), "version": "2.2.0"} in qemus
assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x42"), "version": "2.2.0"} in qemus
assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": "2.2.0"} not in qemus