Skip to content

Commit

Permalink
Support disabling inactive links for Juniper
Browse files Browse the repository at this point in the history
Adds the necessary code to the Juniper Junos device driver to support
disabling inactive links. This feature is enabled by setting the
per-device config flag 'ngs_disable_inactive_ports'.

Change-Id: I636613d0c910d10601422ad094f835c17a606e37
Story: 2003391
Task: 24933
  • Loading branch information
markgoddard committed Aug 30, 2018
1 parent e373156 commit 25fb79c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions networking_generic_switch/devices/netmiko_devices/juniper.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ class Juniper(netmiko_devices.NetmikoSwitch):
'vlan members',
)

ENABLE_PORT = (
'delete interface {port} disable',
)

DISABLE_PORT = (
'set interface {port} disable',
)

PLUG_TRUNK_PORT_TO_NETWORK = (
'set interface {port} unit 0 family ethernet-switching '
'vlan members {segmentation_id}',
Expand Down
24 changes: 24 additions & 0 deletions networking_generic_switch/tests/unit/netmiko/test_juniper.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ def test_plug_port_to_network(self, mock_exec):
'set interface 3333 unit 0 family ethernet-switching '
'vlan members 33'])

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_plug_port_to_network_disable_inactive(self, m_sctd):
switch = self._make_switch_device(
{'ngs_disable_inactive_ports': 'true'})
switch.plug_port_to_network(3333, 33)
m_sctd.assert_called_with(
['delete interface 3333 disable',
'delete interface 3333 unit 0 family ethernet-switching '
'vlan members',
'set interface 3333 unit 0 family ethernet-switching '
'vlan members 33'])

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_delete_port(self, mock_exec):
Expand All @@ -88,6 +101,17 @@ def test_delete_port(self, mock_exec):
['delete interface 3333 unit 0 family ethernet-switching '
'vlan members'])

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_delete_port_disable_inactive(self, m_sctd):
switch = self._make_switch_device(
{'ngs_disable_inactive_ports': 'true'})
switch.delete_port(3333, 33)
m_sctd.assert_called_with(
['delete interface 3333 unit 0 family ethernet-switching '
'vlan members',
'set interface 3333 disable'])

def test_send_config_set(self):
connect_mock = mock.MagicMock(netmiko.base_connection.BaseConnection)
connect_mock.send_config_set.return_value = 'fake output'
Expand Down

0 comments on commit 25fb79c

Please sign in to comment.