mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	Storage Motion UI development
This commit is contained in:
		
							parent
							
								
									59bee8d1b4
								
							
						
					
					
						commit
						fc4f19f915
					
				@ -11603,6 +11603,17 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it
 | 
			
		||||
  background-position: 0px -707px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.migrate .icon,
 | 
			
		||||
.migrateVolume .icon {
 | 
			
		||||
  background-position: 0px -125px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.migrate:hover .icon,
 | 
			
		||||
.migrateVolume:hover .icon {
 | 
			
		||||
  background-position: 0px -707px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
.attach .icon,
 | 
			
		||||
.attachISO .icon,
 | 
			
		||||
.attachDisk .icon {
 | 
			
		||||
 | 
			
		||||
@ -15,6 +15,7 @@
 | 
			
		||||
// specific language governing permissions and limitations
 | 
			
		||||
// under the License.
 | 
			
		||||
(function($, cloudStack) {
 | 
			
		||||
  var requiresStorageMotion = false;
 | 
			
		||||
  cloudStack.sections.instances = {
 | 
			
		||||
    title: 'label.instances',
 | 
			
		||||
    id: 'instances',
 | 
			
		||||
@ -958,17 +959,31 @@
 | 
			
		||||
                  validation: { required: true },
 | 
			
		||||
                  select: function(args) {
 | 
			
		||||
                    $.ajax({
 | 
			
		||||
                      url: createURL("listHosts&VirtualMachineId=" + args.context.instances[0].id),
 | 
			
		||||
                      url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.instances[0].id),
 | 
			
		||||
                      //url: createURL("listHosts"),	//for testing only, comment it out before checking in.
 | 
			
		||||
                      dataType: "json",
 | 
			
		||||
                      async: true,
 | 
			
		||||
                      success: function(json) {
 | 
			
		||||
                        var hosts = json.listhostsresponse.host;
 | 
			
		||||
                        if(json.findhostsformigrationresponse.host != undefined){
 | 
			
		||||
                        var hosts = json.findhostsformigrationresponse.host;
 | 
			
		||||
                        requiresStorageMotion =  json.findhostsformigrationresponse.host[0].requiresStorageMotion;
 | 
			
		||||
                        var items = [];
 | 
			
		||||
                        $(hosts).each(function() {
 | 
			
		||||
                          items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable": "Not Suitable") + ")")});
 | 
			
		||||
                        });
 | 
			
		||||
                        if(this.requiresStorageMotion == true){
 | 
			
		||||
                          items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable, ": "Not Suitable, ")  +  "Storage migration required)"  )});
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                     
 | 
			
		||||
                          items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable": "Not Suitable")  + ")"  )});
 | 
			
		||||
 | 
			
		||||
                          }
 | 
			
		||||
                         });
 | 
			
		||||
                        args.response.success({data: items});
 | 
			
		||||
                        }
 | 
			
		||||
                       else
 | 
			
		||||
                          cloudStack.dialog.notice({ message: _l('No Hosts are avaialble for Migration') }); //Only a single host in the set up 
 | 
			
		||||
                        
 | 
			
		||||
                      }
 | 
			
		||||
                    });
 | 
			
		||||
                  }
 | 
			
		||||
@ -976,7 +991,31 @@
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            action: function(args) {
 | 
			
		||||
              
 | 
			
		||||
            if(requiresStorageMotion == true){   
 | 
			
		||||
              $.ajax({
 | 
			
		||||
                url: createURL("migrateVirtualMachineWithVolume&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.instances[0].id),
 | 
			
		||||
                dataType: "json",
 | 
			
		||||
                async: true,
 | 
			
		||||
                success: function(json) {
 | 
			
		||||
                  var jid = json.migratevirtualmachinewithvolumeresponse.jobid;
 | 
			
		||||
                  args.response.success(
 | 
			
		||||
                    {_custom:
 | 
			
		||||
                     {jobId: jid,
 | 
			
		||||
                      getUpdatedItem: function(json) {
 | 
			
		||||
                        return json.queryasyncjobresultresponse.jobresult.virtualmachine;
 | 
			
		||||
                      },
 | 
			
		||||
                      getActionFilter: function() {
 | 
			
		||||
                        return vmActionfilter;
 | 
			
		||||
                      }
 | 
			
		||||
                     }
 | 
			
		||||
                    }
 | 
			
		||||
                  );
 | 
			
		||||
                }
 | 
			
		||||
              });
 | 
			
		||||
             }
 | 
			
		||||
             else{
 | 
			
		||||
                  $.ajax({
 | 
			
		||||
                url: createURL("migrateVirtualMachine&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.instances[0].id),
 | 
			
		||||
                dataType: "json",
 | 
			
		||||
                async: true,
 | 
			
		||||
@ -987,21 +1026,6 @@
 | 
			
		||||
                     {jobId: jid,
 | 
			
		||||
                      getUpdatedItem: function(json) {
 | 
			
		||||
                        return json.queryasyncjobresultresponse.jobresult.virtualmachine;
 | 
			
		||||
                        /*
 | 
			
		||||
                         var vmObj;
 | 
			
		||||
                         $.ajax({
 | 
			
		||||
                         url: createURL("listVirtualMachines&id=" + args.context.instances[0].id),
 | 
			
		||||
                         dataType: "json",
 | 
			
		||||
                         async: false,
 | 
			
		||||
                         success: function(json) {
 | 
			
		||||
                         var items =  json.listvirtualmachinesresponse.virtualmachine;
 | 
			
		||||
                         if(items != null && items.length > 0) {
 | 
			
		||||
                         vmObj = items[0];
 | 
			
		||||
                         }
 | 
			
		||||
                         }
 | 
			
		||||
                         });
 | 
			
		||||
                         return vmObj;
 | 
			
		||||
                         */
 | 
			
		||||
                      },
 | 
			
		||||
                      getActionFilter: function() {
 | 
			
		||||
                        return vmActionfilter;
 | 
			
		||||
@ -1011,6 +1035,8 @@
 | 
			
		||||
                  );
 | 
			
		||||
                }
 | 
			
		||||
              });
 | 
			
		||||
 | 
			
		||||
              } 
 | 
			
		||||
            },
 | 
			
		||||
            notification: {
 | 
			
		||||
              poll: pollAsyncJobResult
 | 
			
		||||
 | 
			
		||||
@ -395,6 +395,69 @@
 | 
			
		||||
            name: 'Volume details',
 | 
			
		||||
            viewAll: { path: 'storage.snapshots', label: 'label.snapshots' },
 | 
			
		||||
            actions: {
 | 
			
		||||
 | 
			
		||||
             migrateVolume:{
 | 
			
		||||
                 label:'Migrate Volume',
 | 
			
		||||
               messages: {
 | 
			
		||||
                  confirm: function(args) {
 | 
			
		||||
                    return 'Do you want to migrate this volume ?' ;
 | 
			
		||||
                  },
 | 
			
		||||
                  notification: function(args) {
 | 
			
		||||
                    return 'Volume migrated';
 | 
			
		||||
                  }
 | 
			
		||||
                },
 | 
			
		||||
 | 
			
		||||
             createForm: {
 | 
			
		||||
              title: 'Migrate Volume',
 | 
			
		||||
              desc: '',
 | 
			
		||||
              fields: {
 | 
			
		||||
                storagePool: {
 | 
			
		||||
                  label: 'Storage Pool',
 | 
			
		||||
                  validation: { required: true },
 | 
			
		||||
                  select: function(args) {
 | 
			
		||||
                    $.ajax({
 | 
			
		||||
                      url: createURL("findStoragePoolsForMigration&id=" + args.context.volumes[0].id),
 | 
			
		||||
                      dataType: "json",
 | 
			
		||||
                      async: true,
 | 
			
		||||
                      success: function(json) {
 | 
			
		||||
                            var pools = json.findstoragepoolsformigrationresponse.storagepool;
 | 
			
		||||
                            var items = [];
 | 
			
		||||
                            $(pools).each(function() {
 | 
			
		||||
                              items.push({id: this.id, description: this.name + " (" + (this.suitableformigration? "Suitable": "Not Suitable")+")"   });
 | 
			
		||||
                            });
 | 
			
		||||
                            args.response.success({data: items});
 | 
			
		||||
 | 
			
		||||
                        }                     
 | 
			
		||||
                    });
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
           
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
                 action: function(args) {
 | 
			
		||||
                  $.ajax({
 | 
			
		||||
                    url: createURL("migrateVolume&livemigrate=true&storageid=" + args.data.storagePool + "&volumeid=" + args.context.volumes[0].id ),
 | 
			
		||||
                    dataType: "json",
 | 
			
		||||
                    async: true,
 | 
			
		||||
                    success: function(json) {
 | 
			
		||||
                      var jid = json.migratevolumeresponse.jobid;
 | 
			
		||||
                      args.response.success(
 | 
			
		||||
                        {_custom:
 | 
			
		||||
                         {
 | 
			
		||||
                            jobId: jid
 | 
			
		||||
                         }
 | 
			
		||||
                        }
 | 
			
		||||
                      );
 | 
			
		||||
                    }
 | 
			
		||||
                  });
 | 
			
		||||
                },
 | 
			
		||||
                notification: {
 | 
			
		||||
                  poll: pollAsyncJobResult
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
               },
 | 
			
		||||
 | 
			
		||||
              takeSnapshot: {
 | 
			
		||||
                label: 'label.action.take.snapshot',
 | 
			
		||||
                messages: {
 | 
			
		||||
@ -961,7 +1024,7 @@
 | 
			
		||||
                },
 | 
			
		||||
                action: function(args) {
 | 
			
		||||
                  $.ajax({
 | 
			
		||||
                    url: createURL("migrateVolume&storageid=" + args.data.storageId + "&volumeid=" + args.context.volumes[0].id),
 | 
			
		||||
                    url: createURL("migrateVolume&storageid=" + args.data.storagePool + "&volumeid=" + args.context.volumes[0].id),
 | 
			
		||||
                    dataType: "json",
 | 
			
		||||
                    async: true,
 | 
			
		||||
                    success: function(json) {
 | 
			
		||||
@ -1538,6 +1601,7 @@
 | 
			
		||||
    var jsonObj = args.context.item;
 | 
			
		||||
    var allowedActions = [];
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    if (jsonObj.state == 'Destroyed' || jsonObj.state == 'Migrating' || jsonObj.state == 'Uploading') {
 | 
			
		||||
      return [];
 | 
			
		||||
    }
 | 
			
		||||
@ -1557,6 +1621,13 @@
 | 
			
		||||
        allowedActions.push("downloadVolume");
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
   if(jsonObj.type == "ROOT" || jsonObj.type =="DATADISK"){ 
 | 
			
		||||
    if(jsonObj.state == "Ready" && isAdmin() && jsonObj.virtualmachineid != null ){
 | 
			
		||||
         allowedActions.push("migrateVolume");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    if(jsonObj.state != "Creating") {
 | 
			
		||||
      if(jsonObj.type == "ROOT") {
 | 
			
		||||
        if (jsonObj.vmstate == "Stopped") {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user