[Kimchi-devel] [PATCH 3/3] create a VM from an iscsi pool template.
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Mar 25 01:45:28 UTC 2014
On 03/20/2014 07:35 AM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> Now this patch do not touch the scsi code, so it does not support to create
> a VM from an scsi pool template at present.
>
> It just supports iscsi luns for template, and create a VM by this
> template.
>
> Will refactor the related code, and support the scsi lun at template
> level.
>
> 1. how to test this patch:
> create a iscsi pool named "my-iscsi" with UI
>
> 2.get the volumes name of this pool:
> $ sudo virsh vol-list my-iscsi
> Name Path
> -----------------------------------------
> unit:0:0:0 /dev/disk/by-id/wwn-0x60014056aefaef96d4e4033953d9627d
>
> 3. create a template with this pool like this:
> $ curl -u shhfeng:123456 -H "Content-Type: application/json" \
>> -H "Accept: application/json" \
>> http://localhost:8000/templates/ -X POST -d '
>> {
>> "cpus": 1,
>> "cdrom":"/home/shhfeng/iso/f17.iso",
>> "name":"F17-ISCSI",
>> "storagepool":"/storagepools/my-iscsi",
>> "disks":[
>> {
>> "index":0,
>> "volume":"unit:0:0:0"
>> }
>> ]
>> }'
> 4. create a VM with this template and start it.
>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
> src/kimchi/model/vms.py | 4 +++-
> src/kimchi/vmtemplate.py | 4 +++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index 79b335c..f962cbb 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -184,7 +184,9 @@ class VMsModel(object):
> # If storagepool is SCSI, volumes will be LUNs and must be passed by
> # the user from UI or manually.
> vol_list = []
> - if t._get_storage_type() in READONLY_POOL_TYPE:
> + if t._get_storage_type() == "iscsi":
> + vol_list = []
> + elif t._get_storage_type() in READONLY_POOL_TYPE:
> if not params.get('volumes'):
> raise MissingParameter('KCHVM0017E')
> else:
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 5e84c55..d13f714 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -305,7 +305,9 @@ class VMTemplate(object):
>
> # Current implementation just allows to create disk in one single
> # storage pool, so we cannot mix the types (scsi volumes vs img file)
> - if self._get_storage_type() in READONLY_POOL_TYPE:
> + if self._get_storage_type() == "iscsi":
> + params['disks'] = self._get_iscsi_disks_xml()
> + elif self._get_storage_type() in READONLY_POOL_TYPE:
> params['disks'] = self._get_scsi_disks_xml(kwargs.get('volumes'))
The function self._get_scsi_disks_xml() is specific for scsi, so I
suggest to properly update the "if" statement.
elif self._get_storage_type() == 'scsi':
params['disks'] = self._get_scsi_disks_xml(kwargs.get('volumes'))
Also instead of calling self._get_storage_type() twice in the "if"
statements, store the value:
storage_type = self._get_storage_type()
if storage_type == 'iscsi':
....
elif storage_type == 'scsi':
....
> else:
> params['disks'] = self._get_disks_xml(vm_uuid)
More information about the Kimchi-devel
mailing list