From 665829703f56a380779730adbcd0a0768d9b5983 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Mon, 30 Jul 2012 11:05:02 -0700 Subject: [PATCH] Clean up indentation/whitespace for autoscaler UI code --- ui/scripts/autoscaler.js | 744 ++++----- ui/scripts/network.js | 2488 ++++++++++++++-------------- ui/scripts/ui-custom/autoscaler.js | 2 +- 3 files changed, 1617 insertions(+), 1617 deletions(-) diff --git a/ui/scripts/autoscaler.js b/ui/scripts/autoscaler.js index 72876b1a291..32f4bfaf7d8 100644 --- a/ui/scripts/autoscaler.js +++ b/ui/scripts/autoscaler.js @@ -17,70 +17,70 @@ var totalScaleDownCondition = 0; cloudStack.autoscaler = { - dataProvider: function(args) { + dataProvider: function(args) { // Reset data scaleUpData = []; totalScaleUpCondition = 0; scaleDownData = []; totalScaleDownCondition = 0; - var sampleData = null; - /* - var sampleData = { - templateNames: '58d3f4b2-e847-4f93-993d-1ab1505129b6', //(will set this value to dropdown) - serviceOfferingId: '4aa823f3-27ec-46af-9e07-b023d7a7a6f1', //(will set this value to dropdown) - minInstance: 1, - maxInstance: 10, - scaleUpPolicy: { - id: 12345, - duration: 1000, - conditions: [ - { - id: 1, - counterid: 'cpu', - relationaloperator: "GE", - threshold: 100 - }, - { - id: 2, - counterid: 'memory', - relationaloperator: "LT", - threshold: 200 - } + var sampleData = null; + /* + var sampleData = { + templateNames: '58d3f4b2-e847-4f93-993d-1ab1505129b6', //(will set this value to dropdown) + serviceOfferingId: '4aa823f3-27ec-46af-9e07-b023d7a7a6f1', //(will set this value to dropdown) + minInstance: 1, + maxInstance: 10, + scaleUpPolicy: { + id: 12345, + duration: 1000, + conditions: [ + { + id: 1, + counterid: 'cpu', + relationaloperator: "GE", + threshold: 100 + }, + { + id: 2, + counterid: 'memory', + relationaloperator: "LT", + threshold: 200 + } - ] - }, - scaleDownPolicy: { - id: 6789, - duration: 500, - conditions: [ - { - id: 1, - counterid: 'cpu', - relationaloperator: "LT", - threshold: 30 - }, - { - id: 2, - counterid: 'cpu', - relationaloperator: "LT", - threshold: 50 - } + ] + }, + scaleDownPolicy: { + id: 6789, + duration: 500, + conditions: [ + { + id: 1, + counterid: 'cpu', + relationaloperator: "LT", + threshold: 30 + }, + { + id: 2, + counterid: 'cpu', + relationaloperator: "LT", + threshold: 50 + } - ] - }, - interval: 200, - quietTime: 300, - destroyVMgracePeriod: null, - securityGroups: null, // (will set this value to dropdown) - diskOfferingId: 'a21c9aa4-ef7e-41dd-91eb-70b2182816b0', // (will set this value to dropdown) - snmpCommunity: 1, - snmpPort: 225, + ] + }, + interval: 200, + quietTime: 300, + destroyVMgracePeriod: null, + securityGroups: null, // (will set this value to dropdown) + diskOfferingId: 'a21c9aa4-ef7e-41dd-91eb-70b2182816b0', // (will set this value to dropdown) + snmpCommunity: 1, + snmpPort: 225, + + isAdvanced: false // Set this to true if any advanced field data is present + }; + */ - isAdvanced: false // Set this to true if any advanced field data is present - }; - */ - args.response.success({ data: sampleData }); }, @@ -117,70 +117,70 @@ templateNames: { label: 'label.template', id: 'templatename', - select: function(args) { - var templates; - var templateIdMap = {}; + select: function(args) { + var templates; + var templateIdMap = {}; $.ajax({ url: createURL('listTemplates'), data: { - templatefilter: 'featured', - zoneid: args.context.networks[0].zoneid - }, - async: false, + templatefilter: 'featured', + zoneid: args.context.networks[0].zoneid + }, + async: false, success: function(json) { - templates = json.listtemplatesresponse.template; - if (templates == null) - templates = []; + templates = json.listtemplatesresponse.template; + if (templates == null) + templates = []; $(templates).each(function() { - templateIdMap[this.id] = 1; - }); + templateIdMap[this.id] = 1; + }); } }); - - $.ajax({ + + $.ajax({ url: createURL('listTemplates'), data: { - templatefilter: 'community', - zoneid: args.context.networks[0].zoneid - }, - async: false, + templatefilter: 'community', + zoneid: args.context.networks[0].zoneid + }, + async: false, success: function(json) { - var items = json.listtemplatesresponse.template; - $(items).each(function() { - if(!(this.id in templateIdMap)) { - templates.push(this); - templateIdMap[this.id] = 1; - } - }); + var items = json.listtemplatesresponse.template; + $(items).each(function() { + if(!(this.id in templateIdMap)) { + templates.push(this); + templateIdMap[this.id] = 1; + } + }); } }); - - $.ajax({ + + $.ajax({ url: createURL('listTemplates'), data: { - templatefilter: 'selfexecutable', - zoneid: args.context.networks[0].zoneid - }, - async: false, + templatefilter: 'selfexecutable', + zoneid: args.context.networks[0].zoneid + }, + async: false, success: function(json) { - var items = json.listtemplatesresponse.template; - $(items).each(function() { - if(!(this.id in templateIdMap)) { - templates.push(this); - templateIdMap[this.id] = 1; - } - }); + var items = json.listtemplatesresponse.template; + $(items).each(function() { + if(!(this.id in templateIdMap)) { + templates.push(this); + templateIdMap[this.id] = 1; + } + }); } }); - - args.response.success({ - data: $.map(templates, function(template) { - return { - id: template.id, - description: template.name - }; - }) - }); + + args.response.success({ + data: $.map(templates, function(template) { + return { + id: template.id, + description: template.name + }; + }) + }); } }, @@ -305,26 +305,26 @@ dependsOn: 'isAdvanced', label: 'User', select: function(args) { - var items = []; - if(isAdmin() || isDomainAdmin()) { - $.ajax({ - url: createURL('listUsers'), - data: { - domainid: g_domainid, - account: g_account - }, - success: function(json) { - var users = json.listusersresponse.user; - $(users).each(function(){ - items.push({id: this.id, description: this.username}); - }); - args.response.success({ data: items }); - } - }); - } - else { //regular user doesn't have access to listUers API call. - items.push({id: "", description: ""}); - } + var items = []; + if(isAdmin() || isDomainAdmin()) { + $.ajax({ + url: createURL('listUsers'), + data: { + domainid: g_domainid, + account: g_account + }, + success: function(json) { + var users = json.listusersresponse.user; + $(users).each(function(){ + items.push({id: this.id, description: this.username}); + }); + args.response.success({ data: items }); + } + }); + } + else { //regular user doesn't have access to listUers API call. + items.push({id: "", description: ""}); + } } } }, @@ -342,7 +342,7 @@ url: createURL("listCounters"), dataType: "json", async: true, - success: function(json) { + success: function(json) { var counters = json.counterresponse.counter; args.response.success({ @@ -478,7 +478,7 @@ url: createURL("listCounters"), dataType: "json", async: true, - success: function(json) { + success: function(json) { var counters = json.counterresponse.counter; args.response.success({ @@ -603,52 +603,52 @@ }, actions: { - add: function(args) { - //validation (begin) ***** - if(isAdmin() || isDomainAdmin()) { //only admin and domain-admin has access to listUers API - var havingApiKeyAndSecretKey = false; - $.ajax({ - url: createURL('listUsers'), - data: { - id: args.data.username - }, - async: false, - success: function(json) { - if(json.listusersresponse.user[0].apikey != null && json.listusersresponse.user[0].secretkey != null) { - havingApiKeyAndSecretKey = true; - } - } - }); - if(havingApiKeyAndSecretKey == false) { - args.response.error('The selected user in advanced settings does not have API key or secret key'); - return; - } - } - - if(isAdmin()) { //only admin has access to listConfigurations API - var hasValidEndpointeUrl = false; - $.ajax({ - url: createURL('listConfigurations'), - data: { - name: 'endpointe.url' - }, - async: false, - success: function(json) { - if(json.listconfigurationsresponse.configuration != null) { - if(json.listconfigurationsresponse.configuration[0].value.indexOf('localhost') == -1) { - hasValidEndpointeUrl = true; - } - } - } - }); - if(hasValidEndpointeUrl == false) { - args.response.error("Global setting endpointe.url has to be set to the Management Server's API end point"); - return; - } - } - //validation (end) ***** - - + add: function(args) { + //validation (begin) ***** + if(isAdmin() || isDomainAdmin()) { //only admin and domain-admin has access to listUers API + var havingApiKeyAndSecretKey = false; + $.ajax({ + url: createURL('listUsers'), + data: { + id: args.data.username + }, + async: false, + success: function(json) { + if(json.listusersresponse.user[0].apikey != null && json.listusersresponse.user[0].secretkey != null) { + havingApiKeyAndSecretKey = true; + } + } + }); + if(havingApiKeyAndSecretKey == false) { + args.response.error('The selected user in advanced settings does not have API key or secret key'); + return; + } + } + + if(isAdmin()) { //only admin has access to listConfigurations API + var hasValidEndpointeUrl = false; + $.ajax({ + url: createURL('listConfigurations'), + data: { + name: 'endpointe.url' + }, + async: false, + success: function(json) { + if(json.listconfigurationsresponse.configuration != null) { + if(json.listconfigurationsresponse.configuration[0].value.indexOf('localhost') == -1) { + hasValidEndpointeUrl = true; + } + } + } + }); + if(hasValidEndpointeUrl == false) { + args.response.error("Global setting endpointe.url has to be set to the Management Server's API end point"); + return; + } + } + //validation (end) ***** + + var scaleVmProfileResponse = []; var loadBalancerResponse = []; var scaleVmGroupResponse = []; @@ -656,171 +656,171 @@ var scaleDownConditionIds = []; var scaleUp = function(args){ - var scaleUpConditionIds = []; - $(scaleUpData).each(function(){ - var data = { - counterid: this.counterid, - relationaloperator: this.relationaloperator, - threshold: this.threshold - }; - $.ajax({ - url: createURL('createCondition'), - data: data, - success: function(json) { - var createConditionIntervalID = setInterval(function() { - $.ajax({ - url: createURL("queryAsyncJobResult&jobid=" + json.conditionresponse.jobid), - dataType: "json", - success: function(json) { - var result = json.queryasyncjobresultresponse; - if(result.jobstatus == 0) { - return; - } - else { - clearInterval(createConditionIntervalID); - if(result.jobstatus == 1) { - var item = json.queryasyncjobresultresponse.jobresult.condition; - scaleUpConditionIds.push(item.id); - if (scaleUpConditionIds.length == scaleUpData.length) { - var data = { - action: 'scaleup', - conditionids: scaleUpConditionIds.join(","), - duration: args.data.scaleUpDuration, - quiettime: args.data.quietTime - }; - $.ajax({ - url: createURL('createAutoScalePolicy'), - data: data, - success: function(json) { - var jobId = json.autoscalepolicyresponse.jobid; - var createAutoScalePolicyInterval = setInterval(function(){ - $.ajax({ - url: createURL("queryAsyncJobResult&jobId="+jobId), - dataType: "json", - success: function(json) { - var result = json.queryasyncjobresultresponse; - if (result.jobstatus == 0) { - return; //Job has not completed - } - else { - clearInterval(createAutoScalePolicyInterval); - if (result.jobstatus == 1) { //AutoScalePolicy successfully created - var item = result.jobresult.autoscalepolicy; - scaleDown($.extend(args, { - scaleUpPolicyResponse: item - })); - } - else if (result.jobstatus == 2) { - args.response.error({ message: _s(result.jobresult.errortext) }); - } - } - } - }); - }, 3000); - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); - } - } - else if(result.jobstatus == 2) { - args.response.error({ message: _s(result.jobresult.errortext) }); - } - } - } - }); - }, 3000); - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); - }); + var scaleUpConditionIds = []; + $(scaleUpData).each(function(){ + var data = { + counterid: this.counterid, + relationaloperator: this.relationaloperator, + threshold: this.threshold + }; + $.ajax({ + url: createURL('createCondition'), + data: data, + success: function(json) { + var createConditionIntervalID = setInterval(function() { + $.ajax({ + url: createURL("queryAsyncJobResult&jobid=" + json.conditionresponse.jobid), + dataType: "json", + success: function(json) { + var result = json.queryasyncjobresultresponse; + if(result.jobstatus == 0) { + return; + } + else { + clearInterval(createConditionIntervalID); + if(result.jobstatus == 1) { + var item = json.queryasyncjobresultresponse.jobresult.condition; + scaleUpConditionIds.push(item.id); + if (scaleUpConditionIds.length == scaleUpData.length) { + var data = { + action: 'scaleup', + conditionids: scaleUpConditionIds.join(","), + duration: args.data.scaleUpDuration, + quiettime: args.data.quietTime + }; + $.ajax({ + url: createURL('createAutoScalePolicy'), + data: data, + success: function(json) { + var jobId = json.autoscalepolicyresponse.jobid; + var createAutoScalePolicyInterval = setInterval(function(){ + $.ajax({ + url: createURL("queryAsyncJobResult&jobId="+jobId), + dataType: "json", + success: function(json) { + var result = json.queryasyncjobresultresponse; + if (result.jobstatus == 0) { + return; //Job has not completed + } + else { + clearInterval(createAutoScalePolicyInterval); + if (result.jobstatus == 1) { //AutoScalePolicy successfully created + var item = result.jobresult.autoscalepolicy; + scaleDown($.extend(args, { + scaleUpPolicyResponse: item + })); + } + else if (result.jobstatus == 2) { + args.response.error({ message: _s(result.jobresult.errortext) }); + } + } + } + }); + }, 3000); + }, + error: function(XMLHttpResponse) { + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } + }); + } + } + else if(result.jobstatus == 2) { + args.response.error({ message: _s(result.jobresult.errortext) }); + } + } + } + }); + }, 3000); + }, + error: function(XMLHttpResponse) { + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } + }); + }); }; var scaleDown = function(args){ - var scaleDownConditionIds = []; - $(scaleDownData).each(function(){ - var data = { - counterid: this.counterid, - relationaloperator: this.relationaloperator, - threshold: this.threshold - }; - $.ajax({ - url: createURL('createCondition'), - data: data, - success: function(json) { - var createConditionIntervalID = setInterval(function() { - $.ajax({ - url: createURL("queryAsyncJobResult&jobid=" + json.conditionresponse.jobid), - dataType: "json", - success: function(json) { - var result = json.queryasyncjobresultresponse; - if(result.jobstatus == 0) { - return; - } - else { - clearInterval(createConditionIntervalID); - if(result.jobstatus == 1) { - var item = json.queryasyncjobresultresponse.jobresult.condition; - scaleDownConditionIds.push(item.id); - if (scaleDownConditionIds.length == scaleDownData.length) { - var data = { - action: 'scaledown', - conditionids: scaleDownConditionIds.join(","), - duration: args.data.scaleDownDuration, - quiettime: args.data.quietTime - }; - $.ajax({ - url: createURL('createAutoScalePolicy'), - data: data, - success: function(json) { - var jobId = json.autoscalepolicyresponse.jobid; - var createAutoScalePolicyInterval = setInterval(function(){ - $.ajax({ - url: createURL("queryAsyncJobResult&jobId="+jobId), - dataType: "json", - success: function(json) { - var result = json.queryasyncjobresultresponse; - if (result.jobstatus == 0) { - return; //Job has not completed - } - else { - clearInterval(createAutoScalePolicyInterval); - if (result.jobstatus == 1) { //AutoScalePolicy successfully created - var item = result.jobresult.autoscalepolicy; - createVmProfile($.extend(args, { - scaleDownPolicyResponse: item - })); - } - else if (result.jobstatus == 2) { - args.response.error({ message: _s(result.jobresult.errortext) }); - } - } - } - }); - }, 3000); - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); - } - } - else if(result.jobstatus == 2) { - args.response.error({ message: _s(result.jobresult.errortext) }); - } - } - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); - }, 3000); + var scaleDownConditionIds = []; + $(scaleDownData).each(function(){ + var data = { + counterid: this.counterid, + relationaloperator: this.relationaloperator, + threshold: this.threshold + }; + $.ajax({ + url: createURL('createCondition'), + data: data, + success: function(json) { + var createConditionIntervalID = setInterval(function() { + $.ajax({ + url: createURL("queryAsyncJobResult&jobid=" + json.conditionresponse.jobid), + dataType: "json", + success: function(json) { + var result = json.queryasyncjobresultresponse; + if(result.jobstatus == 0) { + return; + } + else { + clearInterval(createConditionIntervalID); + if(result.jobstatus == 1) { + var item = json.queryasyncjobresultresponse.jobresult.condition; + scaleDownConditionIds.push(item.id); + if (scaleDownConditionIds.length == scaleDownData.length) { + var data = { + action: 'scaledown', + conditionids: scaleDownConditionIds.join(","), + duration: args.data.scaleDownDuration, + quiettime: args.data.quietTime + }; + $.ajax({ + url: createURL('createAutoScalePolicy'), + data: data, + success: function(json) { + var jobId = json.autoscalepolicyresponse.jobid; + var createAutoScalePolicyInterval = setInterval(function(){ + $.ajax({ + url: createURL("queryAsyncJobResult&jobId="+jobId), + dataType: "json", + success: function(json) { + var result = json.queryasyncjobresultresponse; + if (result.jobstatus == 0) { + return; //Job has not completed + } + else { + clearInterval(createAutoScalePolicyInterval); + if (result.jobstatus == 1) { //AutoScalePolicy successfully created + var item = result.jobresult.autoscalepolicy; + createVmProfile($.extend(args, { + scaleDownPolicyResponse: item + })); + } + else if (result.jobstatus == 2) { + args.response.error({ message: _s(result.jobresult.errortext) }); + } + } + } + }); + }, 3000); + }, + error: function(XMLHttpResponse) { + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } + }); + } + } + else if(result.jobstatus == 2) { + args.response.error({ message: _s(result.jobresult.errortext) }); + } + } + }, + error: function(XMLHttpResponse) { + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } + }); + }, 3000); } - }); - }); + }); + }); }; var createVmProfile = function(args){ @@ -870,45 +870,45 @@ loadBalancer(args); } else if (result.jobstatus == 2) { - args.response.error({message: _s(result.jobresult.errortext)}); + args.response.error({message: _s(result.jobresult.errortext)}); } } } }); }, 3000); - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } + }, + error: function(XMLHttpResponse) { + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } }); }; - var loadBalancer = function(args){ - var networkid; - if('vpc' in args.context) { //from VPC section - if(args.data.tier == null) { - cloudStack.dialog.notice({ message: 'Tier is required' }); - return; - } - networkid = args.data.tier; - } - else if('networks' in args.context) { //from Guest Network section - networkid = args.context.networks[0].id; - } - var data = { - algorithm: args.formData.algorithm, - name: args.formData.name, - privateport: args.formData.privateport, - publicport: args.formData.publicport, - openfirewall: false, - networkid: networkid, - publicipid: args.context.ipAddresses[0].id - }; - + var loadBalancer = function(args){ + var networkid; + if('vpc' in args.context) { //from VPC section + if(args.data.tier == null) { + cloudStack.dialog.notice({ message: 'Tier is required' }); + return; + } + networkid = args.data.tier; + } + else if('networks' in args.context) { //from Guest Network section + networkid = args.context.networks[0].id; + } + var data = { + algorithm: args.formData.algorithm, + name: args.formData.name, + privateport: args.formData.privateport, + publicport: args.formData.publicport, + openfirewall: false, + networkid: networkid, + publicipid: args.context.ipAddresses[0].id + }; + $.ajax({ url: createURL('createLoadBalancerRule'), dataType: 'json', - data: data, + data: data, async: true, success: function(json) { var jobId = json.createloadbalancerruleresponse.jobid; @@ -928,16 +928,16 @@ autoScaleVmGroup(args); } else if (result.jobstatus == 2) { - args.response.error({message: _s(result.jobresult.errortext)}); + args.response.error({message: _s(result.jobresult.errortext)}); } } } }); }, 3000); - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } + }, + error: function(XMLHttpResponse) { + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } }); }; @@ -947,7 +947,7 @@ array1.push("&minMembers=" + args.data.minInstance); array1.push("&maxMembers=" + args.data.maxInstance ); array1.push("&vmprofileid=" + scaleVmProfileResponse.id); - array1.push("&interval=" + args.data.interval); + array1.push("&interval=" + args.data.interval); array1.push("&scaleuppolicyids=" + args.scaleUpPolicyResponse.id); array1.push("&scaledownpolicyids=" + args.scaleDownPolicyResponse.id ); $.ajax({ @@ -969,24 +969,24 @@ clearInterval(scaleVmGroupTimer); if (result.jobstatus == 1) { //autoscale Vm group successfully created scaleVmGroupResponse = result.jobresult.autoscalevmgroup; - args.response.success(); + args.response.success(); } else if (result.jobstatus == 2) { - args.response.error({message: _s(result.jobresult.errortext)}); + args.response.error({message: _s(result.jobresult.errortext)}); } } } }); }, 3000); - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } + }, + error: function(XMLHttpResponse) { + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } }); }; scaleUp(args); - + //setTimeout(function() { args.response.success(); }, 1000); //setTimeout(function() { args.response.error('Error!'); }, 1000); }, diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 603c0a5c673..494e11f964c 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -8,7 +8,7 @@ // 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. -// +// // Automatically generated by addcopyright.py at 04/03/2012 (function(cloudStack, $) { @@ -33,7 +33,7 @@ var allowedActions = args.context.actions; var disallowedActions = []; var item = args.context.item; - var status = item.state; + var status = item.state; if (status == 'Destroyed' || status == 'Releasing' || @@ -42,78 +42,78 @@ status == 'Allocating' || item.account == 'system' || item.issystem == true ) { - return []; + return []; + } + + if(item.networkOfferingConserveMode == false) { + /* + (1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added. + */ + if (item.issourcenat == true){ + disallowedActions.push('enableStaticNAT'); + disallowedActions.push('enableVPN'); + } + + /* + (2) If IP is non-SourceNat, show StaticNat/VPN/PortForwarding/LoadBalancer at first. + 1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. + 2. Once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. + 3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. + 4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. + */ + else { //item.issourcenat == false + if (item.isstaticnat) { //1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. + disallowedActions.push('enableVPN'); + } + if (item.vpnenabled) { //2. Once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. + disallowedActions.push('enableStaticNAT'); + } + + //3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. + $.ajax({ + url: createURL('listPortForwardingRules'), + data: { + ipaddressid: item.id, + listAll: true + }, + dataType: 'json', + async: false, + success: function(json) { + var rules = json.listportforwardingrulesresponse.portforwardingrule; + if(rules != null && rules.length > 0) { + disallowedActions.push('enableVPN'); + disallowedActions.push('enableStaticNAT'); + } + } + }); + + //4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. + $.ajax({ + url: createURL('listLoadBalancerRules'), + data: { + publicipid: item.id, + listAll: true + }, + dataType: 'json', + async: false, + success: function(json) { + var rules = json.listloadbalancerrulesresponse.loadbalancerrule; + if(rules != null && rules.length > 0) { + disallowedActions.push('enableVPN'); + disallowedActions.push('enableStaticNAT'); + } + } + }); + } } - - if(item.networkOfferingConserveMode == false) { - /* - (1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added. - */ - if (item.issourcenat == true){ - disallowedActions.push('enableStaticNAT'); - disallowedActions.push('enableVPN'); - } - - /* - (2) If IP is non-SourceNat, show StaticNat/VPN/PortForwarding/LoadBalancer at first. - 1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. - 2. Once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. - 3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. - 4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. - */ - else { //item.issourcenat == false - if (item.isstaticnat) { //1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. - disallowedActions.push('enableVPN'); - } - if (item.vpnenabled) { //2. Once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. - disallowedActions.push('enableStaticNAT'); - } - - //3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. - $.ajax({ - url: createURL('listPortForwardingRules'), - data: { - ipaddressid: item.id, - listAll: true - }, - dataType: 'json', - async: false, - success: function(json) { - var rules = json.listportforwardingrulesresponse.portforwardingrule; - if(rules != null && rules.length > 0) { - disallowedActions.push('enableVPN'); - disallowedActions.push('enableStaticNAT'); - } - } - }); - - //4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. - $.ajax({ - url: createURL('listLoadBalancerRules'), - data: { - publicipid: item.id, - listAll: true - }, - dataType: 'json', - async: false, - success: function(json) { - var rules = json.listloadbalancerrulesresponse.loadbalancerrule; - if(rules != null && rules.length > 0) { - disallowedActions.push('enableVPN'); - disallowedActions.push('enableStaticNAT'); - } - } - }); - } - } - + if (item.isstaticnat) { disallowedActions.push('enableStaticNAT'); } else { disallowedActions.push('disableStaticNAT'); } - if(item.networkOfferingHavingVpnService == true) { + if(item.networkOfferingHavingVpnService == true) { if (item.vpnenabled) { disallowedActions.push('enableVPN'); } else { @@ -140,7 +140,7 @@ securityGroups: function(args) { var allowedActions = []; var isSecurityGroupOwner = isAdmin() || isDomainAdmin() || - args.context.item.account == args.context.users[0].account; + args.context.item.account == args.context.users[0].account; if (isSecurityGroupOwner && args.context.item.state != 'Destroyed' && @@ -152,8 +152,8 @@ } }; - var networkOfferingObjs = []; - + var networkOfferingObjs = []; + cloudStack.sections.network = { title: 'label.network', id: 'network', @@ -172,11 +172,11 @@ var basicZones = $.grep(zones, function(zone) { return zone.networktype == 'Basic'; }); - + havingBasicZones = basicZones.length ? true : false; } }); - + $.ajax({ url: createURL('listNetworks', { ignoreProject: true }), data: { @@ -196,7 +196,7 @@ if (!havingBasicZones) { sectionsToShow.push('vpc'); } - + if(havingSecurityGroupNetwork == true) sectionsToShow.push('securityGroups'); @@ -270,8 +270,8 @@ networkOfferingId: { label: 'label.network.offering', validation: { required: true }, - dependsOn: 'zoneId', - select: function(args) { + dependsOn: 'zoneId', + select: function(args) { $.ajax({ url: createURL('listNetworkOfferings&zoneid=' + args.zoneId), data: { @@ -294,74 +294,74 @@ }); } }, - vpcid: { - label: 'VPC', - dependsOn: 'networkOfferingId', - select: function(args) { - var networkOfferingObj; - $(networkOfferingObjs).each(function(key, value) { - if(value.id == args.networkOfferingId) { - networkOfferingObj = value; - return false; //break each loop - } - }); - if(networkOfferingObj.forvpc == true) { - args.$select.closest('.form-item').css('display', 'inline-block'); - $.ajax({ - url: createURL('listVPCs'), - data: { - listAll: true - }, - success: function(json) { - var items = json.listvpcsresponse.vpc; - var data; - if(items != null && items.length > 0) { - data = $.map(items, function(item) { - return { - id: item.id, - description: item.name - } - }); - } - args.response.success({ data: data }); - } - }); - } - else { - args.$select.closest('.form-item').hide(); - args.response.success({ data: null }); - } - } - }, + vpcid: { + label: 'VPC', + dependsOn: 'networkOfferingId', + select: function(args) { + var networkOfferingObj; + $(networkOfferingObjs).each(function(key, value) { + if(value.id == args.networkOfferingId) { + networkOfferingObj = value; + return false; //break each loop + } + }); + if(networkOfferingObj.forvpc == true) { + args.$select.closest('.form-item').css('display', 'inline-block'); + $.ajax({ + url: createURL('listVPCs'), + data: { + listAll: true + }, + success: function(json) { + var items = json.listvpcsresponse.vpc; + var data; + if(items != null && items.length > 0) { + data = $.map(items, function(item) { + return { + id: item.id, + description: item.name + } + }); + } + args.response.success({ data: data }); + } + }); + } + else { + args.$select.closest('.form-item').hide(); + args.response.success({ data: null }); + } + } + }, guestGateway: { label: 'label.guest.gateway' }, guestNetmask: { label: 'label.guest.netmask' } } }, action: function(args) { - var dataObj = { - zoneId: args.data.zoneId, - name: args.data.name, - displayText: args.data.displayText, - networkOfferingId: args.data.networkOfferingId - }; - if(args.data.guestGateway != null && args.data.guestGateway.length > 0) { - $.extend(dataObj, { - gateway: args.data.guestGateway - }); - } - if(args.data.guestNetmask != null && args.data.guestNetmask.length > 0) { - $.extend(dataObj, { - netmask: args.data.guestNetmask - }); - } - if(args.$form.find('.form-item[rel=vpcid]').css("display") != "none") { - $.extend(dataObj, { - vpcid: args.data.vpcid - }); - } + var dataObj = { + zoneId: args.data.zoneId, + name: args.data.name, + displayText: args.data.displayText, + networkOfferingId: args.data.networkOfferingId + }; + if(args.data.guestGateway != null && args.data.guestGateway.length > 0) { + $.extend(dataObj, { + gateway: args.data.guestGateway + }); + } + if(args.data.guestNetmask != null && args.data.guestNetmask.length > 0) { + $.extend(dataObj, { + netmask: args.data.guestNetmask + }); + } + if(args.$form.find('.form-item[rel=vpcid]').css("display") != "none") { + $.extend(dataObj, { + vpcid: args.data.vpcid + }); + } $.ajax({ url: createURL('createNetwork'), - data: dataObj, + data: dataObj, success: function(json) { args.response.success({ data: json.createnetworkresponse.network @@ -386,16 +386,16 @@ vlan: { label: 'label.vlan' }, cidr: { label: 'label.cidr' } /* - state: { - label: 'State', - indicator: { - 'Implemented': 'on', - 'Setup': 'on', - 'Allocated': 'on', - 'Destroyed': 'off' - } - } - */ + state: { + label: 'State', + indicator: { + 'Implemented': 'on', + 'Setup': 'on', + 'Allocated': 'on', + 'Destroyed': 'off' + } + } + */ }, dataProvider: function(args) { var array1 = []; @@ -414,7 +414,7 @@ dataType: 'json', async: false, success: function(data) { - args.response.success({ + args.response.success({ data: data.listnetworksresponse.network }); }, @@ -579,29 +579,29 @@ createForm: { title: 'label.restart.network', desc: 'message.restart.network', - preFilter: function(args) { - var zoneObj; - $.ajax({ - url: createURL("listZones&id=" + args.context.networks[0].zoneid), - dataType: "json", - async: false, - success: function(json){ - zoneObj = json.listzonesresponse.zone[0]; - } - }); - if(zoneObj.networktype == "Basic") { - args.$form.find('.form-item[rel=cleanup]').find('input').removeAttr('checked'); //unchecked - args.$form.find('.form-item[rel=cleanup]').hide(); //hidden - } - else { - args.$form.find('.form-item[rel=cleanup]').find('input').attr('checked', 'checked'); //checked - args.$form.find('.form-item[rel=cleanup]').css('display', 'inline-block'); //shown - } - }, - fields: { + preFilter: function(args) { + var zoneObj; + $.ajax({ + url: createURL("listZones&id=" + args.context.networks[0].zoneid), + dataType: "json", + async: false, + success: function(json){ + zoneObj = json.listzonesresponse.zone[0]; + } + }); + if(zoneObj.networktype == "Basic") { + args.$form.find('.form-item[rel=cleanup]').find('input').removeAttr('checked'); //unchecked + args.$form.find('.form-item[rel=cleanup]').hide(); //hidden + } + else { + args.$form.find('.form-item[rel=cleanup]').find('input').attr('checked', 'checked'); //checked + args.$form.find('.form-item[rel=cleanup]').css('display', 'inline-block'); //shown + } + }, + fields: { cleanup: { label: 'label.clean.up', - isBoolean: true + isBoolean: true } } }, @@ -611,7 +611,7 @@ } }, action: function(args) { - var array1 = []; + var array1 = []; array1.push("&cleanup=" + (args.data.cleanup == "on")); $.ajax({ url: createURL("restartNetwork&id=" + args.context.networks[0].id + array1.join("")), @@ -821,37 +821,37 @@ domain: { label: 'label.domain' }, account: { label: 'label.account' }, - - vpcid: { - label: 'VPC ID', - converter: function(args) { + + vpcid: { + label: 'VPC ID', + converter: function(args) { if(args != null) - return args; - else - return 'N/A'; - } - } + return args; + else + return 'N/A'; + } + } } ], tags: cloudStack.api.tags({ resourceType: 'Network', contextId: 'networks' }), - - dataProvider: function(args) { - $.ajax({ - url: createURL("listNetworks&id=" + args.context.networks[0].id), //pass "&listAll=true" to "listNetworks&id=xxxxxxxx" for now before API gets fixed. - dataType: "json", - async: true, - success: function(json) { - var jsonObj = json.listnetworksresponse.network[0]; - args.response.success( - { - actionFilter: cloudStack.actionFilter.guestNetwork, - data: jsonObj - } - ); - } - }); + + dataProvider: function(args) { + $.ajax({ + url: createURL("listNetworks&id=" + args.context.networks[0].id), //pass "&listAll=true" to "listNetworks&id=xxxxxxxx" for now before API gets fixed. + dataType: "json", + async: true, + success: function(json) { + var jsonObj = json.listnetworksresponse.network[0]; + args.response.success( + { + actionFilter: cloudStack.actionFilter.guestNetwork, + data: jsonObj + } + ); + } + }); } }, @@ -866,21 +866,21 @@ listView: $.extend(true, {}, cloudStack.sections.instances, { listView: { filters: false, - dataProvider: function(args) { - var networkid; - if('vpc' in args.context) - networkid = args.context.multiData.tier; - else - networkid = args.context.ipAddresses[0].associatednetworkid; - - var data = { - page: args.page, - pageSize: pageSize, - networkid: networkid, - listAll: true - }; - - $.ajax({ + dataProvider: function(args) { + var networkid; + if('vpc' in args.context) + networkid = args.context.multiData.tier; + else + networkid = args.context.ipAddresses[0].associatednetworkid; + + var data = { + page: args.page, + pageSize: pageSize, + networkid: networkid, + listAll: true + }; + + $.ajax({ url: createURL('listVirtualMachines'), data: data, dataType: 'json', @@ -930,11 +930,11 @@ } }, 'autoScale': { - label: 'AutoScale', - custom: { - buttonLabel: 'label.configure', - action: cloudStack.uiCustom.autoscaler(cloudStack.autoscaler) - } + label: 'AutoScale', + custom: { + buttonLabel: 'label.configure', + action: cloudStack.uiCustom.autoscaler(cloudStack.autoscaler) + } }, 'add-vm': { label: 'label.add.vms', @@ -943,34 +943,34 @@ }, add: { label: 'label.add.vms', - action: function(args) { + action: function(args) { var data = { algorithm: args.data.algorithm, name: args.data.name, privateport: args.data.privateport, publicport: args.data.publicport, - openfirewall: false, - domainid: g_domainid, - account: g_account + openfirewall: false, + domainid: g_domainid, + account: g_account }; - - if('vpc' in args.context) { //from VPC section - if(args.data.tier == null) { - args.response.error('Tier is required'); - return; - } - $.extend(data, { - networkid: args.data.tier - }); - } - else { //from Guest Network section - $.extend(data, { - networkid: args.context.networks[0].id - }); - } - + + if('vpc' in args.context) { //from VPC section + if(args.data.tier == null) { + args.response.error('Tier is required'); + return; + } + $.extend(data, { + networkid: args.data.tier + }); + } + else { //from Guest Network section + $.extend(data, { + networkid: args.context.networks[0].id + }); + } + var stickyData = $.extend(true, {}, args.data.sticky); - + $.ajax({ url: createURL('createLoadBalancerRule'), data: data, @@ -1064,7 +1064,7 @@ title: 'label.menu.ipaddresses', listView: { id: 'ipAddresses', - label: 'IPs', + label: 'IPs', fields: { ipaddress: { label: 'IP', @@ -1077,8 +1077,8 @@ } }, zonename: { label: 'label.zone' }, - //vlanname: { label: 'VLAN' }, - virtualmachinedisplayname: { label: 'label.vm.name' }, + //vlanname: { label: 'VLAN' }, + virtualmachinedisplayname: { label: 'label.vm.name' }, state: { converter: function(str) { // For localization @@ -1090,48 +1090,48 @@ actions: { add: { label: 'label.acquire.new.ip', - addRow: 'true', + addRow: 'true', preFilter: function(args) { - if('networks' in args.context) { //from Guest Network section - if(args.context.networks[0].vpcid == null) //if it's a non-VPC network, show Acquire IP button - return true; - else //if it's a VPC network, hide Acquire IP button - return false; - } - else { //from VPC section - return true; //show Acquire IP button - } - }, - messages: { + if('networks' in args.context) { //from Guest Network section + if(args.context.networks[0].vpcid == null) //if it's a non-VPC network, show Acquire IP button + return true; + else //if it's a VPC network, hide Acquire IP button + return false; + } + else { //from VPC section + return true; //show Acquire IP button + } + }, + messages: { confirm: function(args) { return 'message.acquire.new.ip'; - }, + }, notification: function(args) { return 'label.acquire.new.ip'; } - }, - action: function(args) { - var dataObj = {}; - if('vpc' in args.context) { //from VPC section - $.extend(dataObj, { - vpcid: args.context.vpc[0].id - }); - } - else if('networks' in args.context) { //from Guest Network section - $.extend(dataObj, { - networkid: args.context.networks[0].id - }); - - if(args.context.networks[0].type == "Shared" && !args.context.projects) { - $.extend(dataObj, { - domainid: g_domainid, - account: g_account - }); - } - } + }, + action: function(args) { + var dataObj = {}; + if('vpc' in args.context) { //from VPC section + $.extend(dataObj, { + vpcid: args.context.vpc[0].id + }); + } + else if('networks' in args.context) { //from Guest Network section + $.extend(dataObj, { + networkid: args.context.networks[0].id + }); + + if(args.context.networks[0].type == "Shared" && !args.context.projects) { + $.extend(dataObj, { + domainid: g_domainid, + account: g_account + }); + } + } $.ajax({ url: createURL('associateIpAddress'), - data: dataObj, + data: dataObj, success: function(data) { args.response.success({ _custom: { @@ -1193,13 +1193,13 @@ } } } - - if("vpc" in args.context) { - $.extend(data, { - vpcid: args.context.vpc[0].id - }); - } - + + if("vpc" in args.context) { + $.extend(data, { + vpcid: args.context.vpc[0].id + }); + } + $.ajax({ url: createURL("listPublicIpAddresses&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), data: data, @@ -1207,10 +1207,10 @@ async: true, success: function(json) { var items = json.listpublicipaddressesresponse.publicipaddress; - - $(items).each(function() { - getExtaPropertiesForIpObj(this, args); - }); + + $(items).each(function() { + getExtaPropertiesForIpObj(this, args); + }); args.response.success({ actionFilter: actionFilters.ipAddress, @@ -1357,7 +1357,7 @@ }, enableStaticNAT: { label: 'label.action.enable.static.NAT', - + action: { noAdd: true, custom: cloudStack.uiCustom.enableStaticNAT({ @@ -1371,7 +1371,7 @@ data: { vpcid: args.context.vpc[0].id, listAll: true, - supportedservices: 'StaticNat' + supportedservices: 'StaticNat' }, success: function(json) { var networks = json.listnetworksresponse.network; @@ -1399,37 +1399,37 @@ var $listView = args.$listView; var data = { page: args.page, - pageSize: pageSize, + pageSize: pageSize, listAll: true }; // See if tier is selected var $tierSelect = $listView.find('.tier-select select'); - + if ($tierSelect.size() && $tierSelect.val() != '-1') { data.networkid = $tierSelect.val(); } - else { - args.response.success({ data: null }); - return; - } + else { + args.response.success({ data: null }); + return; + } + + if('vpc' in args.context) { + $.extend(data, { + vpcid: args.context.vpc[0].id + }); + } + else if('networks' in args.context) { + $.extend(data, { + networkid: args.context.networks[0].id + }); + } - if('vpc' in args.context) { - $.extend(data, { - vpcid: args.context.vpc[0].id - }); - } - else if('networks' in args.context) { - $.extend(data, { - networkid: args.context.networks[0].id - }); - } - if (!args.context.projects) { $.extend(data, { account: args.context.ipAddresses[0].account, domainid: args.context.ipAddresses[0].domainid - }); + }); } $.ajax({ @@ -1457,22 +1457,22 @@ } } }), - action: function(args) { - var data = { - ipaddressid: args.context.ipAddresses[0].id, - virtualmachineid: args.context.instances[0].id - }; - - if('vpc' in args.context) { - if(args.tierID == '-1') { - args.response.error('Tier is required'); - return; - } - $.extend(data, { - networkid: args.tierID - }); - } - + action: function(args) { + var data = { + ipaddressid: args.context.ipAddresses[0].id, + virtualmachineid: args.context.instances[0].id + }; + + if('vpc' in args.context) { + if(args.tierID == '-1') { + args.response.error('Tier is required'); + return; + } + $.extend(data, { + networkid: args.tierID + }); + } + $.ajax({ url: createURL('enableStaticNat'), data: data, @@ -1608,38 +1608,38 @@ tabs: { details: { title: 'label.details', - - preFilter: function(args) { - var hiddenFields = []; - var zoneObj; - $.ajax({ - url: createURL("listZones&id=" + args.context.ipAddresses[0].zoneid), - dataType: "json", - async: false, - success: function(json) { - zoneObj = json.listzonesresponse.zone[0]; - } - }); - if(zoneObj.networktype == "Advanced") { - hiddenFields.push("issystem"); - hiddenFields.push("purpose"); - } - return hiddenFields; - }, - + + preFilter: function(args) { + var hiddenFields = []; + var zoneObj; + $.ajax({ + url: createURL("listZones&id=" + args.context.ipAddresses[0].zoneid), + dataType: "json", + async: false, + success: function(json) { + zoneObj = json.listzonesresponse.zone[0]; + } + }); + if(zoneObj.networktype == "Advanced") { + hiddenFields.push("issystem"); + hiddenFields.push("purpose"); + } + return hiddenFields; + }, + fields: [ { ipaddress: { label: 'IP' } }, { - id: { label: 'label.id' }, + id: { label: 'label.id' }, networkid: { label: 'label.network.id' }, associatednetworkid: { label: 'label.associated.network.id' }, state: { label: 'label.state' }, issourcenat: { label: 'label.source.nat', converter: cloudStack.converters.toBooleanText }, isstaticnat: { label: 'label.static.nat', converter: cloudStack.converters.toBooleanText }, issystem: { label: 'label.is.system', converter: cloudStack.converters.toBooleanText }, //(basic zone only) - purpose: { label: 'label.purpose' }, //(basic zone only) When an IP is system-generated, the purpose it serves can be Lb or static nat. + purpose: { label: 'label.purpose' }, //(basic zone only) When an IP is system-generated, the purpose it serves can be Lb or static nat. virtualmachinedisplayname: { label: 'label.vm.name' }, domain: { label: 'label.domain' }, account: { label: 'label.account' }, @@ -1647,7 +1647,7 @@ vlanname: { label: 'label.vlan' } } ], - + tags: cloudStack.api.tags({ resourceType: 'PublicIpAddress', contextId: 'ipAddresses' }), dataProvider: function(args) { @@ -1656,20 +1656,20 @@ // Get network data $.ajax({ url: createURL('listPublicIpAddresses'), - data: { + data: { id: args.context.ipAddresses[0].id, - listAll: true + listAll: true }, dataType: "json", async: true, - success: function(json) { - var ipObj = json.listpublicipaddressesresponse.publicipaddress[0]; - getExtaPropertiesForIpObj(ipObj, args); - + success: function(json) { + var ipObj = json.listpublicipaddressesresponse.publicipaddress[0]; + getExtaPropertiesForIpObj(ipObj, args); + args.response.success({ - actionFilter: actionFilters.ipAddress, - data: ipObj - }); + actionFilter: actionFilters.ipAddress, + data: ipObj + }); }, error: function(data) { args.response.error(parseXMLHttpResponse(data)); @@ -1681,7 +1681,7 @@ ipRules: { //Configuration tab title: 'label.configuration', custom: cloudStack.ipRules({ - preFilter: function(args) { + preFilter: function(args) { var disallowedActions = []; if (args.context.ipAddresses[0].isstaticnat) disallowedActions.push("nonStaticNATChart"); //tell ipRules widget to show staticNAT chart instead of non-staticNAT chart. @@ -1689,140 +1689,140 @@ var havingFirewallService = false; var havingPortForwardingService = false; var havingLbService = false; - var havingVpnService = false; - + var havingVpnService = false; + if('networks' in args.context && args.context.networks[0].vpcid == null) { //a non-VPC network from Guest Network section - $.ajax({ - url: createURL("listNetworkOfferings&id=" + args.context.networks[0].networkofferingid), - dataType: "json", - async: false, - success: function(json) { - var networkoffering = json.listnetworkofferingsresponse.networkoffering[0]; - $(networkoffering.service).each(function(){ - var thisService = this; - if(thisService.name == "Firewall") - havingFirewallService = true; - if(thisService.name == "PortForwarding") - havingPortForwardingService = true; - if(thisService.name == "Lb") - havingLbService = true; - if(thisService.name == "Vpn") - havingVpnService = true; - }); - } - }); - } - else { //a VPC network from Guest Network section or from VPC section + $.ajax({ + url: createURL("listNetworkOfferings&id=" + args.context.networks[0].networkofferingid), + dataType: "json", + async: false, + success: function(json) { + var networkoffering = json.listnetworkofferingsresponse.networkoffering[0]; + $(networkoffering.service).each(function(){ + var thisService = this; + if(thisService.name == "Firewall") + havingFirewallService = true; + if(thisService.name == "PortForwarding") + havingPortForwardingService = true; + if(thisService.name == "Lb") + havingLbService = true; + if(thisService.name == "Vpn") + havingVpnService = true; + }); + } + }); + } + else { //a VPC network from Guest Network section or from VPC section // Firewall is not supported in IP from VPC section // (because ACL has already supported in tier from VPC section) - havingFirewallService = false; - disallowedActions.push("firewall"); - - havingVpnService = false; //VPN is not supported in IP from VPC section - - if(args.context.ipAddresses[0].associatednetworkid == null) { //IP is not associated with any tier yet - havingPortForwardingService = true; - havingLbService = true; - } - else { //IP is associated with a tier - $.ajax({ - url: createURL("listNetworks&id=" + args.context.ipAddresses[0].associatednetworkid), - async: false, - success: function(json) { - var networkObj = json.listnetworksresponse.network[0]; - $.ajax({ - url: createURL("listNetworkOfferings&id=" + networkObj.networkofferingid), - async: false, - success: function(json) { - var networkoffering = json.listnetworkofferingsresponse.networkoffering[0]; - $(networkoffering.service).each(function(){ - var thisService = this; - if(thisService.name == "PortForwarding") - havingPortForwardingService = true; - if(thisService.name == "Lb") - havingLbService = true; - }); - } - }); - } - }); - } - } - - if(args.context.ipAddresses[0].networkOfferingConserveMode == false) { - /* - (1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added. - */ - if (args.context.ipAddresses[0].issourcenat){ - if(havingFirewallService == false) { //firewall is not supported in IP from VPC section (because ACL has already supported in tier from VPC section) - disallowedActions.push("firewall"); - } - - disallowedActions.push("portForwarding"); - disallowedActions.push("loadBalancing"); - } - - /* - (2) If IP is non-SourceNat, show StaticNat/VPN/PortForwarding/LoadBalancer at first. - 1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. - 2. If VPN service is supported (i.e. IP comes from Guest Network section, not from VPC section), once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. - 3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. - 4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. - */ - else { //args.context.ipAddresses[0].issourcenat == false - if(havingFirewallService == false) - disallowedActions.push("firewall"); - if(havingPortForwardingService == false) - disallowedActions.push("portForwarding"); - if(havingLbService == false) - disallowedActions.push("loadBalancing"); - - if (args.context.ipAddresses[0].isstaticnat) { //1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. - disallowedActions.push("portForwarding"); - disallowedActions.push("loadBalancing"); - } - if (havingVpnService && args.context.ipAddresses[0].vpnenabled) { //2. If VPN service is supported (i.e. IP comes from Guest Network section, not from VPC section), once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. - disallowedActions.push("portForwarding"); - disallowedActions.push("loadBalancing"); - } - - //3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. - $.ajax({ - url: createURL('listPortForwardingRules'), - data: { - ipaddressid: args.context.ipAddresses[0].id, - listAll: true - }, - dataType: 'json', - async: false, - success: function(json) { - // Get instance - var rules = json.listportforwardingrulesresponse.portforwardingrule; - if(rules != null && rules.length > 0) { - disallowedActions.push("loadBalancing"); - } - } - }); - - //4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. - $.ajax({ - url: createURL('listLoadBalancerRules'), - data: { - publicipid: args.context.ipAddresses[0].id, - listAll: true - }, - dataType: 'json', - async: false, - success: function(json) { - var rules = json.listloadbalancerrulesresponse.loadbalancerrule; - if(rules != null && rules.length > 0) { - disallowedActions.push("portForwarding"); - } - } - }); - } - } - + havingFirewallService = false; + disallowedActions.push("firewall"); + + havingVpnService = false; //VPN is not supported in IP from VPC section + + if(args.context.ipAddresses[0].associatednetworkid == null) { //IP is not associated with any tier yet + havingPortForwardingService = true; + havingLbService = true; + } + else { //IP is associated with a tier + $.ajax({ + url: createURL("listNetworks&id=" + args.context.ipAddresses[0].associatednetworkid), + async: false, + success: function(json) { + var networkObj = json.listnetworksresponse.network[0]; + $.ajax({ + url: createURL("listNetworkOfferings&id=" + networkObj.networkofferingid), + async: false, + success: function(json) { + var networkoffering = json.listnetworkofferingsresponse.networkoffering[0]; + $(networkoffering.service).each(function(){ + var thisService = this; + if(thisService.name == "PortForwarding") + havingPortForwardingService = true; + if(thisService.name == "Lb") + havingLbService = true; + }); + } + }); + } + }); + } + } + + if(args.context.ipAddresses[0].networkOfferingConserveMode == false) { + /* + (1) If IP is SourceNat, no StaticNat/VPN/PortForwarding/LoadBalancer can be enabled/added. + */ + if (args.context.ipAddresses[0].issourcenat){ + if(havingFirewallService == false) { //firewall is not supported in IP from VPC section (because ACL has already supported in tier from VPC section) + disallowedActions.push("firewall"); + } + + disallowedActions.push("portForwarding"); + disallowedActions.push("loadBalancing"); + } + + /* + (2) If IP is non-SourceNat, show StaticNat/VPN/PortForwarding/LoadBalancer at first. + 1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. + 2. If VPN service is supported (i.e. IP comes from Guest Network section, not from VPC section), once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. + 3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. + 4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. + */ + else { //args.context.ipAddresses[0].issourcenat == false + if(havingFirewallService == false) + disallowedActions.push("firewall"); + if(havingPortForwardingService == false) + disallowedActions.push("portForwarding"); + if(havingLbService == false) + disallowedActions.push("loadBalancing"); + + if (args.context.ipAddresses[0].isstaticnat) { //1. Once StaticNat is enabled, hide VPN/PortForwarding/LoadBalancer. + disallowedActions.push("portForwarding"); + disallowedActions.push("loadBalancing"); + } + if (havingVpnService && args.context.ipAddresses[0].vpnenabled) { //2. If VPN service is supported (i.e. IP comes from Guest Network section, not from VPC section), once VPN is enabled, hide StaticNat/PortForwarding/LoadBalancer. + disallowedActions.push("portForwarding"); + disallowedActions.push("loadBalancing"); + } + + //3. Once a PortForwarding rule is added, hide StaticNat/VPN/LoadBalancer. + $.ajax({ + url: createURL('listPortForwardingRules'), + data: { + ipaddressid: args.context.ipAddresses[0].id, + listAll: true + }, + dataType: 'json', + async: false, + success: function(json) { + // Get instance + var rules = json.listportforwardingrulesresponse.portforwardingrule; + if(rules != null && rules.length > 0) { + disallowedActions.push("loadBalancing"); + } + } + }); + + //4. Once a LoadBalancer rule is added, hide StaticNat/VPN/PortForwarding. + $.ajax({ + url: createURL('listLoadBalancerRules'), + data: { + publicipid: args.context.ipAddresses[0].id, + listAll: true + }, + dataType: 'json', + async: false, + success: function(json) { + var rules = json.listloadbalancerrulesresponse.loadbalancerrule; + if(rules != null && rules.length > 0) { + disallowedActions.push("portForwarding"); + } + } + }); + } + } + return disallowedActions; }, @@ -1984,14 +1984,14 @@ url: createURL('listPublicIpAddresses'), data: { id: args.context.ipAddresses[0].id, - listAll: true + listAll: true }, dataType: 'json', async: true, - success: function(data) { + success: function(data) { var ipObj = data.listpublicipaddressesresponse.publicipaddress[0]; getExtaPropertiesForIpObj(ipObj, args); - + args.response.success({ data: ipObj }); @@ -2024,111 +2024,111 @@ vmDetails: cloudStack.sections.instances.listView.detailView, - - //"NAT Port Range" multiEdit screen for StaticNAT is obsolete in cloudstack 3.0 because createIpForwardingRule/deleteIpForwardingRule/listIpForwardingRules API are obsolete in cloudstack 3.0. - //cloudstack 3.0 is using createFirewallRule/listFirewallRules/deleteFirewallRule API for both staticNAT and non-staticNAT . - /* - staticNAT: { - noSelect: true, - fields: { - 'protocol': { - label: 'label.protocol', - select: function(args) { - args.response.success({ - data: [ - { name: 'tcp', description: 'TCP' }, - { name: 'udp', description: 'UDP' } - ] - }); - } - }, - 'startport': { edit: true, label: 'label.start.port' }, - 'endport': { edit: true, label: 'label.end.port' }, - 'add-rule': { - label: 'label.add.rule', - addButton: true - } - }, - add: { - label: 'label.add', - action: function(args) { - $.ajax({ - url: createURL('createIpForwardingRule'), - data: $.extend(args.data, { - ipaddressid: args.context.ipAddresses[0].id - }), - dataType: 'json', - success: function(data) { - args.response.success({ - _custom: { - jobId: data.createipforwardingruleresponse.jobid - }, - notification: { - label: 'label.add.static.nat.rule', - poll: pollAsyncJobResult - } - }); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - } - }, - actions: { - destroy: { - label: 'label.remove.rule', - action: function(args) { - $.ajax({ - url: createURL('deleteIpForwardingRule'), - data: { - id: args.context.multiRule[0].id - }, - dataType: 'json', - async: true, - success: function(data) { - var jobID = data.deleteipforwardingruleresponse.jobid; - args.response.success({ - _custom: { - jobId: jobID - }, - notification: { - label: 'label.remove.static.nat.rule', - poll: pollAsyncJobResult - } - }); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - } - } - }, - dataProvider: function(args) { - setTimeout(function() { - $.ajax({ - url: createURL('listIpForwardingRules'), - data: { - listAll: true, - ipaddressid: args.context.ipAddresses[0].id - }, - dataType: 'json', - async: true, - success: function(data) { - args.response.success({ - data: data.listipforwardingrulesresponse.ipforwardingrule - }); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, 100); - } - }, - */ - + + //"NAT Port Range" multiEdit screen for StaticNAT is obsolete in cloudstack 3.0 because createIpForwardingRule/deleteIpForwardingRule/listIpForwardingRules API are obsolete in cloudstack 3.0. + //cloudstack 3.0 is using createFirewallRule/listFirewallRules/deleteFirewallRule API for both staticNAT and non-staticNAT . + /* + staticNAT: { + noSelect: true, + fields: { + 'protocol': { + label: 'label.protocol', + select: function(args) { + args.response.success({ + data: [ + { name: 'tcp', description: 'TCP' }, + { name: 'udp', description: 'UDP' } + ] + }); + } + }, + 'startport': { edit: true, label: 'label.start.port' }, + 'endport': { edit: true, label: 'label.end.port' }, + 'add-rule': { + label: 'label.add.rule', + addButton: true + } + }, + add: { + label: 'label.add', + action: function(args) { + $.ajax({ + url: createURL('createIpForwardingRule'), + data: $.extend(args.data, { + ipaddressid: args.context.ipAddresses[0].id + }), + dataType: 'json', + success: function(data) { + args.response.success({ + _custom: { + jobId: data.createipforwardingruleresponse.jobid + }, + notification: { + label: 'label.add.static.nat.rule', + poll: pollAsyncJobResult + } + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + } + }, + actions: { + destroy: { + label: 'label.remove.rule', + action: function(args) { + $.ajax({ + url: createURL('deleteIpForwardingRule'), + data: { + id: args.context.multiRule[0].id + }, + dataType: 'json', + async: true, + success: function(data) { + var jobID = data.deleteipforwardingruleresponse.jobid; + args.response.success({ + _custom: { + jobId: jobID + }, + notification: { + label: 'label.remove.static.nat.rule', + poll: pollAsyncJobResult + } + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + } + } + }, + dataProvider: function(args) { + setTimeout(function() { + $.ajax({ + url: createURL('listIpForwardingRules'), + data: { + listAll: true, + ipaddressid: args.context.ipAddresses[0].id + }, + dataType: 'json', + async: true, + success: function(data) { + args.response.success({ + data: data.listipforwardingrulesresponse.ipforwardingrule + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + }, 100); + } + }, + */ + // Load balancing rules loadBalancing: { @@ -2137,14 +2137,14 @@ filters: false, dataProvider: function(args) { var itemData = $.isArray(args.context.multiRule) && args.context.multiRule[0]['_itemData'] ? - args.context.multiRule[0]['_itemData'] : []; - - var networkid; - if('vpc' in args.context) - networkid = args.context.multiData.tier; - else - networkid = args.context.ipAddresses[0].associatednetworkid; - + args.context.multiRule[0]['_itemData'] : []; + + var networkid; + if('vpc' in args.context) + networkid = args.context.multiData.tier; + else + networkid = args.context.ipAddresses[0].associatednetworkid; + var data = { page: args.page, pageSize: pageSize, @@ -2156,7 +2156,7 @@ $.extend(data, { account: args.context.ipAddresses[0].account, domainid: args.context.ipAddresses[0].domainid - }); + }); } $.ajax({ @@ -2192,36 +2192,36 @@ headerFields: { tier: { label: 'Tier', - select: function(args) { - if('vpc' in args.context) { + select: function(args) { + if('vpc' in args.context) { var data = { - listAll: true, - supportedservices: 'Lb' - }; - if(args.context.ipAddresses[0].associatednetworkid == null) { - $.extend(data, { - vpcid: args.context.vpc[0].id - }); - } - else { - $.extend(data, { - id: args.context.ipAddresses[0].associatednetworkid - }); - } - - $.ajax({ - url: createURL("listNetworks"), - data: data, - success: function(json) { - var networks = json.listnetworksresponse.network; - var items = []; - $(networks).each(function(){ - items.push({id: this.id, description: this.displaytext}); - }); - args.response.success({ data: items }); - } - }); - } + listAll: true, + supportedservices: 'Lb' + }; + if(args.context.ipAddresses[0].associatednetworkid == null) { + $.extend(data, { + vpcid: args.context.vpc[0].id + }); + } + else { + $.extend(data, { + id: args.context.ipAddresses[0].associatednetworkid + }); + } + + $.ajax({ + url: createURL("listNetworks"), + data: data, + success: function(json) { + var networks = json.listnetworksresponse.network; + var items = []; + $(networks).each(function(){ + items.push({id: this.id, description: this.displaytext}); + }); + args.response.success({ data: items }); + } + }); + } } } }, @@ -2251,13 +2251,13 @@ action: cloudStack.lbStickyPolicy.dialog() } }, - 'autoScale': { - label: 'AutoScale', - custom: { - buttonLabel: 'label.configure', - action: cloudStack.uiCustom.autoscaler(cloudStack.autoscaler) - } - }, + 'autoScale': { + label: 'AutoScale', + custom: { + buttonLabel: 'label.configure', + action: cloudStack.uiCustom.autoscaler(cloudStack.autoscaler) + } + }, 'add-vm': { label: 'label.add.vms', @@ -2269,29 +2269,29 @@ add: { label: 'label.add.vms', - action: function(args) { - var networkid; - if('vpc' in args.context) { //from VPC section - if(args.data.tier == null) { - args.response.error('Tier is required'); - return; - } - networkid = args.data.tier; - } - else if('networks' in args.context) { //from Guest Network section - networkid = args.context.networks[0].id; - } + action: function(args) { + var networkid; + if('vpc' in args.context) { //from VPC section + if(args.data.tier == null) { + args.response.error('Tier is required'); + return; + } + networkid = args.data.tier; + } + else if('networks' in args.context) { //from Guest Network section + networkid = args.context.networks[0].id; + } var data = { algorithm: args.data.algorithm, name: args.data.name, privateport: args.data.privateport, publicport: args.data.publicport, - openfirewall: false, - networkid: networkid, - publicipid: args.context.ipAddresses[0].id + openfirewall: false, + networkid: networkid, + publicipid: args.context.ipAddresses[0].id }; - - var stickyData = $.extend(true, {}, args.data.sticky); + + var stickyData = $.extend(true, {}, args.data.sticky); $.ajax({ url: createURL('createLoadBalancerRule'), @@ -2380,7 +2380,7 @@ } }); } - }); + }); } }, destroy: { @@ -2476,10 +2476,10 @@ $.ajax({ url: createURL('listLoadBalancerRules'), - data: { - publicipid: args.context.ipAddresses[0].id, - listAll: true - }, + data: { + publicipid: args.context.ipAddresses[0].id, + listAll: true + }, dataType: 'json', async: true, success: function(data) { @@ -2503,7 +2503,7 @@ }, success: function(json) { var stickyPolicy = json.listlbstickinesspoliciesresponse.stickinesspolicies ? - json.listlbstickinesspoliciesresponse.stickinesspolicies[0].stickinesspolicy : null; + json.listlbstickinesspoliciesresponse.stickinesspolicies[0].stickinesspolicy : null; if (stickyPolicy && stickyPolicy.length) { stickyPolicy = stickyPolicy[0]; @@ -2539,7 +2539,7 @@ id: item.id }, success: function(data) { - lbInstances = data.listloadbalancerruleinstancesresponse.loadbalancerruleinstance ? + lbInstances = data.listloadbalancerruleinstancesresponse.loadbalancerruleinstance ? data.listloadbalancerruleinstancesresponse.loadbalancerruleinstance : []; }, error: function(data) { @@ -2553,7 +2553,7 @@ return $.extend(vm, { _displayName: vm.id == vm.displayname ? (vm.instancename ? vm.instancename : vm.name) - : vm.displayname + : vm.displayname }); }), _maxLength: { @@ -2572,36 +2572,36 @@ } }); - // Check if tiers are present; hide/show header drop-down (begin) *** + // Check if tiers are present; hide/show header drop-down (begin) *** //dataProvider() is called when a LB rule is added in multiEdit. However, adding a LB rule might change parent object (IP Address object). So, we have to force to refresh args.context.ipAddresses[0] here - $.ajax({ - url: createURL('listPublicIpAddresses'), - data: { - id: args.context.ipAddresses[0].id, - listAll: true - }, - success: function(json) { - var ipObj = json.listpublicipaddressesresponse.publicipaddress[0]; - getExtaPropertiesForIpObj(ipObj, args); - - args.context.ipAddresses.shift(); //remove the first element in args.context.ipAddresses - args.context.ipAddresses.push(ipObj); - - var $headerFields = $multi.find('.header-fields'); - if ('vpc' in args.context) { - if(args.context.ipAddresses[0].associatednetworkid == null) { - $headerFields.show(); - } - else { - $headerFields.hide(); - } - } - else if('networks' in args.context){ - $headerFields.hide(); - } - } - }); - // Check if tiers are present; hide/show header drop-down (end) *** + $.ajax({ + url: createURL('listPublicIpAddresses'), + data: { + id: args.context.ipAddresses[0].id, + listAll: true + }, + success: function(json) { + var ipObj = json.listpublicipaddressesresponse.publicipaddress[0]; + getExtaPropertiesForIpObj(ipObj, args); + + args.context.ipAddresses.shift(); //remove the first element in args.context.ipAddresses + args.context.ipAddresses.push(ipObj); + + var $headerFields = $multi.find('.header-fields'); + if ('vpc' in args.context) { + if(args.context.ipAddresses[0].associatednetworkid == null) { + $headerFields.show(); + } + else { + $headerFields.hide(); + } + } + else if('networks' in args.context){ + $headerFields.hide(); + } + } + }); + // Check if tiers are present; hide/show header drop-down (end) *** } }, @@ -2611,34 +2611,34 @@ tier: { label: 'Tier', select: function(args) { - if('vpc' in args.context) { + if('vpc' in args.context) { var data = { - listAll: true, - supportedservices: 'PortForwarding' - }; - if(args.context.ipAddresses[0].associatednetworkid == null) { - $.extend(data, { - vpcid: args.context.vpc[0].id - }); - } - else { - $.extend(data, { - id: args.context.ipAddresses[0].associatednetworkid - }); - } - $.ajax({ - url: createURL("listNetworks"), - data: data, - success: function(json) { - var networks = json.listnetworksresponse.network; - var items = []; - $(networks).each(function(){ - items.push({id: this.id, description: this.displaytext}); - }); - args.response.success({ data: items }); - } - }); - } + listAll: true, + supportedservices: 'PortForwarding' + }; + if(args.context.ipAddresses[0].associatednetworkid == null) { + $.extend(data, { + vpcid: args.context.vpc[0].id + }); + } + else { + $.extend(data, { + id: args.context.ipAddresses[0].associatednetworkid + }); + } + $.ajax({ + url: createURL("listNetworks"), + data: data, + success: function(json) { + var networks = json.listnetworksresponse.network; + var items = []; + $(networks).each(function(){ + items.push({id: this.id, description: this.displaytext}); + }); + args.response.success({ data: items }); + } + }); + } } } }, @@ -2647,12 +2647,12 @@ filters: false, dataProvider: function(args) { var networkid; - if('vpc' in args.context) - networkid = args.context.multiData.tier; - else - networkid = args.context.ipAddresses[0].associatednetworkid; - - var data = { + if('vpc' in args.context) + networkid = args.context.multiData.tier; + else + networkid = args.context.ipAddresses[0].associatednetworkid; + + var data = { page: args.page, pageSize: pageSize, listAll: true, @@ -2663,7 +2663,7 @@ $.extend(data, { account: args.context.ipAddresses[0].account, domainid: args.context.ipAddresses[0].domainid - }); + }); } $.ajax({ @@ -2725,34 +2725,34 @@ add: { label: 'label.add.vm', - action: function(args) { - var data = { - ipaddressid: args.context.ipAddresses[0].id, - privateport: args.data.privateport, - publicport: args.data.publicport, - protocol: args.data.protocol, - virtualmachineid: args.itemData[0].id, - openfirewall: false - }; - - if('vpc' in args.context) { //from VPC section - if(args.data.tier == null) { - args.response.error('Tier is required'); - return; - } + action: function(args) { + var data = { + ipaddressid: args.context.ipAddresses[0].id, + privateport: args.data.privateport, + publicport: args.data.publicport, + protocol: args.data.protocol, + virtualmachineid: args.itemData[0].id, + openfirewall: false + }; + + if('vpc' in args.context) { //from VPC section + if(args.data.tier == null) { + args.response.error('Tier is required'); + return; + } + $.extend(data, { + networkid: args.data.tier + }); + } + else { //from Guest Network section $.extend(data, { - networkid: args.data.tier - }); - } - else { //from Guest Network section - $.extend(data, { networkid: args.context.networks[0].id - }); - } - + }); + } + $.ajax({ url: createURL('createPortForwardingRule'), - data: data, + data: data, success: function(data) { args.response.success({ _custom: { @@ -2816,7 +2816,7 @@ }, dataProvider: function(args) { var $multi = args.$multi; - + $.ajax({ url: createURL('listPortForwardingRules'), data: { @@ -2834,7 +2834,7 @@ $(portForwardingData).each(function() { var item = this; - + item._itemName = '_displayName'; $.ajax({ @@ -2868,37 +2868,37 @@ } }); }); - - // Check if tiers are present; hide/show header drop-down (begin) *** - //dataProvider() is called when a PF rule is added in multiEdit. However, adding a LB rule might change parent object (IP Address object). So, we have to force to refresh args.context.ipAddresses[0] here - $.ajax({ - url: createURL('listPublicIpAddresses'), - data: { - id: args.context.ipAddresses[0].id, - listAll: true - }, - success: function(json) { - var ipObj = json.listpublicipaddressesresponse.publicipaddress[0]; - getExtaPropertiesForIpObj(ipObj, args); - - args.context.ipAddresses.shift(); //remove the first element in args.context.ipAddresses - args.context.ipAddresses.push(ipObj); - - var $headerFields = $multi.find('.header-fields'); - if ('vpc' in args.context) { - if(args.context.ipAddresses[0].associatednetworkid == null) { - $headerFields.show(); - } - else { - $headerFields.hide(); - } - } - else if('networks' in args.context){ - $headerFields.hide(); - } - } - }); - // Check if tiers are present; hide/show header drop-down (end) *** + + // Check if tiers are present; hide/show header drop-down (begin) *** + //dataProvider() is called when a PF rule is added in multiEdit. However, adding a LB rule might change parent object (IP Address object). So, we have to force to refresh args.context.ipAddresses[0] here + $.ajax({ + url: createURL('listPublicIpAddresses'), + data: { + id: args.context.ipAddresses[0].id, + listAll: true + }, + success: function(json) { + var ipObj = json.listpublicipaddressesresponse.publicipaddress[0]; + getExtaPropertiesForIpObj(ipObj, args); + + args.context.ipAddresses.shift(); //remove the first element in args.context.ipAddresses + args.context.ipAddresses.push(ipObj); + + var $headerFields = $multi.find('.header-fields'); + if ('vpc' in args.context) { + if(args.context.ipAddresses[0].associatednetworkid == null) { + $headerFields.show(); + } + else { + $headerFields.hide(); + } + } + else if('networks' in args.context){ + $headerFields.hide(); + } + } + }); + // Check if tiers are present; hide/show header drop-down (end) *** }, error: function(data) { args.response.error(parseXMLHttpResponse(data)); @@ -2943,9 +2943,9 @@ $.ajax({ url: createURL('addVpnUser'), data: $.extend(args.data, { - domainid: args.context.ipAddresses[0].domainid, - account: args.context.ipAddresses[0].account - }), + domainid: args.context.ipAddresses[0].domainid, + account: args.context.ipAddresses[0].account + }), dataType: 'json', success: function(data) { args.response.success({ @@ -3306,7 +3306,7 @@ success: function(data) { args.response.success({ data: $.map( - data.listsecuritygroupsresponse.securitygroup[0].ingressrule ? + data.listsecuritygroupsresponse.securitygroup[0].ingressrule ? data.listsecuritygroupsresponse.securitygroup[0].ingressrule : [], function(elem) { return { @@ -3483,7 +3483,7 @@ success: function(data) { args.response.success({ data: $.map( - data.listsecuritygroupsresponse.securitygroup[0].egressrule ? + data.listsecuritygroupsresponse.securitygroup[0].egressrule ? data.listsecuritygroupsresponse.securitygroup[0].egressrule : [], function(elem) { return { @@ -3552,59 +3552,59 @@ id: 'vpc', label: 'VPC', fields: { - name: { label: 'label.name' }, - displaytext: { label: 'label.description' }, - zonename: { label: 'label.zone' }, - cidr: { label: 'label.cidr' } + name: { label: 'label.name' }, + displaytext: { label: 'label.description' }, + zonename: { label: 'label.zone' }, + cidr: { label: 'label.cidr' } }, - dataProvider: function(args) { - var array1 = []; - if(args.filterBy != null) { - if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) { - switch(args.filterBy.search.by) { - case "name": - if(args.filterBy.search.value.length > 0) - array1.push("&keyword=" + args.filterBy.search.value); - break; - } - } - } - + dataProvider: function(args) { + var array1 = []; + if(args.filterBy != null) { + if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) { + switch(args.filterBy.search.by) { + case "name": + if(args.filterBy.search.value.length > 0) + array1.push("&keyword=" + args.filterBy.search.value); + break; + } + } + } + $.ajax({ url: createURL("listVPCs&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), dataType: "json", async: true, success: function(json) { - var items = json.listvpcsresponse.vpc; + var items = json.listvpcsresponse.vpc; args.response.success({data:items}); } - }); + }); }, actions: { add: { - label: 'Add VPC', - messages: { - notification: function(args) { - return 'Add VPC'; - } - }, + label: 'Add VPC', + messages: { + notification: function(args) { + return 'Add VPC'; + } + }, createForm: { title: 'Add VPC', - messages: { - notification: function(args) { - return 'Add VPC'; - } - }, + messages: { + notification: function(args) { + return 'Add VPC'; + } + }, fields: { - name: { - label: 'label.name', - validation: { required: true } - }, + name: { + label: 'label.name', + validation: { required: true } + }, displaytext: { label: 'label.description', - validation: { required: true } - }, - zoneid: { + validation: { required: true } + }, + zoneid: { label: 'Zone', validation: { required: true }, select: function(args) { @@ -3613,10 +3613,10 @@ url: createURL('listZones'), data: data, success: function(json) { - var zones = json.listzonesresponse.zone; - var advZones = $.grep(zones, function(zone) { - return zone.networktype == 'Advanced'; - }); + var zones = json.listzonesresponse.zone; + var advZones = $.grep(zones, function(zone) { + return zone.networktype == 'Advanced'; + }); args.response.success({ data: $.map(advZones, function(zone) { return { @@ -3629,64 +3629,64 @@ }); } }, - cidr: { - label: 'label.cidr', - validation: { required: true } - }, - networkdomain: { - label: 'label.network.domain' - } + cidr: { + label: 'label.cidr', + validation: { required: true } + }, + networkdomain: { + label: 'label.network.domain' + } } - }, - action: function(args) { - var defaultvpcofferingid; - $.ajax({ - url: createURL("listVPCOfferings"), - dataType: "json", - data: { - isdefault: true - }, - async: false, - success: function(json) { - defaultvpcofferingid = json.listvpcofferingsresponse.vpcoffering[0].id; - } - }); - - var dataObj = { - name: args.data.name, - displaytext: args.data.displaytext, - zoneid: args.data.zoneid, - cidr: args.data.cidr, - vpcofferingid: defaultvpcofferingid - }; - - if(args.data.networkdomain != null && args.data.networkdomain.length > 0) - $.extend(dataObj, { networkdomain: args.data.networkdomain }); - - $.ajax({ + }, + action: function(args) { + var defaultvpcofferingid; + $.ajax({ + url: createURL("listVPCOfferings"), + dataType: "json", + data: { + isdefault: true + }, + async: false, + success: function(json) { + defaultvpcofferingid = json.listvpcofferingsresponse.vpcoffering[0].id; + } + }); + + var dataObj = { + name: args.data.name, + displaytext: args.data.displaytext, + zoneid: args.data.zoneid, + cidr: args.data.cidr, + vpcofferingid: defaultvpcofferingid + }; + + if(args.data.networkdomain != null && args.data.networkdomain.length > 0) + $.extend(dataObj, { networkdomain: args.data.networkdomain }); + + $.ajax({ url: createURL("createVPC"), dataType: "json", - data: dataObj, + data: dataObj, async: true, success: function(json) { var jid = json.createvpcresponse.jobid; args.response.success( {_custom: - {jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.vpc; - } + {jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.vpc; } + } } ); } - }); + }); }, - - notification: { + + notification: { poll: pollAsyncJobResult - } - + } + }, configureVpc: { label: 'Configure VPC', @@ -3695,11 +3695,11 @@ custom: cloudStack.uiCustom.vpc(cloudStack.vpc) } } - }, - - detailView: { - name: 'label.details', - actions: { + }, + + detailView: { + name: 'label.details', + actions: { configureVpc: { label: 'Edit VPC', textLabel: 'label.configure', @@ -3708,68 +3708,29 @@ }, messages: { notification: function() { return ''; } } }, - - edit: { + + edit: { label: 'label.edit', - action: function(args) { + action: function(args) { $.ajax({ url: createURL('updateVPC'), data: { - id: args.context.vpc[0].id, - name: args.data.name, - displaytext: args.data.displaytext - }, + id: args.context.vpc[0].id, + name: args.data.name, + displaytext: args.data.displaytext + }, success: function(json) { var jid = json.updatevpcresponse.jobid; args.response.success( {_custom: - { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.vpc; - } - } + { + jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.vpc; + } + } } - ); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - restart: { - label: 'restart VPC', - messages: { - confirm: function(args) { - return 'Please confirm that you want to restart the VPC'; - }, - notification: function(args) { - return 'restart VPC'; - } - }, - action: function(args) { - $.ajax({ - url: createURL("restartVPC"), - data: { - id: args.context.vpc[0].id - }, - success: function(json) { - var jid = json.restartvpcresponse.jobid; - args.response.success( - {_custom: - { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.vpc; - } - } - } - ); + ); }, error: function(data) { args.response.error(parseXMLHttpResponse(data)); @@ -3779,8 +3740,47 @@ notification: { poll: pollAsyncJobResult } - }, - + }, + + restart: { + label: 'restart VPC', + messages: { + confirm: function(args) { + return 'Please confirm that you want to restart the VPC'; + }, + notification: function(args) { + return 'restart VPC'; + } + }, + action: function(args) { + $.ajax({ + url: createURL("restartVPC"), + data: { + id: args.context.vpc[0].id + }, + success: function(json) { + var jid = json.restartvpcresponse.jobid; + args.response.success( + {_custom: + { + jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.vpc; + } + } + } + ); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + }, + remove: { label: 'remove VPC', messages: { @@ -3791,21 +3791,21 @@ return 'remove VPC'; } }, - action: function(args) { + action: function(args) { $.ajax({ url: createURL("deleteVPC"), data: { - id: args.context.vpc[0].id - }, - success: function(json) { - var jid = json.deletevpcresponse.jobid; + id: args.context.vpc[0].id + }, + success: function(json) { + var jid = json.deletevpcresponse.jobid; args.response.success( {_custom: - { - jobId: jid - } + { + jobId: jid + } } - ); + ); }, error: function(data) { args.response.error(parseXMLHttpResponse(data)); @@ -3816,47 +3816,47 @@ poll: pollAsyncJobResult } } - }, + }, tabs: { details: { title: 'label.details', fields: [ - { + { name: { label: 'label.name', isEditable: true } }, - { - displaytext: { label: 'label.description', isEditable: true }, - zonename: { label: 'label.zone' }, - cidr: { label: 'label.cidr' }, - networkdomain: { label: 'label.network.domain' }, - state: { label: 'label.state' }, - id: { label: 'label.id' } + { + displaytext: { label: 'label.description', isEditable: true }, + zonename: { label: 'label.zone' }, + cidr: { label: 'label.cidr' }, + networkdomain: { label: 'label.network.domain' }, + state: { label: 'label.state' }, + id: { label: 'label.id' } } ], tags: cloudStack.api.tags({ resourceType: 'Vpc', contextId: 'vpc' }), - dataProvider: function(args) { - $.ajax({ - url: createURL("listVPCs"), - dataType: "json", - data: { - id: args.context.vpc[0].id - }, - async: true, - success: function(json) { - var item = json.listvpcsresponse.vpc[0]; - args.response.success({data: item}); - } - }); - } + dataProvider: function(args) { + $.ajax({ + url: createURL("listVPCs"), + dataType: "json", + data: { + id: args.context.vpc[0].id + }, + async: true, + success: function(json) { + var item = json.listvpcsresponse.vpc[0]; + args.response.success({data: item}); + } + }); + } } } - } + } } - }, - - vpnCustomerGateway: { + }, + + vpnCustomerGateway: { type: 'select', title: 'VPN Customer Gateway', listView: { @@ -3865,128 +3865,128 @@ fields: { gateway: { label: 'label.gateway' }, cidrlist: { label: 'CIDR list' }, - ipsecpsk: { label: 'IPsec Preshared-Key' } + ipsecpsk: { label: 'IPsec Preshared-Key' } }, - dataProvider: function(args) { - var array1 = []; - if(args.filterBy != null) { - if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) { - switch(args.filterBy.search.by) { - case "name": - if(args.filterBy.search.value.length > 0) - array1.push("&keyword=" + args.filterBy.search.value); - break; - } - } - } - + dataProvider: function(args) { + var array1 = []; + if(args.filterBy != null) { + if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) { + switch(args.filterBy.search.by) { + case "name": + if(args.filterBy.search.value.length > 0) + array1.push("&keyword=" + args.filterBy.search.value); + break; + } + } + } + $.ajax({ url: createURL("listVpnCustomerGateways&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), dataType: "json", async: true, - success: function(json) { + success: function(json) { var items = json.listvpncustomergatewaysresponse.vpncustomergateway; args.response.success({data: items}); } }); }, - - actions: { - add: { - label: 'add VPN Customer Gateway', - messages: { - notification: function(args) { - return 'add VPN Customer Gateway'; - } - }, - createForm: { - title: 'add VPN Customer Gateway', - fields: { - gateway: { - label: 'label.gateway', - validation: { required: true } - }, - cidrlist: { - label: 'CIDR list', - validation: { required: true } - }, - ipsecpsk: { - label: 'IPsec Preshared-Key', - validation: { required: true } - }, - ikepolicy: { - label: 'IKE policy', - select: function(args) { - var items = []; - items.push({id: '3des-md5', description: '3des-md5'}); - items.push({id: 'aes-md5', description: 'aes-md5'}); - items.push({id: 'aes128-md5', description: 'aes128-md5'}); - items.push({id: 'des-md5', description: 'des-md5'}); - items.push({id: '3des-sha1', description: '3des-sha1'}); - items.push({id: 'aes-sha1', description: 'aes-sha1'}); - items.push({id: 'aes128-sha1', description: 'aes128-sha1'}); - items.push({id: 'des-sha1', description: 'des-sha1'}); - args.response.success({data: items}); - } - }, - esppolicy: { - label: 'ESP policy', - select: function(args) { - var items = []; - items.push({id: '3des-md5', description: '3des-md5'}); - items.push({id: 'aes-md5', description: 'aes-md5'}); - items.push({id: 'aes128-md5', description: 'aes128-md5'}); - - items.push({id: '3des-sha1', description: '3des-sha1'}); - items.push({id: 'aes-sha1', description: 'aes-sha1'}); - items.push({id: 'aes128-sha1', description: 'aes128-sha1'}); - args.response.success({data: items}); - } - }, - lifetime: { - label: 'Lifetime (second)', - defaultValue: '86400', - validation: { required: false, number: true } - } - } - }, - action: function(args) { - $.ajax({ - url: createURL('createVpnCustomerGateway'), - data: { - gateway: args.data.gateway, - cidrlist: args.data.cidrlist, - ipsecpsk: args.data.ipsecpsk, - ikepolicy: args.data.ikepolicy, - esppolicy: args.data.esppolicy, - lifetime: args.data.lifetime - }, - dataType: 'json', - success: function(json) { - var jid = json.createvpncustomergatewayresponse.jobid; - args.response.success( - {_custom: - { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.vpncustomergateway; - } - } - } - ); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - } - }, - - detailView: { - name: 'label.details', - actions: { - add: { + + actions: { + add: { + label: 'add VPN Customer Gateway', + messages: { + notification: function(args) { + return 'add VPN Customer Gateway'; + } + }, + createForm: { + title: 'add VPN Customer Gateway', + fields: { + gateway: { + label: 'label.gateway', + validation: { required: true } + }, + cidrlist: { + label: 'CIDR list', + validation: { required: true } + }, + ipsecpsk: { + label: 'IPsec Preshared-Key', + validation: { required: true } + }, + ikepolicy: { + label: 'IKE policy', + select: function(args) { + var items = []; + items.push({id: '3des-md5', description: '3des-md5'}); + items.push({id: 'aes-md5', description: 'aes-md5'}); + items.push({id: 'aes128-md5', description: 'aes128-md5'}); + items.push({id: 'des-md5', description: 'des-md5'}); + items.push({id: '3des-sha1', description: '3des-sha1'}); + items.push({id: 'aes-sha1', description: 'aes-sha1'}); + items.push({id: 'aes128-sha1', description: 'aes128-sha1'}); + items.push({id: 'des-sha1', description: 'des-sha1'}); + args.response.success({data: items}); + } + }, + esppolicy: { + label: 'ESP policy', + select: function(args) { + var items = []; + items.push({id: '3des-md5', description: '3des-md5'}); + items.push({id: 'aes-md5', description: 'aes-md5'}); + items.push({id: 'aes128-md5', description: 'aes128-md5'}); + + items.push({id: '3des-sha1', description: '3des-sha1'}); + items.push({id: 'aes-sha1', description: 'aes-sha1'}); + items.push({id: 'aes128-sha1', description: 'aes128-sha1'}); + args.response.success({data: items}); + } + }, + lifetime: { + label: 'Lifetime (second)', + defaultValue: '86400', + validation: { required: false, number: true } + } + } + }, + action: function(args) { + $.ajax({ + url: createURL('createVpnCustomerGateway'), + data: { + gateway: args.data.gateway, + cidrlist: args.data.cidrlist, + ipsecpsk: args.data.ipsecpsk, + ikepolicy: args.data.ikepolicy, + esppolicy: args.data.esppolicy, + lifetime: args.data.lifetime + }, + dataType: 'json', + success: function(json) { + var jid = json.createvpncustomergatewayresponse.jobid; + args.response.success( + {_custom: + { + jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.vpncustomergateway; + } + } + } + ); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + } + }, + + detailView: { + name: 'label.details', + actions: { + add: { addRow: 'false', label: 'Create VPN Connection', messages: { @@ -3998,105 +3998,105 @@ } }, createForm: { - title: 'Create VPN Connection', - fields: { - zoneid: { - label: 'Zone', - validation: { required: true }, - select: function(args) { - $.ajax({ - url: createURL('listZones'), - data: { - available: true - }, - success: function(json) { - var zones = json.listzonesresponse.zone; - args.response.success({ - data: $.map(zones, function(zone) { - return { - id: zone.id, - description: zone.name - }; - }) - }); - } - }); - } - }, - vpcid: { - label: 'VPC', - validation: { required: true }, - dependsOn: 'zoneid', - select: function(args) { - $.ajax({ - url: createURL('listVPCs'), - data: { - zoneid: args.zoneid, - listAll: true - }, - success: function(json) { - var items = json.listvpcsresponse.vpc; - var data; - if(items != null && items.length > 0) { - data = $.map(items, function(item) { - return { - id: item.id, - description: item.name - } - }); - } - args.response.success({ data: data }); - } - }); - } - } + title: 'Create VPN Connection', + fields: { + zoneid: { + label: 'Zone', + validation: { required: true }, + select: function(args) { + $.ajax({ + url: createURL('listZones'), + data: { + available: true + }, + success: function(json) { + var zones = json.listzonesresponse.zone; + args.response.success({ + data: $.map(zones, function(zone) { + return { + id: zone.id, + description: zone.name + }; + }) + }); + } + }); + } + }, + vpcid: { + label: 'VPC', + validation: { required: true }, + dependsOn: 'zoneid', + select: function(args) { + $.ajax({ + url: createURL('listVPCs'), + data: { + zoneid: args.zoneid, + listAll: true + }, + success: function(json) { + var items = json.listvpcsresponse.vpc; + var data; + if(items != null && items.length > 0) { + data = $.map(items, function(item) { + return { + id: item.id, + description: item.name + } + }); + } + args.response.success({ data: data }); + } + }); + } + } } }, - action: function(args) { - var vpngatewayid = null; - $.ajax({ - url: createURL('listVpnGateways'), - data: { - vpcid: args.data.vpcid - }, - async: false, - success: function(json) { - var items = json.listvpngatewaysresponse.vpngateway; - if(items != null && items.length > 0) { - vpngatewayid = items[0].id; - } - } - }); + action: function(args) { + var vpngatewayid = null; + $.ajax({ + url: createURL('listVpnGateways'), + data: { + vpcid: args.data.vpcid + }, + async: false, + success: function(json) { + var items = json.listvpngatewaysresponse.vpngateway; + if(items != null && items.length > 0) { + vpngatewayid = items[0].id; + } + } + }); - if(vpngatewayid == null) { - args.response.error('The selected VPC does not have a VPN gateway. Please create a VPN gateway for the VPC first.'); - return; - } - - $.ajax({ - url: createURL('createVpnConnection'), - data: { - s2svpngatewayid: vpngatewayid, - s2scustomergatewayid: args.context.vpnCustomerGateway[0].id - }, - success: function(json) { - var jid = json.createvpnconnectionresponse.jobid; - args.response.success( - {_custom: - { - jobId: jid - } - } - ); - } - }); + if(vpngatewayid == null) { + args.response.error('The selected VPC does not have a VPN gateway. Please create a VPN gateway for the VPC first.'); + return; + } + + $.ajax({ + url: createURL('createVpnConnection'), + data: { + s2svpngatewayid: vpngatewayid, + s2scustomergatewayid: args.context.vpnCustomerGateway[0].id + }, + success: function(json) { + var jid = json.createvpnconnectionresponse.jobid; + args.response.success( + {_custom: + { + jobId: jid + } + } + ); + } + }); }, notification: { poll: pollAsyncJobResult } - }, - - remove: { + }, + + remove: { label: 'delete VPN Customer Gateway', messages: { confirm: function(args) { @@ -4106,19 +4106,19 @@ return 'delete VPN Customer Gateway'; } }, - action: function(args) { + action: function(args) { $.ajax({ url: createURL("deleteVpnCustomerGateway"), data: { - id: args.context.vpnCustomerGateway[0].id - }, + id: args.context.vpnCustomerGateway[0].id + }, success: function(json) { var jid = json.deletecustomergatewayresponse.jobid; args.response.success( {_custom: - { - jobId: jid - } + { + jobId: jid + } } ); } @@ -4127,36 +4127,36 @@ notification: { poll: pollAsyncJobResult } - } - }, - + } + }, + tabs: { details: { title: 'label.details', fields: [ { gateway: { label: 'label.gateway' } - }, - { - cidrlist: { label: 'CIDR list' }, - ipsecpsk: { label: 'IPsec Preshared-Key' }, - id: { label: 'label.id' }, - domain: { label: 'label.domain' }, - account: { label: 'label.account' } + }, + { + cidrlist: { label: 'CIDR list' }, + ipsecpsk: { label: 'IPsec Preshared-Key' }, + id: { label: 'label.id' }, + domain: { label: 'label.domain' }, + account: { label: 'label.account' } } ], - dataProvider: function(args) { - $.ajax({ - url: createURL("listVpnCustomerGateways"), - data: { - id: args.context.vpnCustomerGateway[0].id - }, - success: function(json) { - var item = json.listvpncustomergatewaysresponse.vpncustomergateway[0]; - args.response.success({data: item}); - } - }); - } + dataProvider: function(args) { + $.ajax({ + url: createURL("listVpnCustomerGateways"), + data: { + id: args.context.vpnCustomerGateway[0].id + }, + success: function(json) { + var item = json.listvpncustomergatewaysresponse.vpncustomergateway[0]; + args.response.success({data: item}); + } + }); + } } } } @@ -4164,50 +4164,50 @@ } } }; - - function getExtaPropertiesForIpObj(ipObj, args){ - if('networks' in args.context) { //from Guest Network section - //get ipObj.networkOfferingConserveMode and ipObj.networkOfferingHavingVpnService from guest network's network offering - $.ajax({ - url: createURL('listNetworkOfferings'), - data: { - id: args.context.networks[0].networkofferingid - }, - async: false, - success: function(json) { - var networkOfferingObj = json.listnetworkofferingsresponse.networkoffering[0]; - ipObj.networkOfferingConserveMode = networkOfferingObj.conservemode; - - $(networkOfferingObj.service).each(function(){ - var thisService = this; - if(thisService.name == "Vpn") - ipObj.networkOfferingHavingVpnService = true; - }); - - if(ipObj.networkOfferingHavingVpnService == true) { - $.ajax({ - url: createURL('listRemoteAccessVpns'), - data: { - listAll: true, - publicipid: ipObj.id - }, - async: false, - success: function(vpnResponse) { - var isVPNEnabled = vpnResponse.listremoteaccessvpnsresponse.count; - if (isVPNEnabled) { - ipObj.vpnenabled = true; - ipObj.remoteaccessvpn = vpnResponse.listremoteaccessvpnsresponse.remoteaccessvpn[0]; - }; - } - }); - } - } - }); - } - else { //from VPC section - ipObj.networkOfferingConserveMode = false; //conserve mode of IP in VPC is always off, so hardcode it as false - ipObj.networkOfferingHavingVpnService = false; //VPN is not supported in IP in VPC, so hardcode it as false - } - } - + + function getExtaPropertiesForIpObj(ipObj, args){ + if('networks' in args.context) { //from Guest Network section + //get ipObj.networkOfferingConserveMode and ipObj.networkOfferingHavingVpnService from guest network's network offering + $.ajax({ + url: createURL('listNetworkOfferings'), + data: { + id: args.context.networks[0].networkofferingid + }, + async: false, + success: function(json) { + var networkOfferingObj = json.listnetworkofferingsresponse.networkoffering[0]; + ipObj.networkOfferingConserveMode = networkOfferingObj.conservemode; + + $(networkOfferingObj.service).each(function(){ + var thisService = this; + if(thisService.name == "Vpn") + ipObj.networkOfferingHavingVpnService = true; + }); + + if(ipObj.networkOfferingHavingVpnService == true) { + $.ajax({ + url: createURL('listRemoteAccessVpns'), + data: { + listAll: true, + publicipid: ipObj.id + }, + async: false, + success: function(vpnResponse) { + var isVPNEnabled = vpnResponse.listremoteaccessvpnsresponse.count; + if (isVPNEnabled) { + ipObj.vpnenabled = true; + ipObj.remoteaccessvpn = vpnResponse.listremoteaccessvpnsresponse.remoteaccessvpn[0]; + }; + } + }); + } + } + }); + } + else { //from VPC section + ipObj.networkOfferingConserveMode = false; //conserve mode of IP in VPC is always off, so hardcode it as false + ipObj.networkOfferingHavingVpnService = false; //VPN is not supported in IP in VPC, so hardcode it as false + } + } + })(cloudStack, jQuery); diff --git a/ui/scripts/ui-custom/autoscaler.js b/ui/scripts/ui-custom/autoscaler.js index f0320b844ff..dd9a17cc062 100644 --- a/ui/scripts/ui-custom/autoscaler.js +++ b/ui/scripts/ui-custom/autoscaler.js @@ -232,7 +232,7 @@ 'class': 'ok', click: function() { var data = cloudStack.serializeForm($('.ui-dialog .autoscaler form')); - + $loading.appendTo($autoscalerDialog); cloudStack.autoscaler.actions.add({ formData: formData,