cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [3/3] git commit: updated refs/heads/master to efb3287
Date Tue, 28 Oct 2014 21:26:01 GMT
CLOUDSTACK-7764: No IP Address Validations when Adding Networks Added validations for Add Network
form on IPv4 Gateway, IPv4 Netmask, IPv4 Start IP, IPv4 End IP, IPv6 Gateway, IPv6 CIDR, IPv6
Start IP, IPv6 End IP fields.


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

Branch: refs/heads/master
Commit: efb3287fdc3d274dd7482e8cee206f06ff934a2e
Parents: 985168a
Author: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
Authored: Wed Oct 22 09:31:54 2014 +0100
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Tue Oct 28 14:23:57 2014 -0700

----------------------------------------------------------------------
 ui/scripts/sharedFunctions.js | 87 ++++++++++++++++++++++++++++++++++----
 1 file changed, 78 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/efb3287f/ui/scripts/sharedFunctions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index 8ec88b3..e044d24 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -634,38 +634,62 @@ var addGuestNetworkDialog = {
                 //IPv4 (begin)
                 ip4gateway: {
                     label: 'label.ipv4.gateway',
-                    docID: 'helpGuestNetworkZoneGateway'
+                    docID: 'helpGuestNetworkZoneGateway',
+                    validation: {
+                        ipv4: true
+                    }
                 },
                 ip4Netmask: {
                     label: 'label.ipv4.netmask',
-                    docID: 'helpGuestNetworkZoneNetmask'
+                    docID: 'helpGuestNetworkZoneNetmask',
+                    validation: {
+                        netmask: true
+                    }
                 },
                 startipv4: {
                     label: 'label.ipv4.start.ip',
-                    docID: 'helpGuestNetworkZoneStartIP'
+                    docID: 'helpGuestNetworkZoneStartIP',
+                    validation: {
+                        ipv4: true
+                    }
                 },
                 endipv4: {
                     label: 'label.ipv4.end.ip',
-                    docID: 'helpGuestNetworkZoneEndIP'
+                    docID: 'helpGuestNetworkZoneEndIP',
+                    validation: {
+                        ipv4: true
+                    }
                 },
                 //IPv4 (end)
 
                 //IPv6 (begin)
                 ip6gateway: {
                     label: 'label.ipv6.gateway',
-                    docID: 'helpGuestNetworkZoneGateway'
+                    docID: 'helpGuestNetworkZoneGateway',
+                    validation: {
+                        ipv6: true
+                    }
                 },
                 ip6cidr: {
-                    label: 'label.ipv6.CIDR'
+                    label: 'label.ipv6.CIDR',
+                    validation: {
+                        ipv6cidr: true
+                    }
                 },
                 startipv6: {
                     label: 'label.ipv6.start.ip',
-                    docID: 'helpGuestNetworkZoneStartIP'
+                    docID: 'helpGuestNetworkZoneStartIP',
+                    validation: {
+                        ipv6: true
+                    }
                 },
                 endipv6: {
                     label: 'label.ipv6.end.ip',
-                    docID: 'helpGuestNetworkZoneEndIP'
-                },
+                    docID: 'helpGuestNetworkZoneEndIP',
+                    validation: {
+                        ipv6: true
+                    }
+               },
                 //IPv6 (end)
 
                 networkdomain: {
@@ -2224,3 +2248,48 @@ function strOrFunc(arg, args) {
         return arg(args);
     return arg;
 }
+
+$.validator.addMethod("netmask", function(value, element) {
+    if (this.optional(element) && value.length == 0)
+        return true;
+
+    var valid = [ 255, 254, 252, 248, 240, 224, 192, 128, 0 ];
+    var octets = value.split('.');
+    if (typeof octets == 'undefined' || octets.length != 4) {
+        return false;
+    }
+    var wasAll255 = true;
+    for (index = 0; index < octets.length; index++) {
+        if (octets[index] != Number(octets[index]).toString()) //making sure that "", " ",
"00", "0 ","255  ", etc. will not pass
+            return false;
+        wasAll255 = wasAll255 && octets[index] == 255;
+        if ($.inArray(Number(octets[index]), valid) < 0)
+            return false;
+        if (!wasAll255 && index > 0 && Number(octets[index]) != 0 &&
Number(octets[index - 1]) != 255)
+            return false;
+    }
+
+    return true;
+}, "The specified netmask is invalid.");
+
+$.validator.addMethod("ipv6cidr", function(value, element) {
+    if (this.optional(element) && value.length == 0)
+        return true;
+
+    var parts = value.split('/');
+    if (typeof parts == 'undefined' || parts.length != 2) {
+        return false;
+    }
+
+    if (!$.validator.methods.ipv6.call(this, parts[0], element))
+        return false;
+
+    if (parts[1] != Number(parts[1]).toString()) //making sure that "", " ", "00", "0 ","2
 ", etc. will not pass
+        return false;
+
+    if (Number(parts[1]) < 0 || Number(parts[1] > 32))
+        return false;
+
+    return true;
+}, "The specified IPv6 CIDR is invalid.");
+


Mime
View raw message