Move common fields to common directory

Change-Id: I3139d562caf82327af71d9dca8af76cdf1c543b4
This commit is contained in:
Lin Yang 2019-03-22 11:20:01 -07:00
parent ad7026fd89
commit c53072527b
8 changed files with 109 additions and 87 deletions

View File

@ -16,7 +16,6 @@
import copy import copy
from sushy.resources import base from sushy.resources import base
from sushy import utils
from rsd_lib import utils as rsd_lib_utils from rsd_lib import utils as rsd_lib_utils
@ -92,46 +91,6 @@ class IdentifierField(base.CompositeField):
"""This represents the format of the DurableName property.""" """This represents the format of the DurableName property."""
class RedundancyCollectionField(ReferenceableMemberField):
"""Redundancy field
This is the redundancy definition to be used in other resource schemas.
"""
name = base.Field("Name")
"""The name of the resource or array element."""
mode = base.Field("Mode")
"""This is the redundancy mode of the group."""
max_num_supported = base.Field(
"MaxNumSupported", adapter=rsd_lib_utils.num_or_none
)
"""This is the maximum number of members allowable for this particular
redundancy group.
"""
min_num_needed = base.Field(
"MinNumNeeded", adapter=rsd_lib_utils.num_or_none
)
"""This is the minumum number of members needed for this group to be
redundant.
"""
status = StatusField("Status")
"""This indicates the known state of the resource, such as if it is
enabled.
"""
redundancy_set = base.Field(
"RedundancySet", adapter=utils.get_members_identities
)
"""Contains any ids that represent components of this redundancy set."""
redundancy_enabled = base.Field("RedundancyEnabled", adapter=bool)
"""This indicates whether redundancy is enabled."""
class ResourceBase(base.ResourceBase): class ResourceBase(base.ResourceBase):
identity = base.Field("Id", required=True) identity = base.Field("Id", required=True)

View File

@ -17,6 +17,7 @@ from sushy.resources import base
from sushy import utils from sushy import utils
from rsd_lib import base as rsd_lib_base from rsd_lib import base as rsd_lib_base
from rsd_lib.resources.v2_1.common import redundancy
from rsd_lib import utils as rsd_lib_utils from rsd_lib import utils as rsd_lib_utils
@ -302,7 +303,7 @@ class PowerSupplyCollectionField(rsd_lib_base.ReferenceableMemberField):
) )
"""The ID(s) of the resources associated with this Power Limit""" """The ID(s) of the resources associated with this Power Limit"""
redundancy = rsd_lib_base.RedundancyCollectionField("Redundancy") redundancy = redundancy.RedundancyCollectionField("Redundancy")
"""This structure is used to show redundancy for power supplies. The """This structure is used to show redundancy for power supplies. The
Component ids will reference the members of the redundancy groups. Component ids will reference the members of the redundancy groups.
""" """
@ -332,6 +333,6 @@ class Power(rsd_lib_base.ResourceBase):
power_supplies = PowerSupplyCollectionField("PowerSupplies") power_supplies = PowerSupplyCollectionField("PowerSupplies")
"""Details of the power supplies associated with this system or device""" """Details of the power supplies associated with this system or device"""
redundancy = rsd_lib_base.RedundancyCollectionField("Redundancy") redundancy = redundancy.RedundancyCollectionField("Redundancy")
"""Redundancy information for the power subsystem of this system or device """Redundancy information for the power subsystem of this system or device
""" """

View File

@ -16,28 +16,10 @@
from sushy.resources import base from sushy.resources import base
from rsd_lib import base as rsd_lib_base from rsd_lib import base as rsd_lib_base
from rsd_lib.resources.v2_1.common import rack_location
from rsd_lib import utils as rsd_lib_utils from rsd_lib import utils as rsd_lib_utils
class RackLocationField(base.CompositeField):
rack_units = base.Field("RackUnits")
"""Indicates the rack unit type"""
xlocation = base.Field("XLocation", adapter=rsd_lib_utils.num_or_none)
"""The horizontal location within uLocation, from left to right
(1.. MAXIMUM) 0 indicate not available
"""
ulocation = base.Field("ULocation", adapter=rsd_lib_utils.num_or_none)
"""The index of the top-most U of the component, from top to bottom
(1.. MAXIMUM) 0 indicate not available
"""
uheight = base.Field("UHeight", adapter=rsd_lib_utils.num_or_none)
"""The height of managed zone, e.g. 8 for 8U, 16 for 16U"""
class PowerSupplyCollectionField(rsd_lib_base.ReferenceableMemberField): class PowerSupplyCollectionField(rsd_lib_base.ReferenceableMemberField):
name = base.Field("Name") name = base.Field("Name")
@ -71,7 +53,7 @@ class PowerSupplyCollectionField(rsd_lib_base.ReferenceableMemberField):
status = rsd_lib_base.StatusField("Status") status = rsd_lib_base.StatusField("Status")
"""The Power supply status""" """The Power supply status"""
rack_location = RackLocationField("RackLocation") rack_location = rack_location.RackLocationField("RackLocation")
"""The PowerZone physical location""" """The PowerZone physical location"""
@ -80,7 +62,7 @@ class PowerZone(rsd_lib_base.ResourceBase):
status = rsd_lib_base.StatusField("Status") status = rsd_lib_base.StatusField("Status")
"""The PowerZone status""" """The PowerZone status"""
rack_location = RackLocationField("RackLocation") rack_location = rack_location.RackLocationField("RackLocation")
"""The PowerZone physical location""" """The PowerZone physical location"""
max_psus_supported = base.Field( max_psus_supported = base.Field(

View File

@ -17,6 +17,7 @@ from sushy.resources import base
from sushy import utils from sushy import utils
from rsd_lib import base as rsd_lib_base from rsd_lib import base as rsd_lib_base
from rsd_lib.resources.v2_1.common import redundancy
from rsd_lib import utils as rsd_lib_utils from rsd_lib import utils as rsd_lib_utils
@ -81,7 +82,7 @@ class FanCollectionField(rsd_lib_base.ReferenceableMemberField):
) )
"""The ID(s) of the resources serviced with this fan""" """The ID(s) of the resources serviced with this fan"""
redundancy = rsd_lib_base.RedundancyCollectionField("Redundancy") redundancy = redundancy.RedundancyCollectionField("Redundancy")
"""This structure is used to show redundancy for fans. The Component ids """This structure is used to show redundancy for fans. The Component ids
will reference the members of the redundancy groups. will reference the members of the redundancy groups.
""" """
@ -184,7 +185,7 @@ class Thermal(rsd_lib_base.ResourceBase):
fans = FanCollectionField("Fans") fans = FanCollectionField("Fans")
"""This is the definition for fans.""" """This is the definition for fans."""
redundancy = rsd_lib_base.RedundancyCollectionField("Redundancy") redundancy = redundancy.RedundancyCollectionField("Redundancy")
"""This structure is used to show redundancy for fans. The Component ids """This structure is used to show redundancy for fans. The Component ids
will reference the members of the redundancy groups. will reference the members of the redundancy groups.
""" """

View File

@ -16,28 +16,10 @@
from sushy.resources import base from sushy.resources import base
from rsd_lib import base as rsd_lib_base from rsd_lib import base as rsd_lib_base
from rsd_lib.resources.v2_1.common import rack_location
from rsd_lib import utils as rsd_lib_utils from rsd_lib import utils as rsd_lib_utils
class RackLocationField(base.CompositeField):
rack_units = base.Field("RackUnits")
"""Indicates the rack unit type"""
xlocation = base.Field("XLocation", adapter=rsd_lib_utils.num_or_none)
"""The horizontal location within uLocation, from left to right
(1.. MAXIMUM) 0 indicate not available
"""
ulocation = base.Field("ULocation", adapter=rsd_lib_utils.num_or_none)
"""The index of the top-most U of the component, from top to bottom
(1.. MAXIMUM) 0 indicate not available
"""
uheight = base.Field("UHeight", adapter=rsd_lib_utils.num_or_none)
"""The height of managed zone, e.g. 8 for 8U, 16 for 16U"""
class TemperatureSensorCollectionField(rsd_lib_base.ReferenceableMemberField): class TemperatureSensorCollectionField(rsd_lib_base.ReferenceableMemberField):
name = base.Field("Name") name = base.Field("Name")
@ -75,7 +57,7 @@ class FanCollectionField(rsd_lib_base.ReferenceableMemberField):
status = rsd_lib_base.StatusField("Status") status = rsd_lib_base.StatusField("Status")
"""The Fan status""" """The Fan status"""
rack_location = RackLocationField("RackLocation") rack_location = rack_location.RackLocationField("RackLocation")
"""The Fan physical location""" """The Fan physical location"""
@ -84,7 +66,7 @@ class ThermalZone(rsd_lib_base.ResourceBase):
status = rsd_lib_base.StatusField("Status") status = rsd_lib_base.StatusField("Status")
"""The ThermalZone status""" """The ThermalZone status"""
rack_location = RackLocationField("RackLocation") rack_location = rack_location.RackLocationField("RackLocation")
"""The ThermalZone physical location""" """The ThermalZone physical location"""
presence = base.Field("Presence") presence = base.Field("Presence")

View File

@ -0,0 +1,37 @@
# 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 rsd_lib import utils as rsd_lib_utils
class RackLocationField(base.CompositeField):
rack_units = base.Field("RackUnits")
"""Indicates the rack unit type"""
xlocation = base.Field("XLocation", adapter=rsd_lib_utils.num_or_none)
"""The horizontal location within uLocation, from left to right
(1.. MAXIMUM) 0 indicate not available
"""
ulocation = base.Field("ULocation", adapter=rsd_lib_utils.num_or_none)
"""The index of the top-most U of the component, from top to bottom
(1.. MAXIMUM) 0 indicate not available
"""
uheight = base.Field("UHeight", adapter=rsd_lib_utils.num_or_none)
"""The height of managed zone, e.g. 8 for 8U, 16 for 16U"""

View File

@ -0,0 +1,60 @@
# 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 import base as rsd_lib_base
from rsd_lib import utils as rsd_lib_utils
class RedundancyCollectionField(rsd_lib_base.ReferenceableMemberField):
"""Redundancy field
This is the redundancy definition to be used in other resource schemas.
"""
name = base.Field("Name")
"""The name of the resource or array element."""
mode = base.Field("Mode")
"""This is the redundancy mode of the group."""
max_num_supported = base.Field(
"MaxNumSupported", adapter=rsd_lib_utils.num_or_none
)
"""This is the maximum number of members allowable for this particular
redundancy group.
"""
min_num_needed = base.Field(
"MinNumNeeded", adapter=rsd_lib_utils.num_or_none
)
"""This is the minumum number of members needed for this group to be
redundant.
"""
status = rsd_lib_base.StatusField("Status")
"""This indicates the known state of the resource, such as if it is
enabled.
"""
redundancy_set = base.Field(
"RedundancySet", adapter=utils.get_members_identities
)
"""Contains any ids that represent components of this redundancy set."""
redundancy_enabled = base.Field("RedundancyEnabled", adapter=bool)
"""This indicates whether redundancy is enabled."""