Skip to content

Commit

Permalink
changed RSVP LSP manual_metric attribute back to manual_metric to kee…
Browse files Browse the repository at this point in the history
…p it from becoming a breaking change
  • Loading branch information
tim-fiola committed Oct 3, 2021
1 parent 669c540 commit 3370a5d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 36 deletions.
5 changes: 3 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Changelog
=========

4.0.0
3.4.0
-----
* Updated test environment to Focal linux (from Xenial) to allow dash and dash-cytoscape for visualization

Expand All @@ -14,7 +14,8 @@ Changelog

* FlexModel had ``lsp_metric`` column name
* PerformanceModel had ``manual_metric`` column name
* Standardized column name to ``manual_lsp_metric``
* Standardized column name to ``manual_metric``


3.3.1
-----
Expand Down
2 changes: 1 addition & 1 deletion docs/model_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ These are in the ``RSVP_LSP_TABLE``.

* ``configured_setup_bw`` - if LSP has a fixed, static configured setup bandwidth, place that static value here,
if LSP is auto-bandwidth, then leave this blank for the LSP
* ``manual_lsp_metric`` - manually assigned metric for LSP, if not using default metric from topology
* ``manual_metric`` - manually assigned metric for LSP, if not using default metric from topology
shortest path
4 changes: 2 additions & 2 deletions examples/lsp_manual_metric_perf_model_prototype.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

print("lsp_a_d_2 config_setup_bw = {}".format(lsp_a_d_2.configured_setup_bandwidth))
print("lsp_a_d_2 setup_bw = {}".format(lsp_a_d_2.setup_bandwidth))
print("lsp_a_d_2 manual_metric = {}".format(lsp_a_d_2.manual_lsp_metric))
print("lsp_a_d_2 manual_metric = {}".format(lsp_a_d_2.manual_metric))
print("lsp_a_d_2 path = ")
pprint(lsp_a_d_2.path)

print()
print("lsp_a_d_1 setup_bw = {}".format(lsp_a_d_1.configured_setup_bandwidth))
print("lsp_a_d_1 manual_metric = {}".format(lsp_a_d_1.manual_lsp_metric))
print("lsp_a_d_1 manual_metric = {}".format(lsp_a_d_1.manual_metric))
print("lsp_a_d_1 effective_metric = {}".format(lsp_a_d_1.effective_metric(model)))
print("lsp_a_d_1 topology_metric = {}".format(lsp_a_d_1.topology_metric(model)))

Expand Down
4 changes: 2 additions & 2 deletions pyNTM/flex_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@ def load_model_file(cls, data_file): # TODO - allow commas instead of tabs
- name - name of LSP
- configured_setup_bw - if LSP has a fixed, static configured setup bandwidth, place that static value here,
if LSP is auto-bandwidth, then leave this blank for the LSP (optional)
- manual_lsp_metric - manually assigned metric for LSP, if not using default metric from topology
- manual_metric - manually assigned metric for LSP, if not using default metric from topology
shortest path (optional)
Functional model files can be found in this directory in
Expand Down Expand Up @@ -1824,7 +1824,7 @@ def load_model_file(cls, data_file): # TODO - allow commas instead of tabs
A B 80 dmd_a_b_1
RSVP_LSP_TABLE
source dest name configured_setup_bw manual_lsp_metric
source dest name configured_setup_bw manual_metric
A B lsp_a_b_1 10 19
A B lsp_a_b_2 6
Expand Down
4 changes: 2 additions & 2 deletions pyNTM/performance_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ def load_model_file(
- name - name of LSP
- configured_setup_bw (optional) - if LSP has a fixed, static configured setup bandwidth, place that static value here,
if LSP is auto-bandwidth, then leave this blank for the LSP
- manual_lsp_metric (optional) - manually assigned metric for LSP, if not using default metric from topology
- manual_metric (optional) - manually assigned metric for LSP, if not using default metric from topology
shortest path
Expand All @@ -1054,7 +1054,7 @@ def load_model_file(
A B 80 dmd_a_b_1
RSVP_LSP_TABLE
source dest name configured_setup_bw manual_lsp_metric
source dest name configured_setup_bw manual_metric
A B lsp_a_b_1 10 15
A B lsp_a_b_2 10
Expand Down
14 changes: 7 additions & 7 deletions pyNTM/rsvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def setup_bandwidth(self, proposed_setup_bw):
raise ModelException(msg)

@property
def manual_lsp_metric(self):
def manual_metric(self):
"""
Manual metric for LSP. If set, this value will override
the default (shortest path) metric for effective_metric.
Expand All @@ -159,16 +159,16 @@ def manual_lsp_metric(self):
self.initial_manual_metric = None
else:
msg = (
"RSVP LSP metric must be positive integer value. Or, set manual_lsp_metric "
"RSVP LSP metric must be positive integer value. Or, set manual_metric "
"to -1 to clear the manual_metric and have the LSP inherit "
"the default metric (that of the shortest path)"
)
raise ModelException(msg)

return self._manual_metric

@manual_lsp_metric.setter
def manual_lsp_metric(self, value):
@manual_metric.setter
def manual_metric(self, value):
if self.initial_manual_metric:
if (
isinstance(self.initial_manual_metric, int)
Expand All @@ -184,7 +184,7 @@ def manual_lsp_metric(self, value):
self._manual_metric = "not set"
else:
msg = (
"RSVP LSP metric must be positive integer value. Or, set manual_lsp_metric "
"RSVP LSP metric must be positive integer value. Or, set manual_metric "
"to -1 to clear the manual_metric and have the LSP inherit "
"the default metric (that of the shortest path)"
)
Expand Down Expand Up @@ -323,9 +323,9 @@ def effective_metric(self, model):
:param model: model object containing self
:return: metric for the LSP's shortest possible path
"""
if self.manual_lsp_metric != "not set":
if self.manual_metric != "not set":
self.initial_manual_metric = None
return self.manual_lsp_metric
return self.manual_metric
elif "Unrouted" in self.path:
return "Unrouted"
else:
Expand Down
2 changes: 1 addition & 1 deletion test/flex_model_parallel_source_dest_lsps.csv
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ B D 10 dmd_b_d_1


RSVP_LSP_TABLE
source dest name configured_setup_bw manual_lsp_metric
source dest name configured_setup_bw manual_metric
B D lsp_b_d_1 20
B D lsp_b_d_2
2 changes: 1 addition & 1 deletion test/lsp_manual_metric_test_model.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ F E 400 dmd_f_e_1
A F 40 dmd_a_f_1

RSVP_LSP_TABLE
source dest name configured_setup_bw manual_lsp_metric
source dest name configured_setup_bw manual_metric
A D lsp_a_d_1 4 5
A D lsp_a_d_2 10
A D lsp_a_d_3
Expand Down
2 changes: 1 addition & 1 deletion test/manual_lsp_metric_test_flex_model.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ A F 10 dmd_a_f_1
D F 8 dmd_d_f_1

RSVP_LSP_TABLE
source dest name configured_setup_bw manual_lsp_metric
source dest name configured_setup_bw manual_metric
B D lsp_b_d_1 2 10
B D lsp_b_d_2 9
B D lsp_b_d_3 3
Expand Down
4 changes: 2 additions & 2 deletions test/test_igp_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_changed_metric(self):
dmd_d_f_1 = model.get_demand_object("D", "F", "dmd_d_f_1")

# Give lsp a lower than default metric
lsp_b_d_1.manual_lsp_metric = 15
lsp_b_d_1.manual_metric = 15
model.update_simulation()

dmd_path_1 = [int_a_b, lsp_b_d_1, lsp_d_f_1]
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_changed_metric(self):
self.assertIn(lsp_c_e_1, int_c_d.lsps(model))

# Give lsp_b_d_1 a higher than default metric
lsp_b_d_1.manual_lsp_metric = 25
lsp_b_d_1.manual_metric = 25
model.update_simulation()

dmd_path_2_1 = [int_a_g, int_g_f]
Expand Down
30 changes: 15 additions & 15 deletions test/test_rsvp_manual_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ def test_model_load_flex_model(self):
lsp_b_d_3 = model.get_rsvp_lsp("B", "D", "lsp_b_d_3")
lsp_b_d_4 = model.get_rsvp_lsp("B", "D", "lsp_b_d_4")

self.assertEqual(lsp_b_d_1.manual_lsp_metric, 10)
self.assertEqual(lsp_b_d_1.manual_metric, 10)
self.assertEqual(lsp_b_d_1.effective_metric(model), 10)
self.assertEqual(lsp_b_d_1.topology_metric(model), 20)
self.assertNotEqual(lsp_b_d_1.path, "Unrouted")
self.assertEqual(lsp_b_d_1.configured_setup_bandwidth, 2)
self.assertEqual(lsp_b_d_1.setup_bandwidth, 2)

self.assertEqual(lsp_b_d_2.manual_lsp_metric, 9)
self.assertEqual(lsp_b_d_2.manual_metric, 9)
self.assertEqual(lsp_b_d_2.effective_metric(model), 9)
self.assertEqual(lsp_b_d_2.topology_metric(model), 20)
self.assertNotEqual(lsp_b_d_2.path, "Unrouted")
self.assertIsNone(lsp_b_d_2.configured_setup_bandwidth)

self.assertEqual(lsp_b_d_3.manual_lsp_metric, "not set")
self.assertEqual(lsp_b_d_3.manual_metric, "not set")
self.assertEqual(lsp_b_d_3.topology_metric(model), 20)
self.assertEqual(lsp_b_d_3.effective_metric(model), 20)
self.assertEqual(lsp_b_d_3.configured_setup_bandwidth, 3)
self.assertEqual(lsp_b_d_3.setup_bandwidth, 3)
self.assertNotEqual(lsp_b_d_3.path, "Unrouted")

self.assertEqual(lsp_b_d_4.manual_lsp_metric, "not set")
self.assertEqual(lsp_b_d_4.manual_metric, "not set")
self.assertEqual(lsp_b_d_4.topology_metric(model), 20)
self.assertEqual(lsp_b_d_4.effective_metric(model), 20)
self.assertNotEqual(lsp_b_d_4.path, "Unrouted")
Expand Down Expand Up @@ -79,8 +79,8 @@ def test_manual_lsp_metric_higher_than_igp_metric(self):
lsp_b_d_1 = model.get_rsvp_lsp("B", "D", "lsp_b_d_1")
lsp_b_d_2 = model.get_rsvp_lsp("B", "D", "lsp_b_d_2")

lsp_b_d_1.manual_lsp_metric = 1000
lsp_b_d_2.manual_lsp_metric = 1000
lsp_b_d_1.manual_metric = 1000
lsp_b_d_2.manual_metric = 1000

model.update_simulation()

Expand All @@ -96,10 +96,10 @@ def test_lsp_reset_manual_lsp_metric(self):

lsp_b_d_1 = model.get_rsvp_lsp(
"B", "D", "lsp_b_d_1"
) # this has manual_lsp_metric set to 20 from model file
) # this has manual_metric set to 20 from model file
lsp_b_d_2 = model.get_rsvp_lsp("B", "D", "lsp_b_d_2")

lsp_b_d_1.manual_lsp_metric = -1
lsp_b_d_1.manual_metric = -1

model.update_simulation()

Expand All @@ -115,13 +115,13 @@ def test_lsp_bad_manual_lsp_metric(self):
model.update_simulation()
lsp_b_d_1 = model.get_rsvp_lsp(
"B", "D", "lsp_b_d_1"
) # this has manual_lsp_metric set to 20 from model file
) # this has manual_metric set to 20 from model file

# TODO - document the -1 setting
err_msg = "RSVP LSP metric must be positive integer value. Or, set manual_lsp_metric to -1 "
err_msg = "RSVP LSP metric must be positive integer value. Or, set manual_metric to -1 "

with self.assertRaises(ModelException) as context:
lsp_b_d_1.manual_lsp_metric = 20.1
lsp_b_d_1.manual_metric = 20.1
self.assertTrue(err_msg in context.exception.args[0])


Expand All @@ -138,24 +138,24 @@ def test_model_load_perf_model(self):
lsp_a_d_4 = model.get_rsvp_lsp("A", "D", "lsp_a_d_4")

self.assertEqual(lsp_a_d_1.effective_metric(model), 5)
self.assertEqual(lsp_a_d_1.manual_lsp_metric, 5)
self.assertEqual(lsp_a_d_1.manual_metric, 5)
self.assertEqual(lsp_a_d_1.topology_metric(model), 40)
self.assertEqual(lsp_a_d_1.configured_setup_bandwidth, 4)
self.assertEqual(lsp_a_d_1.setup_bandwidth, 4)
self.assertNotEqual(lsp_a_d_1.path, "Unrouted")

self.assertEqual(lsp_a_d_2.effective_metric(model), 10)
self.assertEqual(lsp_a_d_2.manual_lsp_metric, 10)
self.assertEqual(lsp_a_d_2.manual_metric, 10)
self.assertEqual(lsp_a_d_2.topology_metric(model), 40)
self.assertNotEqual(lsp_a_d_2.path, "Unrouted")

self.assertEqual(lsp_a_d_3.effective_metric(model), 40)
self.assertEqual(lsp_a_d_3.topology_metric(model), 40)
self.assertEqual(lsp_a_d_3.manual_lsp_metric, "not set")
self.assertEqual(lsp_a_d_3.manual_metric, "not set")
self.assertNotEqual(lsp_a_d_3.path, "Unrouted")

self.assertEqual(lsp_a_d_4.effective_metric(model), 40)
self.assertEqual(lsp_a_d_4.manual_lsp_metric, "not set")
self.assertEqual(lsp_a_d_4.manual_metric, "not set")
self.assertEqual(lsp_a_d_4.topology_metric(model), 40)
self.assertEqual(lsp_a_d_4.configured_setup_bandwidth, 4)
self.assertEqual(lsp_a_d_4.setup_bandwidth, 4)
Expand Down

0 comments on commit 3370a5d

Please sign in to comment.