[Kimchi-devel] [PATCH 1/2] Add UI support of iscsi
Zhou Zheng Sheng
zhshzhou at linux.vnet.ibm.com
Tue Dec 24 02:41:08 UTC 2013
于 2013年12月23日 10:09, zhoumeina 写道:
> On 12/20/2013 09:32 PM, Aline Manera wrote:
>> On 12/20/2013 03:28 AM, zhoumeina wrote:
>>> This patch is working for add iscsi type in storage pool create
>>> page.
>>> 1.Add iscsi server to create storage pool page.
>>> 2.Add iscsi target to create storage pool page.
>>>
>>> Signed-off-by: zhoumeina <zhoumein at linux.vnet.ibm.com>
>>> ---
>>> ui/js/src/kimchi.storagepool_add_main.js | 54
>>> ++++++++++++++++++++++++-----
>>> ui/pages/i18n.html.tmpl | 7 ++--
>>> ui/pages/storagepool-add.html.tmpl | 19 ++++++++++
>>> 3 files changed, 67 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/ui/js/src/kimchi.storagepool_add_main.js
>>> b/ui/js/src/kimchi.storagepool_add_main.js
>>> index b31610a..cd8f1ae 100644
>>> --- a/ui/js/src/kimchi.storagepool_add_main.js
>>> +++ b/ui/js/src/kimchi.storagepool_add_main.js
>>> @@ -35,6 +35,9 @@ kimchi.initStorageAddPage = function() {
>>> }, {
>>> label : "NFS",
>>> value : "netfs"
>>> + } ,{
>>> + label : "ISCSI",
>>> + value : "iscsi"
>>> } ];
>>> kimchi.listHostPartitions(function(data) {
>>> if (data.length > 0) {
>>> @@ -57,14 +60,22 @@ kimchi.initStorageAddPage = function() {
>>> $('.path-section').removeClass('tmpl-html');
>>> $('.logical-section').addClass('tmpl-html');
>>> $('.nfs-section').addClass('tmpl-html');
>>> + $('.iscsi-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');
>>> + } 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');
>>> } else {
>>> $('.path-section').addClass('tmpl-html');
>>> $('.logical-section').removeClass('tmpl-html');
>>> $('.nfs-section').addClass('tmpl-html');
>>> + $('.iscsi-section').addClass('tmpl-html');
>>> }
>>> });
>>> });
>>> @@ -85,6 +96,8 @@ kimchi.validateForm = function() {
>>> return kimchi.validateDirForm();
>>> } else if (poolType === "netfs") {
>>> return kimchi.validateNfsForm();
>>> + } else if (poolType === "iscsi") {
>>> + return kimchi.validateIscsiForm();
>>> } else {
>>> return kimchi.validateLogicalForm();
>>> }
>>> @@ -107,26 +120,44 @@ kimchi.validateDirForm = function () {
>>> kimchi.validateNfsForm = function () {
>>> var nfspath = $('#nfspathId').val();
>>> var nfsserver = $('#nfsserverId').val();
>>> - if ('' === nfsserver) {
>>> - kimchi.message.error(i18n['msg.pool.edit.nfsserver.blank']);
>>> + if (!kimchi.validateServer(nfsserver)) {
>>> return false;
>>> }
>>> -
>>> if ('' === nfspath) {
>>> kimchi.message.error(i18n['msg.pool.edit.nfspath.blank']);
>>> return false;
>>> }
>>> - var domain =
>>> "([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6}"
>>> - var ip = "(\\d{1,3}\.){3}\\d{1,3}"
>>> - regex = new RegExp('^' + domain + '|' + ip + '$')
>>> + if (!/((\/([0-9a-zA-Z-_\.]+)))$/.test(nfspath)) {
>>> + kimchi.message.error(i18n['msg.validate.pool.edit.nfspath']);
>>> + return false;
>>> + }
>>> + return true;
>>> +};
>>>
>>> - if(!regex.test(nfsserver)) {
>>> - kimchi.message.error(i18n['msg.validate.pool.edit.nfsserver']);
>>> +kimchi.validateIscsiForm = function() {
>>> + var iscsiServer = $('#iscsiserverId').val();
>>> + var iscsiTarget = $('#iscsiTargetId').val();
>>> + if (!kimchi.validateServer(iscsiServer)) {
>>> return false;
>>> }
>>> + if ('' === iscsiTarget) {
>>> + kimchi.message.error(i18n['msg.pool.edit.iscsitarget.blank']);
>>> + return false;
>>> + }
>>> + return true;
>>> +};
>>>
>>> - if (!/((\/([0-9a-zA-Z-_\.]+)))$/.test(nfspath)) {
>>> - kimchi.message.error(i18n['msg.validate.pool.edit.nfspath']);
>>> +kimchi.validateServer = function(serverField) {
>>> + if ('' === serverField) {
>>> + kimchi.message.error(i18n['msg.pool.edit.server.blank']);
>>> + return false;
>>> + }
>>> + var domain =
>>> "([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6}"
>>> + var ip = "(\\d{1,3}\.){3}\\d{1,3}"
>>> + regex = new RegExp('^' + domain + '|' + ip + '$')
>>> +
>>> + if (!regex.test(serverField)) {
>>> + kimchi.message.error(i18n['msg.validate.pool.edit.server']);
>>> return false;
>>> }
>>> return true;
>>> @@ -153,6 +184,9 @@ kimchi.addPool = function(event) {
>>> deviceObj[0] = formData.devices;
>>> formData.devices = deviceObj;
>>> }
>>> + } else if (poolType === 'iscsi'){
>>> + formData.srcTarget = $('#iscsiserverId').val();
>>> + formData.srcHost = $('#iscsiTargetId').val();
>>> } else {
>>> formData.nfspath = $('#nfspathId').val();
>>> formData.nfsserver = $('#nfsserverId').val();
>>> diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
>>> index c1fc3d1..9d4603a 100644
>>> --- a/ui/pages/i18n.html.tmpl
>>> +++ b/ui/pages/i18n.html.tmpl
>>> @@ -94,11 +94,9 @@ var i18n = {
>>> 'msg.storagepool.confirm.delete':"$_("This will permanently
>>> delete the Storage Pool. Would you like to continue?")",
>>> 'msg.pool.edit.name.blank':"$_("The storage pool name can not
>>> be blank.")",
>>> 'msg.pool.edit.path.blank':"$_("The storage pool path can not
>>> be blank.")",
>>> - 'msg.pool.edit.nfsserver.blank':"$_("NFS server can not be
>>> blank.")",
>>> 'msg.pool.edit.nfspath.blank':"$_("NFS server mount path can
>>> not be blank.")",
>>> 'msg.validate.pool.edit.name':"$_("Invalid Storage Pool name.
>>> It may only contain letters, numbers, underscores, and hyphens.")",
>>> 'msg.validate.pool.edit.path':"$_("This is not a real linux
>>> path.")",
>>> - 'msg.validate.pool.edit.nfsserver':"$_("This is not a valid NFS
>>> server.")",
>>> 'msg.validate.pool.edit.nfspath':"$_("Invalid nfs mount path.")",
>>> 'msg.kimchi.storage.pool.empty':"$_("This storage pool is
>>> empty.")",
>>> 'msg.kimchi.list.volume.fail':"$_("Failed to list the storage
>>> pool.")",
>>> @@ -121,7 +119,10 @@ var i18n = {
>>> 'action_create': "$_("Create")",
>>> 'msg_warning': "$_("Warning")",
>>> 'msg.logicalpool.confirm.delete': "$_("It will format your disk
>>> and you will loose any data in"
>>> - " there, are you sure to
>>> continue? ")"
>>> + " there, are you sure to
>>> continue? ")",
>>> + 'msg.pool.edit.iscsitarget.blank': "$_("The iscsi target can not
>>> be blank.")",
>>> + 'msg.pool.edit.server.blank':"$_("Server name can not be blank.")",
>>> + 'msg.validate.pool.edit.server':"$_("This is not a valid Server
>>> Name or IP, please modify it.")"
>>
>> "This is not a valid Server Name or IP. Please, modify it."
>>
>>
>>
>>> };
>>> </script>
>>> </body>
>>> diff --git a/ui/pages/storagepool-add.html.tmpl
>>> b/ui/pages/storagepool-add.html.tmpl
>>> index d7b046d..ce1e65d 100644
>>> --- a/ui/pages/storagepool-add.html.tmpl
>>> +++ b/ui/pages/storagepool-add.html.tmpl
>>> @@ -96,6 +96,25 @@
>>> <div class="host-partition"></div>
>>> </section>
>>> </div>
>>> + <div class="iscsi-section tmpl-html">
>>> + <section class="form-section">
>>> + <h2>3. $_("ISCSI server")</h2>
>>> + <div class="field">
>>> + <p class="text-help">
>>> + $_("ISCSI server IP or hostname. It
>>> should not be empty.")</p>
>>> + <input id="iscsiserverId" type="text"
>>> class="text"
>>> + style="width: 300px">
>>> + </div>
>>> + </section>
>>> + <section class="form-section">
>>> + <h2>4. $_("Target")</h2>
>>> + <div class="field">
>>> + <p class="text-help">$_("The iscsi
>>> target on iscsi server")</p>
>>
>> "The ISCSI target on ISCSI server"
> ok, thanks for your new translation.
I think "iSCSI" is a better format for this word, and "iSCSI server" can
be changed to "iSCSI host".
>>
>>
>>
>>> + <input id="iscsiTargetId" type="text"
>>> class="text" style="width: 300px">
>>> + </div>
>>> + <div class="clear"></div>
>>> + </section>
>>> + </div>
>>> </form>
>>> </div>
>>> <footer>
>>
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>
--
Thanks and best regards!
Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou at linux.vnet.ibm.com
Telephone: 86-10-82454397
More information about the Kimchi-devel
mailing list