Add OEM Task extension

Added to get OEM JobType to determine if rebooting is done by iDRAC
for OEM RAID jobs.

Depends-On: https://review.opendev.org/c/openstack/sushy/+/800267
Change-Id: I1c83d59f1c99f0b70fbf4f5a5d71698b76d8e975
This commit is contained in:
Aija Jauntēva 2021-07-09 10:26:57 -04:00
parent be0b8450bc
commit 0a7249467b
7 changed files with 433 additions and 0 deletions

View File

@ -28,6 +28,8 @@ sushy.resources.manager.oems =
dell = sushy_oem_idrac.resources.manager.manager:get_extension
sushy.resources.system.oems =
dell = sushy_oem_idrac.resources.system.system:get_extension
sushy.resources.task.oems =
dell = sushy_oem_idrac.resources.taskservice.task:get_extension
[build_sphinx]
source-dir = doc/source

View File

@ -14,3 +14,4 @@
from sushy_oem_idrac.resources.manager.constants import * # noqa
from sushy_oem_idrac.resources.system.constants import * # noqa
from sushy_oem_idrac.resources.taskservice.constants import * # noqa

View File

@ -0,0 +1,177 @@
# Copyright (c) 2021 Dell Inc. or its subsidiaries.
#
# 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.
# Job state constants
JOB_STATE_COMPLETED = "Completed"
"""A job is in completed state"""
JOB_STATE_COMPLETED_ERRORS = "Completed with errors"
"""A job is in completed state with errors"""
JOB_STATE_DOWNLOADED = "Downloaded"
"""A job is in downloaded state"""
JOB_STATE_DOWNLOADING = "Downloading"
"""A job is in downloading state"""
JOB_STATE_FAILED = "Failed"
"""A job is in failed state"""
JOB_STATE_NEW = "New"
"""A job is in newly created state"""
JOB_STATE_PAUSED = "Paused"
"""A job is in paused state"""
JOB_STATE_PENDING_ACTIVATION = "Pending activation"
"""A job is in pending activation state"""
JOB_STATE_READY_EXECUTION = "Ready for execution"
"""A job is in ready for execution state"""
JOB_STATE_REBOOT_COMPLETED = "Reboot completed"
"""A job is in reboot completed state"""
JOB_STATE_REBOOT_FAILED = "Reboot failed"
"""A job is in reboot failed state"""
JOB_STATE_REBOOT_PENDING = "Reboot pending"
"""A job is in pending state for reboot"""
JOB_STATE_RUNNING = "Running"
"""A job is in running state"""
JOB_STATE_SCHEDULED = "Scheduled"
"""A job is in scheduled state"""
JOB_STATE_SCHEDULING = "Scheduling"
"""A job is in scheduling state"""
JOB_STATE_UNKNOWN = "Unknown"
"""A job is in unknown state"""
JOB_STATE_WAITING = "Waiting"
"""A job is in waiting state"""
# Job type constants
JOB_TYPE_BIOS_CONF = "BIOS configuration"
"""A BIOS configuration job"""
JOB_TYPE_EXPORT_CONF = "Export configuration"
"""A server configuration profile export job"""
JOB_TYPE_FC_CONF = "Fibre Channel configuration"
"""A Fibre Channel configuration job"""
JOB_TYPE_FACTORY_CONF_EXPORT = "Factory configuration export"
"""A factory configuration export job"""
JOB_TYPE_FIRMWARE_ROLLBACK = "Firmware rollback"
"""A firmware rollback job"""
JOB_TYPE_FIRMWARE_UPDATE = "Firmware update"
"""A firmware update job"""
JOB_TYPE_HW_INVENTORY_EXPORT = "Hardware inventory export"
"""A hardware inventory export job"""
JOB_TYPE_IMPORT_CONF = "Import configuration"
"""A server configuration profile import job"""
JOB_TYPE_INBAND_BIOS_CONF = "Inband BIOS configuration"
"""An inband BIOS configuration job"""
JOB_TYPE_LC_CONF = "LC configuration"
"""A lifecycle controller attribute configuration job"""
JOB_TYPE_LC_EXPORT = "LC export"
"""A lifecycle controller export job"""
JOB_TYPE_LC_LOG_EXPORT = "LC log export"
"""A lifecycle controller log export job"""
JOB_TYPE_LICENSE_EXPORT = "License export"
"""A license export job"""
JOB_TYPE_LICENSE_IMPORT = "License import"
"""A license import job"""
JOB_TYPE_MSG_REG_EXPORT = "Message registry export"
"""Export message registry report job"""
JOB_TYPE_NIC_CONF = "NIC configuration"
"""A NIC configuration job"""
JOB_TYPE_OS_DEPLOY = "OS deploy"
"""Operating System deploy job"""
JOB_TYPE_RAID_CONF = "RAID configuration"
"""A RAID configuration job"""
JOB_TYPE_RT_NO_REBOOT_CONF = "Real-time no reboot configuration"
"""A real time configuration job without reboot"""
JOB_TYPE_REBOOT_FORCE = "Reboot force"
"""A reboot job with forced shutdown"""
JOB_TYPE_REBOOT_NO_FORCE = "Reboot no force"
"""A graceful reboot job without forced shutdown"""
JOB_TYPE_REBOOT_POWER_CYCLE = "Reboot power cycle"
"""A power cycle job"""
JOB_TYPE_REMOTE_DIAG = "Remote diagnostics"
"""A remote diagnostics job"""
JOB_TYPE_REPO_UPDATE = "Repository update"
"""An update job from a repository"""
JOB_TYPE_SA_COL_EXP_HEALTH_DATA = "SA collect and export health data"
"""Support Assist collect and export health data job"""
JOB_TYPE_SA_COL_HEALTH_DATA = "SA collect health data"
"""Support Assist collect health data job"""
JOB_TYPE_SA_EXP_HEALTH_DATA = "SA export health data"
"""Support Assist export health data job"""
JOB_TYPE_SA_ISM = "SA expose iSM"
"""Support Assist expose iDRAC Service Module installer package to host job"""
JOB_TYPE_SA_REG = "SA registration"
"""Support Assist register iDRAC to Dell backend server job"""
JOB_TYPE_SEKM_REKEY = "SEKM rekey"
"""A Secure Enterprise Key Manager rekey job"""
JOB_TYPE_SEKM_STATUS_SET = "SEKM status set"
"""A Secure Enterprise Key Manager status set job"""
JOB_TYPE_SHUTDOWN = "Shutdown"
"""A shutdown job"""
JOB_TYPE_SYS_ERASE = "System erase"
"""A selective system erase job"""
JOB_TYPE_SYS_INFO_CONF = "System info configuration"
"""A system info configuration job"""
JOB_TYPE_THERMAL_HIST_EXP = "Thermal history export"
"""A thermal history export job"""
JOB_TYPE_UNKNOWN = "Unknown"
"""An unknown job"""
JOB_TYPE_IDRAC_CONF = "iDRAC configuration"
"""An iDRAC configuration job"""

View File

@ -0,0 +1,81 @@
# Copyright (c) 2021 Dell Inc. or its subsidiaries.
#
# 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.
from sushy import utils
from sushy_oem_idrac.resources.taskservice import constants as ts_cons
JOB_STATE_VALUE_MAP = {
"New": ts_cons.JOB_STATE_NEW,
"Scheduled": ts_cons.JOB_STATE_SCHEDULED,
"Running": ts_cons.JOB_STATE_RUNNING,
"Completed": ts_cons.JOB_STATE_COMPLETED,
"Downloading": ts_cons.JOB_STATE_DOWNLOADING,
"Downloaded": ts_cons.JOB_STATE_DOWNLOADED,
"Scheduling": ts_cons.JOB_STATE_SCHEDULING,
"ReadyForExecution": ts_cons.JOB_STATE_READY_EXECUTION,
"Waiting": ts_cons.JOB_STATE_WAITING,
"Paused": ts_cons.JOB_STATE_PAUSED,
"Failed": ts_cons.JOB_STATE_FAILED,
"CompletedWithErrors": ts_cons.JOB_STATE_COMPLETED_ERRORS,
"RebootPending": ts_cons.JOB_STATE_REBOOT_PENDING,
"RebootFailed": ts_cons.JOB_STATE_REBOOT_FAILED,
"RebootCompleted": ts_cons.JOB_STATE_REBOOT_COMPLETED,
"PendingActivation": ts_cons.JOB_STATE_PENDING_ACTIVATION,
"Unknown": ts_cons.JOB_STATE_UNKNOWN
}
JOB_STATE_VALUE_MAP_REV = utils.revert_dictionary(JOB_STATE_VALUE_MAP)
JOB_TYPE_VALUE_MAP = {
"FirmwareUpdate": ts_cons.JOB_TYPE_FIRMWARE_UPDATE,
"FirmwareRollback": ts_cons.JOB_TYPE_FIRMWARE_ROLLBACK,
"RepositoryUpdate": ts_cons.JOB_TYPE_REPO_UPDATE,
"RebootPowerCycle": ts_cons.JOB_TYPE_REBOOT_POWER_CYCLE,
"RebootForce": ts_cons.JOB_TYPE_REBOOT_FORCE,
"RebootNoForce": ts_cons.JOB_TYPE_REBOOT_NO_FORCE,
"Shutdown": ts_cons.JOB_TYPE_SHUTDOWN,
"RAIDConfiguration": ts_cons.JOB_TYPE_RAID_CONF,
"BIOSConfiguration": ts_cons.JOB_TYPE_BIOS_CONF,
"NICConfiguration": ts_cons.JOB_TYPE_NIC_CONF,
"FCConfiguration": ts_cons.JOB_TYPE_FC_CONF,
"iDRACConfiguration": ts_cons.JOB_TYPE_IDRAC_CONF,
"SystemInfoConfiguration": ts_cons.JOB_TYPE_SYS_INFO_CONF,
"InbandBIOSConfiguration": ts_cons.JOB_TYPE_INBAND_BIOS_CONF,
"ExportConfiguration": ts_cons.JOB_TYPE_EXPORT_CONF,
"ImportConfiguration": ts_cons.JOB_TYPE_IMPORT_CONF,
"RemoteDiagnostics": ts_cons.JOB_TYPE_REMOTE_DIAG,
"RealTimeNoRebootConfiguration": ts_cons.JOB_TYPE_RT_NO_REBOOT_CONF,
"LCLogExport": ts_cons.JOB_TYPE_LC_LOG_EXPORT,
"HardwareInventoryExport": ts_cons.JOB_TYPE_HW_INVENTORY_EXPORT,
"FactoryConfigurationExport": ts_cons.JOB_TYPE_FACTORY_CONF_EXPORT,
"LicenseImport": ts_cons.JOB_TYPE_LICENSE_IMPORT,
"LicenseExport": ts_cons.JOB_TYPE_LICENSE_EXPORT,
"ThermalHistoryExport": ts_cons.JOB_TYPE_THERMAL_HIST_EXP,
"LCConfig": ts_cons.JOB_TYPE_LC_CONF,
"LCExport": ts_cons.JOB_TYPE_LC_EXPORT,
"SACollectHealthData": ts_cons.JOB_TYPE_SA_COL_HEALTH_DATA,
"SAExportHealthData": ts_cons.JOB_TYPE_SA_EXP_HEALTH_DATA,
"SACollectExportHealthData": ts_cons.JOB_TYPE_SA_COL_EXP_HEALTH_DATA,
"SAExposeISM": ts_cons.JOB_TYPE_SA_ISM,
"SARegistration": ts_cons.JOB_TYPE_SA_REG,
"SystemErase": ts_cons.JOB_TYPE_SYS_ERASE,
"MessageRegistryExport": ts_cons.JOB_TYPE_MSG_REG_EXPORT,
"OSDeploy": ts_cons.JOB_TYPE_OS_DEPLOY,
"SEKMRekey": ts_cons.JOB_TYPE_SEKM_REKEY,
"SEKMStatusSet": ts_cons.JOB_TYPE_SEKM_STATUS_SET,
"Unknown": ts_cons.JOB_TYPE_UNKNOWN
}
JOB_TYPE_VALUE_MAP_REV = utils.revert_dictionary(JOB_TYPE_VALUE_MAP)

View File

@ -0,0 +1,73 @@
# Copyright (c) 2021 Dell Inc. or its subsidiaries.
#
# 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 logging
from sushy.resources import base
from sushy.resources.oem import base as oem_base
from sushy_oem_idrac.resources.taskservice import mappings as ts_maps
LOG = logging.getLogger(__name__)
class DellTaskExtension(oem_base.OEMResourceBase):
"""Dell OEM extension for DellJob type"""
identity = base.Field('Id', required=True)
name = base.Field('Name', required=True)
description = base.Field('Description')
completion_time = base.Field('CompletionTime')
"""Job completion time"""
end_time = base.Field('EndTime')
"""End time of job
Timestamp until when the service will wait for a job to complete.
If a job does not complete within this time, it is killed and marked
as failed. TIME_NA is a default value and implies EndTime is not
applicable.
"""
job_state = base.MappedField('JobState', ts_maps.JOB_STATE_VALUE_MAP)
"""Job state"""
job_type = base.MappedField('JobType', ts_maps.JOB_TYPE_VALUE_MAP)
"""Job type"""
message = base.Field('Message')
"""The status message for job"""
message_args = base.Field('MessageArgs')
"""Array of message arguments for message field"""
message_id = base.Field('MessageId')
"""Message id for job"""
percent_complete = base.Field('PercentComplete', adapter=int)
"""The percentage completion of job"""
start_time = base.Field('StartTime')
"""Scheduled start time of job
String that will contain a timestamp in Edm.DateTime format.
TIME_NOW is a default value and implies apply pending configuration
now.
"""
def get_extension(*args, **kwargs):
return DellTaskExtension

View File

@ -0,0 +1,38 @@
{
"@odata.context": "/redfish/v1/$metadata#Task.Task",
"@odata.id": "/redfish/v1/TaskService/Tasks/JID_257309938313",
"@odata.type": "#Task.v1_4_3.Task",
"Description": "Server Configuration and other Tasks running on iDRAC are listed here",
"Id": "JID_257309938313",
"Messages": [
{
"Message": "Task successfully scheduled.",
"MessageArgs": [],
"MessageArgs@odata.count": 0,
"MessageId": "IDRAC.2.5.JCP001"
}
],
"Messages@odata.count": 1,
"Name": "Configure: RAID.Integrated.1-1",
"Oem": {
"Dell": {
"@odata.type": "#DellJob.v1_1_0.DellJob",
"CompletionTime": null,
"Description": "Job Instance",
"EndTime": "TIME_NA",
"Id": "JID_257309938313",
"JobState": "Scheduled",
"JobType": "RAIDConfiguration",
"Message": "Task successfully scheduled.",
"MessageArgs": [],
"MessageId": "IDRAC.2.5.JCP001",
"Name": "Configure: RAID.Integrated.1-1",
"PercentComplete": 0,
"StartTime": "TIME_NOW",
"TargetSettingsURI": null
}
},
"PercentComplete": 0,
"TaskState": "Starting",
"TaskStatus": "OK"
}

View File

@ -0,0 +1,61 @@
# Copyright (c) 2021 Dell Inc. or its subsidiaries.
#
# 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
from unittest import mock
from oslotest.base import BaseTestCase
from sushy.resources.taskservice import task as sushy_task
from sushy_oem_idrac.resources.taskservice import constants as ts_cons
from sushy_oem_idrac.resources.taskservice import task
class TaskTestCase(BaseTestCase):
def setUp(self):
super(TaskTestCase, self).setUp()
self.conn = mock.Mock()
with open('sushy_oem_idrac/tests/unit/json_samples/'
'task.json') as f:
mock_response = self.conn.get.return_value
mock_response.json.return_value = json.load(f)
mock_response.status_code = 200
self.task = sushy_task.Task(
self.conn,
'/redfish/v1/TaskService/Tasks/JID_257309938313')
self.oem_task = task.DellTaskExtension(
self.conn,
'/redfish/v1/TaskService/Tasks/JID_257309938313')
self.oem_task = self.oem_task.set_parent_resource(
self.task, 'Dell')
def test_parse_attributes(self):
self.assertEqual('JID_257309938313', self.oem_task.identity)
self.assertEqual('Configure: RAID.Integrated.1-1',
self.oem_task.name)
self.assertEqual('Job Instance', self.oem_task.description)
self.assertIsNone(self.oem_task.completion_time)
self.assertEqual('TIME_NA', self.oem_task.end_time)
self.assertEqual(ts_cons.JOB_STATE_SCHEDULED,
self.oem_task.job_state)
self.assertEqual(ts_cons.JOB_TYPE_RAID_CONF,
self.oem_task.job_type)
self.assertEqual('Task successfully scheduled.',
self.oem_task.message)
self.assertEqual([], self.oem_task.message_args)
self.assertEqual('IDRAC.2.5.JCP001', self.oem_task.message_id)
self.assertEqual(0, self.oem_task.percent_complete)
self.assertEqual('TIME_NOW', self.oem_task.start_time)