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 2012/11/28 20:57:35 UTC

git commit: Re-enable network-level egress UI

Updated Branches:
  refs/heads/master 936f84bb7 -> 66e04c9bf


Re-enable network-level egress UI

-Adds complete egress rules tab to the network detail view

-Updated server calls per functional spec

-Add localization labels


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

Branch: refs/heads/master
Commit: 66e04c9bf97658a635cafa673697b43a1f1b9fc3
Parents: 936f84b
Author: Brian Federle <br...@citrix.com>
Authored: Wed Nov 28 11:57:22 2012 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Wed Nov 28 11:57:22 2012 -0800

----------------------------------------------------------------------
 .../WEB-INF/classes/resources/messages.properties  |    1 +
 ui/dictionary.jsp                                  |    1 +
 ui/scripts/network.js                              |  178 ++++++++++++++-
 3 files changed, 178 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/66e04c9b/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 626e44a..b606cce 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -17,6 +17,7 @@
 
 
 #new labels (begin) **********************************************************************************************
+label.egress.rules=Egress rules
 message.acquire.new.ip.vpc=Please confirm that you would like to acquire a new IP for this VPC.
 label.zoneWizard.trafficType.management=Mangement: Traffic between CloudStack\'s internal resources, including any components that communicate with the Management Server, such as hosts and CloudStack system VMs
 label.zoneWizard.trafficType.public=Public: Traffic between the internet and virtual machines in the cloud.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/66e04c9b/ui/dictionary.jsp
----------------------------------------------------------------------
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index b80e296..e72481e 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -25,6 +25,7 @@ under the License.
 <% long now = System.currentTimeMillis(); %>
 <script language="javascript">
 dictionary = {
+'label.egress.rules': '<fmt:message key="label.egress.rules"/>',
 'message.acquire.new.ip.vpc': '<fmt:message key="message.acquire.new.ip.vpc"/>',
 'label.quickview': '<fmt:message key="label.quickview"/>',
 'label.migrate.to.host': '<fmt:message key="label.migrate.to.host"/>',

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/66e04c9b/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index b2b5900..547802a 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -833,13 +833,13 @@
                 }
               });
 
-              var hiddenTabs = ['egressRules']; // Disable egress UI, for now
+              var hiddenTabs = [];
               
               if (!networkOfferingHavingELB) {
                 hiddenTabs.push("addloadBalancer");
               }
 
-              if (!hasNetworkACL || isVPC) {
+              if (isVPC) {
                 hiddenTabs.push('egressRules');
               }
               
@@ -1016,6 +1016,180 @@
                 }
               },
 
+              egressRules: {
+                title: 'label.egress.rules',
+                custom: function(args) {
+                  var context = args.context;
+
+                  return $('<div>').multiEdit({
+                    context: context,
+                    noSelect: true,
+                    noHeaderActionsColumn: true,
+                    fields: {
+                      'cidrlist': { edit: true, label: 'label.cidr', isOptional: true },
+                      'protocol': {
+                        label: 'label.protocol',
+                        select: function(args) {
+                          args.$select.change(function() {
+                            var $inputs = args.$form.find('th, td');
+                            var $icmpFields = $inputs.filter(function() {
+                              var name = $(this).attr('rel');
+
+                              return $.inArray(name, [
+                                'icmptype',
+                                'icmpcode'
+                              ]) > -1;
+                            });
+                            var $otherFields = $inputs.filter(function() {
+                              var name = $(this).attr('rel');
+
+                              return name != 'cidrlist' &&
+                                name != 'icmptype' &&
+                                name != 'icmpcode' &&
+                                name != 'protocol' &&
+                                name != 'add-rule';
+                            });
+
+                            if ($(this).val() == 'icmp') {
+                              $icmpFields.show();
+                              $otherFields.hide();
+                            } else if ($(this).val() == 'all') {
+                              $icmpFields.hide();
+                              $otherFields.hide();
+                            } else {
+                              $icmpFields.hide();
+                              $otherFields.show();
+                            }
+                          });
+
+                          args.response.success({
+                            data: [
+                              { name: 'tcp', description: 'TCP' },
+                              { name: 'udp', description: 'UDP' },
+                              { name: 'icmp', description: 'ICMP' },
+                              { name: 'all', description: 'All' }
+                            ]
+                          });
+                        }
+                      },
+                      'startport': { edit: true, label: 'label.start.port' },
+                      'endport': { edit: true, label: 'label.end.port' },
+                      'icmptype': { edit: true, label: 'ICMP.type', isHidden: true },
+                      'icmpcode': { edit: true, label: 'ICMP.code', isHidden: true },
+                      'add-rule': {
+                        label: 'label.add',
+                        addButton: true
+                      }
+                    },
+                    add: {
+                      label: 'label.add',
+                      action: function(args) {
+                        var data = {
+                          protocol: args.data.protocol,
+                          cidrlist: args.data.cidrlist,
+                          networkid: args.context.networks[0].id
+                        };
+
+                        if (args.data.icmptype && args.data.icmpcode) { // ICMP
+                          $.extend(data, {
+                            icmptype: args.data.icmptype,
+                            icmpcode: args.data.icmpcode
+                          });
+                        } else { // TCP/UDP
+                          $.extend(data, {
+                            startport: args.data.startport,
+                            endport: args.data.endport
+                          });
+                        }
+
+                        $.ajax({
+                          url: createURL('createEgressFirewallRule'),
+                          data: data,
+                          dataType: 'json',
+                          async: true,
+                          success: function(json) {
+                            var jobId = json.createegressfirewallruleresponse.jobid;
+
+                            args.response.success({
+                              _custom: {
+                                jobId: jobId
+                              },
+                              notification: {
+                                label: 'label.add.egress.rule',
+                                poll: pollAsyncJobResult
+                              }
+                            });
+                          },
+                          error: function(json) {
+                            args.response.error(parseXMLHttpResponse(json));
+                          }
+                        });
+                      }
+                    },
+                    actions: {
+                      destroy: {
+                        label: 'label.remove.rule',
+                        action: function(args) {
+                          $.ajax({
+                            url: createURL('deleteEgressFirewallRule'),
+                            data: {
+                              id: args.context.multiRule[0].id
+                            },
+                            dataType: 'json',
+                            async: true,
+                            success: function(data) {
+                              var jobID = data.deleteegressfirewallruleresponse.jobid;
+
+                              args.response.success({
+                                _custom: {
+                                  jobId: jobID
+                                },
+                                notification: {
+                                  label: 'label.remove.egress.rule',
+                                  poll: pollAsyncJobResult
+                                }
+                              });
+                            },
+                            error: function(json) {
+                              args.response.error(parseXMLHttpResponse(json));
+                            }
+                          });
+                        }
+                      }
+                    },
+                    ignoreEmptyFields: true,
+                    dataProvider: function(args) {
+                      $.ajax({
+                        url: createURL('listEgressFirewallRules'),
+                        data: {
+                          listAll: true,
+                          networkid: args.context.networks[0].id
+                        },
+                        dataType: 'json',
+                        async: true,
+                        success: function(json) {
+                          var response = json.listegressfirewallrulesresponse.firewallrule ?
+                                json.listegressfirewallrulesresponse.firewallrule : [];
+                          
+                          args.response.success({
+                            data: $.map(response, function(rule) {
+                              if (rule.protocol == 'all') {
+                                $.extend(rule, {
+                                  startport: 'All',
+                                  endport: 'All'
+                                });
+                              }
+
+                              return rule;
+                            })
+                          });
+                        }
+                      });
+                    }
+                  });
+                }
+              },
+
               addloadBalancer: {
                 title: 'label.add.load.balancer',
                 custom: function(args) {