Update Fixed to flex mapping 77/84077/13
authorBalagangadhar Bathula <bb4341@att.com>
Thu, 29 Aug 2019 20:25:21 +0000 (16:25 -0400)
committerguillaume.lambert <guillaume.lambert@orange.com>
Wed, 4 Sep 2019 09:25:41 +0000 (11:25 +0200)
1. Updated the formula for converting the wavlength number to start,
   stop and center frequency.
2. Fix Test cases to match Common/org-openroadm-wavelength-map.txt file
   in 1.2.1 and 2.2.1 openroadm yang models.

Change-Id: Ieb4c9fd59a3af5bbee3169c7b4b0bf72c9d20c1a
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
common/src/main/java/org/opendaylight/transportpce/common/fixedflex/FixedFlexImpl.java
tests/transportpce_tests/1.2.1/test_end2end.py
tests/transportpce_tests/2.2.1/test_end2end.py
tests/transportpce_tests/2.2.1/test_olm.py
tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py

index bc829630a8c19afbcba5bb4afd7700aee174b40a..9b4e3b1457e1e6166cc70c51548bb6a8b6de964b 100644 (file)
@@ -14,6 +14,12 @@ public final class FixedFlexImpl implements FixedFlexInterface {
     private double start;
     private double stop;
     private double wavelength;
+    // wavelengthSpacing is in GHz
+    float wavelengthSpacing = 50;
+    // beginWavelength is in nm: f or F is appended to treat it explicitly as simple float (and not double float)
+    final float beginWavelength = 1528.77f;
+    // java double is double float - d or D is appended to treat it explicitly as double float
+    final double precision = 10000d;
 
     public FixedFlexImpl(Long index, double centreFrequency, double start, double stop, double wavelength) {
         this.index = index;
@@ -32,12 +38,15 @@ public final class FixedFlexImpl implements FixedFlexInterface {
     }
 
     public FixedFlexImpl(long wlIndex) {
-        this.index = wlIndex;
-        long mappedWL = wlIndex - 36;
-        this.centerFrequency = 193.1 + (50.0 / 1000.0) * mappedWL;
-        this.start = 193.1 + (50.0 * mappedWL - 25) / 1000.0;
-        this.stop = 193.1 + (50.0 * mappedWL + 25) / 1000.0;
-        this.wavelength = 1528.77 + ((wlIndex - 1) * 0.39);
+        this.centerFrequency = 196.1 - (wlIndex - 1) * wavelengthSpacing / 1000;
+        // Truncate the value to the two decimal places
+        this.centerFrequency = Math.round(this.centerFrequency * precision) / precision;
+        this.start = this.centerFrequency - (wavelengthSpacing / 2) / 1000;
+        this.start = Math.round(this.start * precision) / precision;
+        this.stop = this.centerFrequency + (wavelengthSpacing / 2) / 1000;
+        this.stop = Math.round(this.stop * precision) / precision;
+        this.wavelength = beginWavelength + ((wlIndex - 1) * 0.40);
+        this.wavelength = Math.round(this.wavelength * precision) / precision;
     }
 
     @Override
@@ -46,11 +55,18 @@ public final class FixedFlexImpl implements FixedFlexInterface {
      * @return Returns FixedFlexImp object with the calculated result.
      **/
     public FixedFlexImpl getFixedFlexWaveMapping(long wlIndex) {
+        // In Flex grid  -35 <= n <= 60
+        long mappedWL = 61 - wlIndex;
         FixedFlexImpl fixedFlex = new FixedFlexImpl();
-        long mappedWL = wlIndex - 36;
         fixedFlex.centerFrequency = 193.1 + (50.0 / 1000.0) * mappedWL;
+        fixedFlex.centerFrequency = Math.round(fixedFlex.centerFrequency * precision) / precision;
+        fixedFlex.wavelength = beginWavelength + ((wlIndex - 1) * 0.40);
+        fixedFlex.wavelength = Math.round(fixedFlex.wavelength * precision) / precision;
         fixedFlex.start = 193.1 + (50.0 * mappedWL - 25) / 1000.0;
+        fixedFlex.start = Math.round(fixedFlex.start * precision) / precision;
         fixedFlex.stop = 193.1 + (50.0 * mappedWL + 25) / 1000.0;
+        fixedFlex.stop = Math.round(fixedFlex.stop * precision) / precision;
+        fixedFlex.index = wlIndex;
         return fixedFlex;
     }
 
index 994b7707e78abf99a224169099a64044383a8430..5f957eff87267b83120ab4725b6a0d85a158cd07 100644 (file)
@@ -528,7 +528,7 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'XPDR1-NETWORK1':
-                self.assertEqual({u'frequency': 191.35, u'width': 40},
+                self.assertEqual({u'frequency': 196.1, u'width': 40},
                                  ele['org-openroadm-network-topology:xpdr-network-attributes']['wavelength'])
             if ele['tp-id'] == 'XPDR1-CLIENT1' or ele['tp-id'] == 'XPDR1-CLIENT3':
                 self.assertNotIn('wavelength', dict.keys(ele['org-openroadm-network-topology:xpdr-client-attributes']))
@@ -548,7 +548,7 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'SRG1-PP1-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35, u'width': 40},
+                self.assertIn({u'index': 1, u'frequency': 196.1, u'width': 40},
                                ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
             if ele['tp-id'] == 'SRG1-PP2-TXRX':
                 self.assertNotIn('used-wavelength', dict.keys(ele))
@@ -566,10 +566,10 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'DEG1-CTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35, u'width': 40},
+                self.assertIn({u'index': 1, u'frequency': 196.1, u'width': 40},
                                ele['org-openroadm-network-topology:ctp-attributes']['used-wavelengths'])
             if ele['tp-id'] == 'DEG1-TTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35, u'width': 40},
+                self.assertIn({u'index': 1, u'frequency': 196.1, u'width': 40},
                                ele['org-openroadm-network-topology:tx-ttp-attributes']['used-wavelengths'])
         time.sleep(3)
 
@@ -822,10 +822,10 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'XPDR1-NETWORK1':
-                self.assertEqual({u'frequency': 191.35, u'width': 40},
+                self.assertEqual({u'frequency': 196.1, u'width': 40},
                                   ele['org-openroadm-network-topology:xpdr-network-attributes']['wavelength'])
             if ele['tp-id'] == 'XPDR1-NETWORK2':
-                self.assertEqual({u'frequency': 191.4, u'width': 40},
+                self.assertEqual({u'frequency': 196.05, u'width': 40},
                                   ele['org-openroadm-network-topology:xpdr-network-attributes']['wavelength'])
             if ele['tp-id'] == 'XPDR1-CLIENT1' or ele['tp-id'] == 'XPDR1-CLIENT3':
                 self.assertNotIn('wavelength', dict.keys(ele['org-openroadm-network-topology:xpdr-client-attributes']))
@@ -843,14 +843,14 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'SRG1-PP1-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35, u'width': 40},
+                self.assertIn({u'index': 1, u'frequency': 196.1, u'width': 40},
                                ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
-                self.assertNotIn({u'index': 2, u'frequency': 191.4, u'width': 40},
+                self.assertNotIn({u'index': 2, u'frequency': 196.05, u'width': 40},
                                   ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
             if ele['tp-id'] == 'SRG1-PP2-TXRX':
-                self.assertIn({u'index': 2, u'frequency': 191.4, u'width': 40},
+                self.assertIn({u'index': 2, u'frequency': 196.05, u'width': 40},
                               ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
-                self.assertNotIn({u'index': 1, u'frequency': 191.35, u'width': 40},
+                self.assertNotIn({u'index': 1, u'frequency': 196.1, u'width': 40},
                                   ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
             if ele['tp-id'] == 'SRG1-PP3-TXRX':
                 self.assertNotIn('org-openroadm-network-topology:pp-attributes', dict.keys(ele))
@@ -869,14 +869,14 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'DEG1-CTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35, u'width': 40},
+                self.assertIn({u'index': 1, u'frequency': 196.1, u'width': 40},
                                ele['org-openroadm-network-topology:ctp-attributes']['used-wavelengths'])
-                self.assertIn({u'index': 2, u'frequency': 191.4, u'width': 40},
+                self.assertIn({u'index': 2, u'frequency': 196.05, u'width': 40},
                               ele['org-openroadm-network-topology:ctp-attributes']['used-wavelengths'])
             if ele['tp-id'] == 'DEG1-TTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35, u'width': 40},
+                self.assertIn({u'index': 1, u'frequency': 196.1, u'width': 40},
                                ele['org-openroadm-network-topology:tx-ttp-attributes']['used-wavelengths'])
-                self.assertIn({u'index': 2, u'frequency': 191.4, u'width': 40},
+                self.assertIn({u'index': 2, u'frequency': 196.05, u'width': 40},
                               ele['org-openroadm-network-topology:tx-ttp-attributes']['used-wavelengths'])
         time.sleep(10)
 
@@ -1630,4 +1630,4 @@ class TransportPCEFulltesting(unittest.TestCase):
 
 
 if __name__ == "__main__":
-    unittest.main(verbosity=2)
\ No newline at end of file
+    unittest.main(verbosity=2)
index 8eae4a8a3793cba79d80f58c48e8fa2c28947982..46d09d71e1be3d620f991eabde34b7dacdac5f16 100644 (file)
@@ -528,7 +528,7 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'XPDR1-NETWORK1':
-                self.assertEqual({u'frequency': 191.35,
+                self.assertEqual({u'frequency': 196.1,
                                   u'width': 40},
                                   ele['org-openroadm-network-topology:xpdr-network-attributes']['wavelength'])
             if ele['tp-id'] == 'XPDR1-CLIENT2' or ele['tp-id'] == 'XPDR1-CLIENT1':
@@ -549,7 +549,7 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'SRG1-PP1-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35,
+                self.assertIn({u'index': 1, u'frequency': 196.1,
                                u'width': 40},
                                ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
             if ele['tp-id'] == 'SRG1-PP2-TXRX':
@@ -568,11 +568,11 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'DEG2-CTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35,
+                self.assertIn({u'index': 1, u'frequency': 196.1,
                                u'width': 40},
                                ele['org-openroadm-network-topology:ctp-attributes']['used-wavelengths'])
             if ele['tp-id'] == 'DEG2-TTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35,
+                self.assertIn({u'index': 1, u'frequency': 196.1,
                                u'width': 40},
                                ele['org-openroadm-network-topology:tx-ttp-attributes']['used-wavelengths'])
         time.sleep(3)
@@ -822,11 +822,11 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'XPDR1-NETWORK1':
-                self.assertEqual({u'frequency': 191.35,
+                self.assertEqual({u'frequency': 196.1,
                                   u'width': 40},
                                   ele['org-openroadm-network-topology:xpdr-network-attributes']['wavelength'])
             if ele['tp-id'] == 'XPDR1-NETWORK2':
-                self.assertEqual({u'frequency': 191.4,
+                self.assertEqual({u'frequency': 196.05,
                                   u'width': 40},
                                   ele['org-openroadm-network-topology:xpdr-network-attributes']['wavelength'])
             if ele['tp-id'] == 'XPDR1-CLIENT1' or ele['tp-id'] == 'XPDR1-CLIENT2':
@@ -845,16 +845,16 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'SRG1-PP1-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35,
+                self.assertIn({u'index': 1, u'frequency': 196.1,
                                u'width': 40},
                                ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
-                self.assertNotIn({u'index': 2, u'frequency': 191.4,
+                self.assertNotIn({u'index': 2, u'frequency': 196.05,
                                   u'width': 40},
                                   ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
             if ele['tp-id'] == 'SRG1-PP2-TXRX':
-                self.assertIn({u'index': 2, u'frequency': 191.4, u'width': 40},
+                self.assertIn({u'index': 2, u'frequency': 196.05, u'width': 40},
                               ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
-                self.assertNotIn({u'index': 1, u'frequency': 191.35,
+                self.assertNotIn({u'index': 1, u'frequency': 196.1,
                                   u'width': 40},
                                   ele['org-openroadm-network-topology:pp-attributes']['used-wavelength'])
             if ele['tp-id'] == 'SRG1-PP3-TXRX':
@@ -874,16 +874,16 @@ class TransportPCEFulltesting(unittest.TestCase):
         liste_tp = res['node'][0]['ietf-network-topology:termination-point']
         for ele in liste_tp:
             if ele['tp-id'] == 'DEG2-CTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35,
+                self.assertIn({u'index': 1, u'frequency': 196.1,
                                u'width': 40},
                                ele['org-openroadm-network-topology:ctp-attributes']['used-wavelengths'])
-                self.assertIn({u'index': 2, u'frequency': 191.4, u'width': 40},
+                self.assertIn({u'index': 2, u'frequency': 196.05, u'width': 40},
                               ele['org-openroadm-network-topology:ctp-attributes']['used-wavelengths'])
             if ele['tp-id'] == 'DEG2-TTP-TXRX':
-                self.assertIn({u'index': 1, u'frequency': 191.35,
+                self.assertIn({u'index': 1, u'frequency': 196.1,
                                u'width': 40},
                                ele['org-openroadm-network-topology:tx-ttp-attributes']['used-wavelengths'])
-                self.assertIn({u'index': 2, u'frequency': 191.4, u'width': 40},
+                self.assertIn({u'index': 2, u'frequency': 196.05, u'width': 40},
                               ele['org-openroadm-network-topology:tx-ttp-attributes']['used-wavelengths'])
         time.sleep(10)
 
index b1a31b93f826beb07786477ff400b55cc750f522..c04830db2283c7a86fefc20c7db228defd6e2714 100644 (file)
@@ -590,7 +590,7 @@ class TransportOlmTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertEqual(-5, res['org-openroadm-optical-channel-interfaces:och']['transmit-power'])
-        self.assertEqual(191.35, res['org-openroadm-optical-channel-interfaces:och']['frequency'])
+        self.assertEqual(196.1, res['org-openroadm-optical-channel-interfaces:och']['frequency'])
 
     def test_21_get_roadmconnection_ROADMA(self):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-A1/yang-ext:mount/"
@@ -663,7 +663,7 @@ class TransportOlmTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertEqual(-5  , res['org-openroadm-optical-channel-interfaces:och']['transmit-power'])
-        self.assertEqual(191.35, res['org-openroadm-optical-channel-interfaces:och']['frequency'])
+        self.assertEqual(196.1, res['org-openroadm-optical-channel-interfaces:och']['frequency'])
 
     def test_25_get_roadmconnection_ROADMC(self):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/node/ROADM-C1/yang-ext:mount/"
index 373b2d87792c5e533f31f5ff0fc432fe3fc12183..ee79b2edc36c4c4c378b4c9d60cade49c20eae68 100644 (file)
@@ -205,7 +205,7 @@ class TransportPCERendererTesting(unittest.TestCase):
               'type': 'org-openroadm-interfaces:networkMediaChannelConnectionTerminationPoint',
               'supporting-port': 'L1'}, res['interface'][0])
         self.assertDictEqual(
-             {u'frequency': 191.65, u'width': 40},
+             {u'frequency': 195.8, u'width': 40},
              res['interface'][0]['org-openroadm-network-media-channel-interfaces:nmc-ctp'])
 
     def test_07_service_path_create_rdm_check(self):
@@ -223,7 +223,7 @@ class TransportPCERendererTesting(unittest.TestCase):
               'type': 'org-openroadm-interfaces:mediaChannelTrailTerminationPoint',
               'supporting-port': 'L1'}, res['interface'][0])
         self.assertDictEqual(
-             {u'min-freq': 191.625, u'max-freq': 191.67499999999998},
+             {u'min-freq': 195.775, u'max-freq': 195.825},
              res['interface'][0]['org-openroadm-media-channel-interfaces:mc-ttp'])
 
 
@@ -242,7 +242,7 @@ class TransportPCERendererTesting(unittest.TestCase):
               'type': 'org-openroadm-interfaces:networkMediaChannelConnectionTerminationPoint',
               'supporting-port': 'C3'}, res['interface'][0])
         self.assertDictEqual(
-             {u'frequency': 191.65, u'width': 40},
+             {u'frequency': 195.8, u'width': 40},
              res['interface'][0]['org-openroadm-network-media-channel-interfaces:nmc-ctp'])
 
     # -mc supporting interfaces must not be created for SRG, only degrees
@@ -301,7 +301,7 @@ class TransportPCERendererTesting(unittest.TestCase):
         self.assertDictEqual(
              {u'rate': u'org-openroadm-common-types:R100G',
               u'transmit-power':-5,
-              u'frequency': 191.65},
+              u'frequency': 195.8},
              res['interface'][0]['org-openroadm-optical-channel-interfaces:och'])
 
     def test_12_service_path_create_xpdr_check(self):