[Kimchi-devel] [PATCH] Fix cdrom eject
lvroyce at linux.vnet.ibm.com
lvroyce at linux.vnet.ibm.com
Mon Sep 15 09:02:52 UTC 2014
From: Royce Lv <lvroyce at linux.vnet.ibm.com>
Cdrom eject intended to use POST "/vms/vm-name/vmstorages/hdc" to eject
cdrom, while UI used PUT "/vms/vm-name/vmstorages/hdc" to implement this,
which makes cdrom eject not working.
Adjust backend code to fix this and delete eject action.
Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
docs/API.md | 2 --
src/kimchi/API.json | 2 +-
src/kimchi/control/vm/storages.py | 1 -
src/kimchi/model/vmstorages.py | 8 +++-----
tests/test_model.py | 2 +-
5 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/docs/API.md b/docs/API.md
index ca64af6..50ed321 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -168,8 +168,6 @@ Represents a snapshot of the Virtual Machine's primary monitor.
**Actions (POST):**
-* eject: Eject cdrom from device.
-
### Collection: Templates
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 2e2f9b0..47bc05b 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -522,7 +522,7 @@
"path": {
"description": "Path of iso image file or disk mount point",
"type": "string",
- "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$",
+ "pattern": "^(|(/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$",
"required": true,
"error": "KCHVMSTOR0003E"
}
diff --git a/src/kimchi/control/vm/storages.py b/src/kimchi/control/vm/storages.py
index a8a037a..984c4d2 100644
--- a/src/kimchi/control/vm/storages.py
+++ b/src/kimchi/control/vm/storages.py
@@ -39,7 +39,6 @@ class VMStorage(Resource):
self.info = {}
self.model_args = [self.vm, self.ident]
self.uri_fmt = '/vms/%s/storages/%s'
- self.eject = self.generate_action_handler('eject')
self.update_params = ['path']
@property
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index 40856d3..54e2685 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -232,8 +232,9 @@ class VMStorageModel(object):
raise OperationFailed("KCHVMSTOR0010E", {'error': e.message})
def update(self, vm_name, dev_name, params):
- if params.get('path'):
- params['src_type'] = _check_path(params['path'])
+ path = params.get('path')
+ if path and len(path) != 0:
+ params['src_type'] = _check_path(path)
ignore_source = False
else:
params['src_type'] = 'file'
@@ -251,6 +252,3 @@ class VMStorageModel(object):
except Exception as e:
raise OperationFailed("KCHVMSTOR0009E", {'error': e.message})
return dev_name
-
- def eject(self, vm_name, dev_name):
- return self.update(vm_name, dev_name, dict())
diff --git a/tests/test_model.py b/tests/test_model.py
index 5ee824d..27f5b80 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -382,7 +382,7 @@ class ModelTests(unittest.TestCase):
self.assertEquals(iso_path, cdrom_info['path'])
# eject cdrom
- cdrom_dev = inst.vmstorage_eject(vm_name, cdrom_dev)
+ cdrom_dev = inst.vmstorage_update(vm_name, cdrom_dev, {'path': ''})
cdrom_info = inst.vmstorage_lookup(vm_name, cdrom_dev)
self.assertEquals('', cdrom_info['path'])
inst.vm_poweroff(vm_name)
--
1.8.3.2
More information about the Kimchi-devel
mailing list