[Kimchi-devel] [PATCH 2/2] List iSCSI targets available for initiator while creating iSCSI Pool

Aline Manera alinefm at linux.vnet.ibm.com
Thu Jun 5 14:54:53 UTC 2014


On 05/28/2014 12:46 AM, Zhou Zheng Sheng wrote:
> on 2014/05/27 23:33, shaohef at linux.vnet.ibm.com wrote:
>> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>>
>> Here we call libvirt findStoragePoolSources to get the iSCSI targets.
>>
>> Zhou Zheng Sheng  aslo provides a method to get the iSCSI targets in
>> commit f163d22e.
>>
> If you mean kimchi.iscsi.TargetClient, it's handy. However it does not
> handle NFS. It seems libvirt API can handle all the storage types, we
> can stay with the API.

If I remember correctly, Royce had problems while using the libvirt API 
when she developed the NFS part.
Some supported distro has different libvirt version that does not work 
properly.
Maybe it is the time to check it again.


>
>> Test this patch by:
>> $ curl -k -u shhfeng:123456 -H "Content-Type: application/json" \
>>> -H "Accept: application/json" \
>>> https://localhost:8001/storageservers/127.0.0.1/storagetargets?_target_type=iscsi
>> [
>>    {
>>      "host":"127.0.0.1",
>>      "target":"iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.edb1a004dc57",
>>      "target_type":"iscsi"
>>    }
>> ]
>>
>> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>> ---
>>   src/kimchi/API.json                |  2 +-
>>   src/kimchi/model/storagetargets.py | 13 ++++++++++---
>>   2 files changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
>> index 05a5866..cea4344 100644
>> --- a/src/kimchi/API.json
>> +++ b/src/kimchi/API.json
>> @@ -428,7 +428,7 @@
>>                   "_target_type": {
>>                       "description": "List storage servers of given type",
>>                       "type": "string",
>> -                    "pattern": "^netfs$"
>> +                    "pattern": "^netfs|iscsi$"
>>                   }
>>               },
>>               "additionalProperties": false,
>> diff --git a/src/kimchi/model/storagetargets.py b/src/kimchi/model/storagetargets.py
>> index caa8dbe..139da55 100644
>> --- a/src/kimchi/model/storagetargets.py
>> +++ b/src/kimchi/model/storagetargets.py
>> @@ -64,8 +64,12 @@ class StorageTargetsModel(object):
>>           # server:
>>           # target_type:
>>           extra_args = []
>> -        if kwargs['target_type'] == 'netfs':
>> +        server_type = kwargs['target_type']
>> +        if server_type == 'netfs':
>>               extra_args.append(E.format(type='nfs'))
>> +        else:
>> +            extra_args.append(E.format(type=server_type))
> I think it could be
>
> if server_type == 'netfs':
>      server_type = 'nfs'
>
> extra_args.append(E.format(type=server_type))
>
>> +
>>           obj = E.source(E.host(name=kwargs['server']), *extra_args)
>>           xml = ET.tostring(obj)
>>           return xml
>> @@ -75,9 +79,12 @@ class StorageTargetsModel(object):
>>           ret = []
>>           for source in root.getchildren():
>>               if target_type == 'netfs':
>> -                host_name = source.host.get('name')
>>                   target_path = source.dir.get('path')
>>                   type = source.format.get('type')
>> -                ret.append(dict(host=host_name, target_type=type,
>> +            if target_type == 'iscsi':
> It seems "elif" is better than "if" here.
>
>> +                target_path = source.device.get('path')
>> +                type = target_type
>> +            host_name = source.host.get('name')
>> +            ret.append(dict(host=host_name, target_type=type,
>>                                   target=target_path))
>>           return ret
>>
>




More information about the Kimchi-devel mailing list