Пример #1
0
 def test__parse_driver_info_good(self):
     node = obj_utils.create_test_node(self.context, driver="fake_iboot", driver_info=INFO_DICT)
     info = iboot._parse_driver_info(node)
     self.assertIsNotNone(info.get("address"))
     self.assertIsNotNone(info.get("username"))
     self.assertIsNotNone(info.get("password"))
     self.assertIsNotNone(info.get("port"))
     self.assertIsNotNone(info.get("relay_id"))
Пример #2
0
 def test__parse_driver_info_good_with_explicit_port(self):
     info = dict(INFO_DICT)
     info['iboot_port'] = '1234'
     node = obj_utils.create_test_node(self.context,
                                       driver='fake_iboot',
                                       driver_info=info)
     info = iboot._parse_driver_info(node)
     self.assertEqual(1234, info.get('port'))
Пример #3
0
 def test__parse_driver_info_good_with_explicit_relay_id(self):
     info = dict(INFO_DICT)
     info['iboot_relay_id'] = '2'
     node = obj_utils.create_test_node(self.context,
                                       driver='fake_iboot',
                                       driver_info=info)
     info = iboot._parse_driver_info(node)
     self.assertEqual(2, info.get('relay_id'))
Пример #4
0
 def setUp(self):
     super(IBootDriverTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver='fake_iboot')
     self.driver = driver_factory.get_driver('fake_iboot')
     self.node = obj_utils.create_test_node(self.context,
                                            driver='fake_iboot',
                                            driver_info=INFO_DICT)
     self.info = iboot._parse_driver_info(self.node)
Пример #5
0
 def test__parse_driver_info_good_with_explicit_relay_id(self):
     info = dict(INFO_DICT)
     info['iboot_relay_id'] = '2'
     node = obj_utils.create_test_node(
             self.context,
             driver='fake_iboot',
             driver_info=info)
     info = iboot._parse_driver_info(node)
     self.assertEqual(2, info.get('relay_id'))
Пример #6
0
 def test__parse_driver_info_good_with_explicit_port(self):
     info = dict(INFO_DICT)
     info['iboot_port'] = '1234'
     node = obj_utils.create_test_node(
             self.context,
             driver='fake_iboot',
             driver_info=info)
     info = iboot._parse_driver_info(node)
     self.assertEqual(1234, info.get('port'))
Пример #7
0
 def setUp(self):
     super(IBootDriverTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver='fake_iboot')
     self.driver = driver_factory.get_driver('fake_iboot')
     self.node = obj_utils.create_test_node(
             self.context,
             driver='fake_iboot',
             driver_info=INFO_DICT)
     self.info = iboot._parse_driver_info(self.node)
Пример #8
0
 def test__parse_driver_info_good(self):
     node = obj_utils.create_test_node(self.context,
                                       driver='fake_iboot',
                                       driver_info=INFO_DICT)
     info = iboot._parse_driver_info(node)
     self.assertIsNotNone(info.get('address'))
     self.assertIsNotNone(info.get('username'))
     self.assertIsNotNone(info.get('password'))
     self.assertIsNotNone(info.get('port'))
     self.assertIsNotNone(info.get('relay_id'))
Пример #9
0
 def test__parse_driver_info_good(self):
     node = obj_utils.create_test_node(self.context,
                                       driver='fake_iboot',
                                       driver_info=INFO_DICT)
     info = iboot._parse_driver_info(node)
     self.assertEqual(INFO_DICT['iboot_address'], info['address'])
     self.assertEqual(INFO_DICT['iboot_username'], info['username'])
     self.assertEqual(INFO_DICT['iboot_password'], info['password'])
     self.assertEqual(9100, info['port'])
     self.assertEqual(1, info['relay_id'])
Пример #10
0
    def test__power_status_exception(self, mock_get_conn):
        mock_connection = mock.MagicMock(spec_set=["get_relays"])
        mock_connection.get_relays.return_value = None
        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(self.context, driver="fake_iboot", driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        status = iboot._power_status(info)
        self.assertEqual(states.ERROR, status)
        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #11
0
 def test__parse_driver_info_good(self):
     node = obj_utils.create_test_node(
             self.context,
             driver='fake_iboot',
             driver_info=INFO_DICT)
     info = iboot._parse_driver_info(node)
     self.assertIsNotNone(info.get('address'))
     self.assertIsNotNone(info.get('username'))
     self.assertIsNotNone(info.get('password'))
     self.assertIsNotNone(info.get('port'))
     self.assertIsNotNone(info.get('relay_id'))
Пример #12
0
 def test__parse_driver_info_good(self):
     node = obj_utils.create_test_node(
         self.context,
         driver='fake_iboot',
         driver_info=INFO_DICT)
     info = iboot._parse_driver_info(node)
     self.assertEqual(INFO_DICT['iboot_address'], info['address'])
     self.assertEqual(INFO_DICT['iboot_username'], info['username'])
     self.assertEqual(INFO_DICT['iboot_password'], info['password'])
     self.assertEqual(9100, info['port'])
     self.assertEqual(1, info['relay_id'])
Пример #13
0
    def test__power_status_exception(self, mock_get_conn):
        mock_connection = mock.MagicMock(spec_set=['get_relays'])
        mock_connection.get_relays.return_value = None
        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(self.context,
                                          driver='fake_iboot',
                                          driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        status = iboot._power_status(info)
        self.assertEqual(states.ERROR, status)
        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #14
0
    def test__power_status_exception(self, mock_get_conn):
        mock_connection = mock.Mock()
        mock_connection.get_relays.return_value = None
        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(self.context,
                                          driver='fake_iboot',
                                          driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        self.assertRaises(exception.IBootOperationError, iboot._power_status,
                          info)

        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #15
0
    def test__power_status_off(self, mock_get_conn):
        mock_connection = mock.Mock()
        mock_connection.get_relays.return_value = [False]
        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(self.context,
                                          driver='fake_iboot',
                                          driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        status = iboot._power_status(info)

        self.assertEqual(states.POWER_OFF, status)
        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #16
0
    def test__power_status_error(self, mock_get_conn):
        mock_connection = mock.Mock()
        mock_connection.get_relays.return_value = list()
        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(
                self.context,
                driver='fake_iboot',
                driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        status = iboot._power_status(info)

        self.assertEqual(states.ERROR, status)
        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #17
0
    def test__power_status_off(self, mock_get_conn):
        mock_connection = mock.MagicMock(spec_set=['get_relays'])
        mock_connection.get_relays.return_value = [False]
        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(
            self.context,
            driver='fake_iboot',
            driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        status = iboot._power_status(info)

        self.assertEqual(states.POWER_OFF, status)
        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #18
0
    def test__power_status_retries(self, mock_get_conn):
        self.config(max_retry=1, group="iboot")

        mock_connection = mock.MagicMock(spec_set=["get_relays"])
        side_effect = TypeError("Surprise!")
        mock_connection.get_relays.side_effect = side_effect

        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(self.context, driver="fake_iboot", driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        status = iboot._power_status(info)
        self.assertEqual(states.ERROR, status)
        mock_get_conn.assert_called_once_with(info)
        self.assertEqual(2, mock_connection.get_relays.call_count)
Пример #19
0
    def test__power_status_exception_index_error(self, mock_get_conn):
        mock_connection = mock.Mock()
        side_effect = IndexError("Gotcha!")
        mock_connection.get_relays.side_effect = side_effect

        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(self.context,
                                          driver='fake_iboot',
                                          driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)
        status = iboot._power_status(info)
        self.assertEqual(states.ERROR, status)

        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #20
0
    def test__power_status_exception(self, mock_get_conn):
        mock_connection = mock.Mock()
        mock_connection.get_relays.return_value = None
        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(
                self.context,
                driver='fake_iboot',
                driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        self.assertRaises(exception.IBootOperationError,
                          iboot._power_status,
                          info)

        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #21
0
    def test__power_status_exception_index_error(self, mock_get_conn):
        mock_connection = mock.MagicMock(spec_set=['get_relays'])
        side_effect = IndexError("Gotcha!")
        mock_connection.get_relays.side_effect = side_effect

        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(
            self.context,
            driver='fake_iboot',
            driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)
        status = iboot._power_status(info)
        self.assertEqual(states.ERROR, status)

        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #22
0
    def test__power_status_retries(self, mock_get_conn):
        self.config(max_retry=1, group='iboot')

        mock_connection = mock.MagicMock(spec_set=['get_relays'])
        side_effect = TypeError("Surprise!")
        mock_connection.get_relays.side_effect = side_effect

        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(self.context,
                                          driver='fake_iboot',
                                          driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        status = iboot._power_status(info)
        self.assertEqual(states.ERROR, status)
        mock_get_conn.assert_called_once_with(info)
        self.assertEqual(2, mock_connection.get_relays.call_count)
Пример #23
0
    def test__power_status_exception_type_error(self, mock_get_conn):
        mock_connection = mock.MagicMock(spec_set=['get_relays'])
        side_effect = TypeError("Surprise!")
        mock_connection.get_relays.side_effect = side_effect

        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(
                self.context,
                driver='fake_iboot',
                driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        self.assertRaises(exception.IBootOperationError,
                          iboot._power_status,
                          info)

        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #24
0
    def test__power_status_exception_type_error(self, mock_get_conn):
        mock_connection = mock.MagicMock(spec_set=['get_relays'])
        side_effect = TypeError("Surprise!")
        mock_connection.get_relays.side_effect = side_effect

        mock_get_conn.return_value = mock_connection
        node = obj_utils.create_test_node(
            self.context,
            driver='fake_iboot',
            driver_info=INFO_DICT)
        info = iboot._parse_driver_info(node)

        self.assertRaises(exception.IBootOperationError,
                          iboot._power_status,
                          info)

        mock_get_conn.assert_called_once_with(info)
        mock_connection.get_relays.assert_called_once_with()
Пример #25
0
 def test__parse_driver_info_good_with_explicit_port(self):
     info = dict(INFO_DICT)
     info["iboot_port"] = "1234"
     node = obj_utils.create_test_node(self.context, driver="fake_iboot", driver_info=info)
     info = iboot._parse_driver_info(node)
     self.assertEqual(1234, info.get("port"))
Пример #26
0
 def test__parse_driver_info_good_with_explicit_relay_id(self):
     info = dict(INFO_DICT)
     info["iboot_relay_id"] = "2"
     node = obj_utils.create_test_node(self.context, driver="fake_iboot", driver_info=info)
     info = iboot._parse_driver_info(node)
     self.assertEqual(2, info.get("relay_id"))