Tests: fix ip mask 32/4632/3
authorVaclav Demcak <vdemcak@cisco.com>
Thu, 23 Jan 2014 10:40:37 +0000 (11:40 +0100)
committerVaclav Demcak <vdemcak@cisco.com>
Thu, 23 Jan 2014 11:32:35 +0000 (12:32 +0100)
Change-Id: I3be6d7d3b63f400ddda1804b956ee4657c344561
Signed-off-by: Vaclav Demcak <vdemcak@cisco.com>
27 files changed:
test-scripts/.gitignore [new file with mode: 0644]
test-scripts/ignore-keywords.csv
test-scripts/odl_tests_new.py
test-scripts/xmls/f1.xml
test-scripts/xmls/f10.xml
test-scripts/xmls/f11.xml
test-scripts/xmls/f26.xml
test-scripts/xmls/f29.xml
test-scripts/xmls/f30.xml
test-scripts/xmls/f31.xml
test-scripts/xmls/f32.xml
test-scripts/xmls/f33.xml
test-scripts/xmls/f34.xml
test-scripts/xmls/f35.xml
test-scripts/xmls/f36.xml
test-scripts/xmls/f37.xml
test-scripts/xmls/f38.xml
test-scripts/xmls/f39.xml
test-scripts/xmls/f40.xml
test-scripts/xmls/f41.xml
test-scripts/xmls/f42.xml
test-scripts/xmls/f5.xml
test-scripts/xmls/f6.xml
test-scripts/xmls/f7.xml
test-scripts/xmls/f8.xml
test-scripts/xmls/f9.xml
test-scripts/xmlvalidator.py

diff --git a/test-scripts/.gitignore b/test-scripts/.gitignore
new file mode 100644 (file)
index 0000000..6782245
--- /dev/null
@@ -0,0 +1,2 @@
+*.pyc
+/.pydevproject
index d4a41750d7f47d1647698c3ef075057ae9073fd7..56b81b4a5fa71ffdb715ad51e78bea3b40a33645 100644 (file)
@@ -9,3 +9,5 @@ flags;flags
 id;id
 cookie_mask;cookie_mask
 dl_type;dl_type
+ip;ip
+installHw;installHw
index f0e74c33364245efd94f9180e9848d0153bad619..0cb8eab61ae8ae3cd142352812f598425d9dde39 100644 (file)
@@ -21,14 +21,32 @@ from mininet.node import OVSKernelSwitch
 import xmltodict
 from xmlvalidator import XMLValidator
 
+# Delay time value is important for slow machines 
+# value mean nr. of seconds for waiting for controller
+TEST_TIME_DELAY = 0
+
 class TestOpenFlowXml_Base(unittest.TestCase):
+    """
+    Base TEST class extends unittest.TestCase and
+    it provides possibilty to add parameters for 
+    all subclasses by call a static constructor:
+    
+    TestOpenFlowXml_Base.load_file_name(sub_class_name, param)
+    """
     
     def __init__(self, methodName='runTest', path_to_xml=None):
+        """
+        private defalut constructor
+        """
         super(TestOpenFlowXml_Base, self).__init__(methodName)
         self.path_to_xml = path_to_xml
         
     @staticmethod
     def load_file_name(clazz, path_to_xml=None):
+        """
+        static constructor for all subclasses with param
+        param -> path_to_xml (default None)
+        """
         testloader = unittest.TestLoader()
         testnames = testloader.getTestCaseNames(clazz)
         suite = unittest.TestSuite()
@@ -38,15 +56,26 @@ class TestOpenFlowXml_Base(unittest.TestCase):
 
 
 class ConvertorTools():
-    
+    """
+    Tool class contains static conversion method
+    for the value conversions
+    """
     CONVERTORS = {
         'cookie': hex, 
+        'metadata': hex
     }  
     
     @staticmethod
     def base_tag_values_conversion(key, value):
-        convertor = ConvertorTools.CONVERTORS.get(key, None)
-        return convertor(int(value)) if convertor > None else value
+        """
+        Check a need to conversion and convert if need
+        """
+        if value is None : return ''
+        else:
+            convertor = ConvertorTools.CONVERTORS.get(key, None)
+            if convertor is None : return value
+            else :
+                return convertor(int(value))
 
 
 class ParseTools(): 
@@ -58,13 +87,14 @@ class ParseTools():
     @staticmethod
     def sort_ordered_dict_to_array(x_dict=None):
         if (x_dict > None):
-            out_put = None
+            out_put = []
             for val in map(lambda val: x_dict.get(val), sorted(x_dict.keys())) : 
-                if (out_put > None) :
-                    out_put += ', %s' %val
-                else :
-                    out_put = val
-            return out_put
+                out_put.append(val)
+#                 if (out_put > None) :
+#                     out_put += ', %s' %val
+#                 else :
+#                     out_put = val
+            return ', '.join(out_put)
         return
 
     @staticmethod
@@ -142,15 +172,16 @@ class ParseTools():
                         ParseTools.__parse_tags_from_xml(child, flow_dict, key_dict, ikwd=ignore_key_dict) 
 
         return flow_dict
-
-    @staticmethod
-    def get_switchflow_dict(switch_dict, ignore_key_dict=None):
-        x_dict={}
-        for sw_key in switch_dict.keys() :
-            if (ignore_key_dict.get(sw_key,None) is None):
-                x_dict[sw_key] = switch_dict.get(sw_key)
-            
-        return x_dict
+        
+        # TODO VD remove this method
+#     @staticmethod
+#     def get_switchflow_dict(switch_dict, ignore_key_dict=None):
+#         x_dict={}
+#         for sw_key in switch_dict.keys() :
+#             if (ignore_key_dict.get(sw_key,None) is None):
+#                 x_dict[sw_key] = switch_dict.get(sw_key)
+#             
+#         return x_dict
     
     @staticmethod
     def all_nodes(xml_root):
@@ -202,7 +233,10 @@ class ParseTools():
 
 
 class MininetTools():
-
+    """
+    Tool class provides static method for Open_vswitch
+    mininet out of box controls 
+    """
     @staticmethod
     def create_network(controller_ip, controller_port):
         """Create topology and mininet network."""
@@ -226,6 +260,15 @@ class MininetTools():
 
         return net
     
+#     @staticmethod #TODO VD finish it
+#     def __mininet_parse_response(resp_str='', x_dict={}, ikwd={}):
+#         for elm in resp_str.split(',') :
+#             if len(elm.split('=')) > 1 :
+#                 x_key = elm.split('=')[0]
+#                 x_val = elm.split
+#                 x_dict[elm] = MininetTools.__mininet_parse_response(elm.split('='), x_dict, ikwd)
+            
+    
     @staticmethod
     def get_flows(net, ikwd={}):
         """Get list of flows from network's first switch.
@@ -260,29 +303,33 @@ class MininetTools():
 
         log.debug('switch flow table: {}'.format(output))
 
+        # dictionary for return
         flows = {}
 
         for line in output.splitlines()[1:] :
             output = line;
         
-        action = re.split('actions=',output,1)[1]
+        if (len(re.split('actions=', output, 1)) > 0) :
+            try :
+                action_str = re.split('actions=',output,1)[1]
+                flows['actions'] = ', '.join((action_str.split(','))) if (len(action_str.split(',')) > 0) else action_str.strip()
+                # TODO: VD look at actions with own param (xml24) __mininet_parse_resp
+            except Exception, e :
+                log.error(e)
+            
+        else :
+            flows['actions'] = ''
+
         output= re.split('actions=',output,1)[0]
 
-        for elem in output.split(',') :
-            elm_d = elem.split('=')
-            a_key = (elm_d[0]).strip()
+        for e in output.split(',') :
+            elem = e.split('=')
+            a_key = (elem[0]).strip()
             if (ikwd.get(a_key, None) is None) :
-                a_value = elm_d[1] if (len(elm_d) > 1) else None
+                a_value = elem[1] if (len(elem) > 1) else None
                 flows[a_key] = a_value.strip() if isinstance(a_value,str) else (str(a_value)).strip()
-        
-        flows['actions'] = action.split(',')
-        
+
         return flows
-#         for line in output.splitlines()[1:]:
-#             flows.append(ParseTools.dump_string_to_dict(line))
-# 
-#          # sort by duration
-#         return sorted(flows, key=lambda x: x['duration'].rstrip('s'))
 
 
 class FileLoaderTools():
@@ -369,7 +416,6 @@ class TestOpenFlowXml(TestOpenFlowXml_Base):
                                                            action_key_dict = action_keywords, 
                                                            match_key_dict = match_keywords,
                                                            ignore_key_dict = ignore_keywords)
-        print (switch_etalon)
         ids = ParseTools.get_values(tree.documentElement, 'table_id', 'id')
         
         
@@ -388,6 +434,8 @@ class TestOpenFlowXml(TestOpenFlowXml_Base):
         log.debug('received content: {}'.format(rsp.text))
         assert rsp.status_code == 204 or rsp.status_code == 200, 'Status' \
                             ' code returned %d' % rsp.status_code
+        time.sleep(TEST_TIME_DELAY)
+        
         try:
             # check request content against restconf's datastore
             response = requests.get(url, auth=('admin', 'admin'),
@@ -405,6 +453,7 @@ class TestOpenFlowXml(TestOpenFlowXml_Base):
             assert switch_etalon == switch_flows, 'expected and stored switch settings are not the same \n'\
                 'expected: %s\nstored: %s' %(switch_etalon,switch_flows)
 
+            # TODO VD remove dead code
             # compare requested object and flow table state
             ## TODO look at action parsing separatly from a flow
 #             switch_flow_dict = ParseTools.get_switchflow_dict(switch_flows[0], ignore_keywords)
@@ -415,16 +464,24 @@ class TestOpenFlowXml(TestOpenFlowXml_Base):
 #             Comparator.compare_results(switch_flows[0], ParseTools.dump_string_to_dict(mn_string))
 #         else:
 #             log.error('cannot find test results - comparison skipped')
+        except Exception, e :
+            log.error(e)
+            print '\n'
+            raise e
+
         finally:
             response = requests.delete(url, auth=('admin', 'admin'),
                                 headers={'Accept': 'application/xml'})
             assert response.status_code == 200
             print '\n\n\n'    
+            time.sleep(TEST_TIME_DELAY)
 
 def suite(path='xmls', test_class='TestOpenFlowXml_Base') :
     suite = unittest.TestSuite()
     if args.xmls is not None:
         xmls = map(int, args.xmls.split(','))
+    else :
+        xmls = None
     
     xmlfiles = None
     if xmls is not None:
index 7afe8fe792414de232d01ad1c922cd3c96df6919..9779efbc70724ab8f56bc7b1cf1aae0c6be8cf1c 100644 (file)
@@ -22,7 +22,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.1.1/24</ipv4-destination>
+        <ipv4-destination>10.0.1.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 25873910088c72a163280d1def9e06a39a0daf0c..5efd6c916d5012c13d0e044cab1d41d63032372e 100644 (file)
@@ -27,8 +27,8 @@
                 <address>00:00:00:11:23:ae</address>
             </ethernet-source>
         </ethernet-match>
-        <ipv4-source>17.1.2.3/8</ipv4-source>
-        <ipv4-destination>172.168.5.6/16</ipv4-destination>
+        <ipv4-source>17.0.0.0/8</ipv4-source>
+        <ipv4-destination>172.168.0.0/16</ipv4-destination>
         <ip-match>
             <ip-protocol>132</ip-protocol>
             <ip-dscp>0</ip-dscp>
index 60590b7348a2c7d8dee26a230d09e2a8000c5335..690a4a8f22d0637c5913278da62a445b4dded89d 100644 (file)
@@ -27,8 +27,8 @@
                 <address>00:00:00:11:23:ae</address>
             </ethernet-source>
         </ethernet-match>
-        <ipv4-source>17.1.2.3/8</ipv4-source>
-        <ipv4-destination>172.168.5.6/16</ipv4-destination>
+        <ipv4-source>17.0.0.0/8</ipv4-source>
+        <ipv4-destination>172.168.0.0/16</ipv4-destination>
         <ip-match>
             <ip-protocol>1</ip-protocol>
             <ip-dscp>27</ip-dscp>
index 105b31e624a33d9d4f1526920216a0156faafe64..d53ea53fc66c5907f4b7a45099ad6630388cc024 100644 (file)
@@ -27,8 +27,8 @@
                 <type>34525</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv6-source>1234:5678:9ABC:DEF0:FDCD:A987:6543:210F/76</ipv6-source>
-        <ipv6-destination>fe80:2acf:e9ff:fe21::6431/94</ipv6-destination>
+        <ipv6-source>1234:5678:9ABC:DEF0:FDCD:A987:6543:0/76</ipv6-source>
+        <ipv6-destination>fe80:2acf:e9ff:fe21::0/94</ipv6-destination>
         <ipv6-nd-target>fe80:3456:789A:fe21::6431</ipv6-nd-target>
         <ipv6-nd-sll>12:34:56:78:9A:BC</ipv6-nd-sll>
         <ipv6-nd-tll>FE:DC:BA:98:76:54</ipv6-nd-tll>
index bbdba6d50d34da2d06682d7fdd9df29820b60c2c..c2bf729a92f1b66bbf51102c35f763b4c0570143 100644 (file)
@@ -24,7 +24,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 96125c9b848a19595422666d8d72c470daa8a09b..8cd7e77618e97398621c75a58e3c71093337281d 100644 (file)
@@ -24,7 +24,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 81cb38c0870b669c87c1adc673259116450a7f08..7b83e99a104bd523020c00f8665e9d941a715e3a 100644 (file)
@@ -21,7 +21,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 3c837225db7cca8269ce568a47d1e4cd5baafeda..bf05bd129e32af9a64beb291a925f6bcd4d70115 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 0294b10209799d4b9a6ace6b5c420069c525a9eb..716e688884ba559621d0b418fd19fde6e4a941e0 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 27a0e7dffc8792ab90fa6f29c698787ad5c659db..adc8a10d51cb21c2c80467dfcc830a395a90d85d 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 60d3eaa4136472558c1d6e2cb2a96feae4264219..1647b8272b0112c66ad4fb350f45839949aaedd5 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 8942668bfa7abd26b6447c7260c1bc29d99b857c..04d2f86b72a6e8f9e25ebd6033736201c23bd061 100644 (file)
@@ -24,7 +24,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 6b82df960a1cbab14cf2bdf1a85918140039589f..cd7e92cce3d73d7a5446c78868a44601328f9477 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index faa2fe8e4ad7770d9fe377cf7ee5de403afc39fe..81f1306719f0bf2dae10a8c6ca36e30c5a56aad1 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 5f2130ec6748642c015aa3c1550e186e4c3e5096..55c8a762af3b6749ca12e908434a8b8d642f3028 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 3eacd6ee1d26884ce937a41b474b23a0ab461a47..578df7b6741d4e74fee87a3d6eddeb1c21599981 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index a1c4539202231e90f84a7384fcd9901d24275dc8..82c4b51084b04dd5b4a243f51e213db507956b2f 100644 (file)
@@ -26,7 +26,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 538ff0012fda256ddd6efa2bbbc860c0f6ff1324..fb5850b3ed476ded7a9ca931c6fc48925ab5fcac 100644 (file)
@@ -24,7 +24,7 @@
                 <type>2048</type>
             </ethernet-type>
         </ethernet-match>
-        <ipv4-destination>10.0.0.1/24</ipv4-destination>
+        <ipv4-destination>10.0.0.0/24</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 9b1a87037982a74a7f55340ac2f7daec0b7d2052..4d318056e3dd731dff5f9bf86835ad992e1003a6 100644 (file)
@@ -27,8 +27,8 @@
                 <address>00:00:00:00:23:ae</address>
             </ethernet-source>
         </ethernet-match>
-        <ipv4-source>10.1.2.3/24</ipv4-source>
-        <ipv4-destination>20.4.5.6/16</ipv4-destination>
+        <ipv4-source>10.1.2.0/24</ipv4-source>
+        <ipv4-destination>20.4.0.0/16</ipv4-destination>
         <in-port>0</in-port>
     </match>
     <hard-timeout>12</hard-timeout>
index a220752942ccf04207d31b7fdaa37f564deba8d2..2ed289889a9f859fac1491267f72b56a1818de61 100644 (file)
@@ -31,8 +31,8 @@
                 <address>00:00:00:01:23:ae</address>
             </ethernet-source>
         </ethernet-match>
-        <ipv4-source>10.1.2.3/24</ipv4-source>
-        <ipv4-destination>40.4.5.6/16</ipv4-destination>
+        <ipv4-source>10.1.2.0/24</ipv4-source>
+        <ipv4-destination>40.4.0.0/16</ipv4-destination>
     </match>
     <hard-timeout>12</hard-timeout>
     <flags>FlowModFlags [_cHECKOVERLAP=false, _rESETCOUNTS=false, _nOPKTCOUNTS=false, _nOBYTCOUNTS=false, _sENDFLOWREM=false]</flags>
index 64047dd9caf4b44523bcd01adc6ddb60c058a428..f8922f0adbf2f19c016be3255554a7fd3ce344ea 100644 (file)
@@ -27,8 +27,8 @@
                 <address>00:00:00:11:23:ae</address>
             </ethernet-source>
         </ethernet-match>
-        <ipv4-source>10.1.2.3/24</ipv4-source>
-        <ipv4-destination>20.4.5.6/16</ipv4-destination>
+        <ipv4-source>10.1.2.0/24</ipv4-source>
+        <ipv4-destination>20.4.0.0/16</ipv4-destination>
         <ip-match>
             <ip-protocol>56</ip-protocol>
             <ip-dscp>15</ip-dscp>
index 8c19936b5c029a400c46d7551203bee7a292b0c1..9f65dff72c3f1631604a96060da6cfd199b83c34 100644 (file)
@@ -27,8 +27,8 @@
                 <address>00:00:00:11:23:ae</address>
             </ethernet-source>
         </ethernet-match>
-        <ipv4-source>17.1.2.3/8</ipv4-source>
-        <ipv4-destination>172.168.5.6/16</ipv4-destination>
+        <ipv4-source>17.0.0.0/8</ipv4-source>
+        <ipv4-destination>172.168.0.0/16</ipv4-destination>
         <ip-match>
             <ip-protocol>6</ip-protocol>
             <ip-dscp>2</ip-dscp>
index b32c39830237b891e3771b1d394629d1db7a9c25..24c9fee8506952211b40fa2c2706dc26a38539b7 100644 (file)
@@ -27,8 +27,8 @@
                 <address>00:00:00:11:23:ae</address>
             </ethernet-source>
         </ethernet-match>
-        <ipv4-source>19.1.2.3/10</ipv4-source>
-        <ipv4-destination>172.168.5.6/18</ipv4-destination>
+        <ipv4-source>19.1.0.0/16</ipv4-source>
+        <ipv4-destination>172.168.5.0/24</ipv4-destination>
         <ip-match>
             <ip-protocol>17</ip-protocol>
             <ip-dscp>8</ip-dscp>
index a6c68001e6acc7d301f36c9ebd17e09f69dcd28c..905d27764dd34de37f1da19d8aa16666c8595298 100644 (file)
@@ -136,7 +136,20 @@ class XMLValidator():
                 raise StandardError
 
     def ipv4_check(self, a):
+        IP_MASK_COMPARE_PATTERNS = {
+                '24' : '.0',
+                '16' : '.0.0',
+                '8' : '.0.0.0'
+        }
         XMLValidator.log.debug('validating ipv4 address: {}'.format(a))
+        ip_arr = a.split('/')
+        if (len(ip_arr) > 1) :
+            m_patt = IP_MASK_COMPARE_PATTERNS.get(ip_arr[1], None)
+            if (m_patt is None) :
+                raise StandardError('{} is not valid ipv4 mask'.format(ip_arr[1]))
+            if (ip_arr[0].endswith(m_patt) != True) :
+                raise StandardError('ipv4 address mask has to *{}/{}'.format(m_patt, ip_arr[1]))
+
         mask_pos = a.find('/')
         if mask_pos > 0:
             a = a[:mask_pos]