mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
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.
This commit is contained in:
parent
ba08af9361
commit
1f420ec085
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user