Lin Yang bedc76e7ed Add missing fields in RSD 2.2 telemetry
Change-Id: I3592e1b2bea87a11327c627913572777653c0c83
2019-02-06 16:48:20 -08:00

64 lines
2.2 KiB
Python

# Copyright 2018 Intel, Inc.
# 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.
from sushy.resources import base
from sushy import utils
from rsd_lib.resources.v2_2.telemetry import metric_definitions
from rsd_lib import utils as rsd_lib_utils
class StatusField(base.CompositeField):
state = base.Field('State')
health = base.Field('Health')
health_rollup = base.Field('HealthRollup')
class Telemetry(base.ResourceBase):
max_reports = base.Field('MaxReports', adapter=rsd_lib_utils.num_or_none)
"""If present, the value shall specify the maximum number of metric
collectors that can be supported by this service
"""
min_collection_interval = base.Field('MinCollectionInterval')
"""If present, the value shall be an ISO 8601 duration specifying the
minimum time between collections
"""
supported_collection_functions = base.Field('SupportedCollectionFunctions')
"""If present, the value shall define the function to apply over the
collection duration
"""
status = StatusField('Status')
"""The telemetry service status"""
def _get_metric_definitions_path(self):
"""Helper function to find the metric definitions path"""
return utils.get_sub_resource_path_by(self, 'MetricDefinitions')
@property
@utils.cache_it
def metric_definitions(self):
"""Property to provide reference to `MetricDefinitions` instance
It is calculated once the first time it is queried. On refresh,
this property is reset.
"""
return metric_definitions.MetricDefinitionsCollection(
self._conn, self._get_metric_definitions_path(),
redfish_version=self.redfish_version)