You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2013/06/21 23:31:05 UTC

git commit: updated refs/heads/master-6-17-stable to b8dec05

Updated Branches:
  refs/heads/master-6-17-stable b8b786d66 -> b8dec054f


CLOUDSTACK-2236: UI - Instances menu - migrate instance to another host - get requiresStorageMotion property from selected option instead of first option from host dropdown.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b8dec054
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b8dec054
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b8dec054

Branch: refs/heads/master-6-17-stable
Commit: b8dec054f58fc39303ed2d377cff83fdadeb61ef
Parents: b8b786d
Author: Jessica Wang <je...@apache.org>
Authored: Wed Jun 19 10:18:52 2013 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Fri Jun 21 14:30:41 2013 -0700

----------------------------------------------------------------------
 ui/scripts/instances.js | 132 ++++++++++++++++++++++---------------------
 1 file changed, 69 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8dec054/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 54b3187..e9a3d67 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 (function($, cloudStack) {
-  var requiresStorageMotion = false;
+  var vmMigrationHostObjs;
   cloudStack.sections.instances = {
     title: 'label.instances',
     id: 'instances',
@@ -1078,83 +1078,89 @@
                   validation: { required: true },
                   select: function(args) {
                     $.ajax({
-                      url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.instances[0].id),
-                      //url: createURL("listHosts"),	//for testing only, comment it out before checking in.
+                      url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.instances[0].id),                      
                       dataType: "json",
                       async: true,
                       success: function(json) {
-                        if(json.findhostsformigrationresponse.host != undefined){
-                        var hosts = json.findhostsformigrationresponse.host;
-                        requiresStorageMotion =  json.findhostsformigrationresponse.host[0].requiresStorageMotion;
-                        var items = [];
-                        $(hosts).each(function() {
-                        if(this.requiresStorageMotion == true){
-                          items.push({id: this.id, description: (this.name + " (" + (this.suitableformigration? "Suitable, ": "Not Suitable, ")  +  "Storage migration required)"  )});
-
+                        if(json.findhostsformigrationresponse.host != undefined) {
+                          vmMigrationHostObjs = json.findhostsformigrationresponse.host;                        
+                          var items = [];
+                          $(vmMigrationHostObjs).each(function() {
+                            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 {
-                     
-                          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 
-                        
+                        }                        
                       }
                     });
                   }
                 }
               }
             },
-            action: function(args) {
+            action: function(args) {         
+              var selectedHostObj;
+              if(vmMigrationHostObjs != null) {
+                for(var i = 0; i < vmMigrationHostObjs.length; i++) {
+                  if(vmMigrationHostObjs[i].id == args.data.hostId) {
+                    selectedHostObj = vmMigrationHostObjs[i];
+                    break;
+                  }
+                }
+              }
+              if(selectedHostObj == null)
+                return;
               
-            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;
+              if(selectedHostObj.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,
-                success: function(json) {
-                  var jid = json.migratevirtualmachineresponse.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,
+                  success: function(json) {
+                    var jid = json.migratevirtualmachineresponse.jobid;
+                    args.response.success(
+                      {_custom:
+                       {jobId: jid,
+                        getUpdatedItem: function(json) {
+                          return json.queryasyncjobresultresponse.jobresult.virtualmachine;
+                        },
+                        getActionFilter: function() {
+                          return vmActionfilter;
+                        }
+                       }
                       }
-                     }
-                    }
-                  );
-                }
-              });
-
+                    );
+                  }
+                });
               } 
             },
             notification: {