On 12/16/2013 04:01 PM, Zhou Zheng Sheng wrote:
This patch implements creating iSCSI storagepool for libvirt.
Each LUN in iSCSI storagepool can be used as a volume, but iSCSI
storagepool does not provide ability to create volume. For now in kimchi
we create volume for each newly created VM. Next is to implement
attaching existing volume to a new VM.
How to test
Create:
curl -u root -H 'Content-type: application/json' \
-H 'Accept: application/json' \
-d '{"srcTarget":
"targetIQN",
"srcHost": "10.0.0.X",
"type": "iscsi",
"name": "iscsipool"}' \
http://127.0.0.1:8000/storagepools
Show Info:
curl -u root -H 'Accept: application/json' \
http://127.0.0.1:8000/storagepools/iscsipool
Activate:
curl -u root -H 'Content-type: application/json' \
-H 'Accept: application/json' \
-d ''
http://127.0.0.1:8000/storagepools/iscsipool/activate
Examine:
iscsiadm -m session
Deactivate:
curl -u root -H 'Content-type: application/json' \
-H 'Accept: application/json' \
-d ''
http://127.0.0.1:8000/storagepools/iscsipool/deactivate
Delete:
curl -u root -X DELETE -H 'Accept: application/json' \
http://127.0.0.1:8000/storagepools/iscsipool
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
docs/API.md | 6 ++++--
src/kimchi/model.py | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/docs/API.md b/docs/API.md
index dd3d7f1..342c583 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -182,16 +182,18 @@ Represents a snapshot of the Virtual Machine's primary
monitor.
* **POST**: Create a new Storage Pool
* name: The name of the Storage Pool.
* type: The type of the defined Storage Pool.
- Supported types: 'dir', 'kimchi-iso', 'netfs',
'logical'
+ Supported types: 'dir', 'kimchi-iso', 'netfs',
'logical', 'iscsi'
* path: The path of the defined Storage Pool.
For 'kimchi-iso' pool refers to targeted deep scan path.
Pool types: 'dir', 'kimchi-iso'.
* srcHost: IP or hostname of server for a pool backed from a remote host.
- Pool types: 'nfs'.
+ Pool types: 'nfs', 'iscsi'.
* srcPath: Export path on NFS server for NFS pool.
Pool types: 'nfs'.
* srcDevices: Array of devices to be used in the Storage Pool
Pool types: 'logical'.
+ * srcTarget: Target IQN of an iSCSI pool.
+ Pool types: 'iscsi'.
### Resource: Storage Pool
diff --git a/src/kimchi/model.py b/src/kimchi/model.py
index af0d728..3888903 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -1475,11 +1475,45 @@ def _get_logical_storagepool_xml(poolArgs):
return xml
+def _get_iscsi_storagepool_xml(poolArgs):
+ # Required parameters
+ # name:
+ # type:
+ # srcHost:
+ # srcTarget:
+ #
+ # Optional parameters
+ # srcPort:
+
+ try:
+ portAttr = "port='%s'" % poolArgs['srcPort']
+ except KeyError:
+ portAttr = ""
+
+ poolArgs.update({'srcPort': portAttr,
+ 'path': '/dev/disk/by-id'})
+
+ xml = """
+ <pool type='%(type)s'>
+ <name>%(name)s</name>
+ <source>
+ <host name='%(srcHost)s' %(srcPort)s/>
+ <device path='%(srcTarget)s'/>
+ </source>
+ <target>
+ <path>%(path)s</path>
+ </target>
+ </pool>
+ """ % poolArgs
+ return xml
+
+
http://libvirt.org/formatstorage.html#exampleISCSI
iSCSI based storage pool
<pool type="iscsi">
<name>virtimages</name>
<source>
<host name="iscsi.example.com"/>
<device path="iqn.2013-06.com.example:iscsi-pool"/>
<auth type='chap' username='myuser'>
<secret usage='libvirtiscsi'/>
</auth>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
auth tag?
def _get_pool_xml(**kwargs):
getPoolXml = {
'dir': _get_dir_storagepool_xml,
'netfs': _get_netfs_storagepool_xml,
'logical': _get_logical_storagepool_xml,
+ 'iscsi': _get_iscsi_storagepool_xml,
}[kwargs['type']]
return getPoolXml(kwargs)
Sheldon Feng(???)
IBM Linux Technology Center
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups
"project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.