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

« back to all changes in this revision

Viewing changes to ironic/tests/drivers/amt/test_vendor.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2015-03-30 11:14:57 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20150330111457-kr4ju3guf22m4vbz
Tags: 2015.1~b3-0ubuntu1
* New upstream release.
  + d/control: 
    - Align with upstream dependencies.
    - Add dh-python to build-dependencies.
    - Add psmisc as a dependency. (LP: #1358820)
  + d/p/fix-requirements.patch: Rediffed.
  + d/ironic-conductor.init.in: Fixed typos in LSB headers,
    thanks to JJ Asghar. (LP: #1429962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
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
 
5
#
 
6
#         http://www.apache.org/licenses/LICENSE-2.0
 
7
#
 
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
 
12
#    under the License.
 
13
 
 
14
"""Test class for AMT Vendor methods."""
 
15
 
 
16
import mock
 
17
 
 
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
 
27
 
 
28
INFO_DICT = db_utils.get_test_amt_info()
 
29
 
 
30
 
 
31
class AMTPXEVendorPassthruTestCase(db_base.DbTestCase):
 
32
 
 
33
    def setUp(self):
 
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)
 
38
 
 
39
    def test_vendor_routes(self):
 
40
        expected = ['heartbeat', 'pass_deploy_info']
 
41
        with task_manager.acquire(self.context, self.node.uuid,
 
42
                                  shared=True) as task:
 
43
            vendor_routes = task.driver.vendor.vendor_routes
 
44
            self.assertIsInstance(vendor_routes, dict)
 
45
            self.assertEqual(sorted(expected), sorted(list(vendor_routes)))
 
46
 
 
47
    def test_driver_routes(self):
 
48
        expected = ['lookup']
 
49
        with task_manager.acquire(self.context, self.node.uuid,
 
50
                                  shared=True) as task:
 
51
            driver_routes = task.driver.vendor.driver_routes
 
52
            self.assertIsInstance(driver_routes, dict)
 
53
            self.assertEqual(sorted(expected), sorted(list(driver_routes)))
 
54
 
 
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,
 
58
                                             mock_ensure):
 
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)