
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