Skip to content

Commit

Permalink
Merge pull request #1052 from rahkumar651991/cluster_id_issue
Browse files Browse the repository at this point in the history
Device version fix for srx when cluster id greater than 15
  • Loading branch information
Nitin Kr authored Jul 6, 2020
2 parents 03a664f + 9cc8b5c commit a574903
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jnpr/junos/facts/current_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_facts(device):
octets = ip.split(".", 3)
# The 2nd octet will be cluster-id << 4
cluster_id_octet = str(
int(device.facts["srx_cluster_id"]) << 4
(int(device.facts["srx_cluster_id"]) & 0x000F) << 4
)
# node0 will have an IP of
# 129.<cluster_id_octet>.0.1
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/facts/test_current_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def test_current_re_fact_srx_cluster_primary(self, mock_execute):
self.dev.facts._cache["srx_cluster_id"] = "15"
self.assertEqual(self.dev.facts["current_re"], ["node0", "primary"])

@patch("jnpr.junos.Device.execute")
def test_current_re_fact_srx_cluster_primary_id_255(self, mock_execute):
mock_execute.side_effect = self._mock_manager_current_re_srx_primary
self.dev.facts._cache["srx_cluster_id"] = "255"
self.assertEqual(self.dev.facts["current_re"], ["node0", "primary"])

@patch("jnpr.junos.Device.execute")
def test_current_re_fact_srx_cluster_primary_id_31(self, mock_execute):
mock_execute.side_effect = self._mock_manager_current_re_srx_primary
self.dev.facts._cache["srx_cluster_id"] = "31"
self.assertEqual(self.dev.facts["current_re"], ["node0", "primary"])

@patch("jnpr.junos.Device.execute")
def test_current_re_fact_srx_cluster_secondary(self, mock_execute):
mock_execute.side_effect = self._mock_manager_current_re_srx_secondary
Expand Down

0 comments on commit a574903

Please sign in to comment.