~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/tests/drivers/drac/test_management.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-05 12:21:37 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20150105122137-171bqrdpcxqipunk
Tags: 2015.1~b1-0ubuntu1
* New upstream beta release:
  - d/control: Align version requirements with upstream release.
* d/watch: Update uversionmangle to deal with kilo beta versioning
  changes.
* d/control: Bumped Standards-Version to 3.9.6, no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from ironic.common import boot_devices
25
25
from ironic.common import exception
 
26
from ironic.conductor import task_manager
26
27
from ironic.drivers.modules.drac import client as drac_client
27
28
from ironic.drivers.modules.drac import common as drac_common
28
29
from ironic.drivers.modules.drac import management as drac_mgmt
172
173
                         sorted(self.driver.get_supported_boot_devices()))
173
174
 
174
175
    @mock.patch.object(drac_mgmt, '_get_next_boot_mode')
175
 
    def test_get_boot_devices(self, mock_gnbm, mock_client_pywsman):
 
176
    def test_get_boot_device(self, mock_gnbm, mock_client_pywsman):
176
177
        mock_gnbm.return_value = {'instance_id': 'OneTime',
177
178
                                  'is_next': drac_mgmt.ONE_TIME_BOOT}
178
179
 
191
192
            resource_uris.DCIM_BootSourceSetting)
192
193
 
193
194
    @mock.patch.object(drac_mgmt, '_get_next_boot_mode')
194
 
    def test_get_boot_devices_persistent(self, mock_gnbm, mock_client_pywsman):
 
195
    def test_get_boot_device_persistent(self, mock_gnbm, mock_client_pywsman):
195
196
        mock_gnbm.return_value = {'instance_id': 'IPL',
196
197
                                  'is_next': drac_mgmt.PERSISTENT}
197
198
 
211
212
 
212
213
    @mock.patch.object(drac_client.Client, 'wsman_enumerate')
213
214
    @mock.patch.object(drac_mgmt, '_get_next_boot_mode')
214
 
    def test_get_boot_devices_client_error(self, mock_gnbm, mock_we,
215
 
                                           mock_client_pywsman):
 
215
    def test_get_boot_device_client_error(self, mock_gnbm, mock_we,
 
216
                                          mock_client_pywsman):
216
217
        mock_gnbm.return_value = {'instance_id': 'OneTime',
217
218
                                  'is_next': drac_mgmt.ONE_TIME_BOOT}
218
219
        mock_we.side_effect = exception.DracClientError('E_FAKE')
237
238
        mock_pywsman.enumerate.return_value = mock_xml_enum
238
239
        mock_pywsman.invoke.return_value = mock_xml_invk
239
240
 
240
 
        result = self.driver.set_boot_device(self.task, boot_devices.PXE)
 
241
        with task_manager.acquire(self.context, self.node.uuid,
 
242
                                  shared=False) as task:
 
243
            task.node = self.node
 
244
            result = self.driver.set_boot_device(task, boot_devices.PXE)
241
245
 
242
246
        self.assertIsNone(result)
243
247
        mock_pywsman.enumerate.assert_called_once_with(mock.ANY, mock.ANY,
264
268
        mock_pywsman = mock_client_pywsman.Client.return_value
265
269
        mock_pywsman.enumerate.return_value = mock_xml_enum
266
270
        mock_pywsman.invoke.return_value = mock_xml_invk
267
 
 
268
 
        self.assertRaises(exception.DracOperationError,
269
 
                          self.driver.set_boot_device, self.task,
270
 
                          boot_devices.PXE)
 
271
        with task_manager.acquire(self.context, self.node.uuid,
 
272
                                  shared=False) as task:
 
273
            task.node = self.node
 
274
            self.assertRaises(exception.DracOperationError,
 
275
                              self.driver.set_boot_device, task,
 
276
                              boot_devices.PXE)
271
277
 
272
278
        mock_pywsman.enumerate.assert_called_once_with(mock.ANY, mock.ANY,
273
279
            resource_uris.DCIM_BootSourceSetting)
282
288
    def test_set_boot_device_client_error(self, mock_cfcj, mock_we,
283
289
                                          mock_client_pywsman):
284
290
        mock_we.side_effect = exception.DracClientError('E_FAKE')
285
 
 
286
 
        self.assertRaises(exception.DracClientError,
287
 
                          self.driver.set_boot_device, self.task,
288
 
                          boot_devices.PXE)
 
291
        with task_manager.acquire(self.context, self.node.uuid,
 
292
                                  shared=False) as task:
 
293
            task.node = self.node
 
294
            self.assertRaises(exception.DracClientError,
 
295
                              self.driver.set_boot_device, task,
 
296
                              boot_devices.PXE)
289
297
        mock_we.assert_called_once_with(resource_uris.DCIM_BootSourceSetting,
290
298
                                        mock.ANY, filter_query=mock.ANY)
291
299