On 06/09/2014 05:47 AM, Royce Lv wrote:
On 2014年06月05日 22:54, Aline Manera wrote:
> On 05/28/2014 12:46 AM, Zhou Zheng Sheng wrote:
>> on 2014/05/27 23:33, shaohef(a)linux.vnet.ibm.com wrote:
>>> From: ShaoHe Feng <shaohef(a)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.
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1264955
This is the problem I documented. It is for ubuntu nfs.
After checked with iscsi, ubuntu pool target probe works well:
virsh # find-storage-pool-sources-as --type iscsi --host 9.115.122.152
<sources>
<source>
<host name='9.115.122.152' port='3260'/>
<device
path='iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.ed2815d63e31'/>
</source>
</sources>
That is great!
So we can only have one code that uses the libvirt API to provide the
iSCSI targets
>
>
>>
>>> 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_ty...
>>>>
>>> [
>>> {
>>> "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(a)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
>>>
>>
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel(a)ovirt.org
>
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>