From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
The server should be already used in an existed iSCSI Pool.
Test this patch by:
$ curl -k -u <user>:<password> -H "Content-Type: application/json"
\
[
{
"host":"127.0.0.1"
"port":"3260"
}
]
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
docs/API.md | 4 +++-
src/kimchi/API.json | 2 +-
src/kimchi/model/storagepools.py | 4 +++-
src/kimchi/model/storageservers.py | 9 ++++++---
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/docs/API.md b/docs/API.md
index bac30eb..1c7d9e2 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -632,7 +632,8 @@ creation.
* **GET**: Retrieve a summarized list of used storage servers.
* Parameters:
- * _target_type: Filter server list with given type, currently support
'netfs'.
+ * _target_type: Filter server list with given type, currently support
+ 'netfs' and 'iscsi'.
### Resource: Storage Server
@@ -642,6 +643,7 @@ creation.
* **GET**: Retrieve description of a Storage Server
* host: IP or host name of storage server
+ * port: port of storage server, only for "iscsi"
### Collection: Storage Targets
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 06da9da..b0df606 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 @@
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..01a7547 100644
--- a/src/kimchi/model/storageservers.py
+++ b/src/kimchi/model/storageservers.py
@@ -21,8 +21,7 @@
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):
@@ -68,7 +67,11 @@ def lookup(self, server):
pool_info = self.pool.lookup(pool)
if (pool_info['type'] in STORAGE_SERVERS and
pool_info['source']['addr'] == server):
- return dict(host=server)
+ info = dict(host=server)
+ if (pool_info['type'] == "iscsi" and
+ 'port' in pool_info['source']):
+ info["port"] =
pool_info['source']['port']
+ return info
except NotFoundError:
# Avoid inconsistent pool result because of lease between list
# lookup
--
1.9.3