<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
    <div id="smartTemplate4-quoteHeader"><br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
    <div class="moz-cite-prefix">On 12/16/2013 04:01 PM, Zhou Zheng
      Sheng wrote:<br>
    </div>
    <blockquote
      cite="mid:1387180891-22791-5-git-send-email-zhshzhou@linux.vnet.ibm.com"
      type="cite">
      <pre wrap="">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"}' \
  <a class="moz-txt-link-freetext" href="http://127.0.0.1:8000/storagepools">http://127.0.0.1:8000/storagepools</a>

Show Info:
curl -u root -H 'Accept: application/json' \
  <a class="moz-txt-link-freetext" href="http://127.0.0.1:8000/storagepools/iscsipool">http://127.0.0.1:8000/storagepools/iscsipool</a>

Activate:
curl -u root -H 'Content-type: application/json' \
  -H 'Accept: application/json' \
  -d '' <a class="moz-txt-link-freetext" href="http://127.0.0.1:8000/storagepools/iscsipool/activate">http://127.0.0.1:8000/storagepools/iscsipool/activate</a>

Examine:
iscsiadm -m session

Deactivate:
curl -u root -H 'Content-type: application/json' \
  -H 'Accept: application/json' \
  -d '' <a class="moz-txt-link-freetext" href="http://127.0.0.1:8000/storagepools/iscsipool/deactivate">http://127.0.0.1:8000/storagepools/iscsipool/deactivate</a>

Delete:
curl -u root -X DELETE -H 'Accept: application/json' \
  <a class="moz-txt-link-freetext" href="http://127.0.0.1:8000/storagepools/iscsipool">http://127.0.0.1:8000/storagepools/iscsipool</a>

Signed-off-by: Zhou Zheng Sheng <a class="moz-txt-link-rfc2396E" href="mailto:zhshzhou@linux.vnet.ibm.com">&lt;zhshzhou@linux.vnet.ibm.com&gt;</a>
---
 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 = """
+    &lt;pool type='%(type)s'&gt;
+      &lt;name&gt;%(name)s&lt;/name&gt;
+      &lt;source&gt;
+        &lt;host name='%(srcHost)s' %(srcPort)s/&gt;
+        &lt;device path='%(srcTarget)s'/&gt;
+      &lt;/source&gt;
+      &lt;target&gt;
+        &lt;path&gt;%(path)s&lt;/path&gt;
+      &lt;/target&gt;
+    &lt;/pool&gt;
+    """ % poolArgs
+    return xml
+
+</pre>
    </blockquote>
    <a class="moz-txt-link-freetext" href="http://libvirt.org/formatstorage.html#exampleISCSI">http://libvirt.org/formatstorage.html#exampleISCSI</a><br>
    <h3> <a name="exampleISCSI" shape="rect" id="exampleISCSI">iSCSI
        based storage pool</a> </h3>
    <pre xml:space="preserve">      &lt;pool type="iscsi"&gt;
        &lt;name&gt;virtimages&lt;/name&gt;
        &lt;source&gt;
          &lt;host name="iscsi.example.com"/&gt;
          &lt;device path="iqn.2013-06.com.example:iscsi-pool"/&gt;
          &lt;auth type='chap' username='myuser'&gt;
            &lt;secret usage='libvirtiscsi'/&gt;
          &lt;/auth&gt;
        &lt;/source&gt;
        &lt;target&gt;
          &lt;path&gt;/dev/disk/by-path&lt;/path&gt;
        &lt;/target&gt;
      &lt;/pool&gt;</pre>
    <br>
    <pre xml:space="preserve">auth tag?</pre>
    <blockquote
      cite="mid:1387180891-22791-5-git-send-email-zhshzhou@linux.vnet.ibm.com"
      type="cite">
      <pre wrap="">
 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)

</pre>
    </blockquote>
    <br>
    <div class="moz-signature">
      <pre>Sheldon Feng(&#20911;&#23569;&#21512;)<shaohef@linux.vnet.ibm.com>
IBM Linux Technology Center</shaohef@linux.vnet.ibm.com></pre>
    </div>
  </body>
</html>

<p></p>

-- <br />
project-kimchi mailing list &lt;project-kimchi@googlegroups.com&gt;<br />
<a href="https://groups.google.com/forum/#!forum/project-kimchi">https://groups.google.com/forum/#!forum/project-kimchi</a><br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;project-kimchi&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe@googlegroups.com.<br />
For more options, visit <a href="https://groups.google.com/groups/opt_out">https://groups.google.com/groups/opt_out</a>.<br />