CLOUDSTACK-4793: UI > Virtual Routers > add new action "Upgrade Router to Newer Template" in detailView.

This commit is contained in:
Jessica Wang 2013-11-19 16:14:47 -08:00
parent d6a38c238a
commit 829f1db6e8

View File

@ -7390,325 +7390,341 @@
return listView; return listView;
}, },
virtualRouters: function() { virtualRouters: function() {
var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters.listView, { var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters.listView, {
//???
actions: { actions: {
upgradeRouterToUseNewerTemplate: { upgradeRouterToUseNewerTemplate: {
isHeader: true, isHeader: true,
label: 'Upgrade Router to Use Newer Template',
messages: { label: 'Upgrade Router to Use Newer Template',
notification: function(args) {
return 'Upgrade Router to Use Newer Template';
}
},
createForm: { messages: {
title: 'Upgrade Router to Use Newer Template', notification: function (args) {
fields: { return 'Upgrade Router to Use Newer Template';
zoneid: { }
label: 'label.zone', },
select: function(args) {
var items = [{ id: '', description: '' }];
$.ajax({
url: createURL('listZones'),
data: {
listAll: true
},
success: function(json) {
var objs = json.listzonesresponse.zone;
if (objs != null) {
for (var i = 0; i < objs.length; i++) {
items.push({ id: objs[i].id, description: objs[i].name });
}
}
args.response.success({
data: items
});
}
});
}
},
podid: {
label: 'Pod',
dependsOn: 'zoneid',
select: function (args) {
var items = [{ id: '', description: '' }];
if (args.zoneid.length > 0) {
$.ajax({
url: createURL('listPods'),
data: {
zoneid: args.zoneid
},
success: function (json) {
var objs = json.listpodsresponse.pod;
if (objs != null) {
for (var i = 0; i < objs.length; i++) {
items.push({ id: objs[i].id, description: objs[i].name });
}
}
args.response.success({
data: items
});
}
});
} else {
args.response.success({
data: items
});
}
}
},
clusterid: {
label: 'label.cluster',
dependsOn: 'podid',
select: function(args) {
var items = [{ id: '', description: '' }];
if (args.podid.length > 0) {
$.ajax({
url: createURL('listClusters'),
data: {
podid: args.podid
},
success: function(json) {
var objs = json.listclustersresponse.cluster;
if (objs != null) {
for (var i = 0; i < objs.length; i++) {
items.push({ id: objs[i].id, description: objs[i].name });
}
}
args.response.success({
data: items
});
}
});
} else {
args.response.success({
data: items
});
}
}
}
}
},
action: function(args) { createForm: {
var data = {}; title: 'Upgrade Router to Use Newer Template',
if (args.data.clusterid.length > 0) { fields: {
$.extend(data, { zoneid: {
clusterid: args.data.clusterid label: 'label.zone',
}); select: function (args) {
} else if (args.data.podid.length > 0) { var items = [{
$.extend(data, { id: '',
podid: args.data.podid description: ''
}); }];
} else if (args.data.zoneid.length > 0) { $.ajax({
$.extend(data, { url: createURL('listZones'),
zoneid: args.data.zoneid data: {
}); listAll: true
} else { },
args.response.error('Please specify a zone, a pod or a cluster.' ); success: function (json) {
return; var objs = json.listzonesresponse.zone;
} if (objs != null) {
for (var i = 0; i < objs.length; i++) {
$.ajax({ items.push({
url: createURL('upgradeRouterTemplate'), id: objs[i].id,
data: data, description: objs[i].name
success: function(json) { });
//example }
/* }
json = { args.response.success({
"upgraderoutertemplateresponse": { data: items
"count": 3, });
"asyncjobs": [ }
{ });
"jobid": "2d51f1f9-ea39-4871-9512-431f4a65a5f2" }
}, },
{ podid: {
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c" label: 'Pod',
}, dependsOn: 'zoneid',
{ select: function (args) {
"jobid": "850a3cfd-c265-48f1-880a-f001481fc7f7" var items = [{
} id: '',
] description: ''
} }];
}; if (args.zoneid.length > 0) {
*/ $.ajax({
url: createURL('listPods'),
var jobs = json.upgraderoutertemplateresponse.asyncjobs; data: {
if (jobs != undefined) { zoneid: args.zoneid
for (var i = 0; i < jobs.length; i++) { },
var jid = jobs[i].jobid; success: function (json) {
args.response.success({ var objs = json.listpodsresponse.pod;
_custom: { if (objs != null) {
jobId: jid for (var i = 0; i < objs.length; i++) {
} items.push({
}); id: objs[i].id,
description: objs[i].name
//example begins });
/* }
{ }
"queryasyncjobresultresponse": { args.response.success({
"accountid": "ce5820a8-5099-11e3-80db-3c970e739c3e", data: items
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e", });
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd", }
"jobstatus": 2, });
"jobprocstatus": 0, } else {
"jobresultcode": 530, args.response.success({
"jobresulttype": "object", data: items
"jobresult": { });
"errorcode": 530, }
"errortext": "Resource [DataCenter:1] is unreachable: Unable to reboot domR, it is not in right state Stopped" }
}, },
"created": "2013-11-19T11:41:40-0800", clusterid: {
"jobid": "2d51f1f9-ea39-4871-9512-431f4a65a5f2" label: 'label.cluster',
} dependsOn: 'podid',
} select: function (args) {
{ var items = [{
"queryasyncjobresultresponse": { id: '',
"accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86", description: ''
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e", }];
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd", if (args.podid.length > 0) {
"jobstatus": 0, $.ajax({
"jobprocstatus": 0, url: createURL('listClusters'),
"jobresultcode": 0, data: {
"jobinstancetype": "DomainRouter", podid: args.podid
"jobinstanceid": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c", },
"created": "2013-11-19T11:41:40-0800", success: function (json) {
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c" var objs = json.listclustersresponse.cluster;
} if (objs != null) {
} for (var i = 0; i < objs.length; i++) {
{ items.push({
"queryasyncjobresultresponse": { id: objs[i].id,
"accountid": "6b5334a2-1c0e-46e0-b4d9-524698549f08", description: objs[i].name
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e", });
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd", }
"jobstatus": 2, }
"jobprocstatus": 0, args.response.success({
"jobresultcode": 530, data: items
"jobresulttype": "object", });
"jobresult": { }
"errorcode": 530, });
"errortext": "Resource [DataCenter:1] is unreachable: Unable to reboot domR, it is not in right state Starting" } else {
}, args.response.success({
"created": "2013-11-19T11:41:40-0800", data: items
"jobid": "850a3cfd-c265-48f1-880a-f001481fc7f7" });
} }
} }
}
}
{ },
"queryasyncjobresultresponse": {
"accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86", action: function (args) {
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e", var data = {};
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd", if (args.data.clusterid.length > 0) {
"jobstatus": 0, $.extend(data, {
"jobprocstatus": 0, clusterid: args.data.clusterid
"jobresultcode": 0, });
"jobinstancetype": "DomainRouter", } else if (args.data.podid.length > 0) {
"jobinstanceid": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c", $.extend(data, {
"created": "2013-11-19T11:41:40-0800", podid: args.data.podid
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c" });
} } else if (args.data.zoneid.length > 0) {
} $.extend(data, {
{ zoneid: args.data.zoneid
"queryasyncjobresultresponse": { });
"accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86", } else {
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e", args.response.error('Please specify a zone, a pod or a cluster.');
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd", return;
"jobstatus": 0, }
"jobprocstatus": 0,
"jobresultcode": 0, $.ajax({
"jobinstancetype": "DomainRouter", url: createURL('upgradeRouterTemplate'),
"jobinstanceid": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c", data: data,
"created": "2013-11-19T11:41:40-0800", success: function (json) {
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c" //example
} /*
} json = {
{ "upgraderoutertemplateresponse": {
"queryasyncjobresultresponse": { "count": 3,
"accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86", "asyncjobs": [
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e", {
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd", "jobid": "2d51f1f9-ea39-4871-9512-431f4a65a5f2"
"jobstatus": 1, },
"jobprocstatus": 0, {
"jobresultcode": 0, "jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c"
"jobresulttype": "object", },
"jobresult": { {
"router": { "jobid": "850a3cfd-c265-48f1-880a-f001481fc7f7"
"id": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c", }
"zoneid": "3bfdd7d1-134a-4d75-8621-0ccfc8641660", ]
"zonename": "jw-adv", }
"dns1": "8.8.8.8", };
"gateway": "10.223.67.1", */
"name": "r-6-VM",
"linklocalip": "169.254.2.29", var jobs = json.upgraderoutertemplateresponse.asyncjobs;
"linklocalmacaddress": "0e:00:a9:fe:02:1d", if (jobs != undefined) {
"linklocalnetmask": "255.255.0.0", for (var i = 0; i < jobs.length; i++) {
"linklocalnetworkid": "4a02a05f-1312-484a-a82b-246a86ed6949", var jid = jobs[i].jobid;
"publicip": "10.223.67.6", args.response.success({
"publicmacaddress": "06:8d:22:00:00:18", _custom: {
"publicnetmask": "255.255.255.0", jobId: jid
"publicnetworkid": "e7056c3c-2c7f-4e84-909e-af288ae170e9", }
"templateid": "cd70f70a-5099-11e3-80db-3c970e739c3e", });
"created": "2013-11-19T11:36:04-0800",
"state": "Running", //example begins
"account": "aaa_admin", /*
"domainid": "b95a5b02-e45d-4971-b0d8-d1620f7bf44e", {
"domain": "aaa", "queryasyncjobresultresponse": {
"serviceofferingid": "7dd7687c-01f0-4a14-846e-8e46067a8ff9", "accountid": "ce5820a8-5099-11e3-80db-3c970e739c3e",
"serviceofferingname": "System Offering For Software Router", "userid": "ce58353e-5099-11e3-80db-3c970e739c3e",
"isredundantrouter": false, "cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd",
"redundantstate": "UNKNOWN", "jobstatus": 2,
"version": "3.0", "jobprocstatus": 0,
"role": "VIRTUAL_ROUTER", "jobresultcode": 530,
"nic": [ "jobresulttype": "object",
{ "jobresult": {
"id": "d41bf67e-1d58-4ec9-bf61-41903140cc53", "errorcode": 530,
"networkid": "e7056c3c-2c7f-4e84-909e-af288ae170e9", "errortext": "Resource [DataCenter:1] is unreachable: Unable to reboot domR, it is not in right state Stopped"
"netmask": "255.255.255.0", },
"gateway": "10.223.67.1", "created": "2013-11-19T11:41:40-0800",
"ipaddress": "10.223.67.6", "jobid": "2d51f1f9-ea39-4871-9512-431f4a65a5f2"
"isolationuri": "vlan://159", }
"broadcasturi": "vlan://159", }
"traffictype": "Public", {
"isdefault": true, "queryasyncjobresultresponse": {
"macaddress": "06:8d:22:00:00:18" "accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86",
}, "userid": "ce58353e-5099-11e3-80db-3c970e739c3e",
{ "cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd",
"id": "a6d1f6ac-fc45-474e-b372-3571e639fa8e", "jobstatus": 0,
"networkid": "4a02a05f-1312-484a-a82b-246a86ed6949", "jobprocstatus": 0,
"netmask": "255.255.0.0", "jobresultcode": 0,
"gateway": "169.254.0.1", "jobinstancetype": "DomainRouter",
"ipaddress": "169.254.2.29", "jobinstanceid": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c",
"traffictype": "Control", "created": "2013-11-19T11:41:40-0800",
"isdefault": false, "jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c"
"macaddress": "0e:00:a9:fe:02:1d" }
} }
], {
"requiresupgrade": true, "queryasyncjobresultresponse": {
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c", "accountid": "6b5334a2-1c0e-46e0-b4d9-524698549f08",
"jobstatus": 0 "userid": "ce58353e-5099-11e3-80db-3c970e739c3e",
} "cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd",
}, "jobstatus": 2,
"created": "2013-11-19T11:41:40-0800", "jobprocstatus": 0,
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c" "jobresultcode": 530,
} "jobresulttype": "object",
} "jobresult": {
*/ "errorcode": 530,
//example ends "errortext": "Resource [DataCenter:1] is unreachable: Unable to reboot domR, it is not in right state Starting"
} },
} "created": "2013-11-19T11:41:40-0800",
} "jobid": "850a3cfd-c265-48f1-880a-f001481fc7f7"
}); }
}, }
notification: {
poll: pollAsyncJobResult
} {
} "queryasyncjobresultresponse": {
}, "accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86",
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e",
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd",
"jobstatus": 0,
"jobprocstatus": 0,
"jobresultcode": 0,
"jobinstancetype": "DomainRouter",
"jobinstanceid": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c",
"created": "2013-11-19T11:41:40-0800",
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c"
}
}
{
"queryasyncjobresultresponse": {
"accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86",
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e",
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd",
"jobstatus": 0,
"jobprocstatus": 0,
"jobresultcode": 0,
"jobinstancetype": "DomainRouter",
"jobinstanceid": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c",
"created": "2013-11-19T11:41:40-0800",
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c"
}
}
{
"queryasyncjobresultresponse": {
"accountid": "9b0ea3b4-a699-431c-932b-570388ef7b86",
"userid": "ce58353e-5099-11e3-80db-3c970e739c3e",
"cmd": "org.apache.cloudstack.api.command.admin.router.RebootRouterCmd",
"jobstatus": 1,
"jobprocstatus": 0,
"jobresultcode": 0,
"jobresulttype": "object",
"jobresult": {
"router": {
"id": "d6e625ea-76f9-4c35-9f89-0998a04a3b9c",
"zoneid": "3bfdd7d1-134a-4d75-8621-0ccfc8641660",
"zonename": "jw-adv",
"dns1": "8.8.8.8",
"gateway": "10.223.67.1",
"name": "r-6-VM",
"linklocalip": "169.254.2.29",
"linklocalmacaddress": "0e:00:a9:fe:02:1d",
"linklocalnetmask": "255.255.0.0",
"linklocalnetworkid": "4a02a05f-1312-484a-a82b-246a86ed6949",
"publicip": "10.223.67.6",
"publicmacaddress": "06:8d:22:00:00:18",
"publicnetmask": "255.255.255.0",
"publicnetworkid": "e7056c3c-2c7f-4e84-909e-af288ae170e9",
"templateid": "cd70f70a-5099-11e3-80db-3c970e739c3e",
"created": "2013-11-19T11:36:04-0800",
"state": "Running",
"account": "aaa_admin",
"domainid": "b95a5b02-e45d-4971-b0d8-d1620f7bf44e",
"domain": "aaa",
"serviceofferingid": "7dd7687c-01f0-4a14-846e-8e46067a8ff9",
"serviceofferingname": "System Offering For Software Router",
"isredundantrouter": false,
"redundantstate": "UNKNOWN",
"version": "3.0",
"role": "VIRTUAL_ROUTER",
"nic": [
{
"id": "d41bf67e-1d58-4ec9-bf61-41903140cc53",
"networkid": "e7056c3c-2c7f-4e84-909e-af288ae170e9",
"netmask": "255.255.255.0",
"gateway": "10.223.67.1",
"ipaddress": "10.223.67.6",
"isolationuri": "vlan://159",
"broadcasturi": "vlan://159",
"traffictype": "Public",
"isdefault": true,
"macaddress": "06:8d:22:00:00:18"
},
{
"id": "a6d1f6ac-fc45-474e-b372-3571e639fa8e",
"networkid": "4a02a05f-1312-484a-a82b-246a86ed6949",
"netmask": "255.255.0.0",
"gateway": "169.254.0.1",
"ipaddress": "169.254.2.29",
"traffictype": "Control",
"isdefault": false,
"macaddress": "0e:00:a9:fe:02:1d"
}
],
"requiresupgrade": true,
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c",
"jobstatus": 0
}
},
"created": "2013-11-19T11:41:40-0800",
"jobid": "d66fa7ef-c91f-425f-b820-2f8ff2a0da8c"
}
}
*/
//example ends
}
}
}
});
},
notification: {
poll: pollAsyncJobResult
}
}
},
dataProvider: function(args) { dataProvider: function(args) {
var data = {}; var data = {};
@ -8148,7 +8164,40 @@
poll: pollAsyncJobResult poll: pollAsyncJobResult
} }
}, },
upgradeRouterToUseNewerTemplate: {
label: 'Upgrade Router to Use Newer Template',
messages: {
confirm: function(args) {
return 'Please confirm that you want to upgrade router to use newer template';
},
notification: function (args) {
return 'Upgrade Router to Use Newer Template';
}
},
action: function (args) {
$.ajax({
url: createURL('upgradeRouterTemplate'),
data: {
id: args.context.routers[0].id
},
success: function (json) {
var jobs = json.upgraderoutertemplateresponse.asyncjobs;
if (jobs != undefined) {
args.response.success({
_custom: {
jobId: jobs[0].jobid
}
});
}
}
});
},
notification: {
poll: pollAsyncJobResult
}
},
'remove': { 'remove': {
label: 'label.destroy.router', label: 'label.destroy.router',
messages: { messages: {
@ -17491,6 +17540,8 @@
var jsonObj = args.context.item; var jsonObj = args.context.item;
var allowedActions = []; var allowedActions = [];
allowedActions.push('upgradeRouterToUseNewerTemplate');
if (jsonObj.state == 'Running') { if (jsonObj.state == 'Running') {
allowedActions.push("stop"); allowedActions.push("stop");