예제 #1
0
파일: fake.py 프로젝트: xiaoliukai/ironic
 def __init__(self):
     if not importutils.try_import('scciclient'):
         raise exception.DriverLoadError(
             driver=self.__class__.__name__,
             reason=_("Unable to import python-scciclient library"))
     self.power = irmc_power.IRMCPower()
     self.deploy = fake.FakeDeploy()
     self.management = irmc_management.IRMCManagement()
예제 #2
0
    def test_management_interface_inject_nmi_ok(self, mock_get_irmc_client,
                                                mock_log):
        irmc_client = mock_get_irmc_client.return_value
        with task_manager.acquire(self.context, self.node.uuid) as task:
            irmc_management.IRMCManagement().inject_nmi(task)

            irmc_client.assert_called_once_with(
                irmc_management.irmc.scci.POWER_RAISE_NMI)
            self.assertFalse(mock_log.called)
예제 #3
0
    def test_management_interface_set_boot_device_ng(self, send_raw_mock):
        """uefi mode, next boot only, unknown device."""
        send_raw_mock.return_value = [None, None]

        with task_manager.acquire(self.context, self.node.uuid) as task:
            driver_utils.add_node_capability(task, 'boot_mode', 'uefi')
            self.assertRaises(exception.InvalidParameterValue,
                              irmc_management.IRMCManagement().set_boot_device,
                              task, "unknown")
예제 #4
0
 def __init__(self):
     if not importutils.try_import('scciclient'):
         raise exception.DriverLoadError(
             driver=self.__class__.__name__,
             reason=_("Unable to import python-scciclient library"))
     self.power = irmc_power.IRMCPower()
     self.console = ipmitool.IPMIShellinaboxConsole()
     self.deploy = pxe.PXEDeploy()
     self.management = irmc_management.IRMCManagement()
     self.vendor = pxe.VendorPassthru()
예제 #5
0
파일: irmc.py 프로젝트: Codixis/ironic
    def __init__(self):
        if not importutils.try_import('scciclient.irmc.scci'):
            raise exception.DriverLoadError(
                driver=self.__class__.__name__,
                reason=_("Unable to import python-scciclient library"))

        self.power = power.IRMCPower()
        self.deploy = deploy.IRMCVirtualMediaAgentDeploy()
        self.console = ipmitool.IPMIShellinaboxConsole()
        self.management = management.IRMCManagement()
        self.vendor = agent.AgentVendorInterface()
예제 #6
0
 def __init__(self):
     if not importutils.try_import('scciclient'):
         raise exception.DriverLoadError(
             driver=self.__class__.__name__,
             reason=_("Unable to import python-scciclient library"))
     self.power = irmc_power.IRMCPower()
     self.console = ipmitool.IPMIShellinaboxConsole()
     self.boot = pxe.PXEBoot()
     self.deploy = iscsi_deploy.ISCSIDeploy()
     self.management = irmc_management.IRMCManagement()
     self.inspect = irmc_inspect.IRMCInspect()
예제 #7
0
    def test_management_interface_inject_nmi_fail(self, mock_get_irmc_client,
                                                  mock_log):
        irmc_client = mock_get_irmc_client.return_value
        irmc_client.side_effect = Exception()
        irmc_management.irmc.scci.SCCIClientError = Exception

        with task_manager.acquire(self.context, self.node.uuid) as task:
            self.assertRaises(exception.IRMCOperationError,
                              irmc_management.IRMCManagement().inject_nmi,
                              task)

            irmc_client.assert_called_once_with(
                irmc_management.irmc.scci.POWER_RAISE_NMI)
            self.assertTrue(mock_log.called)
예제 #8
0
    def _test_management_interface_set_boot_device_ok(self, boot_mode, params,
                                                      expected_raw_code,
                                                      send_raw_mock):
        send_raw_mock.return_value = [None, None]

        with task_manager.acquire(self.context, self.node.uuid) as task:
            task.node.properties['capabilities'] = ''
            if boot_mode:
                driver_utils.add_node_capability(task, 'boot_mode', boot_mode)
            irmc_management.IRMCManagement().set_boot_device(task, **params)
            send_raw_mock.assert_has_calls([
                mock.call(task, "0x00 0x08 0x03 0x08"),
                mock.call(task, expected_raw_code)
            ])
예제 #9
0
    def test_management_interface_get_sensors_data_exception(
            self, get_irmc_report_mock):
        """'FailedToGetSensorData Exception."""

        get_irmc_report_mock.side_effect = exception.InvalidParameterValue(
            "Fake Error")
        irmc_management.irmc.scci.SCCIInvalidInputError = Exception
        irmc_management.irmc.scci.SCCIClientError = Exception

        with task_manager.acquire(self.context, self.node.uuid) as task:
            task.node.driver_info['irmc_sensor_method'] = 'scci'
            e = self.assertRaises(
                exception.FailedToGetSensorData,
                irmc_management.IRMCManagement().get_sensors_data, task)
        self.assertEqual(
            "Failed to get sensor data for node %s. "
            "Error: Fake Error" % self.node.uuid, str(e))
예제 #10
0
    def test_management_interface_get_sensors_data_scci_ok(
            self, mock_get_irmc_report, mock_scci):
        """'irmc_sensor_method' = 'scci' specified and OK data."""
        with open(
                os.path.join(os.path.dirname(__file__),
                             'fake_sensors_data_ok.xml'), "r") as report:
            fake_txt = report.read()
        fake_xml = ET.fromstring(fake_txt)

        mock_get_irmc_report.return_value = fake_xml
        mock_scci.get_sensor_data.return_value = fake_xml.find(
            "./System/SensorDataRecords")

        with task_manager.acquire(self.context, self.node.uuid) as task:
            task.node.driver_info['irmc_sensor_method'] = 'scci'
            sensor_dict = irmc_management.IRMCManagement().get_sensors_data(
                task)

        expected = {
            'Fan (4)': {
                'FAN1 SYS (29)': {
                    'Units': 'RPM',
                    'Sensor ID': 'FAN1 SYS (29)',
                    'Sensor Reading': '600 RPM'
                },
                'FAN2 SYS (29)': {
                    'Units': 'None',
                    'Sensor ID': 'FAN2 SYS (29)',
                    'Sensor Reading': 'None None'
                }
            },
            'Temperature (1)': {
                'Systemboard 1 (7)': {
                    'Units': 'degree C',
                    'Sensor ID': 'Systemboard 1 (7)',
                    'Sensor Reading': '80 degree C'
                },
                'Ambient (55)': {
                    'Units': 'degree C',
                    'Sensor ID': 'Ambient (55)',
                    'Sensor Reading': '42 degree C'
                }
            }
        }
        self.assertEqual(expected, sensor_dict)
예제 #11
0
    def test_management_interface_get_sensors_data_scci_ng(
            self, mock_get_irmc_report, mock_scci):
        """'irmc_sensor_method' = 'scci' specified and NG data."""
        with open(
                os.path.join(os.path.dirname(__file__),
                             'fake_sensors_data_ng.xml'), "r") as report:
            fake_txt = report.read()
        fake_xml = ET.fromstring(fake_txt)

        mock_get_irmc_report.return_value = fake_xml
        mock_scci.get_sensor_data.return_value = fake_xml.find(
            "./System/SensorDataRecords")

        with task_manager.acquire(self.context, self.node.uuid) as task:
            task.node.driver_info['irmc_sensor_method'] = 'scci'
            sensor_dict = irmc_management.IRMCManagement().get_sensors_data(
                task)

        self.assertEqual(len(sensor_dict), 0)