python-dracclient/dracclient/tests/test_lifecycle_controller.py
Richard Pioso 38d863e489 Simplify get Lifecycle Controller version
A Dell technical white paper [0], "Lifecycle Controller Integration --
Best Practices Guide", describes how to determine the Lifecycle
Controller version. See section 31.4, "Check Version of Lifecycle
Controller (LC)". It simply enumerates the DCIM_SystemView class. No
filter query is used to limit the items returned. And notably, that use
case does not require the LC remote service to be in a "ready" state.

That use case is implemented by the
dracclient.resource.lifecycle_controller.LifecycleControllerManagement.get_version()
method. It has used a filter query and waited for the integrated Dell
Remote Access Controller (iDRAC) to be ready. To align it with best
practices, this patch eliminates its use of a filter query and wait for
the iDRAC.

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

Change-Id: I9a499522b59f18282fc9a57227570f54e46dfd3e
Closes-Bug: #1697558
2017-07-27 10:37:20 -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 lifecycle_controller
from dracclient.resources import uris
from dracclient.tests import base
from dracclient.tests import utils as test_utils
class ClientLifecycleControllerManagementTestCase(base.BaseTest):
def setUp(self):
super(ClientLifecycleControllerManagementTestCase, self).setUp()
self.drac_client = dracclient.client.DRACClient(
**test_utils.FAKE_ENDPOINT)
@requests_mock.Mocker()
def test_get_lifecycle_controller_version(self, mock_requests):
mock_requests.post(
'https://1.2.3.4:443/wsman',
text=test_utils.LifecycleControllerEnumerations[
uris.DCIM_SystemView]['ok'])
version = self.drac_client.get_lifecycle_controller_version()
self.assertEqual((2, 1, 0), version)
class ClientLCConfigurationTestCase(base.BaseTest):
def setUp(self):
super(ClientLCConfigurationTestCase, 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_lifecycle_settings(self, mock_requests,
mock_wait_until_idrac_is_ready):
expected_enum_attr = lifecycle_controller.LCEnumerableAttribute(
name='Lifecycle Controller State',
instance_id='LifecycleController.Embedded.1#LCAttributes.1#LifecycleControllerState', # noqa
read_only=False,
current_value='Enabled',
pending_value=None,
possible_values=['Disabled', 'Enabled', 'Recovery'])
expected_string_attr = lifecycle_controller.LCStringAttribute(
name='SYSID',
instance_id='LifecycleController.Embedded.1#LCAttributes.1#SystemID', # noqa
read_only=True,
current_value='639',
pending_value=None,
min_length=0,
max_length=3)
mock_requests.post('https://1.2.3.4:443/wsman', [
{'text': test_utils.LifecycleControllerEnumerations[
uris.DCIM_LCEnumeration]['ok']},
{'text': test_utils.LifecycleControllerEnumerations[
uris.DCIM_LCString]['ok']}])
lifecycle_settings = self.drac_client.list_lifecycle_settings()
self.assertEqual(14, len(lifecycle_settings))
# enumerable attribute
self.assertIn(
'LifecycleController.Embedded.1#LCAttributes.1#LifecycleControllerState', # noqa
lifecycle_settings)
self.assertEqual(expected_enum_attr, lifecycle_settings[
'LifecycleController.Embedded.1#LCAttributes.1#LifecycleControllerState']) # noqa
# string attribute
self.assertIn(
'LifecycleController.Embedded.1#LCAttributes.1#SystemID',
lifecycle_settings)
self.assertEqual(expected_string_attr,
lifecycle_settings['LifecycleController.Embedded.1#LCAttributes.1#SystemID']) # noqa