diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 0e051f1dd8e..ad8f42b0e78 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -14,7 +14,16 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. - +label.add.affinity.group=Add new affinity group +message.delete.affinity.group=Please confirm that you would like to remove this affinity group. +label.delete.affinity.group=Delete Affinity Group +label.edit.affinity.group=Edit Affinity Group +label.affinity=Affinity +label.anti.affinity=Anti-affinity +label.affinity.groups=Affinity Groups +label.anti.affinity.groups=Anti-affinity Groups +label.affinity.group=Affinity Group +label.anti.affinity.group=Anti-affinity Group changed.item.properties=Changed item properties confirm.enable.s3=Please fill in the following information to enable support for S3-backed Secondary Storage confirm.enable.swift=Please fill in the following information to enable support for Swift diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index 85f7dff433d..340b089c4e6 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -1502,7 +1502,6 @@ div.list-view td.state.off span { position: relative; left: 0px; float: left; - width: 460px; height: 22px; border-top: 1px solid #808080; /*+box-shadow:inset 0px 1px #FFFFFF;*/ @@ -1907,7 +1906,7 @@ div.detail-group td.view-all a { background: url(../images/gradients.png) repeat-x 0px -529px; font-size: 11px; display: block; - height: 25px; + height: 27px; text-decoration: none; color: #4C5D6C; /*+text-shadow:0px 1px 2px #FFFFFF;*/ @@ -1916,7 +1915,7 @@ div.detail-group td.view-all a { -o-text-shadow: 0px 1px 2px #FFFFFF; text-shadow: 0px 1px 2px #FFFFFF; float: left; - padding: 0 8px 0 5px; + padding: 0 1px; border-left: 1px solid #9B9EA2; /*+border-radius:5px 0 0 5px;*/ -moz-border-radius: 5px 0 0 5px; @@ -1971,10 +1970,10 @@ div.details .main-groups label.error { } .detail-view td.view-all.multiple { - width: 123px !important; - height: 22px; - float: left; + max-width: 145px; + height: 17px; display: block; + float: left; margin: 8px 2px 8px 8px; border: none !important; /*+box-shadow:none;*/ @@ -5265,6 +5264,10 @@ label.error { position: relative; } +.multi-wizard.instance-wizard .progress ul li { + width: 109px; +} + .multi-wizard .progress ul li.first { /*+border-radius:5px 0 0 5px;*/ -moz-border-radius: 5px 0 0 5px; @@ -5306,6 +5309,10 @@ label.error { text-align: center; } +.multi-wizard.instance-wizard .progress ul li span { + left: 36px; +} + .multi-wizard .progress ul li span.multiline { width: 71px; top: 12px; @@ -5322,6 +5329,10 @@ label.error { z-index: 1000; } +.multi-wizard.instance-wizard .progress ul li span.arrow { + left: 27px; +} + .multi-wizard .progress ul li.active span.arrow { background-position: -1px -396px; } @@ -5342,6 +5353,15 @@ label.error { background: transparent; } +.multi-wizard.instance-wizard .progress ul li span.number { + left: 16px; +} + +.multi-wizard.instance-wizard .progress ul li span.multiline { + width: 79px; + left: 23px; +} + .multi-wizard .progress ul li.active span { /*+text-shadow:0px -1px 1px #004AFF;*/ -moz-text-shadow: 0px -1px 1px #004AFF; @@ -11670,7 +11690,6 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it background-position: 0px -707px; } - .attach .icon, .attachISO .icon, .attachDisk .icon { @@ -11854,16 +11873,13 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it } .removeVlanRange .icon { - background-position: 1px -92px; } -.removeVlanRange:hover .icon{ - +.removeVlanRange:hover .icon { background-position: 1px -92px; } - .resize .icon, .updateResourceCount .icon { background-position: -167px -66px; @@ -11893,9 +11909,8 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it background-position: -168px -31px; } -.scaleUp .icon{ - background-position: -167px -66px; - +.scaleUp .icon { + background-position: -167px -66px; } .restoreVM:hover .icon, @@ -12027,6 +12042,30 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it background-position: -228px -646px; } +.changeAffinity .icon { + background-position: -264px -2px; +} + +.changeAffinity:hover .icon { + background-position: -263px -583px; +} + +.releaseFromAccount .icon { + background-position: -230px -123px; +} + +.releaseFromAccount:hover .icon { + background-position: -229px -704px; +} + +.addAccount .icon { + background-position: -231px -96px; +} + +.addAccount:hover .icon { + background-position: -230px -677px; +} + .label-hovered { cursor: pointer; color: #0000FF !important; diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index 11e98cf5024..1880be53e7e 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -25,6 +25,16 @@ under the License. <% long now = System.currentTimeMillis(); %> + + diff --git a/ui/scripts/affinity.js b/ui/scripts/affinity.js new file mode 100644 index 00000000000..a9c66957ad5 --- /dev/null +++ b/ui/scripts/affinity.js @@ -0,0 +1,183 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +(function(cloudStack) { + cloudStack.sections.affinityGroups = { + title: 'label.affinity.groups', + listView: { + id: 'affinityGroups', + fields: { + name: { label: 'label.name' }, + type: { label: 'label.type' } + }, + dataProvider: function(args) { + var data = {}; + if (args.context != null) { + if ("instances" in args.context) { + $.extend(data, { + virtualmachineid: args.context.instances[0].id + }); + } + } + $.ajax({ + url: createURL('listAffinityGroups'), + data: data, + success: function(json) { + var items = json.listaffinitygroupsresponse.affinitygroup; + args.response.success({data: items}); + } + }); + }, + actions: { + add: { + label: 'label.add.affinity.group', + + messages: { + notification: function(args) { + return 'label.add.affinity.group'; + } + }, + + createForm: { + title: 'label.add.affinity.group', + fields: { + name: { + label: 'label.name', + validation: { required: true } + }, + description: { + label: 'label.description' + }, + type: { + label: 'label.type', + select: function(args) { + $.ajax({ + url: createURL('listAffinityGroupTypes'), + success: function(json) { + var types = []; + var items = json.listaffinitygrouptypesresponse.affinityGroupType; + if(items != null) { + for(var i = 0; i < items.length; i++) { + types.push({id: items[i].type, description: items[i].type}); + } + } + args.response.success({data: types}) + } + }); + } + } + } + }, + + action: function(args) { + var data = { + name: args.data.name, + type: args.data.type + }; + if(args.data.description != null && args.data.description.length > 0) + $.extend(data, {description: args.data.description}); + + $.ajax({ + url: createURL('createAffinityGroup'), + data: data, + success: function(json) { + var jid = json.createaffinitygroupresponse.jobid; + args.response.success( + {_custom: + {jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.affinitygroup; + } + } + } + ); + } + }); + }, + + notification: { + poll: pollAsyncJobResult + } + } + }, + detailView: { + actions: { + remove: { + label: 'label.delete.affinity.group', + messages: { + confirm: function(args) { + return 'message.delete.affinity.group'; + }, + notification: function(args) { + return 'label.delete.affinity.group'; + } + }, + action: function(args) { + $.ajax({ + url: createURL('deleteAffinityGroup'), + data: { + id: args.context.affinityGroups[0].id + }, + success: function(json) { + var jid = json.deleteaffinitygroupresponse.jobid; + args.response.success({ + _custom:{ + jobId: jid + } + }); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + } + }, + + viewAll: { path: 'instances', label: 'label.instances' }, + + tabs: { + details: { + title: 'label.details', + fields: [ + { + name: { label: 'label.name' } + }, + { + description: { label: 'label.description' }, + type: { label: 'label.type' }, + id: { label: 'label.id' } + } + ], + + dataProvider: function(args) { + $.ajax({ + url: createURL('listAffinityGroups'), + data: { + id: args.context.affinityGroups[0].id + }, + success: function(json) { + var item = json.listaffinitygroupsresponse.affinitygroup[0]; + args.response.success({data: item}); + } + }); + } + } + } + } + } + }; +})(cloudStack); diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js index 35969a27251..b943a946c8f 100644 --- a/ui/scripts/cloudStack.js +++ b/ui/scripts/cloudStack.js @@ -22,16 +22,16 @@ var sections = []; if(isAdmin()) { - sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "system", "global-settings", "configuration", "projects", "regions"]; + sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "system", "global-settings", "configuration", "projects", "regions", "affinityGroups"]; } else if(isDomainAdmin()) { - sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "projects", "regions"]; + sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "projects", "regions", "affinityGroups"]; } else if (g_userProjectsEnabled) { - sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "events", "projects", "regions"]; + sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "events", "projects", "regions", "affinityGroups"]; } else { //normal user - sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "events", "regions"]; + sections = ["dashboard", "instances", "storage", "network", "templates", "accounts", "events", "regions", "affinityGroups"]; } if (cloudStack.plugins.length) { @@ -46,6 +46,7 @@ */ dashboard: {}, instances: {}, + affinityGroups: {}, storage: {}, network: {}, templates: {}, diff --git a/ui/scripts/instanceWizard.js b/ui/scripts/instanceWizard.js index 13828c848b6..f3deb66d6ba 100644 --- a/ui/scripts/instanceWizard.js +++ b/ui/scripts/instanceWizard.js @@ -18,7 +18,7 @@ (function($, cloudStack) { var zoneObjs, hypervisorObjs, featuredTemplateObjs, communityTemplateObjs, myTemplateObjs, featuredIsoObjs, community, networkObjs; var selectedZoneObj, selectedTemplateObj, selectedHypervisor, selectedDiskOfferingObj; - var step5ContainerType = 'nothing-to-select'; //'nothing-to-select', 'select-network', 'select-security-group', 'select-advanced-sg'(advanced sg-enabled zone) + var step6ContainerType = 'nothing-to-select'; //'nothing-to-select', 'select-network', 'select-security-group', 'select-advanced-sg'(advanced sg-enabled zone) cloudStack.instanceWizard = { maxDiskOfferingSize: function() { @@ -68,492 +68,485 @@ // Data providers for each wizard step steps: [ - - // Step 1: Setup - function(args) { - if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart (VPC is only available in Advanced zone) - if(args.context.zoneType == 'Basic'){ //Basic type - zoneObjs = []; + // Step 1: Setup + function(args) { + if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart + //populate only one zone to the dropdown, the zone which the VPC is under. + zoneObjs = [{ + id: args.context.vpc[0].zoneid, + name: args.context.vpc[0].zonename, + networktype: 'Advanced' + }]; + args.response.success({ data: {zones: zoneObjs}}); + } + else { //from Instance page + $.ajax({ + url: createURL("listZones&available=true"), + dataType: "json", + async: false, + success: function(json) { + zoneObjs = json.listzonesresponse.zone; + args.response.success({ data: {zones: zoneObjs}}); + } + }); + } + }, + + // Step 2: Select template + function(args) { + $(zoneObjs).each(function(){ + if(this.id == args.currentData.zoneid) { + selectedZoneObj = this; + return false; //break the $.each() loop + } + }); + if(selectedZoneObj == null) { + alert("error: can't find matched zone object"); + return; } - else { //Advanced type or all types - //populate only one zone to the dropdown, the zone which the VPC is under. (networktype should be 'Advanced' since VPC is only available in Advanced zone) - zoneObjs = [{ - id: args.context.vpc[0].zoneid, - name: args.context.vpc[0].zonename, - networktype: 'Advanced' - }]; - } - args.response.success({ data: {zones: zoneObjs}}); - } - else { //from Instance page - $.ajax({ - url: createURL("listZones&available=true"), - dataType: "json", - async: false, - success: function(json) { - if(args.context.zoneType == null || args.context.zoneType == '') { //all types - zoneObjs = json.listzonesresponse.zone; + + $.ajax({ + url: createURL("listHypervisors&zoneid="+args.currentData.zoneid), + dataType: "json", + async: false, + success: function(json) { + hypervisorObjs = json.listhypervisorsresponse.hypervisor; + } + }); + + //***** get templates/ISOs (begin) ***** + var selectedTemplate = args.currentData['select-template']; + if (selectedTemplate == 'select-template') { + var hypervisorArray = []; + $(hypervisorObjs).each(function(index, item) { + hypervisorArray.push(item.name); + }); + + $.ajax({ + url: createURL("listTemplates&templatefilter=featured&zoneid="+args.currentData.zoneid), + dataType: "json", + async: false, + success: function(json) { + if(json.listtemplatesresponse.template == null) { + featuredTemplateObjs = null; + } + else { + featuredTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); + } } - else { //Basic type or Advanced type - zoneObjs = []; - var items = json.listzonesresponse.zone; - if(items != null) { - for(var i = 0; i < items.length; i++) { - if(items[i].networktype == args.context.zoneType) - zoneObjs.push(items[i]); - } - } - } - args.response.success({ data: {zones: zoneObjs}}); - } - }); - } - }, - - // Step 2: Select template - function(args) { - $(zoneObjs).each(function(){ - if(this.id == args.currentData.zoneid) { - selectedZoneObj = this; - return false; //break the $.each() loop - } - }); - if(selectedZoneObj == null) { - alert("error: can't find matched zone object"); - return; - } - - $.ajax({ - url: createURL("listHypervisors&zoneid="+args.currentData.zoneid), - dataType: "json", - async: false, - success: function(json) { - hypervisorObjs = json.listhypervisorsresponse.hypervisor; - } - }); - - //***** get templates/ISOs (begin) ***** - var selectedTemplate = args.currentData['select-template']; - if (selectedTemplate == 'select-template') { - var hypervisorArray = []; - $(hypervisorObjs).each(function(index, item) { - hypervisorArray.push(item.name); - }); - - $.ajax({ - url: createURL("listTemplates&templatefilter=featured&zoneid="+args.currentData.zoneid), - dataType: "json", - async: false, - success: function(json) { - if(json.listtemplatesresponse.template == null) { - featuredTemplateObjs = null; - } - else { - featuredTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { - if($.inArray(item.hypervisor, hypervisorArray) > -1) - return true; - }); - } - } - }); - $.ajax({ - url: createURL("listTemplates&templatefilter=community&zoneid="+args.currentData.zoneid), - dataType: "json", - async: false, - success: function(json) { - if(json.listtemplatesresponse.template == null) { - communityTemplateObjs = null; - } - else { - communityTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { - if($.inArray(item.hypervisor, hypervisorArray) > -1) - return true; - }); - } - } - }); - $.ajax({ - url: createURL("listTemplates&templatefilter=selfexecutable&zoneid="+args.currentData.zoneid), - dataType: "json", - async: false, - success: function(json) { - if(json.listtemplatesresponse.template == null) { - myTemplateObjs = null; - } - else { - myTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { - if($.inArray(item.hypervisor, hypervisorArray) > -1) - return true; - }); - } - } - }); - } else if (selectedTemplate == 'select-iso') { - $.ajax({ - url: createURL("listIsos&isofilter=featured&zoneid=" + args.currentData.zoneid + "&bootable=true"), - dataType: "json", - async: false, - success: function(json) { - if(json.listisosresponse.iso == null) { - featuredIsoObjs = null; - } - else { - featuredIsoObjs = json.listisosresponse.iso; - } - } - }); - $.ajax({ - url: createURL("listIsos&isofilter=community&zoneid=" + args.currentData.zoneid + "&bootable=true"), - dataType: "json", - async: false, - success: function(json) { - if(json.listisosresponse.iso == null) { - communityIsoObjs = null; - } - else { - communityIsoObjs = json.listisosresponse.iso; - } - } - }); - $.ajax({ - url: createURL("listIsos&isofilter=selfexecutable&zoneid=" + args.currentData.zoneid + "&bootable=true"), - dataType: "json", - async: false, - success: function(json) { - if(json.listisosresponse.iso == null) { - myIsoObjs = null; - } - else { - myIsoObjs = json.listisosresponse.iso; - } - } - }); - } - //***** get templates/ISOs (end) ***** - - - var templatesObj = {}; - if (selectedTemplate == 'select-template') { - templatesObj = { - featuredtemplates: featuredTemplateObjs, - communitytemplates: communityTemplateObjs, - mytemplates: myTemplateObjs - } - } else if (selectedTemplate == 'select-iso') { - templatesObj = { - featuredisos: featuredIsoObjs, - communityisos: communityIsoObjs, - myisos: myIsoObjs - } - } - args.response.success({ - hypervisor: { - idField: 'name', - nameField: 'name' - }, - data: { - templates: templatesObj, - hypervisors: hypervisorObjs - } - }); - }, - - // Step 3: Service offering - function(args) { - if(args.currentData["select-template"] == "select-template") { - if(featuredTemplateObjs != null && featuredTemplateObjs.length > 0) { - for(var i=0; i < featuredTemplateObjs.length; i++) { - if(featuredTemplateObjs[i].id == args.currentData.templateid) { - selectedTemplateObj = featuredTemplateObjs[i]; - break; + }); + $.ajax({ + url: createURL("listTemplates&templatefilter=community&zoneid="+args.currentData.zoneid), + dataType: "json", + async: false, + success: function(json) { + if(json.listtemplatesresponse.template == null) { + communityTemplateObjs = null; + } + else { + communityTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); + } } + }); + $.ajax({ + url: createURL("listTemplates&templatefilter=selfexecutable&zoneid="+args.currentData.zoneid), + dataType: "json", + async: false, + success: function(json) { + if(json.listtemplatesresponse.template == null) { + myTemplateObjs = null; + } + else { + myTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); + } + } + }); + } else if (selectedTemplate == 'select-iso') { + $.ajax({ + url: createURL("listIsos&isofilter=featured&zoneid=" + args.currentData.zoneid + "&bootable=true"), + dataType: "json", + async: false, + success: function(json) { + if(json.listisosresponse.iso == null) { + featuredIsoObjs = null; + } + else { + featuredIsoObjs = json.listisosresponse.iso; + } + } + }); + $.ajax({ + url: createURL("listIsos&isofilter=community&zoneid=" + args.currentData.zoneid + "&bootable=true"), + dataType: "json", + async: false, + success: function(json) { + if(json.listisosresponse.iso == null) { + communityIsoObjs = null; + } + else { + communityIsoObjs = json.listisosresponse.iso; + } + } + }); + $.ajax({ + url: createURL("listIsos&isofilter=selfexecutable&zoneid=" + args.currentData.zoneid + "&bootable=true"), + dataType: "json", + async: false, + success: function(json) { + if(json.listisosresponse.iso == null) { + myIsoObjs = null; + } + else { + myIsoObjs = json.listisosresponse.iso; + } + } + }); + } + //***** get templates/ISOs (end) ***** + + + var templatesObj = {}; + if (selectedTemplate == 'select-template') { + templatesObj = { + featuredtemplates: featuredTemplateObjs, + communitytemplates: communityTemplateObjs, + mytemplates: myTemplateObjs + } + } else if (selectedTemplate == 'select-iso') { + templatesObj = { + featuredisos: featuredIsoObjs, + communityisos: communityIsoObjs, + myisos: myIsoObjs } } - if(selectedTemplateObj == null) { - if(communityTemplateObjs != null && communityTemplateObjs.length > 0) { - for(var i=0; i < communityTemplateObjs.length; i++) { - if(communityTemplateObjs[i].id == args.currentData.templateid) { - selectedTemplateObj = communityTemplateObjs[i]; + args.response.success({ + hypervisor: { + idField: 'name', + nameField: 'name' + }, + data: { + templates: templatesObj, + hypervisors: hypervisorObjs + } + }); + }, + + // Step 3: Service offering + function(args) { + if(args.currentData["select-template"] == "select-template") { + if(featuredTemplateObjs != null && featuredTemplateObjs.length > 0) { + for(var i=0; i < featuredTemplateObjs.length; i++) { + if(featuredTemplateObjs[i].id == args.currentData.templateid) { + selectedTemplateObj = featuredTemplateObjs[i]; break; } } } - } - if(selectedTemplateObj == null) { - if(myTemplateObjs != null && myTemplateObjs.length > 0) { - for(var i=0; i < myTemplateObjs.length; i++) { - if(myTemplateObjs[i].id == args.currentData.templateid) { - selectedTemplateObj = myTemplateObjs[i]; - break; - } - } - } - } - if(selectedTemplateObj == null) - alert("unable to find matched template object"); - else - selectedHypervisor = selectedTemplateObj.hypervisor; - } - else { //(args.currentData["select-template"] == "select-iso" - selectedHypervisor = args.currentData.hypervisorid; - } - - $.ajax({ - url: createURL("listServiceOfferings&issystem=false"), - dataType: "json", - async: true, - success: function(json) { - serviceOfferingObjs = json.listserviceofferingsresponse.serviceoffering; - args.response.success({ - data: {serviceOfferings: serviceOfferingObjs} - }); - } - }); - }, - - // Step 4: Data disk offering - function(args) { - var isRequred = (args.currentData["select-template"] == "select-iso"? true: false); - $.ajax({ - url: createURL("listDiskOfferings"), - dataType: "json", - async: true, - success: function(json) { - diskOfferingObjs = json.listdiskofferingsresponse.diskoffering; - args.response.success({ - required: isRequred, - customFlag: 'iscustomized', // Field determines if custom slider is shown - data: {diskOfferings: diskOfferingObjs} - }); - } - }); - }, - - // Step 5: Network - function(args) { - if(diskOfferingObjs != null && diskOfferingObjs.length > 0) { - for(var i=0; i < diskOfferingObjs.length; i++) { - if(diskOfferingObjs[i].id == args.currentData.diskofferingid) { - selectedDiskOfferingObj = diskOfferingObjs[i]; - break; - } - } - } - - if (selectedZoneObj.networktype == "Advanced") { //Advanced zone. Show network list. - var $networkStep = $(".step.network:visible .nothing-to-select"); - var $networkStepContainer = $('.step.network:visible'); - - if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart - step5ContainerType = 'nothing-to-select'; - $networkStep.find("#from_instance_page_1").hide(); - $networkStep.find("#from_instance_page_2").hide(); - $networkStep.find("#from_vpc_tier").text("tier " + args.context.networks[0].name); - $networkStep.find("#from_vpc_tier").show(); - } else { //from Instance page - if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone - step5ContainerType = 'select-network'; - $networkStep.find("#from_instance_page_1").show(); - $networkStep.find("#from_instance_page_2").show(); - $networkStep.find("#from_vpc_tier").text(""); - $networkStep.find("#from_vpc_tier").hide(); - $networkStepContainer.removeClass('next-use-security-groups'); - } else { // Advanced SG-enabled zone - step5ContainerType = 'select-advanced-sg'; - } - - if ($networkStepContainer.hasClass('next-use-security-groups')) { - $networkStepContainer.removeClass('repeat next-use-security-groups loaded'); - step5ContainerType = 'select-security-group'; - } - } - } - else { //Basic zone. Show securigy group list or nothing(when no SecurityGroup service in guest network) - var includingSecurityGroupService = false; - $.ajax({ - url: createURL("listNetworks&trafficType=Guest&zoneId=" + selectedZoneObj.id), - dataType: "json", - async: false, - success: function(json) { - //basic zone should have only one guest network returned in this API call - var items = json.listnetworksresponse.network; - if(items != null && items.length > 0) { - var networkObj = items[0]; //basic zone has only one guest network - var serviceObjArray = networkObj.service; - for(var k = 0; k < serviceObjArray.length; k++) { - if(serviceObjArray[k].name == "SecurityGroup") { - includingSecurityGroupService = true; + if(selectedTemplateObj == null) { + if(communityTemplateObjs != null && communityTemplateObjs.length > 0) { + for(var i=0; i < communityTemplateObjs.length; i++) { + if(communityTemplateObjs[i].id == args.currentData.templateid) { + selectedTemplateObj = communityTemplateObjs[i]; break; } } } } - }); - - if(includingSecurityGroupService == false || selectedHypervisor == "VMware") { - step5ContainerType = 'nothing-to-select'; - } - else { - step5ContainerType = 'select-security-group'; - } - } - - //step5ContainerType = 'nothing-to-select'; //for testing only, comment it out before checking in - if(step5ContainerType == 'select-network' || step5ContainerType == 'select-advanced-sg') { - var defaultNetworkArray = [], optionalNetworkArray = []; - var networkData = { - zoneId: args.currentData.zoneid, - canusefordeploy: true - }; - - if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) { - $.extend(networkData, { - type: 'Shared' - }); - } - - if (!(cloudStack.context.projects && cloudStack.context.projects[0])) { - networkData.domainid = g_domainid; - networkData.account = g_account; - } - - var vpcObjs; - - //listVPCs without account/domainid/listAll parameter will return only VPCs belonging to the current login. That's what should happen in Instances page's VM Wizard. - //i.e. If the current login is root-admin, do not show VPCs belonging to regular-user/domain-admin in Instances page's VM Wizard. - $.ajax({ - url: createURL('listVPCs'), - async: false, - success: function(json) { - vpcObjs = json.listvpcsresponse.vpc ? json.listvpcsresponse.vpc : []; - } - }); - - var networkObjsToPopulate = []; - $.ajax({ - url: createURL('listNetworks'), - data: networkData, - async: false, - success: function(json) { - networkObjs = json.listnetworksresponse.network ? json.listnetworksresponse.network : []; - if(networkObjs.length > 0) { - for(var i = 0; i < networkObjs.length; i++) { - var networkObj = networkObjs[i]; - var includingSecurityGroup = false; - var serviceObjArray = networkObj.service; - for(var k = 0; k < serviceObjArray.length; k++) { - if(serviceObjArray[k].name == "SecurityGroup") { - networkObjs[i].type = networkObjs[i].type + ' (sg)'; - includingSecurityGroup = true; - break; - } - } - - if (networkObj.vpcid) { - networkObj._singleSelect = true; + if(selectedTemplateObj == null) { + if(myTemplateObjs != null && myTemplateObjs.length > 0) { + for(var i=0; i < myTemplateObjs.length; i++) { + if(myTemplateObjs[i].id == args.currentData.templateid) { + selectedTemplateObj = myTemplateObjs[i]; + break; } - - //for Advanced SG-enabled zone, list only SG network offerings - if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) { - if(includingSecurityGroup == false) - continue; //skip to next network offering - } - networkObjsToPopulate.push(networkObj); - } - } - } - }); - - $.ajax({ - url: createURL("listNetworkOfferings"), - dataType: "json", - data: { - forvpc: false, - zoneid: args.currentData.zoneid, - guestiptype: 'Isolated', - supportedServices: 'SourceNat', - specifyvlan: false, - state: 'Enabled' - }, - async: false, - success: function(json) { - networkOfferingObjs = json.listnetworkofferingsresponse.networkoffering; - } - }); - //get network offerings (end) *** - - $networkStepContainer.removeClass('repeat next-use-security-groups'); - - if (step5ContainerType == 'select-advanced-sg') { - $networkStepContainer.addClass('repeat next-use-security-groups'); - - // Add guest network is disabled - $networkStepContainer.find('.select-network').addClass('no-add-network'); - } else { - $networkStepContainer.find('.select-network').removeClass('no-add-network'); - } - - args.response.success({ - type: 'select-network', - data: { - networkObjs: networkObjsToPopulate, - securityGroups: [], - networkOfferings: networkOfferingObjs, - vpcs: vpcObjs - } - }); - } - - else if(step5ContainerType == 'select-security-group') { - var securityGroupArray = []; - var data = { - domainid: g_domainid, - account: g_account - }; - - $.ajax({ - url: createURL("listSecurityGroups"), - dataType: "json", - async: false, - data: cloudStack.context.projects ? {} : data, - success: function(json) { - var items = json.listsecuritygroupsresponse.securitygroup; - if (items != null && items.length > 0) { - for (var i = 0; i < items.length; i++) { - securityGroupArray.push(items[i]); } } } - }); - args.response.success({ - type: 'select-security-group', - data: { - networkObjs: [], - securityGroups: securityGroupArray, - networkOfferings: [], - vpcs: [] + if(selectedTemplateObj == null) + alert("unable to find matched template object"); + else + selectedHypervisor = selectedTemplateObj.hypervisor; + } + else { //(args.currentData["select-template"] == "select-iso" + selectedHypervisor = args.currentData.hypervisorid; + } + + $.ajax({ + url: createURL("listServiceOfferings&issystem=false"), + dataType: "json", + async: true, + success: function(json) { + serviceOfferingObjs = json.listserviceofferingsresponse.serviceoffering; + args.response.success({ + data: {serviceOfferings: serviceOfferingObjs} + }); } }); - } + }, - else if(step5ContainerType == 'nothing-to-select') { - args.response.success({ - type: 'nothing-to-select', - data: { - networkObjs: [], - securityGroups: [], - networkOfferings: [], - vpcs: [] + // Step 4: Data disk offering + function(args) { + var isRequred = (args.currentData["select-template"] == "select-iso"? true: false); + $.ajax({ + url: createURL("listDiskOfferings"), + dataType: "json", + async: true, + success: function(json) { + diskOfferingObjs = json.listdiskofferingsresponse.diskoffering; + args.response.success({ + required: isRequred, + customFlag: 'iscustomized', // Field determines if custom slider is shown + data: {diskOfferings: diskOfferingObjs} + }); } }); + }, + + // Step 5: Affinity + function(args) { + $.ajax({ + url: createURL('listAffinityGroups'), + success: function(json) { + var items = json.listaffinitygroupsresponse.affinitygroup; + args.response.success({data: {affinityGroups: items}}); + } + }); + }, + + // Step 6: Network + function(args) { + if(diskOfferingObjs != null && diskOfferingObjs.length > 0) { + for(var i=0; i < diskOfferingObjs.length; i++) { + if(diskOfferingObjs[i].id == args.currentData.diskofferingid) { + selectedDiskOfferingObj = diskOfferingObjs[i]; + break; + } + } + } + + if (selectedZoneObj.networktype == "Advanced") { //Advanced zone. Show network list. + var $networkStep = $(".step.network:visible .nothing-to-select"); + var $networkStepContainer = $('.step.network:visible'); + + if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart + step6ContainerType = 'nothing-to-select'; + $networkStep.find("#from_instance_page_1").hide(); + $networkStep.find("#from_instance_page_2").hide(); + $networkStep.find("#from_vpc_tier").text("tier " + args.context.networks[0].name); + $networkStep.find("#from_vpc_tier").show(); + } else { //from Instance page + if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone + step6ContainerType = 'select-network'; + $networkStep.find("#from_instance_page_1").show(); + $networkStep.find("#from_instance_page_2").show(); + $networkStep.find("#from_vpc_tier").text(""); + $networkStep.find("#from_vpc_tier").hide(); + $networkStepContainer.removeClass('next-use-security-groups'); + } else { // Advanced SG-enabled zone + step6ContainerType = 'select-advanced-sg'; + } + + if ($networkStepContainer.hasClass('next-use-security-groups')) { + $networkStepContainer.removeClass('repeat next-use-security-groups loaded'); + step6ContainerType = 'select-security-group'; + } + } + } + else { //Basic zone. Show securigy group list or nothing(when no SecurityGroup service in guest network) + var includingSecurityGroupService = false; + $.ajax({ + url: createURL("listNetworks&trafficType=Guest&zoneId=" + selectedZoneObj.id), + dataType: "json", + async: false, + success: function(json) { + //basic zone should have only one guest network returned in this API call + var items = json.listnetworksresponse.network; + if(items != null && items.length > 0) { + var networkObj = items[0]; //basic zone has only one guest network + var serviceObjArray = networkObj.service; + for(var k = 0; k < serviceObjArray.length; k++) { + if(serviceObjArray[k].name == "SecurityGroup") { + includingSecurityGroupService = true; + break; + } + } + } + } + }); + + if(includingSecurityGroupService == false || selectedHypervisor == "VMware") { + step6ContainerType = 'nothing-to-select'; + } + else { + step6ContainerType = 'select-security-group'; + } + } + + //step6ContainerType = 'nothing-to-select'; //for testing only, comment it out before checking in + if(step6ContainerType == 'select-network' || step6ContainerType == 'select-advanced-sg') { + var defaultNetworkArray = [], optionalNetworkArray = []; + var networkData = { + zoneId: args.currentData.zoneid, + canusefordeploy: true + }; + + if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) { + $.extend(networkData, { + type: 'Shared' + }); + } + + if (!(cloudStack.context.projects && cloudStack.context.projects[0])) { + networkData.domainid = g_domainid; + networkData.account = g_account; + } + + var vpcObjs; + + //listVPCs without account/domainid/listAll parameter will return only VPCs belonging to the current login. That's what should happen in Instances page's VM Wizard. + //i.e. If the current login is root-admin, do not show VPCs belonging to regular-user/domain-admin in Instances page's VM Wizard. + $.ajax({ + url: createURL('listVPCs'), + async: false, + success: function(json) { + vpcObjs = json.listvpcsresponse.vpc ? json.listvpcsresponse.vpc : []; + } + }); + + var networkObjsToPopulate = []; + $.ajax({ + url: createURL('listNetworks'), + data: networkData, + async: false, + success: function(json) { + networkObjs = json.listnetworksresponse.network ? json.listnetworksresponse.network : []; + if(networkObjs.length > 0) { + for(var i = 0; i < networkObjs.length; i++) { + var networkObj = networkObjs[i]; + var includingSecurityGroup = false; + var serviceObjArray = networkObj.service; + for(var k = 0; k < serviceObjArray.length; k++) { + if(serviceObjArray[k].name == "SecurityGroup") { + networkObjs[i].type = networkObjs[i].type + ' (sg)'; + includingSecurityGroup = true; + break; + } + } + + if (networkObj.vpcid) { + networkObj._singleSelect = true; + } + + //for Advanced SG-enabled zone, list only SG network offerings + if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) { + if(includingSecurityGroup == false) + continue; //skip to next network offering + } + networkObjsToPopulate.push(networkObj); + } + } + } + }); + + $.ajax({ + url: createURL("listNetworkOfferings"), + dataType: "json", + data: { + forvpc: false, + zoneid: args.currentData.zoneid, + guestiptype: 'Isolated', + supportedServices: 'SourceNat', + specifyvlan: false, + state: 'Enabled' + }, + async: false, + success: function(json) { + networkOfferingObjs = json.listnetworkofferingsresponse.networkoffering; + } + }); + //get network offerings (end) *** + + $networkStepContainer.removeClass('repeat next-use-security-groups'); + + if (step6ContainerType == 'select-advanced-sg') { + $networkStepContainer.addClass('repeat next-use-security-groups'); + + // Add guest network is disabled + $networkStepContainer.find('.select-network').addClass('no-add-network'); + } else { + $networkStepContainer.find('.select-network').removeClass('no-add-network'); + } + + args.response.success({ + type: 'select-network', + data: { + networkObjs: networkObjsToPopulate, + securityGroups: [], + networkOfferings: networkOfferingObjs, + vpcs: vpcObjs + } + }); + } + + else if(step6ContainerType == 'select-security-group') { + var securityGroupArray = []; + var data = { + domainid: g_domainid, + account: g_account + }; + + $.ajax({ + url: createURL("listSecurityGroups"), + dataType: "json", + async: false, + data: cloudStack.context.projects ? {} : data, + success: function(json) { + var items = json.listsecuritygroupsresponse.securitygroup; + if (items != null && items.length > 0) { + for (var i = 0; i < items.length; i++) { + securityGroupArray.push(items[i]); + } + } + } + }); + args.response.success({ + type: 'select-security-group', + data: { + networkObjs: [], + securityGroups: securityGroupArray, + networkOfferings: [], + vpcs: [] + } + }); + } + + else if(step6ContainerType == 'nothing-to-select') { + args.response.success({ + type: 'nothing-to-select', + data: { + networkObjs: [], + securityGroups: [], + networkOfferings: [], + vpcs: [] + } + }); + } + + }, + + // Step 7: Review + function(args) { + return false; } - - }, - - // Step 6: Review - function(args) { - return false; - } ], action: function(args) { // Create a new VM!!!! @@ -575,9 +568,25 @@ if(selectedDiskOfferingObj.iscustomized == true) array1.push("&size=" + args.data.size); } + + //step 5: select an affinity group + var checkedAffinityGroupIdArray; + if(typeof(args.data["affinity-groups"]) == "object" && args.data["affinity-groups"].length != null) { //args.data["affinity-groups"] is an array of string, e.g. ["2375f8cc-8a73-4b8d-9b26-50885a25ffe0", "27c60d2a-de7f-4bb7-96e5-a602cec681df","c6301d77-99b5-4e8a-85e2-3ea2ab31c342"], + checkedAffinityGroupIdArray = args.data["affinity-groups"]; + } + else if(typeof(args.data["affinity-groups"]) == "string" && args.data["affinity-groups"].length > 0) { //args.data["affinity-groups"] is a string, e.g. "2375f8cc-8a73-4b8d-9b26-50885a25ffe0" + checkedAffinityGroupIdArray = []; + checkedAffinityGroupIdArray.push(args.data["affinity-groups"]); + } + else { // typeof(args.data["affinity-groups"]) == null + checkedAffinityGroupIdArray = []; + } - //step 5: select network - if (step5ContainerType == 'select-network' || step5ContainerType == 'select-advanced-sg') { + if(checkedAffinityGroupIdArray.length > 0) + array1.push("&affinitygroupids=" + checkedAffinityGroupIdArray.join(",")); + + //step 6: select network + if (step6ContainerType == 'select-network' || step6ContainerType == 'select-advanced-sg') { var array2 = []; var defaultNetworkId = args.data.defaultNetwork; //args.data.defaultNetwork might be equal to string "new-network" or a network ID @@ -640,7 +649,7 @@ array1.push("&networkIds=" + array2.join(",")); } - else if (step5ContainerType == 'select-security-group') { + else if (step6ContainerType == 'select-security-group') { var checkedSecurityGroupIdArray; if(typeof(args.data["security-groups"]) == "object" && args.data["security-groups"].length != null) { //args.data["security-groups"] is an array of string, e.g. ["2375f8cc-8a73-4b8d-9b26-50885a25ffe0", "27c60d2a-de7f-4bb7-96e5-a602cec681df","c6301d77-99b5-4e8a-85e2-3ea2ab31c342"], checkedSecurityGroupIdArray = args.data["security-groups"]; @@ -655,12 +664,12 @@ if(checkedSecurityGroupIdArray.length > 0) array1.push("&securitygroupids=" + checkedSecurityGroupIdArray.join(",")); - + if(selectedZoneObj.networktype == "Advanced" && selectedZoneObj.securitygroupsenabled == true) { // Advanced SG-enabled zone var array2 = []; var myNetworks = $('.multi-wizard:visible form').data('my-networks'); //widget limitation: If using an advanced security group zone, get the guest networks like this var defaultNetworkId = $('.multi-wizard:visible form').find('input[name=defaultNetwork]:checked').val(); - + var checkedNetworkIdArray; if(typeof(myNetworks) == "object" && myNetworks.length != null) { //myNetworks is an array of string, e.g. ["203", "202"], checkedNetworkIdArray = myNetworks; @@ -688,7 +697,7 @@ array1.push("&networkIds=" + array2.join(",")); } } - else if (step5ContainerType == 'nothing-to-select') { + else if (step6ContainerType == 'nothing-to-select') { if(args.context.networks != null) { //from VPC tier array1.push("&networkIds=" + args.context.networks[0].id); array1.push("&domainid=" + args.context.vpc[0].domainid); @@ -720,30 +729,30 @@ var vmid = json.deployvirtualmachineresponse.id; args.response.success( {_custom: - {jobId: jid, - getUpdatedItem: function(json) { - var item = json.queryasyncjobresultresponse.jobresult.virtualmachine; - if (item.password != null) - alert("Password of new VM " + item.displayname + " is " + item.password); - return item; - }, - getActionFilter: function() { - return cloudStack.actionFilter.vmActionFilter; - }, - getUpdatedItemWhenAsyncJobFails: function() { - var item; - $.ajax({ - url: createURL("listVirtualMachines&id="+vmid), - dataType: "json", - async: false, - success: function(json) { - item = json.listvirtualmachinesresponse.virtualmachine[0]; - } - }); - return item; - } - } - } + {jobId: jid, + getUpdatedItem: function(json) { + var item = json.queryasyncjobresultresponse.jobresult.virtualmachine; + if (item.password != null) + alert("Password of new VM " + item.displayname + " is " + item.password); + return item; + }, + getActionFilter: function() { + return cloudStack.actionFilter.vmActionFilter; + }, + getUpdatedItemWhenAsyncJobFails: function() { + var item; + $.ajax({ + url: createURL("listVirtualMachines&id="+vmid), + dataType: "json", + async: false, + success: function(json) { + item = json.listvirtualmachinesresponse.virtualmachine[0]; + } + }); + return item; + } + } + } ); }, error: function(XMLHttpResponse) { diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 0c4c7d2172a..f95f0a35dc9 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -194,17 +194,23 @@ } if("hosts" in args.context) { - $.extend(data, { - hostid: args.context.hosts[0].id - }); - } - + $.extend(data, { + hostid: args.context.hosts[0].id + }); + } + + if("affinityGroups" in args.context) { + $.extend(data, { + affinitygroupid: args.context.affinityGroups[0].id + }); + } + if(args.context.zoneType != null && args.context.zoneType.length > 0) { //Basic type or Advanced type $.extend(data, { zonetype: args.context.zoneType }); - } - + } + $.ajax({ url: createURL('listVirtualMachines'), data: data, @@ -223,6 +229,7 @@ viewAll: [ { path: 'storage.volumes', label: 'label.volumes' }, { path: 'vmsnapshots', label: 'label.snapshots' }, + { path: 'affinityGroups', label: 'label.affinity.groups' }, { path: '_zone.hosts', label: 'label.hosts', @@ -426,7 +433,6 @@ poll: pollAsyncJobResult } }, - snapshot: { messages: { notification: function(args) { @@ -489,7 +495,6 @@ pool: pollAsyncJobResult } }, - destroy: { label: 'label.action.destroy.instance', compactLabel: 'label.destroy', @@ -555,7 +560,6 @@ } } }, - reset: { label: 'Reset VM', messages:{ @@ -586,8 +590,128 @@ } } - }, + }, + changeAffinity: { + label: 'Change affinity', + + action: { + custom: cloudStack.uiCustom.affinity({ + tierSelect: function(args) { + if ('vpc' in args.context) { //from VPC section + args.$tierSelect.show(); //show tier dropdown + + $.ajax({ //populate tier dropdown + url: createURL("listNetworks"), + async: false, + data: { + vpcid: args.context.vpc[0].id, + //listAll: true, //do not pass listAll to listNetworks under VPC + domainid: args.context.vpc[0].domainid, + account: args.context.vpc[0].account, + supportedservices: 'StaticNat' + }, + success: function(json) { + var networks = json.listnetworksresponse.network; + var items = [{ id: -1, description: 'Please select a tier' }]; + $(networks).each(function(){ + items.push({id: this.id, description: this.displaytext}); + }); + args.response.success({ data: items }); + } + }); + } + else { //from Guest Network section + args.$tierSelect.hide(); + } + + args.$tierSelect.change(function() { + args.$tierSelect.closest('.list-view').listView('refresh'); + }); + args.$tierSelect.closest('.list-view').listView('refresh'); + }, + + listView: { + listView: { + id: 'affinityGroups', + fields: { + name: { label: 'label.name' }, + type: { label: 'label.type' } + }, + dataProvider: function(args) { + $.ajax({ + url: createURL('listAffinityGroups'), + async: false, //make it sync to avoid dataProvider() being called twice which produces duplicate data + success: function(json) { + var items = []; + var allAffinityGroups = json.listaffinitygroupsresponse.affinitygroup; + var previouslySelectedAffinityGroups = args.context.instances[0].affinitygroup; + if(allAffinityGroups != null) { + for(var i = 0; i < allAffinityGroups.length; i++) { + var isPreviouslySelected = false; + if(previouslySelectedAffinityGroups != null) { + for(var k = 0; k < previouslySelectedAffinityGroups.length; k++) { + if(previouslySelectedAffinityGroups[k].id == allAffinityGroups[i].id) { + isPreviouslySelected = true; + break; //break for loop + } + } + } + items.push($.extend(allAffinityGroups[i], { + _isSelected: isPreviouslySelected + })); + } + } + args.response.success({data: items}); + } + }); + } + } + }, + action: function(args) { + var affinityGroupIdArray = []; + if(args.context.affinityGroups != null) { + for(var i = 0; i < args.context.affinityGroups.length; i++) { + if(args.context.affinityGroups[i]._isSelected == true) { + affinityGroupIdArray.push(args.context.affinityGroups[i].id); + } + } + } + var data = { + id: args.context.instances[0].id, + affinitygroupids: affinityGroupIdArray.join(",") + }; + $.ajax({ + url: createURL('updateVMAffinityGroup'), + data: data, + success: function(json) { + var jid = json.updatevirtualmachineresponse.jobid; + args.response.success( + {_custom: + {jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.virtualmachine; + }, + getActionFilter: function() { + return vmActionfilter; + } + } + } + ); + } + }); + } + }) + }, + messages: { + notification: function(args) { + return 'Change affinity'; + } + }, + notification: { + poll: pollAsyncJobResult + } + }, edit: { label: 'label.edit', @@ -597,7 +721,7 @@ group: args.data.group, ostypeid: args.data.guestosid }; - + if(args.data.displayname != args.context.instances[0].displayname) { $.extend(data, { displayName: args.data.displayname @@ -1380,7 +1504,7 @@ args.response.success({data: args.context.instances[0].securitygroup}); } }, - + /** * Statistics tab */ @@ -1450,6 +1574,7 @@ allowedActions.push("reset"); allowedActions.push("snapshot"); allowedActions.push("scaleUp"); + allowedActions.push("changeAffinity"); if(isAdmin()) allowedActions.push("migrateToAnotherStorage"); diff --git a/ui/scripts/ui-custom/affinity.js b/ui/scripts/ui-custom/affinity.js new file mode 100644 index 00000000000..1a23ff763ee --- /dev/null +++ b/ui/scripts/ui-custom/affinity.js @@ -0,0 +1,173 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +(function(cloudStack, $) { + cloudStack.uiCustom.affinity = function(args) { + var listView = args.listView; + var action = args.action; + var tierSelect = args.tierSelect; + + return function(args) { + var context = args.context; + var $instanceRow = args.$instanceRow; + + var vmList = function(args) { + // Create a listing of instances, based on limited information + // from main instances list view + var $listView; + var instances = $.extend(true, {}, args.listView, { + context: context, + uiCustom: true + }); + + instances.listView.actions = { + select: { + label: _l('label.select.instance'), + type: 'checkbox', + action: { + uiCustom: function(args) { + var $item = args.$item; + var $input = $item.find('td.actions input:visible'); + + if ($input.attr('type') == 'checkbox') { + if ($input.is(':checked')) + $item.addClass('multi-edit-selected'); + else + $item.removeClass('multi-edit-selected'); + } else { + $item.siblings().removeClass('multi-edit-selected'); + $item.addClass('multi-edit-selected'); + } + } + } + } + }; + + $listView = $('