You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/05/22 20:46:07 UTC
[23/25] git commit: updated refs/heads/ui-vpc-redesign to 7ac0141
CLOUDSTACK-747: internalLb in VPC - Infrastructure menu - network service provider - add InternalLbVm. Clicking it will lead to a screen that can enable/disable provider and have instances tab that can start/stop LB Instance.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c7b90202
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c7b90202
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c7b90202
Branch: refs/heads/ui-vpc-redesign
Commit: c7b902024c321776bc1d00cf23dcf91793cda1d7
Parents: 2957426
Author: Jessica Wang <je...@apache.org>
Authored: Wed May 22 10:42:49 2013 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Wed May 22 10:49:26 2013 -0700
----------------------------------------------------------------------
ui/scripts/system.js | 385 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 383 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7b90202/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 31e47e4..2e23fc4 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -2708,7 +2708,363 @@
}
}
},
-
+
+ InternalLbVm: {
+ id: 'InternalLbVm',
+ label: 'InternalLbVm',
+ isMaximized: true,
+ type: 'detailView',
+ fields: {
+ name: { label: 'label.name' },
+ ipaddress: { label: 'label.ip.address' },
+ state: { label: 'label.status', indicator: { 'Enabled': 'on' } }
+ },
+ tabs: {
+ network: {
+ title: 'label.network',
+ fields: [
+ {
+ name: { label: 'label.name' }
+ },
+ {
+ id: { label: 'label.id' },
+ state: { label: 'label.state' },
+ physicalnetworkid: { label: 'label.physical.network.ID' },
+ destinationphysicalnetworkid: { label: 'label.destination.physical.network.id' },
+ supportedServices: { label: 'label.supported.services' }
+ }
+ ],
+ dataProvider: function(args) {
+ refreshNspData("InternalLbVm");
+ args.response.success({
+ actionFilter: virtualRouterProviderActionFilter,
+ data: $.extend(nspMap["InternalLbVm"], {
+ supportedServices: nspMap["InternalLbVm"].servicelist.join(', ')
+ })
+ });
+ }
+ },
+
+ instances: {
+ title: 'label.instances',
+ listView: {
+ label: 'label.virtual.appliances',
+ id: 'internallbinstances',
+ fields: {
+ name: { label: 'label.name' },
+ zonename: { label: 'label.zone' },
+ routerType: {
+ label: 'label.type'
+ },
+ state: {
+ converter: function(str) {
+ // For localization
+ return str;
+ },
+ label: 'label.status',
+ indicator: {
+ 'Running': 'on',
+ 'Stopped': 'off',
+ 'Error': 'off'
+ }
+ }
+ },
+ 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;
+ }
+ }
+ }
+
+ var routers = [];
+ $.ajax({
+ url: createURL("listInternalLoadBalancerVMs&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")),
+ success: function(json) {
+ var items = json.listinternallbvmssresponse.internalloadbalancervm ?
+ json.listinternallbvmssresponse.internalloadbalancervm : [];
+
+ $(items).map(function(index, item) {
+ routers.push(item);
+ });
+
+ // Get project routers
+ $.ajax({
+ url: createURL("listInternalLoadBalancerVMs&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"),
+ success: function(json) {
+ var items = json.listinternallbvmssresponse.internalloadbalancervm ?
+ json.listinternallbvmssresponse.internalloadbalancervm : [];
+
+ $(items).map(function(index, item) {
+ routers.push(item);
+ });
+ args.response.success({
+ actionFilter: internallbinstanceActionfilter,
+ data: $(routers).map(mapRouterType)
+ });
+ }
+ });
+ }
+ });
+ },
+ detailView: {
+ name: 'Virtual applicance details',
+ actions: {
+ start: {
+ label: 'Start LB VM',
+ messages: {
+ confirm: function(args) {
+ return 'Please confirm you want to start LB VM';
+ },
+ notification: function(args) {
+ return 'Start LB VM';
+ }
+ },
+ action: function(args) {
+ $.ajax({
+ url: createURL('startInternalLoadBalancerVM&id=' + args.context.internallbinstances[0].id),
+ dataType: 'json',
+ async: true,
+ success: function(json) {
+ var jid = json.startinternallbvmresponse.jobid;
+ args.response.success({
+ _custom: {
+ jobId: jid,
+ getUpdatedItem: function(json) {
+ return json.queryasyncjobresultresponse.jobresult.internalloadbalancervm;
+ },
+ getActionFilter: function() {
+ return internallbinstanceActionfilter;
+ }
+ }
+ });
+ }
+ });
+ },
+ notification: {
+ poll: pollAsyncJobResult
+ }
+ },
+
+ stop: {
+ label: 'Stop LB VM',
+ createForm: {
+ title: 'Please confirm you want to stop LB VM',
+ desc: 'Stop LB VM',
+ fields: {
+ forced: {
+ label: 'force.stop',
+ isBoolean: true,
+ isChecked: false
+ }
+ }
+ },
+ messages: {
+ notification: function(args) {
+ return 'Stop LB VM';
+ }
+ },
+ action: function(args) {
+ var array1 = [];
+ array1.push("&forced=" + (args.data.forced == "on"));
+ $.ajax({
+ url: createURL('stopInternalLoadBalancerVM&id=' + args.context.internallbinstances[0].id + array1.join("")),
+ dataType: 'json',
+ async: true,
+ success: function(json) {
+ var jid = json.stopinternallbvmresponse.jobid;
+ args.response.success({
+ _custom: {
+ jobId: jid,
+ getUpdatedItem: function(json) {
+ return json.queryasyncjobresultresponse.jobresult.internalloadbalancervm;
+ },
+ getActionFilter: function() {
+ return internallbinstanceActionfilter;
+ }
+ }
+ });
+ }
+ });
+ },
+ notification: {
+ poll: pollAsyncJobResult
+ }
+ }
+ },
+ tabs: {
+ details: {
+ title: 'label.details',
+ preFilter: function(args) {
+ var hiddenFields = [];
+ if (!args.context.internallbinstances[0].project) {
+ hiddenFields.push('project');
+ hiddenFields.push('projectid');
+ }
+ if(selectedZoneObj.networktype == 'Basic') {
+ hiddenFields.push('publicip'); //In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API.
+ }
+ return hiddenFields;
+ },
+ fields: [
+ {
+ name: { label: 'label.name' },
+ project: { label: 'label.project' }
+ },
+ {
+ id: { label: 'label.id' },
+ projectid: { label: 'label.project.id' },
+ state: { label: 'label.state' },
+ guestnetworkid: { label: 'label.network.id' },
+ publicip: { label: 'label.public.ip' },
+ guestipaddress: { label: 'label.guest.ip' },
+ linklocalip: { label: 'label.linklocal.ip' },
+ hostname: { label: 'label.host' },
+ serviceofferingname: { label: 'label.compute.offering' },
+ networkdomain: { label: 'label.network.domain' },
+ domain: { label: 'label.domain' },
+ account: { label: 'label.account' },
+ created: { label: 'label.created', converter: cloudStack.converters.toLocalDate },
+ isredundantrouter: {
+ label: 'label.redundant.router',
+ converter: cloudStack.converters.toBooleanText
+ },
+ redundantRouterState: { label: 'label.redundant.state' }
+ }
+ ],
+ dataProvider: function(args) {
+ $.ajax({
+ url: createURL("listInternalLoadBalancerVMs&id=" + args.context.internallbinstances[0].id),
+ dataType: 'json',
+ async: true,
+ success: function(json) {
+ var jsonObj = json.listinternallbvmssresponse.internalloadbalancervm[0];
+ addExtraPropertiesToRouterInstanceObject(jsonObj);
+ args.response.success({
+ actionFilter: internallbinstanceActionfilter,
+ data: jsonObj
+ });
+ }
+ });
+ }
+ },
+ nics: {
+ title: 'label.nics',
+ multiple: true,
+ fields: [
+ {
+ name: { label: 'label.name', header: true },
+ type: { label: 'label.type' },
+ traffictype: { label: 'label.traffic.type' },
+ networkname: { label: 'label.network.name' },
+ netmask: { label: 'label.netmask' },
+ ipaddress: { label: 'label.ip.address' },
+ id: { label: 'label.id' },
+ networkid: { label: 'label.network.id' },
+ isolationuri: { label: 'label.isolation.uri' },
+ broadcasturi: { label: 'label.broadcast.uri' }
+ }
+ ],
+ dataProvider: function(args) {
+ $.ajax({
+ url: createURL("listInternalLoadBalancerVMs&id=" + args.context.internallbinstances[0].id),
+ dataType: 'json',
+ async: true,
+ success: function(json) {
+ var jsonObj = json.listinternallbvmssresponse.internalloadbalancervm[0].nic;
+
+ args.response.success({
+ actionFilter: internallbinstanceActionfilter,
+ data: $.map(jsonObj, function(nic, index) {
+ var name = 'NIC ' + (index + 1);
+ if (nic.isdefault) {
+ name += ' (' + _l('label.default') + ')';
+ }
+ return $.extend(nic, {
+ name: name
+ });
+ })
+ });
+ }
+ });
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ actions: {
+ enable: {
+ label: 'label.enable.provider',
+ action: function(args) {
+ $.ajax({
+ url: createURL("updateNetworkServiceProvider&id=" + nspMap["InternalLbVm"].id + "&state=Enabled"),
+ dataType: "json",
+ success: function(json) {
+ var jid = json.updatenetworkserviceproviderresponse.jobid;
+ args.response.success(
+ {_custom:
+ {
+ jobId: jid,
+ getUpdatedItem: function(json) {
+ $(window).trigger('cloudStack.fullRefresh');
+ }
+ }
+ }
+ );
+ }
+ });
+ },
+ messages: {
+ confirm: function(args) {
+ return 'message.confirm.enable.provider';
+ },
+ notification: function() {
+ return 'label.enable.provider';
+ }
+ },
+ notification: { poll: pollAsyncJobResult }
+ },
+ disable: {
+ label: 'label.disable.provider',
+ action: function(args) {
+ $.ajax({
+ url: createURL("updateNetworkServiceProvider&id=" + nspMap["InternalLbVm"].id + "&state=Disabled"),
+ dataType: "json",
+ success: function(json) {
+ var jid = json.updatenetworkserviceproviderresponse.jobid;
+ args.response.success(
+ {_custom:
+ {
+ jobId: jid,
+ getUpdatedItem: function(json) {
+ $(window).trigger('cloudStack.fullRefresh');
+ }
+ }
+ }
+ );
+ }
+ });
+ },
+ messages: {
+ confirm: function(args) {
+ return 'message.confirm.disable.provider';
+ },
+ notification: function() {
+ return 'label.disable.provider';
+ }
+ },
+ notification: { poll: pollAsyncJobResult }
+ }
+ }
+ },
+
vpcVirtualRouter: {
id: 'vpcVirtualRouterProviders',
label: 'VPC Virtual Router',
@@ -12020,7 +12376,20 @@
}
return allowedActions;
}
+
+ var internallbinstanceActionfilter = function(args) {
+ var jsonObj = args.context.item;
+ var allowedActions = [];
+ if (jsonObj.state == 'Running') {
+ allowedActions.push("stop");
+ }
+ else if (jsonObj.state == 'Stopped') {
+ allowedActions.push("start");
+ }
+ return allowedActions;
+ }
+
var systemvmActionfilter = function(args) {
var jsonObj = args.context.item;
var allowedActions = [];
@@ -12102,6 +12471,9 @@
case "VirtualRouter":
nspMap["virtualRouter"] = items[i];
break;
+ case "InternalLbVm":
+ nspMap["InternalLbVm"] = items[i];
+ break;
case "VpcVirtualRouter":
nspMap["vpcVirtualRouter"] = items[i];
break;
@@ -12178,7 +12550,16 @@
state: nspMap.midoNet? nspMap.midoNet.state : 'Disabled'
}
);
- nspHardcodingArray.push(
+
+ nspHardcodingArray.push(
+ {
+ id: 'InternalLbVm',
+ name: 'InternalLbVm',
+ state: nspMap.InternalLbVm ? nspMap.InternalLbVm.state : 'Disabled'
+ }
+ );
+
+ nspHardcodingArray.push(
{
id: 'vpcVirtualRouter',
name: 'VPC Virtual Router',