Exemple #1
0
 def test_get_system_by_id_with_invalid_system(self, mock_eesv):
     system = expether_fakes.fake_eesv()
     system['device']['status'] = 'eeio'
     mock_eesv.return_value = system
     self.assertRaises(exception.ExpEtherException,
                       self.expether_manager.get_system_by_id,
                       '0x1111111111')
Exemple #2
0
 def test__system_dict(self):
     result = self.expether_manager._system_dict(
         expether_fakes.fake_eesv()['device'])
     expected = {
         'id': '0x1111111111',
         'resource_uri': 'devices/0x1111111111',
         'pooled_group_id': '1234',
         'type': '40g',
         'mac_address': '11:11:11:11:11:11',
         'host_serial_num': '',
         'host_model': ''
     }
     self.assertEqual(result, expected)
Exemple #3
0
 def test_get_node_info(self, mock_get_eesv):
     mock_get_eesv.return_value = expether_fakes.fake_eesv()
     result = self.expether_manager.get_node_info('0x1111111111')
     expected = {
         'name': '0x1111111111',
         'resource_uri': 'devices/0x1111111111',
         'serial_number': 'abcd 01234',
         'power_state': 'on',
         'host_model': '',
         'host_serial_number': '',
         'index': '0x1111111111',
         'description': 'ExpEther Board (40G)',
         'type': '40g',
         'mac_address': '11:11:11:11:11:11',
         'pooled_group_id': '1234'
     }
     self.assertEqual(result, expected)
Exemple #4
0
 def test_attach_to_node_with_max_devices_attached(self, mock_req_to_eem,
                                                   mock_update_device):
     device = device_fakes.fake_device()
     device['pooled_group_id'] = '4093'
     eesv = expether_fakes.fake_eesv()
     eesv['device']['max_eeio_count'] = '2'
     mock_req_to_eem.side_effect = [
         eesv, {
             "devices": [{
                 "id": "0x8cdf9d911cb0"
             }, {
                 "id": "0x8cdf9d53e9d8"
             }],
             "timestamp": "1521117379726"
         }
     ]
     self.assertRaises(exception.ExpEtherException,
                       self.expether_manager.attach, device, '0x1111111111')
Exemple #5
0
 def test_get_system_by_id(self, mock_eesv):
     mock_eesv.return_value = expether_fakes.fake_eesv()
     result = self.expether_manager.get_system_by_id('0x1111111111')
     expected = {
         'id': '0x1111111111',
         'type': '40g',
         'pooled_group_id': '1234',
         'mac_address': '11:11:11:11:11:11',
         'serial_number': 'abcd 01234',
         'name': 'eesv',
         'power_state': 'on',
         'host_model': '',
         'host_serial_number': '',
         'description': 'ExpEther Board (40G)',
         'ee_version': 'v1.0',
         'update_time': '2018-02-19 00:25:10'
     }
     self.assertEqual(result, expected)
Exemple #6
0
 def test_attach_to_node_with_default_gid(self, mock_req_to_eem,
                                          mock_set_gid, mock_update_device):
     device = device_fakes.fake_device()
     device['pooled_group_id'] = '4093'
     eesv = expether_fakes.fake_eesv()
     eesv['device']['group_id'] = '4094'
     mock_req_to_eem.side_effect = [
         eesv, {
             "devices": [{
                 "id": "0x8cdf9d911cb0"
             }, {
                 "id": "0x8cdf9d53e9d8"
             }],
             "timestamp": "1521117379726"
         }
     ]
     mock_set_gid.return_value = {'group_id': '678'}
     self.expether_manager.attach(device, '0x1111111111')
     mock_set_gid.assert_any_call(device_id='0x1111111111', group_id=None)
     mock_set_gid.assert_any_call(device_id='0x7777777777', group_id='678')
Exemple #7
0
 def test_attach(self, mock_req_to_eem, mock_update_device):
     mock_req_to_eem.side_effect = [
         expether_fakes.fake_eesv(), {
             "devices": [{
                 "id": "0x8cdf9d911cb0"
             }, {
                 "id": "0x8cdf9d53e9d8"
             }],
             "timestamp": "1521117379726"
         }, None
     ]
     device = device_fakes.fake_device()
     device['pooled_group_id'] = '4093'
     self.expether_manager.attach(device, '0x1111111111')
     mock_update_device.assert_called_once_with(
         device['uuid'], {
             'pooled_group_id': '1234',
             'node_id': '0x1111111111',
             'state': 'allocated'
         })
Exemple #8
0
 def test_get_node_info_with_invalid_node(self, mock_get_eesv):
     eesv_info = expether_fakes.fake_eesv()
     eesv_info['device']['status'] = 'eeio'
     mock_get_eesv.return_value = eesv_info
     self.assertRaises(exception.ExpEtherException,
                       self.expether_manager.get_node_info, '0x1111111111')