On 01/23/2014 10:29 PM, Rodrigo Trujillo wrote:
This patch modifies the storagepool add user interface in order to
show all
Fibre Channel scsi hosts found in the host system and let user to create a
pool attached to this host (the LUNs will be the volumes).
A second option to use and enable FC storages is when a LUN is assigned as
a pool of FS type, hosting guest images. This second option will be implement
in the future.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.api.js | 11 +++++++++
ui/js/src/kimchi.storagepool_add_main.js | 40 +++++++++++++++++++++++++++++++-
ui/pages/i18n.html.tmpl | 1 +
ui/pages/storagepool-add.html.tmpl | 12 ++++++++++
4 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 63ddd88..66fc41e 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -731,5 +731,16 @@ var kimchi = {
success : suc,
error : err
});
+ },
+
+ listFCHosts : function(suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url + 'host/devices?_cap=fc_host',
For older libvirt version this filter is not true.
My suggestion:
1) Use /host/devices?_cap='scsi_host'
2) In backend:
- Return all scsi_host devices and identify which are FC
I think we will only be able to identify the FC scsi_host for newer
libvirt versions. You need to investigate it.
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json',
+ success : suc,
+ error : err
+ });
}
};
diff --git a/ui/js/src/kimchi.storagepool_add_main.js
b/ui/js/src/kimchi.storagepool_add_main.js
index e5922b3..8331076 100644
--- a/ui/js/src/kimchi.storagepool_add_main.js
+++ b/ui/js/src/kimchi.storagepool_add_main.js
@@ -40,7 +40,21 @@ kimchi.initStorageAddPage = function() {
label : "iSCSI",
value : "iscsi"
} ];
- kimchi.listHostPartitions(function(data) {
+ kimchi.listFCHosts(function(data){
+ if (data.length > 0) {
+ options.push( {
+ label : "SCSI Fibre Channel",
+ value : "scsi"
+ });
+ }
+ var scsiFCHtml = $('#scsiFCTmpl').html();
+ var scsiFCHostListHtml = '';
+ $.each(data, function(index, value) {
+ scsiFCHostListHtml += kimchi.template(scsiFCHtml, value);
+ });
+ $('.scsifc-hosts').html(scsiFCHostListHtml);
+
+ kimchi.listHostPartitions(function(data) {
if (data.length > 0) {
options.push({
label : "LOGICAL",
@@ -107,21 +121,31 @@ kimchi.initStorageAddPage = function() {
$('.logical-section').addClass('tmpl-html');
$('.nfs-section').addClass('tmpl-html');
$('.iscsi-section').addClass('tmpl-html');
+ $('.scsifc-section').addClass('tmpl-html');
} else if ($(this).val() === 'netfs') {
$('.path-section').addClass('tmpl-html');
$('.logical-section').addClass('tmpl-html');
$('.nfs-section').removeClass('tmpl-html');
$('.iscsi-section').addClass('tmpl-html');
+ $('.scsifc-section').addClass('tmpl-html');
} else if ($(this).val() === 'iscsi') {
$('.path-section').addClass('tmpl-html');
$('.logical-section').addClass('tmpl-html');
$('.nfs-section').addClass('tmpl-html');
$('.iscsi-section').removeClass('tmpl-html');
+ $('.scsifc-section').addClass('tmpl-html');
+ } else if ($(this).val() === 'scsi') {
+ $('.path-section').addClass('tmpl-html');
+ $('.logical-section').addClass('tmpl-html');
+ $('.nfs-section').addClass('tmpl-html');
+ $('.iscsi-section').addClass('tmpl-html');
+ $('.scsifc-section').removeClass('tmpl-html');
} else if ($(this).val() === 'logical') {
$('.path-section').addClass('tmpl-html');
$('.logical-section').removeClass('tmpl-html');
$('.nfs-section').addClass('tmpl-html');
$('.iscsi-section').addClass('tmpl-html');
+ $('.scsifc-section').addClass('tmpl-html');
}
});
$('#authId').click(function() {
@@ -134,6 +158,7 @@ kimchi.initStorageAddPage = function() {
$('#iscsiportId').keyup(function(event) {
$(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val()));
});
+ });
});
};
@@ -154,6 +179,8 @@ kimchi.validateForm = function() {
return kimchi.validateNfsForm();
} else if (poolType === "iscsi") {
return kimchi.validateIscsiForm();
+ } else if (poolType === "scsi") {
+ return kimchi.validateScsiFCForm();
} else if (poolType === "logical") {
return kimchi.validateLogicalForm();
} else {
@@ -204,6 +231,15 @@ kimchi.validateIscsiForm = function() {
return true;
};
+kimchi.validateScsiFCForm = function() {
+ var fcHost = $('input:radio[name=adapter_name]:checked').val();
+ if (fcHost === undefined) {
+ kimchi.message.error(i18n['msg.validate.pool.edit.scsifchost']);
+ return false;
+ }
+ return true;
+};
+
kimchi.validateServer = function(serverField) {
if ('' === serverField) {
kimchi.message.error(i18n['msg.pool.edit.server.blank']);
@@ -248,6 +284,8 @@ kimchi.addPool = function(event) {
source.path = $('#nfspathId').val();
source.host = $('#nfsserverId').val();
formData.source = source;
+ } else if (poolType === 'scsi'){
+ formData.adapter_type = 'fc_host';
} else if (poolType === 'iscsi') {
var source = {};
source.target = $('#iscsiTargetId').val();
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index d63d4e9..0d6550f 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -100,6 +100,7 @@ var i18n = {
'msg.validate.pool.edit.path':"$_("This is not a real linux
path.")",
'msg.validate.pool.edit.nfspath':"$_("Invalid nfs mount
path.")",
'msg.validate.pool.edit.logical.device':"$_("No logical device
selected.")",
+ 'msg.validate.pool.edit.scsifchost':"$_("A Fibre Channel SCSI host
must be selected.")",
'msg.kimchi.storage.pool.empty':"$_("This storage pool is
empty.")",
'msg.kimchi.list.volume.fail':"$_("Failed to list the storage
pool.")",
'msg.kimchi.storage.pool.not.active':"$_("The storage pool is not
active now.")",
diff --git a/ui/pages/storagepool-add.html.tmpl b/ui/pages/storagepool-add.html.tmpl
index 14ef23a..c8d4114 100644
--- a/ui/pages/storagepool-add.html.tmpl
+++ b/ui/pages/storagepool-add.html.tmpl
@@ -104,6 +104,12 @@
<div class="host-partition"></div>
</section>
</div>
+ <div class="scsifc-section tmpl-html">
+ <section class="form-section">
+ <h2>3. $_("Select SCSI Fibre Channel
Host")</h2>
+ <div class="scsifc-hosts"></div>
+ </section>
+ </div>
<div class="iscsi-section tmpl-html">
<section class="form-section">
<h2>3. $_("iSCSI Server")</h2>
@@ -154,5 +160,11 @@
<label>{path}</label>
</div>
</script>
+ <script id="scsiFCTmpl" type="html/text">
+ <div class="field">
+ <input type="radio" value="{name}"
name="adapter_name">
+ <label>{name}</label>
+ </div>
+ </script>
</body>
</html>