[Kimchi-devel] [PATCH] Fix cdrom eject
Paulo Ricardo Paz Vital
pvital at linux.vnet.ibm.com
Tue Sep 16 19:01:24 UTC 2014
--
Tested-by: Paulo Vital <pvital at linux.vnet.ibm.com>
Reviewed-by: Paulo Vital <pvital at linux.vnet.ibm.com>
On Mon, 2014-09-15 at 17:02 +0800, lvroyce at linux.vnet.ibm.com wrote:
> 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)
More information about the Kimchi-devel
mailing list