cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject git commit: updated refs/heads/master to acc71fb
Date Mon, 03 Jun 2013 18:45:36 GMT
Updated Branches:
  refs/heads/master 24d605517 -> acc71fb73


CLOUDSTACK-766: Support assigning VLAN ID to network

On add network form, if selected network offering has
specifyVlan=true, show VLAN text field.


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

Branch: refs/heads/master
Commit: acc71fb735ded8e9e6378699a140d72c67a6428d
Parents: 24d6055
Author: Brian Federle <bfederle@gmail.com>
Authored: Mon Jun 3 11:29:40 2013 -0700
Committer: Brian Federle <bfederle@gmail.com>
Committed: Mon Jun 3 11:45:28 2013 -0700

----------------------------------------------------------------------
 ui/scripts/network.js |   61 ++++++++++++++++++++++++++++++++++++--------
 ui/scripts/vpc.js     |   20 +++++++++++++-
 2 files changed, 69 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/acc71fb7/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index d66ec83..aa22290 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -376,20 +376,41 @@
                           var items = json.listvpcsresponse.vpc;
                           var baseUrl = 'listNetworkOfferings&zoneid=' + args.zoneId;
                           var listUrl;
+                          var data = {
+                            guestiptype: 'Isolated',
+                            supportedServices: 'SourceNat',
+                            state: 'Enabled',
+                          };
+                          
                           if(items != null && items.length > 0) 
                             listUrl = baseUrl;
                           else
                             listUrl = baseUrl + '&forVpc=false';
+
+                          if (args.context.vpc) {
+                            data.forVpc = true;
+                          }
+                          
                           $.ajax({
                             url: createURL(listUrl),
-                            data: {
-                              guestiptype: 'Isolated',
-                              supportedServices: 'SourceNat',
-                              specifyvlan: false,
-                              state: 'Enabled'
-                            },
+                            data: data,
                             success: function(json) {
                               networkOfferingObjs = json.listnetworkofferingsresponse.networkoffering;
+                              args.$select.change(function() {
+                                var $vlan = args.$select.closest('form').find('[rel=vlan]');
+                                var networkOffering = $.grep(
+                                  networkOfferingObjs, function(netoffer) {
+                                    return netoffer.id == args.$select.val();
+                                  }
+                                )[0];
+
+                                if (networkOffering.specifyvlan) {
+                                  $vlan.css('display', 'inline-block');
+                                } else {
+                                  $vlan.hide();
+                                }
+                              });
+                              
                               args.response.success({
                                 data: $.map(networkOfferingObjs, function(zone) {
                                   return {
@@ -405,26 +426,39 @@
                     }
                   },
 
+                  vlan: {
+                    label: 'VLAN',
+                    validation: { required: true },
+                    isHidden: true
+                  },
+
                   vpcid: {
                     label: 'label.vpc',
                     dependsOn: 'networkOfferingId',
                     select: function(args) {
                       var networkOfferingObj;
                       var $form = args.$select.closest('form');
+                      var data = {
+                        listAll: true,
+												details: 'min'
+                      };
+
+                      if (args.context.vpc) {
+                        data.id = args.context.vpc[0].id;
+                      }
+                      
                       $(networkOfferingObjs).each(function(key, value) {
                         if(value.id == args.networkOfferingId) {
                           networkOfferingObj = value;
                           return false; //break each loop
                         }
                       });
+                      
                       if(networkOfferingObj.forvpc == true) {
                         args.$select.closest('.form-item').css('display', 'inline-block');
                         $.ajax({
                           url: createURL('listVPCs'),
-                          data: {
-                            listAll: true,
-														details: 'min'
-                          },
+                          data: data,
                           success: function(json) {
                             var items = json.listvpcsresponse.vpc;
                             var data;
@@ -477,12 +511,17 @@
                     vpcid: args.data.vpcid
                   });
                 }
+
+                if (args.$form.find('.form-item[rel=vlan]').css('display') != 'none') {
+                  $.extend(dataObj, { vlan: args.data.vlan });
+                }
+
                 if(args.data.networkDomain != null && args.data.networkDomain.length
> 0 && args.$form.find('.form-item[rel=vpcid]').css("display") == "none") {
                   $.extend(dataObj, {
                     networkDomain: args.data.networkDomain
                   });                
                 }
-															
+
                 $.ajax({
                   url: createURL('createNetwork'),
 									data: dataObj,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/acc71fb7/ui/scripts/vpc.js
----------------------------------------------------------------------
diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js
index b57a562..ebfcc3b 100644
--- a/ui/scripts/vpc.js
+++ b/ui/scripts/vpc.js
@@ -3047,11 +3047,24 @@
                           zoneid: args.zoneId,
                           guestiptype: 'Isolated',
                           supportedServices: 'SourceNat',
-                          specifyvlan: false,
                           state: 'Enabled'
                         },
                         success: function(json) {
                           var networkOfferings = json.listnetworkofferingsresponse.networkoffering;
+                          args.$select.change(function() {
+                            var $vlan = args.$select.closest('form').find('[rel=vlan]');
+                            var networkOffering = $.grep(
+                              networkOfferings, function(netoffer) {
+                                return netoffer.id == args.$select.val();
+                              }
+                            )[0];
+
+                            if (networkOffering.specifyvlan) {
+                              $vlan.css('display', 'inline-block');
+                            } else {
+                              $vlan.hide();
+                            }
+                          });
 
                           //only one network(tier) is allowed to have PublicLb (i.e. provider
is PublicLb provider like "VpcVirtualRouter", "Netscaler") in a VPC
                           var items;                          
@@ -3086,6 +3099,11 @@
                   });
                 }
               },
+              vlan: {
+                label: 'VLAN',
+                validation: { required: true },
+                isHidden: true
+              },
               gateway: {
                 label: 'label.gateway',
                 docID: 'helpTierGateway',


Mime
View raw message