python-dracclient/dracclient/tests/test_system.py
Richard Pioso 3207d9e1bc Enumerate operations can wait until iDRAC is ready
Web Services Management (WS-Management and WS-Man) Enumerate operations
can fail or return invalid results when issued to an integrated Dell
Remote Access Controller (iDRAC) whose Lifecycle Controller remote
service is not "ready". The following are examples of failures which
have been observed:

+ The result of Enumerate is an error.
+ Enumerate succeeds, but no items are returned when they are known to
exist.
+ Enumerate succeeds, but items for all those known to exist are not
returned.

A Dell technical white paper [0], "Lifecycle Controller Integration --
Best Practices Guide", states that for Lifecycle Controller firmware
1.5.0 and later "The Lifecycle Controller remote service must be in a
'ready' state before running any other WSMAN commands." That applies to
almost all of the workflows and use cases documented by that paper and
supported by this project, openstack/python-dracclient.

This patch defines a new method in class dracclient.client.WSManClient,
enumerate(). It extends its base class's implementation by adding a new
parameter that indicates whether or not it should wait until the iDRAC
is ready to accept commands before issuing the Enumerate command. When
it is true, that method waits until the iDRAC is ready before issuing
the command. Since almost all Enumerate operations require the iDRAC to
be ready, the new parameter's default value is 'True'.

[0]
http://en.community.dell.com/techcenter/extras/m/white_papers/20442332

Change-Id: Ied659a4ee45b1dd55cd3a420301d866d52c838fb
Partial-Bug: #1697558
Related-Bug: #1691808
2017-07-25 17:27:42 -04:00

92 lines
3.7 KiB
Python

#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
import requests_mock
import dracclient.client
from dracclient.resources import system
from dracclient.resources import uris
from dracclient.tests import base
from dracclient.tests import utils as test_utils
class ClientSystemConfigurationTestCase(base.BaseTest):
def setUp(self):
super(ClientSystemConfigurationTestCase, self).setUp()
self.drac_client = dracclient.client.DRACClient(
**test_utils.FAKE_ENDPOINT)
@requests_mock.Mocker()
@mock.patch.object(dracclient.client.WSManClient,
'wait_until_idrac_is_ready', spec_set=True,
autospec=True)
def test_list_system_settings(
self, mock_requests, mock_wait_until_idrac_is_ready):
expected_enum_attr = system.SystemEnumerableAttribute(
name='ChassisLEDState',
instance_id='System.Embedded.1#ChassisPwrState.1#ChassisLEDState', # noqa
read_only=False,
current_value='Off',
pending_value=None,
fqdd='System.Embedded.1',
group_id='ChassisPwrState.1',
possible_values=['Unknown', 'Blinking', 'Off'])
expected_string_attr = system.SystemStringAttribute(
name='UserDefinedString',
instance_id='System.Embedded.1#LCD.1#UserDefinedString',
read_only=False,
current_value=None,
pending_value=None,
fqdd='System.Embedded.1',
group_id='LCD.1',
min_length=0,
max_length=62)
expected_integer_attr = system.SystemIntegerAttribute(
name='PowerCapValue',
instance_id='System.Embedded.1#ServerPwr.1#PowerCapValue',
read_only=False,
current_value=555,
pending_value=None,
fqdd='System.Embedded.1',
group_id='ServerPwr.1',
lower_bound=302,
upper_bound=578)
mock_requests.post('https://1.2.3.4:443/wsman', [
{'text': test_utils.SystemEnumerations[
uris.DCIM_SystemEnumeration]['ok']},
{'text': test_utils.SystemEnumerations[
uris.DCIM_SystemString]['ok']},
{'text': test_utils.SystemEnumerations[
uris.DCIM_SystemInteger]['ok']}])
system_settings = self.drac_client.list_system_settings()
self.assertEqual(44, len(system_settings))
# enumerable attribute
self.assertIn('System.Embedded.1#ChassisPwrState.1#ChassisLEDState',
system_settings)
self.assertEqual(expected_enum_attr, system_settings[
'System.Embedded.1#ChassisPwrState.1#ChassisLEDState']) # noqa
# string attribute
self.assertIn('System.Embedded.1#LCD.1#UserDefinedString',
system_settings)
self.assertEqual(expected_string_attr, system_settings[
'System.Embedded.1#LCD.1#UserDefinedString'])
self.assertIn('System.Embedded.1#ServerPwr.1#PowerCapValue',
system_settings)
self.assertEqual(expected_integer_attr,
system_settings['System.Embedded.1#ServerPwr.1#PowerCapValue']) # noqa