You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/04/10 00:58:45 UTC

[1/2] git commit: updated refs/heads/ui-vm-affinity to e907a08

Updated Branches:
  refs/heads/ui-vm-affinity e0692b39d -> e907a08fb


Instance wizard: clean up JS formatting


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

Branch: refs/heads/ui-vm-affinity
Commit: 9d5c375678fd7477361b8f6aaab914ba682e4cf8
Parents: e0692b3
Author: Brian Federle <br...@citrix.com>
Authored: Tue Apr 9 14:52:06 2013 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Tue Apr 9 14:52:06 2013 -0700

----------------------------------------------------------------------
 ui/scripts/instanceWizard.js |  890 ++++++++++++++++++------------------
 1 files changed, 445 insertions(+), 445 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d5c3756/ui/scripts/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instanceWizard.js b/ui/scripts/instanceWizard.js
index e1aeafd..277719c 100644
--- a/ui/scripts/instanceWizard.js
+++ b/ui/scripts/instanceWizard.js
@@ -68,475 +68,475 @@
 
     // Data providers for each wizard step
     steps: [
-    
-		// Step 1: Setup
-    function(args) {
-		  if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart			  
-			  //populate only one zone to the dropdown, the zone which the VPC is under.
-				zoneObjs = [{
-				  id: args.context.vpc[0].zoneid, 
-					name: args.context.vpc[0].zonename, 
-					networktype: 'Advanced'
-				}];	        		
-				args.response.success({ data: {zones: zoneObjs}});
-			}
-			else { //from Instance page 			 
-				$.ajax({
-					url: createURL("listZones&available=true"),
-					dataType: "json",
-					async: false,
-					success: function(json) {
-						zoneObjs = json.listzonesresponse.zone;						
-						args.response.success({ data: {zones: zoneObjs}});
-					}
-				});				
-			}		
-    },
-
-    // Step 2: Select template
-    function(args) {
-      $(zoneObjs).each(function(){
-        if(this.id == args.currentData.zoneid) {
-          selectedZoneObj = this;
-          return false; //break the $.each() loop
-        }
-      });
-      if(selectedZoneObj == null) {
-        alert("error: can't find matched zone object");
-        return;
-      }
-
-      $.ajax({
-        url: createURL("listHypervisors&zoneid="+args.currentData.zoneid),
-        dataType: "json",
-        async: false,
-        success: function(json) {
-          hypervisorObjs = json.listhypervisorsresponse.hypervisor;
-        }
-      });
-
-      //***** get templates/ISOs (begin) *****
-      var selectedTemplate = args.currentData['select-template'];
-      if (selectedTemplate == 'select-template') {
-        var hypervisorArray = [];
-        $(hypervisorObjs).each(function(index, item) {									 
-          hypervisorArray.push(item.name);
-        });
-
-        $.ajax({
-          url: createURL("listTemplates&templatefilter=featured&zoneid="+args.currentData.zoneid),
-          dataType: "json",
-          async: false,
-          success: function(json) {										  
-            if(json.listtemplatesresponse.template == null) {
-						  featuredTemplateObjs = null;
-						}
-						else {
-							featuredTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) {											  
-								if($.inArray(item.hypervisor, hypervisorArray) > -1)
-									return true;
-							});	
-						}
-          }
-        });
-        $.ajax({
-          url: createURL("listTemplates&templatefilter=community&zoneid="+args.currentData.zoneid),
-          dataType: "json",
-          async: false,
-          success: function(json) {
-					  if(json.listtemplatesresponse.template == null) {
-						  communityTemplateObjs = null;
-						}
-						else {
-							communityTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) {											  
-								if($.inArray(item.hypervisor, hypervisorArray) > -1)
-									return true;
-							});	
-						}
-          }
-        });
-        $.ajax({
-          url: createURL("listTemplates&templatefilter=selfexecutable&zoneid="+args.currentData.zoneid),
-          dataType: "json",
-          async: false,
-          success: function(json) {
-					  if(json.listtemplatesresponse.template == null) {
-						  myTemplateObjs = null;
-						}
-						else {
-							myTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) {											  
-								if($.inArray(item.hypervisor, hypervisorArray) > -1)
-									return true;
-							});	
-						}
-          }
-        });
-      } else if (selectedTemplate == 'select-iso') {
-        $.ajax({
-          url: createURL("listIsos&isofilter=featured&zoneid=" + args.currentData.zoneid + "&bootable=true"),
-          dataType: "json",
-          async: false,
-          success: function(json) {
-					  if(json.listisosresponse.iso == null) {
-						  featuredIsoObjs = null;
-						}
-						else {					
-              featuredIsoObjs = json.listisosresponse.iso;
-						}
-          }
-        });
-        $.ajax({
-          url: createURL("listIsos&isofilter=community&zoneid=" + args.currentData.zoneid + "&bootable=true"),
-          dataType: "json",
-          async: false,
-          success: function(json) {
-					  if(json.listisosresponse.iso == null) {
-						  communityIsoObjs = null;
-						}
-						else {					 
-              communityIsoObjs = json.listisosresponse.iso;
-						}
+      
+		  // Step 1: Setup
+      function(args) {
+		    if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart			  
+			    //populate only one zone to the dropdown, the zone which the VPC is under.
+				  zoneObjs = [{
+				    id: args.context.vpc[0].zoneid, 
+					  name: args.context.vpc[0].zonename, 
+					  networktype: 'Advanced'
+				  }];	        		
+				  args.response.success({ data: {zones: zoneObjs}});
+			  }
+			  else { //from Instance page 			 
+				  $.ajax({
+					  url: createURL("listZones&available=true"),
+					  dataType: "json",
+					  async: false,
+					  success: function(json) {
+						  zoneObjs = json.listzonesresponse.zone;						
+						  args.response.success({ data: {zones: zoneObjs}});
+					  }
+				  });				
+			  }		
+      },
+
+      // Step 2: Select template
+      function(args) {
+        $(zoneObjs).each(function(){
+          if(this.id == args.currentData.zoneid) {
+            selectedZoneObj = this;
+            return false; //break the $.each() loop
           }
         });
+        if(selectedZoneObj == null) {
+          alert("error: can't find matched zone object");
+          return;
+        }
+
         $.ajax({
-          url: createURL("listIsos&isofilter=selfexecutable&zoneid=" + args.currentData.zoneid + "&bootable=true"),
+          url: createURL("listHypervisors&zoneid="+args.currentData.zoneid),
           dataType: "json",
           async: false,
           success: function(json) {
-					  if(json.listisosresponse.iso == null) {
-						  myIsoObjs = null;
-						}
-						else {					
-              myIsoObjs = json.listisosresponse.iso;
-						}
+            hypervisorObjs = json.listhypervisorsresponse.hypervisor;
           }
         });
-      }
-      //***** get templates/ISOs (end) *****
 
+        //***** get templates/ISOs (begin) *****
+        var selectedTemplate = args.currentData['select-template'];
+        if (selectedTemplate == 'select-template') {
+          var hypervisorArray = [];
+          $(hypervisorObjs).each(function(index, item) {									 
+            hypervisorArray.push(item.name);
+          });
 
-      var templatesObj = {};
-      if (selectedTemplate == 'select-template') {
-        templatesObj = {
-          featuredtemplates: featuredTemplateObjs,
-          communitytemplates: communityTemplateObjs,
-          mytemplates: myTemplateObjs
-        }
-      } else if (selectedTemplate == 'select-iso') {
-        templatesObj = {
-          featuredisos: featuredIsoObjs,
-          communityisos: communityIsoObjs,
-          myisos: myIsoObjs
-        }
-      }
-      args.response.success({
-        hypervisor: {
-          idField: 'name',
-          nameField: 'name'
-        },
-        data: {
-          templates: templatesObj,
-          hypervisors: hypervisorObjs
+          $.ajax({
+            url: createURL("listTemplates&templatefilter=featured&zoneid="+args.currentData.zoneid),
+            dataType: "json",
+            async: false,
+            success: function(json) {										  
+              if(json.listtemplatesresponse.template == null) {
+						    featuredTemplateObjs = null;
+						  }
+						  else {
+							  featuredTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) {											  
+								  if($.inArray(item.hypervisor, hypervisorArray) > -1)
+									  return true;
+							  });	
+						  }
+            }
+          });
+          $.ajax({
+            url: createURL("listTemplates&templatefilter=community&zoneid="+args.currentData.zoneid),
+            dataType: "json",
+            async: false,
+            success: function(json) {
+					    if(json.listtemplatesresponse.template == null) {
+						    communityTemplateObjs = null;
+						  }
+						  else {
+							  communityTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) {											  
+								  if($.inArray(item.hypervisor, hypervisorArray) > -1)
+									  return true;
+							  });	
+						  }
+            }
+          });
+          $.ajax({
+            url: createURL("listTemplates&templatefilter=selfexecutable&zoneid="+args.currentData.zoneid),
+            dataType: "json",
+            async: false,
+            success: function(json) {
+					    if(json.listtemplatesresponse.template == null) {
+						    myTemplateObjs = null;
+						  }
+						  else {
+							  myTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) {											  
+								  if($.inArray(item.hypervisor, hypervisorArray) > -1)
+									  return true;
+							  });	
+						  }
+            }
+          });
+        } else if (selectedTemplate == 'select-iso') {
+          $.ajax({
+            url: createURL("listIsos&isofilter=featured&zoneid=" + args.currentData.zoneid + "&bootable=true"),
+            dataType: "json",
+            async: false,
+            success: function(json) {
+					    if(json.listisosresponse.iso == null) {
+						    featuredIsoObjs = null;
+						  }
+						  else {					
+                featuredIsoObjs = json.listisosresponse.iso;
+						  }
+            }
+          });
+          $.ajax({
+            url: createURL("listIsos&isofilter=community&zoneid=" + args.currentData.zoneid + "&bootable=true"),
+            dataType: "json",
+            async: false,
+            success: function(json) {
+					    if(json.listisosresponse.iso == null) {
+						    communityIsoObjs = null;
+						  }
+						  else {					 
+                communityIsoObjs = json.listisosresponse.iso;
+						  }
+            }
+          });
+          $.ajax({
+            url: createURL("listIsos&isofilter=selfexecutable&zoneid=" + args.currentData.zoneid + "&bootable=true"),
+            dataType: "json",
+            async: false,
+            success: function(json) {
+					    if(json.listisosresponse.iso == null) {
+						    myIsoObjs = null;
+						  }
+						  else {					
+                myIsoObjs = json.listisosresponse.iso;
+						  }
+            }
+          });
         }
-      });
-    },
+        //***** get templates/ISOs (end) *****
 
-    // Step 3: Service offering
-    function(args) {
-      if(args.currentData["select-template"] == "select-template") {
-        if(featuredTemplateObjs != null && featuredTemplateObjs.length > 0) {
-          for(var i=0; i < featuredTemplateObjs.length; i++) {
-            if(featuredTemplateObjs[i].id == args.currentData.templateid) {
-              selectedTemplateObj = featuredTemplateObjs[i];
-              break;
-            }
+
+        var templatesObj = {};
+        if (selectedTemplate == 'select-template') {
+          templatesObj = {
+            featuredtemplates: featuredTemplateObjs,
+            communitytemplates: communityTemplateObjs,
+            mytemplates: myTemplateObjs
+          }
+        } else if (selectedTemplate == 'select-iso') {
+          templatesObj = {
+            featuredisos: featuredIsoObjs,
+            communityisos: communityIsoObjs,
+            myisos: myIsoObjs
           }
         }
-        if(selectedTemplateObj == null) {
-          if(communityTemplateObjs != null && communityTemplateObjs.length > 0) {
-            for(var i=0; i < communityTemplateObjs.length; i++) {
-              if(communityTemplateObjs[i].id == args.currentData.templateid) {
-                selectedTemplateObj = communityTemplateObjs[i];
+        args.response.success({
+          hypervisor: {
+            idField: 'name',
+            nameField: 'name'
+          },
+          data: {
+            templates: templatesObj,
+            hypervisors: hypervisorObjs
+          }
+        });
+      },
+
+      // Step 3: Service offering
+      function(args) {
+        if(args.currentData["select-template"] == "select-template") {
+          if(featuredTemplateObjs != null && featuredTemplateObjs.length > 0) {
+            for(var i=0; i < featuredTemplateObjs.length; i++) {
+              if(featuredTemplateObjs[i].id == args.currentData.templateid) {
+                selectedTemplateObj = featuredTemplateObjs[i];
                 break;
               }
             }
           }
-        }
-        if(selectedTemplateObj == null) {
-          if(myTemplateObjs != null && myTemplateObjs.length > 0) {
-            for(var i=0; i < myTemplateObjs.length; i++) {
-              if(myTemplateObjs[i].id == args.currentData.templateid) {
-                selectedTemplateObj = myTemplateObjs[i];
-                break;
+          if(selectedTemplateObj == null) {
+            if(communityTemplateObjs != null && communityTemplateObjs.length > 0) {
+              for(var i=0; i < communityTemplateObjs.length; i++) {
+                if(communityTemplateObjs[i].id == args.currentData.templateid) {
+                  selectedTemplateObj = communityTemplateObjs[i];
+                  break;
+                }
               }
             }
           }
-        }
-        if(selectedTemplateObj == null)
-          alert("unable to find matched template object");
-        else
-          selectedHypervisor = selectedTemplateObj.hypervisor;
-      }
-      else { //(args.currentData["select-template"] == "select-iso"
-        selectedHypervisor = args.currentData.hypervisorid;
-      }
-
-      $.ajax({
-        url: createURL("listServiceOfferings&issystem=false"),
-        dataType: "json",
-        async: true,
-        success: function(json) {
-          serviceOfferingObjs = json.listserviceofferingsresponse.serviceoffering;
-          args.response.success({
-            data: {serviceOfferings: serviceOfferingObjs}
-          });
-        }
-      });
-    },
-
-    // Step 4: Data disk offering
-    function(args) {
-      var isRequred = (args.currentData["select-template"] == "select-iso"? true: false);
-      $.ajax({
-        url: createURL("listDiskOfferings"),
-        dataType: "json",
-        async: true,
-        success: function(json) {
-          diskOfferingObjs = json.listdiskofferingsresponse.diskoffering;
-          args.response.success({
-            required: isRequred,
-            customFlag: 'iscustomized', // Field determines if custom slider is shown
-            data: {diskOfferings: diskOfferingObjs}
-          });
-        }
-      });
-    },
-
-    // Step 5: Network
-    function(args) {
-      if(diskOfferingObjs != null && diskOfferingObjs.length > 0) {
-        for(var i=0; i < diskOfferingObjs.length; i++) {
-          if(diskOfferingObjs[i].id == args.currentData.diskofferingid) {
-            selectedDiskOfferingObj = diskOfferingObjs[i];
-            break;
-          }
-        }
-      }
-
-      if (selectedZoneObj.networktype == "Advanced") {  //Advanced zone. Show network list.	 
-				var $networkStep = $(".step.network:visible .nothing-to-select");
-				var $networkStepContainer = $('.step.network:visible');
-
-				if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart
-				  step5ContainerType = 'nothing-to-select'; 					
-					$networkStep.find("#from_instance_page_1").hide();		
-          $networkStep.find("#from_instance_page_2").hide();					
-					$networkStep.find("#from_vpc_tier").text("tier " + args.context.networks[0].name);					
-					$networkStep.find("#from_vpc_tier").show();					
-				} else { //from Instance page
-				  if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone
-						step5ContainerType = 'select-network';
-						$networkStep.find("#from_instance_page_1").show();		
-						$networkStep.find("#from_instance_page_2").show();
-						$networkStep.find("#from_vpc_tier").text("");			
-						$networkStep.find("#from_vpc_tier").hide();
-            $networkStepContainer.removeClass('next-use-security-groups');
-					} else { // Advanced SG-enabled zone
-					  step5ContainerType = 'select-advanced-sg';
-					}
-
-          if ($networkStepContainer.hasClass('next-use-security-groups')) {
-            $networkStepContainer.removeClass('repeat next-use-security-groups loaded');
-            step5ContainerType = 'select-security-group';
-          }
-				}
-      }
-      else { //Basic zone. Show securigy group list or nothing(when no SecurityGroup service in guest network)
-        var includingSecurityGroupService = false;
-        $.ajax({
-          url: createURL("listNetworks&trafficType=Guest&zoneId=" + selectedZoneObj.id),
-          dataType: "json",
-          async: false,
-          success: function(json) {
-            //basic zone should have only one guest network returned in this API call
-            var items = json.listnetworksresponse.network;
-            if(items != null && items.length > 0) {
-              var networkObj = items[0];    //basic zone has only one guest network
-              var serviceObjArray = networkObj.service;
-              for(var k = 0; k < serviceObjArray.length; k++) {
-                if(serviceObjArray[k].name == "SecurityGroup") {
-                  includingSecurityGroupService = true;
+          if(selectedTemplateObj == null) {
+            if(myTemplateObjs != null && myTemplateObjs.length > 0) {
+              for(var i=0; i < myTemplateObjs.length; i++) {
+                if(myTemplateObjs[i].id == args.currentData.templateid) {
+                  selectedTemplateObj = myTemplateObjs[i];
                   break;
                 }
               }
             }
           }
-        });
-
-        if(includingSecurityGroupService == false || selectedHypervisor == "VMware") {
-          step5ContainerType = 'nothing-to-select';
+          if(selectedTemplateObj == null)
+            alert("unable to find matched template object");
+          else
+            selectedHypervisor = selectedTemplateObj.hypervisor;
         }
-        else {
-          step5ContainerType = 'select-security-group';
+        else { //(args.currentData["select-template"] == "select-iso"
+          selectedHypervisor = args.currentData.hypervisorid;
         }
-      }
 
-      //step5ContainerType = 'nothing-to-select'; //for testing only, comment it out before checking in
-      if(step5ContainerType == 'select-network' || step5ContainerType == 'select-advanced-sg') {
-        var defaultNetworkArray = [], optionalNetworkArray = [];
-        var networkData = {
-          zoneId: args.currentData.zoneid,
-					canusefordeploy: true
-        };
-				
-				if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) {
-				  $.extend(networkData, {
-					  type: 'Shared'
-					});
-				}				
-				
-        if (!(cloudStack.context.projects && cloudStack.context.projects[0])) {
-          networkData.domainid = g_domainid;
-          networkData.account = g_account;
-        }
-
-        var vpcObjs;
-
-        //listVPCs without account/domainid/listAll parameter will return only VPCs belonging to the current login. That's what should happen in Instances page's VM Wizard. 
-				//i.e. If the current login is root-admin, do not show VPCs belonging to regular-user/domain-admin in Instances page's VM Wizard. 
-        $.ajax({
-          url: createURL('listVPCs'), 
-          async: false,
-          success: function(json) {
-            vpcObjs = json.listvpcsresponse.vpc ? json.listvpcsresponse.vpc : [];
-          }
-        });
-        
-				var networkObjsToPopulate = [];
         $.ajax({
-          url: createURL('listNetworks'),
-          data: networkData,
-          async: false,
+          url: createURL("listServiceOfferings&issystem=false"),
+          dataType: "json",
+          async: true,
           success: function(json) {
-            networkObjs = json.listnetworksresponse.network ? json.listnetworksresponse.network : [];            
-						if(networkObjs.length > 0) {
-						  for(var i = 0; i < networkObjs.length; i++) {
-								var networkObj = networkObjs[i];    
-								var includingSecurityGroup = false;
-								var serviceObjArray = networkObj.service;
-								for(var k = 0; k < serviceObjArray.length; k++) {
-									if(serviceObjArray[k].name == "SecurityGroup") {
-									  networkObjs[i].type = networkObjs[i].type + ' (sg)';	
-                    includingSecurityGroup = true;
-										break;   								
-									}
-								}
-
-                if (networkObj.vpcid) {
-                  networkObj._singleSelect = true;
-                }
-                
-								//for Advanced SG-enabled zone, list only SG network offerings 
-								if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) {
-									if(includingSecurityGroup == false)
-										continue; //skip to next network offering
-								}										
-								networkObjsToPopulate.push(networkObj);		
-							}
-            }						
+            serviceOfferingObjs = json.listserviceofferingsresponse.serviceoffering;
+            args.response.success({
+              data: {serviceOfferings: serviceOfferingObjs}
+            });
           }
         });
-                  
+      },
+
+      // Step 4: Data disk offering
+      function(args) {
+        var isRequred = (args.currentData["select-template"] == "select-iso"? true: false);
         $.ajax({
-          url: createURL("listNetworkOfferings"), 
+          url: createURL("listDiskOfferings"),
           dataType: "json",
-					data: {
-						forvpc: false, 
-						zoneid: args.currentData.zoneid,
-						guestiptype: 'Isolated',
-						supportedServices: 'SourceNat',
-						specifyvlan: false,
-						state: 'Enabled'
-					},
-          async: false,
+          async: true,
           success: function(json) {
-            networkOfferingObjs  = json.listnetworkofferingsresponse.networkoffering;
+            diskOfferingObjs = json.listdiskofferingsresponse.diskoffering;
+            args.response.success({
+              required: isRequred,
+              customFlag: 'iscustomized', // Field determines if custom slider is shown
+              data: {diskOfferings: diskOfferingObjs}
+            });
           }
         });
-        //get network offerings (end)	***			
-
-        $networkStepContainer.removeClass('repeat next-use-security-groups');
+      },
+
+      // Step 6: Network
+      function(args) {
+        if(diskOfferingObjs != null && diskOfferingObjs.length > 0) {
+          for(var i=0; i < diskOfferingObjs.length; i++) {
+            if(diskOfferingObjs[i].id == args.currentData.diskofferingid) {
+              selectedDiskOfferingObj = diskOfferingObjs[i];
+              break;
+            }
+          }
+        }
 
-        if (step5ContainerType == 'select-advanced-sg') {
-          $networkStepContainer.addClass('repeat next-use-security-groups');
+        if (selectedZoneObj.networktype == "Advanced") {  //Advanced zone. Show network list.	 
+				  var $networkStep = $(".step.network:visible .nothing-to-select");
+				  var $networkStepContainer = $('.step.network:visible');
+
+				  if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart
+				    step5ContainerType = 'nothing-to-select'; 					
+					  $networkStep.find("#from_instance_page_1").hide();		
+            $networkStep.find("#from_instance_page_2").hide();					
+					  $networkStep.find("#from_vpc_tier").text("tier " + args.context.networks[0].name);					
+					  $networkStep.find("#from_vpc_tier").show();					
+				  } else { //from Instance page
+				    if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone
+						  step5ContainerType = 'select-network';
+						  $networkStep.find("#from_instance_page_1").show();		
+						  $networkStep.find("#from_instance_page_2").show();
+						  $networkStep.find("#from_vpc_tier").text("");			
+						  $networkStep.find("#from_vpc_tier").hide();
+              $networkStepContainer.removeClass('next-use-security-groups');
+					  } else { // Advanced SG-enabled zone
+					    step5ContainerType = 'select-advanced-sg';
+					  }
+
+            if ($networkStepContainer.hasClass('next-use-security-groups')) {
+              $networkStepContainer.removeClass('repeat next-use-security-groups loaded');
+              step5ContainerType = 'select-security-group';
+            }
+				  }
+        }
+        else { //Basic zone. Show securigy group list or nothing(when no SecurityGroup service in guest network)
+          var includingSecurityGroupService = false;
+          $.ajax({
+            url: createURL("listNetworks&trafficType=Guest&zoneId=" + selectedZoneObj.id),
+            dataType: "json",
+            async: false,
+            success: function(json) {
+              //basic zone should have only one guest network returned in this API call
+              var items = json.listnetworksresponse.network;
+              if(items != null && items.length > 0) {
+                var networkObj = items[0];    //basic zone has only one guest network
+                var serviceObjArray = networkObj.service;
+                for(var k = 0; k < serviceObjArray.length; k++) {
+                  if(serviceObjArray[k].name == "SecurityGroup") {
+                    includingSecurityGroupService = true;
+                    break;
+                  }
+                }
+              }
+            }
+          });
 
-          // Add guest network is disabled
-          $networkStepContainer.find('.select-network').addClass('no-add-network');
-        } else {
-          $networkStepContainer.find('.select-network').removeClass('no-add-network');
+          if(includingSecurityGroupService == false || selectedHypervisor == "VMware") {
+            step5ContainerType = 'nothing-to-select';
+          }
+          else {
+            step5ContainerType = 'select-security-group';
+          }
         }
 
-        args.response.success({
-          type: 'select-network',
-          data: {            
-            networkObjs: networkObjsToPopulate,
-            securityGroups: [],
-            networkOfferings: networkOfferingObjs,
-            vpcs: vpcObjs
+        //step5ContainerType = 'nothing-to-select'; //for testing only, comment it out before checking in
+        if(step5ContainerType == 'select-network' || step5ContainerType == 'select-advanced-sg') {
+          var defaultNetworkArray = [], optionalNetworkArray = [];
+          var networkData = {
+            zoneId: args.currentData.zoneid,
+					  canusefordeploy: true
+          };
+				  
+				  if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) {
+				    $.extend(networkData, {
+					    type: 'Shared'
+					  });
+				  }				
+				  
+          if (!(cloudStack.context.projects && cloudStack.context.projects[0])) {
+            networkData.domainid = g_domainid;
+            networkData.account = g_account;
           }
-        });
-      }
 
-      else if(step5ContainerType == 'select-security-group') {
-        var securityGroupArray = [];
-        var data = {
-          domainid: g_domainid,
-          account: g_account
-        };
+          var vpcObjs;
 
-        $.ajax({
-          url: createURL("listSecurityGroups"),
-          dataType: "json",
-          async: false,
-          data: cloudStack.context.projects ? {} : data,
-          success: function(json) {
-            var items = json.listsecuritygroupsresponse.securitygroup;
-            if (items != null && items.length > 0) {
-              for (var i = 0; i < items.length; i++) {
-                securityGroupArray.push(items[i]);
-              }
+          //listVPCs without account/domainid/listAll parameter will return only VPCs belonging to the current login. That's what should happen in Instances page's VM Wizard. 
+				  //i.e. If the current login is root-admin, do not show VPCs belonging to regular-user/domain-admin in Instances page's VM Wizard. 
+          $.ajax({
+            url: createURL('listVPCs'), 
+            async: false,
+            success: function(json) {
+              vpcObjs = json.listvpcsresponse.vpc ? json.listvpcsresponse.vpc : [];
             }
-          }
-        });
-        args.response.success({
-          type: 'select-security-group',
-          data: {            
-            networkObjs: [],
-            securityGroups: securityGroupArray,
-            networkOfferings: [],
-            vpcs: []
-          }
-        });
-      }
+          });
+          
+				  var networkObjsToPopulate = [];
+          $.ajax({
+            url: createURL('listNetworks'),
+            data: networkData,
+            async: false,
+            success: function(json) {
+              networkObjs = json.listnetworksresponse.network ? json.listnetworksresponse.network : [];            
+						  if(networkObjs.length > 0) {
+						    for(var i = 0; i < networkObjs.length; i++) {
+								  var networkObj = networkObjs[i];    
+								  var includingSecurityGroup = false;
+								  var serviceObjArray = networkObj.service;
+								  for(var k = 0; k < serviceObjArray.length; k++) {
+									  if(serviceObjArray[k].name == "SecurityGroup") {
+									    networkObjs[i].type = networkObjs[i].type + ' (sg)';	
+                      includingSecurityGroup = true;
+										  break;   								
+									  }
+								  }
+
+                  if (networkObj.vpcid) {
+                    networkObj._singleSelect = true;
+                  }
+                  
+								  //for Advanced SG-enabled zone, list only SG network offerings 
+								  if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) {
+									  if(includingSecurityGroup == false)
+										  continue; //skip to next network offering
+								  }										
+								  networkObjsToPopulate.push(networkObj);		
+							  }
+              }						
+            }
+          });
+          
+          $.ajax({
+            url: createURL("listNetworkOfferings"), 
+            dataType: "json",
+					  data: {
+						  forvpc: false, 
+						  zoneid: args.currentData.zoneid,
+						  guestiptype: 'Isolated',
+						  supportedServices: 'SourceNat',
+						  specifyvlan: false,
+						  state: 'Enabled'
+					  },
+            async: false,
+            success: function(json) {
+              networkOfferingObjs  = json.listnetworkofferingsresponse.networkoffering;
+            }
+          });
+          //get network offerings (end)	***			
 
-      else if(step5ContainerType == 'nothing-to-select') {
-        args.response.success({
-          type: 'nothing-to-select',
-          data: {            
-            networkObjs: [],
-            securityGroups: [],
-            networkOfferings: [],
-            vpcs: []
+          $networkStepContainer.removeClass('repeat next-use-security-groups');
+
+          if (step5ContainerType == 'select-advanced-sg') {
+            $networkStepContainer.addClass('repeat next-use-security-groups');
+
+            // Add guest network is disabled
+            $networkStepContainer.find('.select-network').addClass('no-add-network');
+          } else {
+            $networkStepContainer.find('.select-network').removeClass('no-add-network');
           }
-        });
-      }
 
-    },
+          args.response.success({
+            type: 'select-network',
+            data: {            
+              networkObjs: networkObjsToPopulate,
+              securityGroups: [],
+              networkOfferings: networkOfferingObjs,
+              vpcs: vpcObjs
+            }
+          });
+        }
 
-    // Step 6: Review
-    function(args) {
-      return false;
-    }
+        else if(step5ContainerType == 'select-security-group') {
+          var securityGroupArray = [];
+          var data = {
+            domainid: g_domainid,
+            account: g_account
+          };
+
+          $.ajax({
+            url: createURL("listSecurityGroups"),
+            dataType: "json",
+            async: false,
+            data: cloudStack.context.projects ? {} : data,
+            success: function(json) {
+              var items = json.listsecuritygroupsresponse.securitygroup;
+              if (items != null && items.length > 0) {
+                for (var i = 0; i < items.length; i++) {
+                  securityGroupArray.push(items[i]);
+                }
+              }
+            }
+          });
+          args.response.success({
+            type: 'select-security-group',
+            data: {            
+              networkObjs: [],
+              securityGroups: securityGroupArray,
+              networkOfferings: [],
+              vpcs: []
+            }
+          });
+        }
+
+        else if(step5ContainerType == 'nothing-to-select') {
+          args.response.success({
+            type: 'nothing-to-select',
+            data: {            
+              networkObjs: [],
+              securityGroups: [],
+              networkOfferings: [],
+              vpcs: []
+            }
+          });
+        }
+
+      },
+
+      // Step 6: Review
+      function(args) {
+        return false;
+      }
     ],
     action: function(args) {
       // Create a new VM!!!!
@@ -638,12 +638,12 @@
 
         if(checkedSecurityGroupIdArray.length > 0)
           array1.push("&securitygroupids=" + checkedSecurityGroupIdArray.join(","));
-				        			
+				
 				if(selectedZoneObj.networktype ==	"Advanced" && selectedZoneObj.securitygroupsenabled == true) { // Advanced SG-enabled zone 	          
           var array2 = [];							
 					var myNetworks = $('.multi-wizard:visible form').data('my-networks'); //widget limitation: If using an advanced security group zone, get the guest networks like this 
 					var defaultNetworkId = $('.multi-wizard:visible form').find('input[name=defaultNetwork]:checked').val();
-										
+					
 					var checkedNetworkIdArray;
 					if(typeof(myNetworks) == "object" && myNetworks.length != null) { //myNetworks is an array of string, e.g. ["203", "202"],
 						checkedNetworkIdArray = myNetworks;
@@ -703,30 +703,30 @@
           var vmid = json.deployvirtualmachineresponse.id;
           args.response.success(
             {_custom:
-              {jobId: jid,
-                getUpdatedItem: function(json) {
-                  var item = json.queryasyncjobresultresponse.jobresult.virtualmachine;
-                  if (item.password != null)
-                    alert("Password of new VM " + item.displayname + " is  " + item.password);
-                  return item;
-                },
-                getActionFilter: function() {
-                  return cloudStack.actionFilter.vmActionFilter;
-                },
-                getUpdatedItemWhenAsyncJobFails: function() {
-                  var item;
-                  $.ajax({
-                    url: createURL("listVirtualMachines&id="+vmid),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      item = json.listvirtualmachinesresponse.virtualmachine[0];
-                    }
-                  });
-                  return item;
-                }
-          }
-          }
+             {jobId: jid,
+              getUpdatedItem: function(json) {
+                var item = json.queryasyncjobresultresponse.jobresult.virtualmachine;
+                if (item.password != null)
+                  alert("Password of new VM " + item.displayname + " is  " + item.password);
+                return item;
+              },
+              getActionFilter: function() {
+                return cloudStack.actionFilter.vmActionFilter;
+              },
+              getUpdatedItemWhenAsyncJobFails: function() {
+                var item;
+                $.ajax({
+                  url: createURL("listVirtualMachines&id="+vmid),
+                  dataType: "json",
+                  async: false,
+                  success: function(json) {
+                    item = json.listvirtualmachinesresponse.virtualmachine[0];
+                  }
+                });
+                return item;
+              }
+             }
+            }
           );
         },
         error: function(XMLHttpResponse) {


[2/2] git commit: updated refs/heads/ui-vm-affinity to e907a08

Posted by bf...@apache.org.
Affinity UI: Add step to instance wizard


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

Branch: refs/heads/ui-vm-affinity
Commit: e907a08fba6a4000e2f5b98192ff69066092c273
Parents: 9d5c375
Author: Brian Federle <br...@citrix.com>
Authored: Tue Apr 9 15:58:29 2013 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Tue Apr 9 15:58:29 2013 -0700

----------------------------------------------------------------------
 .../WEB-INF/classes/resources/messages.properties  |    6 +++
 ui/css/cloudstack3.css                             |   28 ++++++++++++--
 ui/dictionary.jsp                                  |    6 +++
 ui/index.jsp                                       |   13 ++++++-
 ui/scripts/instanceWizard.js                       |   12 ++++++
 ui/scripts/ui-custom/instanceWizard.js             |   19 ++++++++++
 6 files changed, 78 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e907a08f/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index d62cbae..abd1e30 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -17,6 +17,12 @@
 
 
 #new labels (begin) **********************************************************************************************
+label.affinity=Affinity
+label.anti.affinity=Anti-affinity
+label.affinity.groups=Affinity Groups
+label.anti.affinity.groups=Anti-affinity Groups
+label.affinity.group=Affinity Group
+label.anti.affinity.group=Anti-affinity Group
 message.redirecting.region=Redirecting to region...
 label.use.vm.ip=Use VM IP:
 label.cpu.limits=CPU limits

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e907a08f/ui/css/cloudstack3.css
----------------------------------------------------------------------
diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css
index 7ebda9b..1890476 100644
--- a/ui/css/cloudstack3.css
+++ b/ui/css/cloudstack3.css
@@ -5222,6 +5222,10 @@ label.error {
   position: relative;
 }
 
+.multi-wizard.instance-wizard .progress ul li {
+  width: 109px;
+}
+
 .multi-wizard .progress ul li.first {
   /*+border-radius:5px 0 0 5px;*/
   -moz-border-radius: 5px 0 0 5px;
@@ -5263,6 +5267,10 @@ label.error {
   text-align: center;
 }
 
+.multi-wizard.instance-wizard .progress ul li span {
+  left: 36px;
+}
+
 .multi-wizard .progress ul li span.multiline {
   width: 71px;
   top: 12px;
@@ -5279,6 +5287,10 @@ label.error {
   z-index: 1000;
 }
 
+.multi-wizard.instance-wizard .progress ul li span.arrow {
+  left: 27px;
+}
+
 .multi-wizard .progress ul li.active span.arrow {
   background-position: -1px -396px;
 }
@@ -5299,6 +5311,15 @@ label.error {
   background: transparent;
 }
 
+.multi-wizard.instance-wizard .progress ul li span.number {
+  left: 16px;
+}
+
+.multi-wizard.instance-wizard .progress ul li span.multiline {
+  width: 79px;
+  left: 23px;
+}
+
 .multi-wizard .progress ul li.active span {
   /*+text-shadow:0px -1px 1px #004AFF;*/
   -moz-text-shadow: 0px -1px 1px #004AFF;
@@ -11761,12 +11782,11 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it
 .updateResourceLimits:hover .icon {
   background-position: -100px -614px;
 }
- 
+
 .addVlanRange .icon {
   background-position: -168px -31px;
 }
 
-
 .addVlanRange:hover .icon {
   background-position: -168px -613px;
 }
@@ -11796,8 +11816,8 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it
   background-position: -168px -31px;
 }
 
-.reset .icon ,
-.scaleUp .icon{
+.reset .icon,
+.scaleUp .icon {
   background-position: -168px -31px;
 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e907a08f/ui/dictionary.jsp
----------------------------------------------------------------------
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index 11e98cf..ffe0e89 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -25,6 +25,12 @@ under the License.
 <% long now = System.currentTimeMillis(); %>
 <script language="javascript">
 dictionary = {
+'label.affinity': '<fmt:message key="label.affinity"/>',
+'label.anti.affinity': '<fmt:message key="-affinitylabel.anti.affinity"/>',
+'label.affinity.groups': '<fmt:message key=" Groupslabel.affinity.groups"/>',
+'label.anti.affinity.groups': '<fmt:message key="-affinity Groupslabel.anti.affinity.groups"/>',
+'label.affinity.group': '<fmt:message key=" Grouplabel.affinity.group"/>',
+'label.anti.affinity.group': '<fmt:message key="-affinity Grouplabel.anti.affinity.group"/>',
 'message.redirecting.region': '<fmt:message key="message.redirecting.region"/>',
 'label.use.vm.ip': '<fmt:message key="label.use.vm.ip"/>',
 'label.cpu.limits': '<fmt:message key="label.cpu.limits"/>',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e907a08f/ui/index.jsp
----------------------------------------------------------------------
diff --git a/ui/index.jsp b/ui/index.jsp
index 3b8f378..c2e2a61 100644
--- a/ui/index.jsp
+++ b/ui/index.jsp
@@ -89,7 +89,8 @@ under the License.
             <li><span class="number">2</span><span class="multiline"><fmt:message key="label.select.a.template"/></span><span class="arrow"></span></li>
             <li><span class="number">3</span><span class="multiline"><fmt:message key="label.compute.offering"/></span><span class="arrow"></span></li>
             <li><span class="number">4</span><span class="multiline"><fmt:message key="label.data.disk.offering"/></span><span class="arrow"></span></li>
-            <li><span class="number">5</span><span><fmt:message key="label.menu.network"/></span><span class="arrow"></span></li>
+            <li><span class="number">5</span><span><fmt:message key="label.affinity"/></span><span class="arrow"></span></li>
+            <li><span class="number">6</span><span><fmt:message key="label.menu.network"/></span><span class="arrow"></span></li>
             <li class="last"><span class="number">6</span><span><fmt:message key="label.review"/></span></li>
           </ul>
         </div>
@@ -220,7 +221,15 @@ under the License.
               </div>
             </div>
 
-            <!-- Step 5: Network -->
+            <!-- Step 5: Affinity groups -->
+            <div class="step affinity" wizard-step-id="affinity">
+              <div class="content">
+                <!-- Existing offerings -->
+                <div class="select-container"></div>
+              </div>
+            </div>
+
+            <!-- Step 6: Network -->
             <div class="step network always-load" wizard-step-id="network">
               <!-- 5a: Network description -->
               <div class="wizard-step-conditional nothing-to-select">     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e907a08f/ui/scripts/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instanceWizard.js b/ui/scripts/instanceWizard.js
index 277719c..2013cb4 100644
--- a/ui/scripts/instanceWizard.js
+++ b/ui/scripts/instanceWizard.js
@@ -312,6 +312,18 @@
         });
       },
 
+      // Step 5: Affinity
+      function(args) {
+        args.response.success({
+          data: {
+            affinityGroups: [
+              { id: 1, name: 'affinity1', description: 'Dummy Affinity Group 1' },
+              { id: 2, name: 'affinity2', description: 'Dummy Affinity Group 2' },
+            ]
+          }
+        });
+      },
+
       // Step 6: Network
       function(args) {
         if(diskOfferingObjs != null && diskOfferingObjs.length > 0) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e907a08f/ui/scripts/ui-custom/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js
index 2c6d9f1..2cb352a 100644
--- a/ui/scripts/ui-custom/instanceWizard.js
+++ b/ui/scripts/ui-custom/instanceWizard.js
@@ -482,6 +482,25 @@
             };
           },
 
+          'affinity': function($step, formData) {
+            return {
+              response: {
+                success: function(args) {
+                  $step.find('.select-container').append(
+                    makeSelects('affinity-groups', args.data.affinityGroups, {
+                      name: 'name',
+                      desc: 'description',
+                      id: 'id'
+                    }, {
+                      type: 'checkbox',
+                      'wizard-field': 'affinity-groups'
+                    })
+                  );
+                }
+              }
+            };
+          },
+
           'network': function($step, formData) {
             var showAddNetwork = true;