Beispiel #1
0
    def test_treat_device_set_device_state_exception(self):
        agent = self.agent
        agent.plugin_rpc = mock.Mock()
        agent.eswitch_mgr = mock.Mock()
        agent.eswitch_mgr.device_exists.return_value = True
        agent.eswitch_mgr.set_device_state.side_effect = (
            pyroute2.NetlinkError(22))

        self.assertFalse(agent.treat_device(DEV1, admin_state_up=True))
Beispiel #2
0
 def test_run_iproute_link_op_not_supported(self):
     with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
         ip_mock = iproute_mock()
         ip_mock.__enter__().link_lookup.return_value = [2]
         ip_mock.__enter__().link.side_effect = pyroute2.NetlinkError(
             code=errno.EOPNOTSUPP)
         self.assertRaises(priv_lib.InterfaceOperationNotSupported,
                           priv_lib._run_iproute_link,
                           "test_cmd",
                           "eth0",
                           None,
                           test_param="test_value")
Beispiel #3
0
 def test_run_iproute_link_interface_removed_during_call(self):
     with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
         ip_mock = iproute_mock()
         ip_mock.__enter__().link_lookup.return_value = [2]
         ip_mock.__enter__().link.side_effect = pyroute2.NetlinkError(
             code=errno.ENODEV)
         self.assertRaises(priv_lib.NetworkInterfaceNotFound,
                           priv_lib._run_iproute_link,
                           "test_cmd",
                           "eth0",
                           None,
                           test_param="test_value")