Adding GUI plug-in for root admins to control infrastructure for shared volumes
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/be5f7da9 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/be5f7da9 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/be5f7da9 Branch: refs/heads/sf-plugins Commit: be5f7da964bc2527fd87b8c15b0d654b1aaaafef Parents: 756c5ce Author: Mike Tutkowski <[email protected]> Authored: Wed Jul 15 18:20:37 2015 -0600 Committer: Mike Tutkowski <[email protected]> Committed: Fri Sep 18 19:28:21 2015 -0600 ---------------------------------------------------------------------- ui/plugins/plugins.js | 3 +- ui/plugins/sfAdministration/config.js | 9 + ui/plugins/sfAdministration/icon.png | Bin 0 -> 7943 bytes ui/plugins/sfAdministration/sfAdministration.js | 284 +++++++++++++++++++ 4 files changed, 295 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5f7da9/ui/plugins/plugins.js ---------------------------------------------------------------------- diff --git a/ui/plugins/plugins.js b/ui/plugins/plugins.js index 6e5557f..d115eef 100644 --- a/ui/plugins/plugins.js +++ b/ui/plugins/plugins.js @@ -17,6 +17,7 @@ (function($, cloudStack) { cloudStack.plugins = [ // 'testPlugin', - // 'sfSharedVolume' + // 'sfSharedVolume', + // 'sfAdministration' ]; }(jQuery, cloudStack)); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5f7da9/ui/plugins/sfAdministration/config.js ---------------------------------------------------------------------- diff --git a/ui/plugins/sfAdministration/config.js b/ui/plugins/sfAdministration/config.js new file mode 100644 index 0000000..7e8bb61 --- /dev/null +++ b/ui/plugins/sfAdministration/config.js @@ -0,0 +1,9 @@ +(function (cloudStack) { + cloudStack.plugins.sfSharedVolume.config = { + title: 'SolidFire Administration', + desc: 'SolidFire Administration', + externalLink: 'http://www.solidfire.com/', + authorName: 'Mike Tutkowski', + authorEmail: '[email protected]' + }; +}(cloudStack)); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5f7da9/ui/plugins/sfAdministration/icon.png ---------------------------------------------------------------------- diff --git a/ui/plugins/sfAdministration/icon.png b/ui/plugins/sfAdministration/icon.png new file mode 100644 index 0000000..a313d35 Binary files /dev/null and b/ui/plugins/sfAdministration/icon.png differ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5f7da9/ui/plugins/sfAdministration/sfAdministration.js ---------------------------------------------------------------------- diff --git a/ui/plugins/sfAdministration/sfAdministration.js b/ui/plugins/sfAdministration/sfAdministration.js new file mode 100644 index 0000000..c836576 --- /dev/null +++ b/ui/plugins/sfAdministration/sfAdministration.js @@ -0,0 +1,284 @@ +(function (cloudStack) { + cloudStack.plugins.sfAdministration = function(plugin) { + plugin.ui.addSection({ + id: 'sfAdministration', + title: 'sfAdministration', + preFilter: function(args) { + return isAdmin(); + }, + listView: { + id: 'sfAdministration', + fields: { + name: { label: 'label.name' }, + iqn: { label: 'MVIP' }, + size: { label: 'Username' }, + miniops: { label: 'label.zone' } + }, + dataProvider: function(args) { + plugin.ui.apiCall('listSolidFireClusters', { + success: function(json) { + var sfclustersfiltered = []; + var sfclusters = json.listsolidfireclustersresponse.sfcluster; + var search = args.filterBy.search.value == null ? "" : args.filterBy.search.value.toLowerCase(); + + if (search == "") { + sfclustersfiltered = sfclusters; + } + else { + for (i = 0; i < sfclusters.length; i++) { + sfcluster = sfclusters[i]; + + if (sfcluster.name.toLowerCase().indexOf(search) > -1 ) { + sfclustersfiltered.push(sfcluster); + } + } + } + + args.response.success({ data: sfclustersfiltered }); + }, + error: function(errorMessage) { + args.response.error(errorMessage); + } + }); + }, + actions: { + add: { + label: 'Add Reference to Cluster', + preFilter: function(args) { + return true; + }, + messages: { + confirm: function(args) { + return 'Please fill in the following data to add a new reference to a cluster.'; + }, + notification: function(args) { + return 'Add Reference to Cluster'; + } + }, + createForm: { + title: 'Add Reference to Cluster', + desc: 'Please fill in the following data to add a new reference to a cluster.', + fields: { + mvip: { + label: 'MVIP', + validation: { + required: true + } + }, + username: { + label: 'label.username', + docID: 'helpUserUsername', + validation: { + required: true + } + }, + password: { + label: 'label.password', + docID: 'helpUserPassword', + isPassword: true, + validation: { + required: true + } + }, + totalCapacity: { + label: 'Total Capacity', + validation: { + required: true, + number: true + } + }, + totalMinIops: { + label: 'Total Min IOPS', + validation: { + required: true, + number: true + } + }, + totalMaxIops: { + label: 'Total Max IOPS', + validation: { + required: true, + number: true + } + }, + totalBurstIops: { + label: 'Total Burst IOPS', + validation: { + required: true, + number: true + } + }, + availabilityZone: { + label: 'label.availability.zone', + docID: 'helpVolumeAvailabilityZone', + validation: { + required: true + }, + select: function(args) { + $.ajax({ + url: createURL("listZones&available=true"), + dataType: "json", + async: true, + success: function(json) { + var zoneObjs = json.listzonesresponse.zone; + + args.response.success({ + descriptionField: 'name', + data: zoneObjs + }); + } + }); + } + } + } + }, + action: function(args) { + var data = { + mvip: args.data.mvip, + username: args.data.username, + password: args.data.password, + totalcapacity: args.data.totalcapacity, + totalminiops: args.data.totalminiops, + totalmaxiops: args.data.totalmaxiops, + totalburstiops: args.data.totalburstiops, + availabilityzone: args.data.availabilityzone + }; + + $.ajax({ + url: createURL('createReferenceToSolidFireCluster'), + data: data, + success: function(json) { + var sfclusterObj = json.createreferencetosolidfireclusterresponse.apicreatereferencetosolidfirecluster; + + args.response.success({ + data: sfclusterObj + }); + }, + error: function(json) { + args.response.error(parseXMLHttpResponse(json)); + } + }); + } + } + }, + detailView: { + name: 'label.details', + actions: { + edit: { + label: 'label.edit', + messages: { + notification: function(args) { + return 'Edit Cluster'; + } + }, + action: function (args) { + var params = []; + + params.push("&name=" + args.context.sfClusters[0].name); + params.push("&totalcapacity=" + args.data.totalcapacity); + params.push("&totalminiops=" + args.data.totalminiops); + params.push("&totalmaxiops=" + args.data.totalmaxiops); + params.push("&totalburstiops=" + args.data.totalburstiops); + + $.ajax({ + url: createURL('updateReferenceToSolidFireCluster' + params.join("")), + success: function(json) { + var sfclusterObj = json.updatereferencetosolidfireclusterresponse.apiupdatereferencetosolidfirecluster; + + args.response.success({ + data: sfclusterObj + }); + }, + error: function(json) { + args.response.error(parseXMLHttpResponse(json)); + } + }); + } + }, + remove: { + label: 'Delete Reference to Cluster', + messages: { + confirm: function(args) { + return 'Are you sure you would like to delete this reference to a SolidFire cluster?'; + }, + notification: function(args) { + return 'Delete Reference to Cluster'; + } + }, + action: function(args) { + $.ajax({ + url: createURL('deleteReferenceToSolidFireCluster&name=' + args.context.sfSharedVolumes[0].name), + success: function(json) { + args.response.success(); + }, + error: function(json) { + args.response.error(parseXMLHttpResponse(json)); + } + }); + } + } + }, + tabs: { + details: { + title: 'label.details', + preFilter: function(args) { + return []; + }, + fields: [ + { + name: { + label: 'label.name' + } + }, + { + uuid: { + label: 'label.id' + }, + mvip: { + label: 'MVIP' + }, + username: { + label: 'Username' + }, + totalcapacity: { + label: 'Total Capacity', + isEditable: true + }, + miniops: { + label: 'Total Min IOPS', + isEditable: true + }, + maxiops: { + label: 'Total Max IOPS', + isEditable: true + }, + burstiops: { + label: 'Total Burst IOPS', + isEditable: true + }, + zone: { + label: 'Zone' + } + } + ], + dataProvider: function(args) { + $.ajax({ + url: createURL("listSolidFireClusters&name=" + args.context.sfClusters[0].name), + dataType: "json", + async: true, + success: function(json) { + var jsonObj = json.listsolidfireclustersresponse.sfcluster[0]; + + args.response.success({ + data: jsonObj + }); + } + }); + } + } + } + } + } + }); + }; +}(cloudStack)); \ No newline at end of file
