2
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3
# not use this file except in compliance with the License. You may obtain
4
# a copy of the License at
6
# http://www.apache.org/licenses/LICENSE-2.0
8
# Unless required by applicable law or agreed to in writing, software
9
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11
# License for the specific language governing permissions and limitations
14
"""Test class for AMT Vendor methods."""
18
from ironic.common import boot_devices
19
from ironic.common import states
20
from ironic.conductor import task_manager
21
from ironic.drivers.modules.amt import management as amt_mgmt
22
from ironic.drivers.modules import pxe
23
from ironic.tests.conductor import utils as mgr_utils
24
from ironic.tests.db import base as db_base
25
from ironic.tests.db import utils as db_utils
26
from ironic.tests.objects import utils as obj_utils
28
INFO_DICT = db_utils.get_test_amt_info()
31
class AMTPXEVendorPassthruTestCase(db_base.DbTestCase):
34
super(AMTPXEVendorPassthruTestCase, self).setUp()
35
mgr_utils.mock_the_extension_manager(driver="pxe_amt")
36
self.node = obj_utils.create_test_node(self.context,
37
driver='pxe_amt', driver_info=INFO_DICT)
39
def test_vendor_routes(self):
40
expected = ['heartbeat', 'pass_deploy_info']
41
with task_manager.acquire(self.context, self.node.uuid,
43
vendor_routes = task.driver.vendor.vendor_routes
44
self.assertIsInstance(vendor_routes, dict)
45
self.assertEqual(sorted(expected), sorted(list(vendor_routes)))
47
def test_driver_routes(self):
49
with task_manager.acquire(self.context, self.node.uuid,
51
driver_routes = task.driver.vendor.driver_routes
52
self.assertIsInstance(driver_routes, dict)
53
self.assertEqual(sorted(expected), sorted(list(driver_routes)))
55
@mock.patch.object(amt_mgmt.AMTManagement, 'ensure_next_boot_device')
56
@mock.patch.object(pxe.VendorPassthru, 'pass_deploy_info')
57
def test_vendorpassthru_pass_deploy_info(self, mock_pxe_vendorpassthru,
59
kwargs = {'address': '123456'}
60
with task_manager.acquire(self.context, self.node.uuid,
61
shared=False) as task:
62
task.node.provision_state = states.DEPLOYWAIT
63
task.node.target_provision_state = states.ACTIVE
64
task.driver.vendor.pass_deploy_info(task, **kwargs)
65
mock_ensure.assert_called_with(task.node, boot_devices.PXE)
66
mock_pxe_vendorpassthru.assert_called_once_with(task, **kwargs)