Skip to content

Commit fc4f19f

Browse files
committed
Storage Motion UI development
1 parent 59bee8d commit fc4f19f

3 files changed

Lines changed: 128 additions & 20 deletions

File tree

ui/css/cloudstack3.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11603,6 +11603,17 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it
1160311603
background-position: 0px -707px;
1160411604
}
1160511605

11606+
.migrate .icon,
11607+
.migrateVolume .icon {
11608+
background-position: 0px -125px;
11609+
}
11610+
11611+
.migrate:hover .icon,
11612+
.migrateVolume:hover .icon {
11613+
background-position: 0px -707px;
11614+
}
11615+
11616+
1160611617
.attach .icon,
1160711618
.attachISO .icon,
1160811619
.attachDisk .icon {

ui/scripts/instances.js

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717
(function($, cloudStack) {
18+
var requiresStorageMotion = false;
1819
cloudStack.sections.instances = {
1920
title: 'label.instances',
2021
id: 'instances',
@@ -958,25 +959,63 @@
958959
validation: { required: true },
959960
select: function(args) {
960961
$.ajax({
961-
url: createURL("listHosts&VirtualMachineId=" + args.context.instances[0].id),
962+
url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.instances[0].id),
962963
//url: createURL("listHosts"), //for testing only, comment it out before checking in.
963964
dataType: "json",
964965
async: true,
965966
success: function(json) {
966-
var hosts = json.listhostsresponse.host;
967+
if(json.findhostsformigrationresponse.host != undefined){
968+
var hosts = json.findhostsformigrationresponse.host;
969+
requiresStorageMotion = json.findhostsformigrationresponse.host[0].requiresStorageMotion;
967970
var items = [];
968971
$(hosts).each(function() {
969-
items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable": "Not Suitable") + ")")});
970-
});
972+
if(this.requiresStorageMotion == true){
973+
items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable, ": "Not Suitable, ") + "Storage migration required)" )});
974+
975+
}
976+
else {
977+
978+
items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable": "Not Suitable") + ")" )});
979+
980+
}
981+
});
971982
args.response.success({data: items});
983+
}
984+
else
985+
cloudStack.dialog.notice({ message: _l('No Hosts are avaialble for Migration') }); //Only a single host in the set up
986+
972987
}
973988
});
974989
}
975990
}
976991
}
977992
},
978993
action: function(args) {
994+
995+
if(requiresStorageMotion == true){
979996
$.ajax({
997+
url: createURL("migrateVirtualMachineWithVolume&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.instances[0].id),
998+
dataType: "json",
999+
async: true,
1000+
success: function(json) {
1001+
var jid = json.migratevirtualmachinewithvolumeresponse.jobid;
1002+
args.response.success(
1003+
{_custom:
1004+
{jobId: jid,
1005+
getUpdatedItem: function(json) {
1006+
return json.queryasyncjobresultresponse.jobresult.virtualmachine;
1007+
},
1008+
getActionFilter: function() {
1009+
return vmActionfilter;
1010+
}
1011+
}
1012+
}
1013+
);
1014+
}
1015+
});
1016+
}
1017+
else{
1018+
$.ajax({
9801019
url: createURL("migrateVirtualMachine&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.instances[0].id),
9811020
dataType: "json",
9821021
async: true,
@@ -987,21 +1026,6 @@
9871026
{jobId: jid,
9881027
getUpdatedItem: function(json) {
9891028
return json.queryasyncjobresultresponse.jobresult.virtualmachine;
990-
/*
991-
var vmObj;
992-
$.ajax({
993-
url: createURL("listVirtualMachines&id=" + args.context.instances[0].id),
994-
dataType: "json",
995-
async: false,
996-
success: function(json) {
997-
var items = json.listvirtualmachinesresponse.virtualmachine;
998-
if(items != null && items.length > 0) {
999-
vmObj = items[0];
1000-
}
1001-
}
1002-
});
1003-
return vmObj;
1004-
*/
10051029
},
10061030
getActionFilter: function() {
10071031
return vmActionfilter;
@@ -1011,6 +1035,8 @@
10111035
);
10121036
}
10131037
});
1038+
1039+
}
10141040
},
10151041
notification: {
10161042
poll: pollAsyncJobResult

ui/scripts/storage.js

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,69 @@
395395
name: 'Volume details',
396396
viewAll: { path: 'storage.snapshots', label: 'label.snapshots' },
397397
actions: {
398+
399+
migrateVolume:{
400+
label:'Migrate Volume',
401+
messages: {
402+
confirm: function(args) {
403+
return 'Do you want to migrate this volume ?' ;
404+
},
405+
notification: function(args) {
406+
return 'Volume migrated';
407+
}
408+
},
409+
410+
createForm: {
411+
title: 'Migrate Volume',
412+
desc: '',
413+
fields: {
414+
storagePool: {
415+
label: 'Storage Pool',
416+
validation: { required: true },
417+
select: function(args) {
418+
$.ajax({
419+
url: createURL("findStoragePoolsForMigration&id=" + args.context.volumes[0].id),
420+
dataType: "json",
421+
async: true,
422+
success: function(json) {
423+
var pools = json.findstoragepoolsformigrationresponse.storagepool;
424+
var items = [];
425+
$(pools).each(function() {
426+
items.push({id: this.id, description: this.name + " (" + (this.suitableformigration? "Suitable": "Not Suitable")+")" });
427+
});
428+
args.response.success({data: items});
429+
430+
}
431+
});
432+
}
433+
}
434+
}
435+
436+
},
437+
438+
action: function(args) {
439+
$.ajax({
440+
url: createURL("migrateVolume&livemigrate=true&storageid=" + args.data.storagePool + "&volumeid=" + args.context.volumes[0].id ),
441+
dataType: "json",
442+
async: true,
443+
success: function(json) {
444+
var jid = json.migratevolumeresponse.jobid;
445+
args.response.success(
446+
{_custom:
447+
{
448+
jobId: jid
449+
}
450+
}
451+
);
452+
}
453+
});
454+
},
455+
notification: {
456+
poll: pollAsyncJobResult
457+
}
458+
459+
},
460+
398461
takeSnapshot: {
399462
label: 'label.action.take.snapshot',
400463
messages: {
@@ -961,7 +1024,7 @@
9611024
},
9621025
action: function(args) {
9631026
$.ajax({
964-
url: createURL("migrateVolume&storageid=" + args.data.storageId + "&volumeid=" + args.context.volumes[0].id),
1027+
url: createURL("migrateVolume&storageid=" + args.data.storagePool + "&volumeid=" + args.context.volumes[0].id),
9651028
dataType: "json",
9661029
async: true,
9671030
success: function(json) {
@@ -1538,6 +1601,7 @@
15381601
var jsonObj = args.context.item;
15391602
var allowedActions = [];
15401603

1604+
15411605
if (jsonObj.state == 'Destroyed' || jsonObj.state == 'Migrating' || jsonObj.state == 'Uploading') {
15421606
return [];
15431607
}
@@ -1557,6 +1621,13 @@
15571621
allowedActions.push("downloadVolume");
15581622
}
15591623
}
1624+
1625+
if(jsonObj.type == "ROOT" || jsonObj.type =="DATADISK"){
1626+
if(jsonObj.state == "Ready" && isAdmin() && jsonObj.virtualmachineid != null ){
1627+
allowedActions.push("migrateVolume");
1628+
}
1629+
}
1630+
15601631
if(jsonObj.state != "Creating") {
15611632
if(jsonObj.type == "ROOT") {
15621633
if (jsonObj.vmstate == "Stopped") {

0 commit comments

Comments
 (0)