[PATCH 1/2] List iSCSI server for initiator while creating iSCSI Pool

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> The server should be already used in an existed iSCSI Pool. Test this patch by: $ curl -k -u shhfeng:123456 -H "Content-Type: application/json" \
-H "Accept: application/json" \ http://localhost:8000/storageservers?_target_type=iscsi [ { "host":"127.0.0.1" } ]
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/API.json | 2 +- src/kimchi/model/storagepools.py | 4 +++- src/kimchi/model/storageservers.py | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/kimchi/API.json b/src/kimchi/API.json index 76c94ab..05a5866 100644 --- a/src/kimchi/API.json +++ b/src/kimchi/API.json @@ -416,7 +416,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/storagepools.py b/src/kimchi/model/storagepools.py index c0f2c58..c699fc6 100644 --- a/src/kimchi/model/storagepools.py +++ b/src/kimchi/model/storagepools.py @@ -37,9 +37,11 @@ POOL_STATE_MAP = {0: 'inactive', 4: 'inaccessible'} # Types of pools supported -# FIXME: Addd 'iscsi' STORAGE_SOURCES = {'netfs': {'addr': '/pool/source/host/@name', 'path': '/pool/source/dir/@path'}, + 'iscsi': {'addr': '/pool/source/host/@name', + 'port': '/pool/source/host/@port', + 'path': '/pool/source/device/@path'}, 'scsi': {'adapter_type': '/pool/source/adapter/@type', 'adapter_name': '/pool/source/adapter/@name', 'wwnn': '/pool/source/adapter/@wwnn', diff --git a/src/kimchi/model/storageservers.py b/src/kimchi/model/storageservers.py index c9dfb25..6259b92 100644 --- a/src/kimchi/model/storageservers.py +++ b/src/kimchi/model/storageservers.py @@ -21,8 +21,7 @@ from kimchi.exception import NotFoundError from kimchi.model.storagepools import StoragePoolModel, StoragePoolsModel # Types of remote storage servers supported -# FIXME: Add iscsi? -STORAGE_SERVERS = ['netfs'] +STORAGE_SERVERS = ['netfs', 'iscsi'] class StorageServersModel(object): -- 1.9.3

From: ShaoHe Feng <shaohef@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. 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=... [ { "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@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)) + 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': + 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 -- 1.9.3

on 2014/05/27 23:33, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@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.
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=... [ { "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@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
-- Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397

On 05/28/2014 12:46 AM, Zhou Zheng Sheng wrote:
on 2014/05/27 23:33, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@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=... [ { "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@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

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@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@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>
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=...
[ { "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@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@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

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@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@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_type=...
[ { "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@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@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
participants (4)
-
Aline Manera
-
Royce Lv
-
shaohef@linux.vnet.ibm.com
-
Zhou Zheng Sheng