Add missing attributes in metric definition resource
Change-Id: If6cf07482b1c4b5ab331e553d41b434b79134ed0
This commit is contained in:
parent
a19db87420
commit
6a1041db3b
@ -15,6 +15,27 @@
|
|||||||
|
|
||||||
from sushy.resources import base
|
from sushy.resources import base
|
||||||
|
|
||||||
|
from rsd_lib import utils as rsd_lib_utils
|
||||||
|
|
||||||
|
|
||||||
|
class WildcardsField(base.ListField):
|
||||||
|
name = base.Field("Name")
|
||||||
|
"""This property shall contain a name for a Wildcard for a key"""
|
||||||
|
|
||||||
|
keys = base.Field("Keys")
|
||||||
|
"""If the value is an empty string, then the server shall substitute every
|
||||||
|
current key. Each not empty key value shall be substituted for the
|
||||||
|
wildcard
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class CalculationParameterField(base.ListField):
|
||||||
|
source_metric = base.Field("SourceMetric")
|
||||||
|
"""The metric property used as the input into the calculation"""
|
||||||
|
|
||||||
|
result_metric = base.Field("ResultMetric")
|
||||||
|
"""The metric property used to store the results of the calculation"""
|
||||||
|
|
||||||
|
|
||||||
class MetricDefinition(base.ResourceBase):
|
class MetricDefinition(base.ResourceBase):
|
||||||
|
|
||||||
@ -28,64 +49,88 @@ class MetricDefinition(base.ResourceBase):
|
|||||||
"""The metric definition description"""
|
"""The metric definition description"""
|
||||||
|
|
||||||
sensor_type = base.Field('SensorType')
|
sensor_type = base.Field('SensorType')
|
||||||
"""The type of sensor"""
|
"""This property represents the type of sensor that this resource
|
||||||
|
represents
|
||||||
|
"""
|
||||||
|
|
||||||
metric_type = base.Field('MetricType')
|
metric_type = base.Field('MetricType')
|
||||||
"""The type of metric"""
|
"""Specifies the type of metric provided"""
|
||||||
|
|
||||||
implementation = base.Field('Implementation')
|
implementation = base.Field('Implementation')
|
||||||
"""The implementation type of sensor"""
|
"""The value of this property shall designate how the sensor is implemented
|
||||||
|
"""
|
||||||
|
|
||||||
sensing_interval = base.Field('SensingInterval')
|
sensing_interval = base.Field('SensingInterval')
|
||||||
"""The sensing interval"""
|
"""This property specifies the time interval between when a metric or
|
||||||
|
sensor reading is updated
|
||||||
|
"""
|
||||||
|
|
||||||
physical_context = base.Field('PhysicalContext')
|
physical_context = base.Field('PhysicalContext')
|
||||||
"""The physical context of this metric definition"""
|
"""Specifies the physical context of the sensor"""
|
||||||
|
|
||||||
units = base.Field('Units')
|
units = base.Field('Units')
|
||||||
"""The units of the sensor"""
|
"""Units of measure for this metric"""
|
||||||
|
|
||||||
min_reading_range = base.Field('MinReadingRange')
|
min_reading_range = base.Field(
|
||||||
"""The min reading range of this sensor"""
|
'MinReadingRange', adapter=rsd_lib_utils.num_or_none)
|
||||||
|
"""Minimum value for Reading"""
|
||||||
|
|
||||||
max_reading_range = base.Field('MaxReadingRange')
|
max_reading_range = base.Field(
|
||||||
"""The max reading range of this sensor"""
|
'MaxReadingRange', adapter=rsd_lib_utils.num_or_none)
|
||||||
|
"""Maximum value for Reading"""
|
||||||
|
|
||||||
discrete_values = base.Field('DiscreteValues')
|
discrete_values = base.Field('DiscreteValues')
|
||||||
"""The allowed discrete values"""
|
"""This array property specifies possible values of a discrete metric"""
|
||||||
|
|
||||||
precision = base.Field('Precision')
|
precision = base.Field('Precision', adapter=rsd_lib_utils.num_or_none)
|
||||||
"""The precision of the sensor"""
|
"""Number of significant digits in the Reading described by
|
||||||
|
MetricProperties field
|
||||||
|
"""
|
||||||
|
|
||||||
calibration = base.Field('Calibration')
|
calibration = base.Field('Calibration', adapter=rsd_lib_utils.num_or_none)
|
||||||
"""The calibration of the sensor"""
|
"""Specifies the calibration offset added to the Reading to obtain an
|
||||||
|
accurate value
|
||||||
|
"""
|
||||||
|
|
||||||
isLinear = base.Field('IsLinear', adapter=bool)
|
isLinear = base.Field('IsLinear', adapter=bool)
|
||||||
"""The boolean indicate this sensor is linear or not"""
|
"""Indicates linear or non-linear values"""
|
||||||
|
|
||||||
calculable = base.Field('Calculable', adapter=bool)
|
calculable = base.Field('Calculable')
|
||||||
"""The variable indicate this sensor is calculable or not"""
|
"""The value shall define the caculatability of this metric"""
|
||||||
|
|
||||||
data_type = base.Field('DataType')
|
data_type = base.Field('DataType')
|
||||||
"""The type of the sensor data"""
|
"""The data type of the corresponding metric values"""
|
||||||
|
|
||||||
accuracy = base.Field('Accuracy')
|
accuracy = base.Field('Accuracy', adapter=rsd_lib_utils.num_or_none)
|
||||||
"""The accuracy of the sensor"""
|
"""Estimated percent error of measured vs. actual values"""
|
||||||
|
|
||||||
time_stamp_accuracy = base.Field('TimeStampAccuracy')
|
time_stamp_accuracy = base.Field('TimeStampAccuracy')
|
||||||
"""The time stamp accuracy of the sensor"""
|
"""Accuracy of the timestamp"""
|
||||||
|
|
||||||
calculation_time_interval = base.Field('CalculationTimeInterval')
|
calculation_time_interval = base.Field('CalculationTimeInterval')
|
||||||
"""The calculation time interval of the sensor"""
|
"""This property specifies the time interval over which a calculated
|
||||||
|
metric algorithm is performed
|
||||||
|
"""
|
||||||
|
|
||||||
calculation_algorithm = base.Field('CalculationAlgorithm')
|
calculation_algorithm = base.Field('CalculationAlgorithm')
|
||||||
"""The calculation algorithm of the sensor"""
|
"""This property specifies the calculation which is performed on a source
|
||||||
|
metric to obtain the metric being defined
|
||||||
|
"""
|
||||||
|
|
||||||
calculation_parameters = base.Field('CalculationParameters')
|
calculation_parameters = CalculationParameterField('CalculationParameters')
|
||||||
"""The calculation parameters of the sensor"""
|
"""Specifies the resource properties (metric) which are characterized by
|
||||||
|
this definition
|
||||||
|
"""
|
||||||
|
|
||||||
wildcards = base.Field('Wildcards')
|
wildcards = WildcardsField("Wildcards")
|
||||||
"""The wildcards of the sensor"""
|
"""The property shall contain an array of wildcards and their replacements
|
||||||
|
strings, which are to appliced to the MetricProperties array property
|
||||||
|
"""
|
||||||
|
|
||||||
|
metric_properties = base.Field('MetricProperties')
|
||||||
|
"""A collection of URI for the properties on which this metric definition
|
||||||
|
is defined
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class MetricDefinitionCollection(base.ResourceCollectionBase):
|
class MetricDefinitionCollection(base.ResourceCollectionBase):
|
||||||
|
@ -66,7 +66,7 @@ class MetricDefinitionTestCase(testtools.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
True, self.metric_definition_inst.isLinear)
|
True, self.metric_definition_inst.isLinear)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False, self.metric_definition_inst.calculable)
|
None, self.metric_definition_inst.calculable)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
None, self.metric_definition_inst.data_type)
|
None, self.metric_definition_inst.data_type)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -184,7 +184,7 @@ class MetricDefinitionsCollectionTestCase(testtools.TestCase):
|
|||||||
super(MetricDefinitionsCollectionTestCase, self).setUp()
|
super(MetricDefinitionsCollectionTestCase, self).setUp()
|
||||||
self.conn = mock.Mock()
|
self.conn = mock.Mock()
|
||||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
'metric_definitions.json', 'r') as f:
|
'metric_definition_collection.json', 'r') as f:
|
||||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
self.metric_def_col = metric_definition.MetricDefinitionCollection(
|
self.metric_def_col = metric_definition.MetricDefinitionCollection(
|
||||||
self.conn, '/redfish/v1/TelemetryService/MetricDefinitions',
|
self.conn, '/redfish/v1/TelemetryService/MetricDefinitions',
|
||||||
|
@ -62,7 +62,7 @@ class TelemetryTestCase(testtools.TestCase):
|
|||||||
# | GIVEN |
|
# | GIVEN |
|
||||||
self.conn.get.return_value.json.reset_mock()
|
self.conn.get.return_value.json.reset_mock()
|
||||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
'metric_definitions.json', 'r') as f:
|
'metric_definition_collection.json', 'r') as f:
|
||||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
# | WHEN |
|
# | WHEN |
|
||||||
actual_metric_definitions = self.telemetry_inst.metric_definitions
|
actual_metric_definitions = self.telemetry_inst.metric_definitions
|
||||||
@ -82,7 +82,7 @@ class TelemetryTestCase(testtools.TestCase):
|
|||||||
def test_metrics_definitions_on_refresh(self):
|
def test_metrics_definitions_on_refresh(self):
|
||||||
# | GIVEN |
|
# | GIVEN |
|
||||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
'metric_definitions.json', 'r') as f:
|
'metric_definition_collection.json', 'r') as f:
|
||||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
# | WHEN & THEN |
|
# | WHEN & THEN |
|
||||||
self.assertIsInstance(self.telemetry_inst.metric_definitions,
|
self.assertIsInstance(self.telemetry_inst.metric_definitions,
|
||||||
@ -98,7 +98,7 @@ class TelemetryTestCase(testtools.TestCase):
|
|||||||
|
|
||||||
# | GIVEN |
|
# | GIVEN |
|
||||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
'metric_definitions.json', 'r') as f:
|
'metric_definition_collection.json', 'r') as f:
|
||||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
# | WHEN & THEN |
|
# | WHEN & THEN |
|
||||||
self.assertIsInstance(self.telemetry_inst.metric_definitions,
|
self.assertIsInstance(self.telemetry_inst.metric_definitions,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user