From 9a27f201b02fe33cdba1dcca7da63497b323a874 Mon Sep 17 00:00:00 2001 From: seif Date: Mon, 23 Jun 2014 00:37:44 +0200 Subject: [PATCH] Enable primary storage to be added that is based on non-default storage plug-ins --- .../classes/resources/messages.properties | 5 +- ui/dictionary.jsp | 3 + ui/scripts/docs.js | 23 ++ ui/scripts/system.js | 277 +++++++++++++----- 4 files changed, 239 insertions(+), 69 deletions(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index b504a18d020..b192cb0e78c 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -425,6 +425,8 @@ label.bytes.received=Bytes Received label.bytes.sent=Bytes Sent label.cancel=Cancel label.capacity=Capacity +label.capacity.bytes=Capacity Bytes +label.capacity.iops=Capacity IOPS label.certificate=Certificate label.change.service.offering=Change service offering label.change.value=Change value @@ -747,6 +749,7 @@ label.lun=LUN label.make.project.owner=Make account project owner label.manage.resources=Manage Resources label.manage=Manage +label.managed=Managed label.management.ips=Management IP Addresses label.management=Management label.max.cpus=Max. CPU cores @@ -1076,7 +1079,7 @@ label.source=Source label.specify.IP.ranges=Specify IP ranges label.specify.vlan=Specify VLAN label.specify.vxlan=Specify VXLAN -label.SR.name = SR Name-Label +label.SR.name=SR Name-Label label.srx=SRX label.PA=Palo Alto label.start.IP=Start IP diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index 9026a36be98..24d6345f5d7 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -76,6 +76,8 @@ dictionary = { 'label.hypervisor.snapshot.reserve': '', 'label.acquire.new.secondary.ip': '', 'label.view.secondary.ips': '', +'label.capacity.bytes': '', +'label.capacity.iops': '', 'message.acquire.ip.nic': '', 'message.select.affinity.groups': '', 'message.no.affinity.groups': '', @@ -736,6 +738,7 @@ dictionary = { 'label.LUN.number': '', 'label.make.project.owner': '', 'label.manage': '', +'label.managed': '', 'label.management': '', 'label.management.ips': '', 'label.max.cpus': '', diff --git a/ui/scripts/docs.js b/ui/scripts/docs.js index aad358bb701..74a08bc8db8 100755 --- a/ui/scripts/docs.js +++ b/ui/scripts/docs.js @@ -85,6 +85,29 @@ cloudStack.docs = { externalLink: '' }, + helpManaged: { + + desc: 'True if CloudStack manages the storage; else, false (check with storage provider if unknown)', + externalLink: '' + }, + + helpCapacityBytes: { + + desc: 'Number of bytes for the primary storage to have', + externalLink: '' + }, + + helpCapacityIops: { + + desc: 'Number of IOPS for the primary storage to have', + externalLink: '' + }, + + helpUrl: { + + desc: 'Arbitrary data to be sent to the storage provider for configuration purposes', + externalLink: '' + }, //Ldap helpLdapQueryFilter: { diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 00ca1d4cace..c5aea925eaf 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -15294,7 +15294,10 @@ id: 'Hyperv', description: _l('Hyperv') }); - + items.push({ + id: 'Any', + description: _l('Any') + }); args.response.success({ data: items }); @@ -15489,6 +15492,10 @@ id: "iscsi", description: "iscsi" }); + items.push({ + id: "custom", + description: "custom" + }); args.response.success({ data: items }); @@ -15502,6 +15509,10 @@ id: "vmfs", description: "vmfs" }); + items.push({ + id: "custom", + description: "custom" + }); args.response.success({ data: items }); @@ -15659,6 +15670,30 @@ $form.find('.form-item[rel=rbdid]').hide(); $form.find('.form-item[rel=rbdsecret]').hide(); + $form.find('.form-item[rel=glustervolume]').hide(); + } else if (protocol == "custom") { + $form.find('.form-item[rel=server]').hide(); + $form.find('.form-item[rel=server]').find(".value").find("input").val("localhost"); + + $form.find('.form-item[rel=path]').hide(); + + $form.find('.form-item[rel=smbUsername]').hide(); + $form.find('.form-item[rel=smbPassword]').hide(); + $form.find('.form-item[rel=smbDomain]').hide(); + + $form.find('.form-item[rel=iqn]').hide(); + $form.find('.form-item[rel=lun]').hide(); + + $form.find('.form-item[rel=volumegroup]').hide(); + + $form.find('.form-item[rel=vCenterDataCenter]').hide(); + $form.find('.form-item[rel=vCenterDataStore]').hide(); + + $form.find('.form-item[rel=rbdmonitor]').hide(); + $form.find('.form-item[rel=rbdpool]').hide(); + $form.find('.form-item[rel=rbdid]').hide(); + $form.find('.form-item[rel=rbdsecret]').hide(); + $form.find('.form-item[rel=glustervolume]').hide(); } else if (protocol == "iscsi") { $form.find('.form-item[rel=server]').css('display', 'inline-block'); @@ -15858,7 +15893,83 @@ }, isHidden: true }, - + provider: { + label: 'label.provider', + docID: 'helpPrimaryStorageZone', + validation: { + required: true + }, + select: function (args) { + var data = args.context.providers ? + { id: args.context.providers[0].id } : + { listAll: true }; + + $.ajax({ + url: createURL('listStorageProviders'), + data: { + type: 'primary' + }, + success: function (json) { + var providers = json.liststorageprovidersresponse.dataStoreProvider ? json.liststorageprovidersresponse.dataStoreProvider : []; + + args.response.success({ + data: $.map(providers, function (provider) { + return { + id: provider.name, + description: provider.name + }; + }) + }); + } + }); + args.$select.change(function () { + var $form = $(this).closest('form'); + var scope = $(this).val(); + + if (scope == 'DefaultPrimary') { + $form.find('.form-item[rel=isManaged]').hide(); + $form.find('.form-item[rel=capacityIops]').hide(); + $form.find('.form-item[rel=capacityBytes]').hide(); + $form.find('.form-item[rel=url]').hide(); + } else { + $form.find('.form-item[rel=isManaged]').css('display', 'inline-block'); + $form.find('.form-item[rel=capacityIops]').css('display', 'inline-block'); + $form.find('.form-item[rel=capacityBytes]').css('display', 'inline-block'); + $form.find('.form-item[rel=url]').css('display', 'inline-block'); + } + } + ) + }}, + isManaged: { + label: 'label.managed', + docID: 'helpManaged', + isBoolean: true, + isChecked: false, + validation: { + required: false + } + }, + capacityBytes: { + label: 'label.capacity.bytes', + docID: 'helpCapacityBytes', + validation: { + required: false + } + }, + capacityIops: { + label: 'label.capacity.iops', + docID: 'helpCapacityIops', + validation: { + required: false + } + }, + url: { + label: 'URL', + docID: 'helpUrl', + validation: { + required: false + } + }, //SMB smbUsername: { label: 'label.smb.username', @@ -15981,6 +16092,7 @@ } }, + /******************************/ action: function (args) { var array1 =[]; array1.push("&scope=" + todb(args.data.scope)); @@ -16003,74 +16115,103 @@ array1.push("&clusterid=" + args.data.clusterId); array1.push("&hostid=" + args.data.hostId); } - - array1.push("&name=" + todb(args.data.name)); - - var server = args.data.server; - var url = null; - if (args.data.protocol == "nfs") { - var path = args.data.path; - if (path.substring(0, 1) != "/") - path = "/" + path; - url = nfsURL(server, path); - } else if (args.data.protocol == "SMB") { - var path = args.data.path; - if (path.substring(0, 1) != "/") - path = "/" + path; - url = smbURL(server, path); - array1.push("&details[0].user=" + args.data.smbUsername); - array1.push("&details[1].password=" + todb(args.data.smbPassword)); - array1.push("&details[2].domain=" + args.data.smbDomain); - } else if (args.data.protocol == "PreSetup") { - var path = args.data.path; - if (path.substring(0, 1) != "/") - path = "/" + path; - url = presetupURL(server, path); - } else if (args.data.protocol == "ocfs2") { - var path = args.data.path; - if (path.substring(0, 1) != "/") - path = "/" + path; - url = ocfs2URL(server, path); - } else if (args.data.protocol == "SharedMountPoint") { - var path = args.data.path; - if (path.substring(0, 1) != "/") - path = "/" + path; - url = SharedMountPointURL(server, path); - } else if (args.data.protocol == "clvm") { - var vg = args.data.volumegroup; - if (vg.substring(0, 1) != "/") - vg = "/" + vg; - url = clvmURL(vg); - } else if (args.data.protocol == "rbd") { - var rbdmonitor = args.data.rbdmonitor; - var rbdpool = args.data.rbdpool; - var rbdid = args.data.rbdid; - var rbdsecret = args.data.rbdsecret; - url = rbdURL(rbdmonitor, rbdpool, rbdid, rbdsecret); - } else if (args.data.protocol == "vmfs") { - var path = args.data.vCenterDataCenter; - if (path.substring(0, 1) != "/") - path = "/" + path; - path += "/" + args.data.vCenterDataStore; - url = vmfsURL("dummy", path); - } else if (args.data.protocol == "gluster") { - var glustervolume = args.data.glustervolume; - if (glustervolume.substring(0, 1) != "/") - glustervolume = "/" + glustervolume; - url = glusterURL(server, glustervolume); - } else { - var iqn = args.data.iqn; - if (iqn.substring(0, 1) != "/") - iqn = "/" + iqn; - var lun = args.data.lun; - url = iscsiURL(server, iqn, lun); + array1.push("&name=" + todb(args.data.name)); + + array1.push("&provider=" + todb(args.data.provider)); + + if (args.data.provider == "DefaultPrimary") + { + var server = args.data.server; + var url = null; + if (args.data.protocol == "nfs") { + var path = args.data.path; + if (path.substring(0, 1) != "/") + path = "/" + path; + url = nfsURL(server, path); + } else if (args.data.protocol == "SMB") { + var path = args.data.path; + if (path.substring(0, 1) != "/") + path = "/" + path; + url = smbURL(server, path); + array1.push("&details[0].user=" + args.data.smbUsername); + array1.push("&details[1].password=" + todb(args.data.smbPassword)); + array1.push("&details[2].domain=" + args.data.smbDomain); + } else if (args.data.protocol == "PreSetup") { + var path = args.data.path; + if (path.substring(0, 1) != "/") + path = "/" + path; + url = presetupURL(server, path); + } else if (args.data.protocol == "ocfs2") { + var path = args.data.path; + if (path.substring(0, 1) != "/") + path = "/" + path; + url = ocfs2URL(server, path); + } else if (args.data.protocol == "SharedMountPoint") { + var path = args.data.path; + if (path.substring(0, 1) != "/") + path = "/" + path; + url = SharedMountPointURL(server, path); + } else if (args.data.protocol == "clvm") { + var vg = args.data.volumegroup; + if (vg.substring(0, 1) != "/") + vg = "/" + vg; + url = clvmURL(vg); + } else if (args.data.protocol == "rbd") { + var rbdmonitor = args.data.rbdmonitor; + var rbdpool = args.data.rbdpool; + var rbdid = args.data.rbdid; + var rbdsecret = args.data.rbdsecret; + url = rbdURL(rbdmonitor, rbdpool, rbdid, rbdsecret); + } else if (args.data.protocol == "vmfs") { + var path = args.data.vCenterDataCenter; + if (path.substring(0, 1) != "/") + path = "/" + path; + path += "/" + args.data.vCenterDataStore; + url = vmfsURL("dummy", path); + } else if (args.data.protocol == "gluster") { + var glustervolume = args.data.glustervolume; + + if (glustervolume.substring(0, 1) != "/") + glustervolume = "/" + glustervolume; + url = glusterURL(server, glustervolume); + } else if (args.data.protocol == "iscsi") { + var iqn = args.data.iqn; + if (iqn.substring(0, 1) != "/") + iqn = "/" + iqn; + var lun = args.data.lun; + url = iscsiURL(server, iqn, lun); + } else { + url = ""; + } + + array1.push("&url=" + todb(url)); } - array1.push("&url=" + todb(url)); - + else + { + array1.push("&managed=" + (args.data.isManaged == "on").toString()); + + if (args.data.capacityBytes != null && args.data.capacityBytes.length > 0) + { + array1.push("&capacityBytes=" + args.data.capacityBytes.split(",").join("")); + } + + if (args.data.capacityIops != null && args.data.capacityIops.length > 0) + { + array1.push("&capacityIops=" + args.data.capacityIops.split(",").join("")); + } + + if (args.data.url != null && args.data.url.length > 0) + { + array1.push("&url=" + todb(args.data.url)); + } + } + if (args.data.storageTags != null && args.data.storageTags.length > 0) - array1.push("&tags=" + todb(args.data.storageTags)); - + { + array1.push("&tags=" + todb(args.data.storageTags)); + } + $.ajax({ url: createURL("createStoragePool" + array1.join("")), dataType: "json", @@ -17899,7 +18040,7 @@ label: 'label.url' }, providername: { - label: 'Provider' + label: 'label.provider' }, scope: { label: 'label.scope'