|
15 | 15 | // specific language governing permissions and limitations |
16 | 16 | // under the License. |
17 | 17 | (function($, cloudStack) { |
| 18 | + var requiresStorageMotion = false; |
18 | 19 | cloudStack.sections.instances = { |
19 | 20 | title: 'label.instances', |
20 | 21 | id: 'instances', |
|
958 | 959 | validation: { required: true }, |
959 | 960 | select: function(args) { |
960 | 961 | $.ajax({ |
961 | | - url: createURL("listHosts&VirtualMachineId=" + args.context.instances[0].id), |
| 962 | + url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.instances[0].id), |
962 | 963 | //url: createURL("listHosts"), //for testing only, comment it out before checking in. |
963 | 964 | dataType: "json", |
964 | 965 | async: true, |
965 | 966 | 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; |
967 | 970 | var items = []; |
968 | 971 | $(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 | + }); |
971 | 982 | 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 | + |
972 | 987 | } |
973 | 988 | }); |
974 | 989 | } |
975 | 990 | } |
976 | 991 | } |
977 | 992 | }, |
978 | 993 | action: function(args) { |
| 994 | + |
| 995 | + if(requiresStorageMotion == true){ |
979 | 996 | $.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({ |
980 | 1019 | url: createURL("migrateVirtualMachine&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.instances[0].id), |
981 | 1020 | dataType: "json", |
982 | 1021 | async: true, |
|
987 | 1026 | {jobId: jid, |
988 | 1027 | getUpdatedItem: function(json) { |
989 | 1028 | 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 | | - */ |
1005 | 1029 | }, |
1006 | 1030 | getActionFilter: function() { |
1007 | 1031 | return vmActionfilter; |
|
1011 | 1035 | ); |
1012 | 1036 | } |
1013 | 1037 | }); |
| 1038 | + |
| 1039 | + } |
1014 | 1040 | }, |
1015 | 1041 | notification: { |
1016 | 1042 | poll: pollAsyncJobResult |
|
0 commit comments