"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ironic/tests/unit/drivers/modules/test_ipxe.py" between
ironic-17.0.2.tar.gz and ironic-17.0.3.tar.gz

About: OpenStack Ironic (Optional Service: Bare-Metal Provisioning) aims to provision bare metal machines instead of virtual machines, forked from the Nova baremetal driver.
The "Wallaby" series (latest release).

test_ipxe.py  (ironic-17.0.2):test_ipxe.py  (ironic-17.0.3)
skipping to change at line 22 skipping to change at line 22
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Test class for iPXE driver.""" """Test class for iPXE driver."""
import os import os
from unittest import mock from unittest import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_serialization import jsonutils as json
from oslo_utils import uuidutils from oslo_utils import uuidutils
from ironic.common import boot_devices from ironic.common import boot_devices
from ironic.common import boot_modes from ironic.common import boot_modes
from ironic.common import dhcp_factory from ironic.common import dhcp_factory
from ironic.common import exception from ironic.common import exception
from ironic.common.glance_service import image_service from ironic.common.glance_service import image_service
from ironic.common import pxe_utils from ironic.common import pxe_utils
from ironic.common import states from ironic.common import states
from ironic.common import utils as common_utils from ironic.common import utils as common_utils
skipping to change at line 146 skipping to change at line 145
return_value='ramdisk', autospec=True) return_value='ramdisk', autospec=True)
def test_validate_with_boot_iso(self, mock_boot_option, mock_glance): def test_validate_with_boot_iso(self, mock_boot_option, mock_glance):
i_info = self.node.driver_info i_info = self.node.driver_info
i_info['boot_iso'] = "http://localhost:1234/boot.iso" i_info['boot_iso'] = "http://localhost:1234/boot.iso"
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
task.driver.boot.validate(task) task.driver.boot.validate(task)
self.assertTrue(mock_boot_option.called) self.assertTrue(mock_boot_option.called)
self.assertTrue(mock_glance.called) self.assertTrue(mock_glance.called)
def test_validate_with_boot_iso_and_image_source(self): @mock.patch('ironic.drivers.modules.deploy_utils.get_boot_option',
return_value='ramdisk', autospec=True)
def test_validate_with_boot_iso_and_image_source(self, mock_boot_option):
i_info = self.node.instance_info i_info = self.node.instance_info
i_info['image_source'] = "http://localhost:1234/image" i_info['image_source'] = "http://localhost:1234/image"
i_info['boot_iso'] = "http://localhost:1234/boot.iso" i_info['boot_iso'] = "http://localhost:1234/boot.iso"
self.node.instance_info = i_info self.node.instance_info = i_info
self.node.save() self.node.save()
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
self.assertRaises(exception.InvalidParameterValue, self.assertRaises(exception.InvalidParameterValue,
task.driver.boot.validate, task.driver.boot.validate,
task) task)
mock_boot_option.assert_called_once_with(task.node)
@mock.patch('ironic.drivers.modules.deploy_utils.get_boot_option',
return_value='local', autospec=True)
def test_validate_no_image_source_for_local_boot(self, mock_boot_option):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
del task.node['instance_info']['image_source']
task.driver.boot.validate(task)
mock_boot_option.assert_called_with(task.node)
def test_validate_fail_missing_image_source(self): @mock.patch('ironic.drivers.modules.deploy_utils.get_boot_option',
info = dict(INST_INFO_DICT) return_value='netboot', autospec=True)
del info['image_source'] def test_validate_fail_missing_image_source(self, mock_boot_option):
self.node.instance_info = json.dumps(info)
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
task.node['instance_info'] = json.dumps(info) del task.node['instance_info']['image_source']
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
mock_boot_option.assert_called_with(task.node)
def test_validate_fail_no_port(self): def test_validate_fail_no_port(self):
new_node = obj_utils.create_test_node( new_node = obj_utils.create_test_node(
self.context, self.context,
uuid='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee', uuid='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
driver=self.driver, boot_interface=self.boot_interface, driver=self.driver, boot_interface=self.boot_interface,
instance_info=INST_INFO_DICT, driver_info=DRV_INFO_DICT) instance_info=INST_INFO_DICT, driver_info=DRV_INFO_DICT)
with task_manager.acquire(self.context, new_node.uuid, with task_manager.acquire(self.context, new_node.uuid,
shared=True) as task: shared=True) as task:
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
skipping to change at line 214 skipping to change at line 225
def test_validate_fail_no_image_kernel_ramdisk_props(self, mock_glance): def test_validate_fail_no_image_kernel_ramdisk_props(self, mock_glance):
instance_info = {"boot_option": "netboot"} instance_info = {"boot_option": "netboot"}
mock_glance.return_value = {'properties': {}} mock_glance.return_value = {'properties': {}}
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
task.node.instance_info['capabilities'] = instance_info task.node.instance_info['capabilities'] = instance_info
self.assertRaises(exception.MissingParameterValue, self.assertRaises(exception.MissingParameterValue,
task.driver.boot.validate, task.driver.boot.validate,
task) task)
@mock.patch('ironic.drivers.modules.deploy_utils.get_boot_option',
return_value='netboot', autospec=True)
@mock.patch.object(image_service.GlanceImageService, 'show', @mock.patch.object(image_service.GlanceImageService, 'show',
autospec=True) autospec=True)
def test_validate_fail_glance_image_doesnt_exists(self, mock_glance): def test_validate_fail_glance_image_doesnt_exists(self, mock_glance,
mock_boot_option):
mock_glance.side_effect = exception.ImageNotFound('not found') mock_glance.side_effect = exception.ImageNotFound('not found')
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
self.assertRaises(exception.InvalidParameterValue, self.assertRaises(exception.InvalidParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
mock_boot_option.assert_called_with(task.node)
@mock.patch('ironic.drivers.modules.deploy_utils.get_boot_option',
return_value='netboot', autospec=True)
@mock.patch.object(image_service.GlanceImageService, 'show', @mock.patch.object(image_service.GlanceImageService, 'show',
autospec=True) autospec=True)
def test_validate_fail_glance_conn_problem(self, mock_glance): def test_validate_fail_glance_conn_problem(self, mock_glance,
mock_boot_option):
exceptions = (exception.GlanceConnectionFailed('connection fail'), exceptions = (exception.GlanceConnectionFailed('connection fail'),
exception.ImageNotAuthorized('not authorized'), exception.ImageNotAuthorized('not authorized'),
exception.Invalid('invalid')) exception.Invalid('invalid'))
mock_glance.side_effect = exceptions mock_glance.side_effect = exceptions
for exc in exceptions: for exc in exceptions:
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:
self.assertRaises(exception.InvalidParameterValue, self.assertRaises(exception.InvalidParameterValue,
task.driver.boot.validate, task) task.driver.boot.validate, task)
mock_boot_option.assert_called_with(task.node)
def test_validate_inspection(self): def test_validate_inspection(self):
with task_manager.acquire(self.context, self.node.uuid) as task: with task_manager.acquire(self.context, self.node.uuid) as task:
task.driver.boot.validate_inspection(task) task.driver.boot.validate_inspection(task)
def test_validate_inspection_no_inspection_ramdisk(self): def test_validate_inspection_no_inspection_ramdisk(self):
driver_info = self.node.driver_info driver_info = self.node.driver_info
del driver_info['deploy_ramdisk'] del driver_info['deploy_ramdisk']
self.node.driver_info = driver_info self.node.driver_info = driver_info
self.node.save() self.node.save()
 End of changes. 12 change blocks. 
9 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)