Redfish: Adds 'activate_license' for redfish systems
This commit provides functionality to activate license for redish based systems. Change-Id: I398dbf229bf7cef6fce2927f4098642dcff326b8
This commit is contained in:
parent
09d869326a
commit
ca8033177c
|
@ -67,6 +67,7 @@ SUPPORTED_REDFISH_METHODS = [
|
|||
'get_one_time_boot',
|
||||
'get_pending_boot_mode',
|
||||
'get_current_boot_mode',
|
||||
'activate_license',
|
||||
]
|
||||
|
||||
LOG = log.get_logger(__name__)
|
||||
|
|
|
@ -56,8 +56,9 @@ BOOT_MODE_MAP = {
|
|||
|
||||
BOOT_MODE_MAP_REV = (
|
||||
utils.revert_dictionary(BOOT_MODE_MAP))
|
||||
# Assuming only one sushy_system present as part of collection,
|
||||
# as we are dealing with iLO's here.
|
||||
# Assuming only one sushy_system and sushy_manager present as part of
|
||||
# collection, as we are dealing with iLO's here.
|
||||
PROLIANT_MANAGER_ID = '1'
|
||||
PROLIANT_SYSTEM_ID = '1'
|
||||
|
||||
LOG = log.get_logger(__name__)
|
||||
|
@ -243,6 +244,22 @@ class RedfishOperations(operations.IloOperations):
|
|||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
|
||||
def activate_license(self, key):
|
||||
"""Activates iLO license.
|
||||
|
||||
:param key: iLO license key.
|
||||
:raises: IloError, on an error from iLO.
|
||||
"""
|
||||
sushy_manager = self._get_sushy_manager(PROLIANT_MANAGER_ID)
|
||||
try:
|
||||
sushy_manager.set_license(key)
|
||||
except sushy.exceptions.SushyError as e:
|
||||
msg = (self._('The Redfish controller failed to update '
|
||||
'the license. Error %(error)s') %
|
||||
{'error': str(e)})
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
|
||||
def get_one_time_boot(self):
|
||||
"""Retrieves the current setting for the one time boot.
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ __author__ = 'HPE'
|
|||
|
||||
from sushy.resources.manager import manager
|
||||
|
||||
from proliantutils.redfish import utils
|
||||
|
||||
|
||||
class HPEManager(manager.Manager):
|
||||
"""Class that extends the functionality of Manager resource class
|
||||
|
@ -23,3 +25,13 @@ class HPEManager(manager.Manager):
|
|||
This class extends the functionality of Manager resource class
|
||||
from sushy
|
||||
"""
|
||||
|
||||
def set_license(self, key):
|
||||
"""Set the license on a redfish system
|
||||
|
||||
:param key: license key
|
||||
"""
|
||||
data = {'LicenseKey': key}
|
||||
license_service_uri = (utils.get_subresource_path_by(self,
|
||||
['Oem', 'Hpe', 'Links', 'LicenseService']))
|
||||
self._conn.post(license_service_uri, data=data)
|
||||
|
|
|
@ -1,196 +1,196 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Managers/Members/$entity",
|
||||
"@odata.etag": "W/\"FD28A1E2\"",
|
||||
"@odata.id": "/redfish/v1/Managers/1/",
|
||||
"@odata.type": "#Manager.v1_1_0.Manager",
|
||||
"Actions": {
|
||||
"#Manager.Reset": {
|
||||
"target": "/redfish/v1/Managers/1/Actions/Manager.Reset/"
|
||||
}
|
||||
},
|
||||
"CommandShell": {
|
||||
"ConnectTypesSupported": [
|
||||
"SSH",
|
||||
"Oem"
|
||||
],
|
||||
"MaxConcurrentSessions": 9,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"EthernetInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/EthernetInterfaces/"
|
||||
},
|
||||
"FirmwareVersion": "iLO 5 v1.15",
|
||||
"GraphicalConsole": {
|
||||
"ConnectTypesSupported": [
|
||||
"KVMIP"
|
||||
],
|
||||
"MaxConcurrentSessions": 10,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"Id": "1",
|
||||
"Links": {
|
||||
"ManagerForChassis": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/1/"
|
||||
}
|
||||
],
|
||||
"ManagerForServers": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/1/"
|
||||
}
|
||||
],
|
||||
"ManagerInChassis": {
|
||||
"@odata.id": "/redfish/v1/Chassis/1/"
|
||||
}
|
||||
},
|
||||
"LogServices": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/LogServices/"
|
||||
},
|
||||
"ManagerType": "BMC",
|
||||
"Name": "Manager",
|
||||
"NetworkProtocol": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/NetworkService/"
|
||||
},
|
||||
"Oem": {
|
||||
"Hpe": {
|
||||
"@odata.type": "#HpeiLO.v2_1_0.HpeiLO",
|
||||
"Actions": {
|
||||
"#HpeiLO.ClearRestApiState": {
|
||||
"target": "/redfish/v1/Managers/1/Actions/Oem/Hpe/HpeiLO.ClearRestApiState/"
|
||||
},
|
||||
"#HpeiLO.DisableiLOFunctionality": {
|
||||
"target": "/redfish/v1/Managers/1/Actions/Oem/Hpe/HpeiLO.DisableiLOFunctionality/"
|
||||
},
|
||||
"#HpeiLO.ResetToFactoryDefaults": {
|
||||
"ResetType@Redfish.AllowableValues": [
|
||||
"Default"
|
||||
],
|
||||
"target": "/redfish/v1/Managers/1/Actions/Oem/Hpe/HpeiLO.ResetToFactoryDefaults/"
|
||||
}
|
||||
},
|
||||
"ClearRestApiStatus": "DataPresent",
|
||||
"ConfigurationSettings": "Current",
|
||||
"FederationConfig": {
|
||||
"IPv6MulticastScope": "Site",
|
||||
"MulticastAnnouncementInterval": 600,
|
||||
"MulticastDiscovery": "Enabled",
|
||||
"MulticastTimeToLive": 5,
|
||||
"iLOFederationManagement": "Enabled"
|
||||
},
|
||||
"Firmware": {
|
||||
"Current": {
|
||||
"Date": "Jun 05 2017",
|
||||
"DebugBuild": false,
|
||||
"MajorVersion": 1,
|
||||
"MinorVersion": 15,
|
||||
"VersionString": "iLO 5 v1.15"
|
||||
}
|
||||
},
|
||||
"FrontPanelUSB": {
|
||||
"State": "Ready"
|
||||
},
|
||||
"IdleConnectionTimeoutMinutes": 30,
|
||||
"License": {
|
||||
"LicenseKey": "XXXXX-XXXXX-XXXXX-XXXXX-456N6",
|
||||
"LicenseString": "iLO Advanced limited-distribution test",
|
||||
"LicenseType": "Internal"
|
||||
},
|
||||
"Links": {
|
||||
"ActiveHealthSystem": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/ActiveHealthSystem/"
|
||||
},
|
||||
"DateTimeService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/DateTime/"
|
||||
},
|
||||
"EmbeddedMediaService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/EmbeddedMedia/"
|
||||
},
|
||||
"FederationDispatch": {
|
||||
"extref": "/dispatch"
|
||||
},
|
||||
"FederationGroups": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/FederationGroups/"
|
||||
},
|
||||
"FederationPeers": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/FederationPeers/"
|
||||
},
|
||||
"LicenseService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/LicenseService/"
|
||||
},
|
||||
"SecurityService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/SecurityService/"
|
||||
},
|
||||
"Thumbnail": {
|
||||
"extref": "/images/thumbnail.bmp"
|
||||
},
|
||||
"VSPLogLocation": {
|
||||
"extref": "/sol.log.gz"
|
||||
}
|
||||
},
|
||||
"PersistentMouseKeyboardEnabled": false,
|
||||
"RIBCLEnabled": true,
|
||||
"RequiredLoginForiLORBSU": false,
|
||||
"SerialCLISpeed": 9600,
|
||||
"SerialCLIStatus": "EnabledAuthReq",
|
||||
"VSPDlLoggingEnabled": false,
|
||||
"VSPLogDownloadEnabled": false,
|
||||
"WebGuiEnabled": true,
|
||||
"iLOFunctionalityRequired": false,
|
||||
"iLORBSUEnabled": true,
|
||||
"iLOSelfTestResults": [
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "NVRAMData",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "Controller firmware revision 2.10.00 ",
|
||||
"SelfTestName": "EmbeddedFlash",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "HostRom",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "SupportedHost",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "Version 1.0.2",
|
||||
"SelfTestName": "PowerManagementController",
|
||||
"Status": "Informational"
|
||||
},
|
||||
{
|
||||
"Notes": "ProLiant DL180 Gen10 System Programmable Logic Device 0x07",
|
||||
"SelfTestName": "CPLDPAL0",
|
||||
"Status": "Informational"
|
||||
}
|
||||
],
|
||||
"iLOServicePort": {
|
||||
"MassStorageAuthenticationRequired": false,
|
||||
"USBEthernetAdaptersEnabled": true,
|
||||
"USBFlashDriveEnabled": true,
|
||||
"iLOServicePortEnabled": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"SerialConsole": {
|
||||
"ConnectTypesSupported": [
|
||||
"SSH",
|
||||
"IPMI",
|
||||
"Oem"
|
||||
],
|
||||
"MaxConcurrentSessions": 13,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"Status": {
|
||||
"State": "Enabled"
|
||||
},
|
||||
"UUID": null,
|
||||
"VirtualMedia": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/VirtualMedia/"
|
||||
}
|
||||
}
|
||||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Managers/Members/$entity",
|
||||
"@odata.etag": "W/\"FD28A1E2\"",
|
||||
"@odata.id": "/redfish/v1/Managers/1/",
|
||||
"@odata.type": "#Manager.v1_1_0.Manager",
|
||||
"Actions": {
|
||||
"#Manager.Reset": {
|
||||
"target": "/redfish/v1/Managers/1/Actions/Manager.Reset/"
|
||||
}
|
||||
},
|
||||
"CommandShell": {
|
||||
"ConnectTypesSupported": [
|
||||
"SSH",
|
||||
"Oem"
|
||||
],
|
||||
"MaxConcurrentSessions": 9,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"EthernetInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/EthernetInterfaces/"
|
||||
},
|
||||
"FirmwareVersion": "iLO 5 v1.15",
|
||||
"GraphicalConsole": {
|
||||
"ConnectTypesSupported": [
|
||||
"KVMIP"
|
||||
],
|
||||
"MaxConcurrentSessions": 10,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"Id": "1",
|
||||
"Links": {
|
||||
"ManagerForChassis": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/1/"
|
||||
}
|
||||
],
|
||||
"ManagerForServers": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/1/"
|
||||
}
|
||||
],
|
||||
"ManagerInChassis": {
|
||||
"@odata.id": "/redfish/v1/Chassis/1/"
|
||||
}
|
||||
},
|
||||
"LogServices": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/LogServices/"
|
||||
},
|
||||
"ManagerType": "BMC",
|
||||
"Name": "Manager",
|
||||
"NetworkProtocol": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/NetworkService/"
|
||||
},
|
||||
"Oem": {
|
||||
"Hpe": {
|
||||
"@odata.type": "#HpeiLO.v2_1_0.HpeiLO",
|
||||
"Actions": {
|
||||
"#HpeiLO.ClearRestApiState": {
|
||||
"target": "/redfish/v1/Managers/1/Actions/Oem/Hpe/HpeiLO.ClearRestApiState/"
|
||||
},
|
||||
"#HpeiLO.DisableiLOFunctionality": {
|
||||
"target": "/redfish/v1/Managers/1/Actions/Oem/Hpe/HpeiLO.DisableiLOFunctionality/"
|
||||
},
|
||||
"#HpeiLO.ResetToFactoryDefaults": {
|
||||
"ResetType@Redfish.AllowableValues": [
|
||||
"Default"
|
||||
],
|
||||
"target": "/redfish/v1/Managers/1/Actions/Oem/Hpe/HpeiLO.ResetToFactoryDefaults/"
|
||||
}
|
||||
},
|
||||
"ClearRestApiStatus": "DataPresent",
|
||||
"ConfigurationSettings": "Current",
|
||||
"FederationConfig": {
|
||||
"IPv6MulticastScope": "Site",
|
||||
"MulticastAnnouncementInterval": 600,
|
||||
"MulticastDiscovery": "Enabled",
|
||||
"MulticastTimeToLive": 5,
|
||||
"iLOFederationManagement": "Enabled"
|
||||
},
|
||||
"Firmware": {
|
||||
"Current": {
|
||||
"Date": "Jun 05 2017",
|
||||
"DebugBuild": false,
|
||||
"MajorVersion": 1,
|
||||
"MinorVersion": 15,
|
||||
"VersionString": "iLO 5 v1.15"
|
||||
}
|
||||
},
|
||||
"FrontPanelUSB": {
|
||||
"State": "Ready"
|
||||
},
|
||||
"IdleConnectionTimeoutMinutes": 30,
|
||||
"License": {
|
||||
"LicenseKey": "XXXXX-XXXXX-XXXXX-XXXXX-456N6",
|
||||
"LicenseString": "iLO Advanced limited-distribution test",
|
||||
"LicenseType": "Internal"
|
||||
},
|
||||
"Links": {
|
||||
"ActiveHealthSystem": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/ActiveHealthSystem/"
|
||||
},
|
||||
"DateTimeService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/DateTime/"
|
||||
},
|
||||
"EmbeddedMediaService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/EmbeddedMedia/"
|
||||
},
|
||||
"FederationDispatch": {
|
||||
"extref": "/dispatch"
|
||||
},
|
||||
"FederationGroups": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/FederationGroups/"
|
||||
},
|
||||
"FederationPeers": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/FederationPeers/"
|
||||
},
|
||||
"LicenseService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/LicenseService/"
|
||||
},
|
||||
"SecurityService": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/SecurityService/"
|
||||
},
|
||||
"Thumbnail": {
|
||||
"extref": "/images/thumbnail.bmp"
|
||||
},
|
||||
"VSPLogLocation": {
|
||||
"extref": "/sol.log.gz"
|
||||
}
|
||||
},
|
||||
"PersistentMouseKeyboardEnabled": false,
|
||||
"RIBCLEnabled": true,
|
||||
"RequiredLoginForiLORBSU": false,
|
||||
"SerialCLISpeed": 9600,
|
||||
"SerialCLIStatus": "EnabledAuthReq",
|
||||
"VSPDlLoggingEnabled": false,
|
||||
"VSPLogDownloadEnabled": false,
|
||||
"WebGuiEnabled": true,
|
||||
"iLOFunctionalityRequired": false,
|
||||
"iLORBSUEnabled": true,
|
||||
"iLOSelfTestResults": [
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "NVRAMData",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "Controller firmware revision 2.10.00 ",
|
||||
"SelfTestName": "EmbeddedFlash",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "HostRom",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "SupportedHost",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "Version 1.0.2",
|
||||
"SelfTestName": "PowerManagementController",
|
||||
"Status": "Informational"
|
||||
},
|
||||
{
|
||||
"Notes": "ProLiant DL180 Gen10 System Programmable Logic Device 0x07",
|
||||
"SelfTestName": "CPLDPAL0",
|
||||
"Status": "Informational"
|
||||
}
|
||||
],
|
||||
"iLOServicePort": {
|
||||
"MassStorageAuthenticationRequired": false,
|
||||
"USBEthernetAdaptersEnabled": true,
|
||||
"USBFlashDriveEnabled": true,
|
||||
"iLOServicePortEnabled": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"SerialConsole": {
|
||||
"ConnectTypesSupported": [
|
||||
"SSH",
|
||||
"IPMI",
|
||||
"Oem"
|
||||
],
|
||||
"MaxConcurrentSessions": 13,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"Status": {
|
||||
"State": "Enabled"
|
||||
},
|
||||
"UUID": null,
|
||||
"VirtualMedia": {
|
||||
"@odata.id": "/redfish/v1/Managers/1/VirtualMedia/"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
# Copyright 2017 Hewlett Packard Enterprise Development LP
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 json
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from proliantutils.redfish.resources.manager import manager
|
||||
|
||||
|
||||
class HPEManagerTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(HPEManagerTestCase, self).setUp()
|
||||
self.conn = mock.MagicMock()
|
||||
with open('proliantutils/tests/redfish/'
|
||||
'json_samples/manager.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.mgr_inst = manager.HPEManager(
|
||||
self.conn, '/redfish/v1/Managers/1',
|
||||
redfish_version='1.0.2')
|
||||
|
||||
def test_set_license(self):
|
||||
self.mgr_inst.set_license('testkey')
|
||||
self.mgr_inst._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Managers/1/LicenseService/',
|
||||
data={'LicenseKey': 'testkey'})
|
|
@ -211,3 +211,16 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
|||
exception.IloError,
|
||||
'The current BIOS Settings was not found.',
|
||||
self.rf_client.get_current_boot_mode)
|
||||
|
||||
def test_activate_license(self):
|
||||
self.rf_client.activate_license('testkey')
|
||||
(self.sushy.get_manager.return_value.set_license.
|
||||
assert_called_once_with('testkey'))
|
||||
|
||||
def test_activate_license_fail(self):
|
||||
self.sushy.get_manager.return_value.set_license.side_effect = (
|
||||
sushy.exceptions.SushyError)
|
||||
self.assertRaisesRegex(
|
||||
exception.IloError,
|
||||
'The Redfish controller failed to update the license',
|
||||
self.rf_client.activate_license, 'key')
|
||||
|
|
Loading…
Reference in New Issue