[PTP dual NIC config] New tables in sysinv dbase

This change introduces the following new tables in the sysinv database:
- PTP instances: ptp4l, phc2sys and ts2phc services running in hosts;
- PTP interfaces: association(s) between an interface and PTP instances;
- PTP parameters: configuration of PTP for an instance or associated
  interface; in previous versions, such configuration was stored in
  service_parameter table in <name-value> pairs.

Test Plan:

PASS: New tables created during population phase of bootstrap install.

Regression:

PASS: Existing unit tests still running with former PTP implementation.

Story: 2009248
Task: 43487
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
Change-Id: Ic31792240304d1df19508b08d256279c06b4253e
This commit is contained in:
Douglas Henrique Koerich 2021-10-01 07:41:05 -03:00
parent a550b9b1bb
commit 7afdb4a6be
10 changed files with 825 additions and 0 deletions

View File

@ -452,6 +452,18 @@ class PTPAlreadyExists(Conflict):
message = _("A PTP with UUID %(uuid)s already exists.")
class PtpInstanceAlreadyExists(Conflict):
message = _("A PTP instance with UUID %(uuid)s already exists.")
class PtpInterfaceAlreadyExists(Conflict):
message = _("A PTP interface with UUID %(uuid)s already exists.")
class PtpParameterAlreadyExists(Conflict):
message = _("A PTP parameter with UUID %(uuid)s already exists.")
class PMAlreadyExists(Conflict):
message = _("A PM with UUID %(uuid)s already exists.")
@ -580,6 +592,18 @@ class PTPNotFound(NotFound):
message = _("No PTP with id %(uuid)s found.")
class PtpInstanceNotFound(NotFound):
message = _("No PTP instance with id %(uuid)s found.")
class PtpInterfaceNotFound(NotFound):
message = _("No PTP interface with id %(uuid)s found.")
class PtpParameterNotFound(NotFound):
message = _("No PTP parameter with id %(uuid)s found.")
class DiskNotFound(NotFound):
message = _("No disk with id %(disk_id)s")

View File

@ -1961,6 +1961,236 @@ class Connection(object):
:param system_id: The value to fill system_id with
"""
@abc.abstractmethod
def ptp_instance_create(self, values):
"""Creates a new PTP service instance for an ihost.
:param values: A dict containing several items used to identify
and track the PTP instance settings.
{
'name': 'default',
'service': 'ptp4l',
'host': 'controller-0'
}
:returns: A PTP service instance.
"""
@abc.abstractmethod
def ptp_instance_get(self, ptp_instance_id):
"""Returns a PTP service instance.
:param ptp_instance_id: The id or uuid of a PTP instance.
:returns: A PTP service instance.
"""
@abc.abstractmethod
def ptp_instance_get_one(self, name=None, service=None):
"""Returns exactly one PTP service instance.
:param name: name of PTP instance given by user.
:param service: service of PTP instance.
:returns: A PTP service instance.
"""
@abc.abstractmethod
def ptp_instances_get_list(self, limit=None, marker=None, sort_key=None,
sort_dir=None):
"""Returns a list of PTP service instances.
:param limit: Maximum number of PTP instances to return.
:param marker: The last item of the previous page; we return the next
result set.
:param sort_key: Attribute by which results should be sorted.
:param sort_dir: direction in which results should be sorted.
(asc, desc)
:returns: A list of PTP instances.
"""
@abc.abstractmethod
def ptp_instances_get_by_ihost(self, ihost_id, limit=None, marker=None,
sort_key=None, sort_dir=None):
"""Returns a list of the PTP instances for a given ihost.
:param ihost_id: The id or uuid of an ihost.
:param limit: Maximum number of PTP instances to return.
:param marker: The last item of the previous page; we return the next
result set.
:param sort_key: Attribute by which results should be sorted
:param sort_dir: direction in which results should be sorted
(asc, desc)
:returns: A list of PTP instances.
"""
@abc.abstractmethod
def ptp_instance_update(self, ptp_instance_id, values):
"""Updates properties of a PTP instance.
:param ptp_instance_id: The id or uuid of a PTP instance.
:param values: May be a partial dict containing the items to update
{
'host': 'worker-0'
}
:returns: A PTP service instance.
"""
@abc.abstractmethod
def ptp_instance_destroy(self, ptp_instance_id):
"""Destroys a PTP service instance.
:param ptp_instance_id: The id or uuid of a PTP instance.
"""
@abc.abstractmethod
def ptp_instance_destroy_by_name(self, name):
"""Destroys a PTP service instance based on name.
:param name: The name given for a PTP instance.
"""
@abc.abstractmethod
def ptp_interface_create(self, values):
"""Creates a new PTP association between an interface
and a PTP instance.
:param values: A dict containing several items used to identify
and track the PTP association to an interface.
{
'interface_id': 101,
'ptp_instance_id': 10,
}
:returns: A PTP interface association.
"""
@abc.abstractmethod
def ptp_interface_get(self, ptp_interface_id):
"""Returns a PTP interface association.
:param ptp_interface_id: The id or uuid of a PTP interface.
:returns: A PTP interface association.
"""
@abc.abstractmethod
def ptp_interface_get_one(self):
"""Returns exactly one PTP interface association.
:returns: A PTP interface association.
"""
@abc.abstractmethod
def ptp_interfaces_get_list(self, limit=None, marker=None, sort_key=None,
sort_dir=None):
"""Returns a list of PTP interface associations.
:param limit: Maximum number of PTP interfaces to return.
:param marker: The last item of the previous page; we return the next
result set.
:param sort_key: Attribute by which results should be sorted.
:param sort_dir: direction in which results should be sorted.
(asc, desc)
:returns: A list of PTP interface associations.
"""
@abc.abstractmethod
def ptp_interfaces_get_by_interface(self, interface_id, limit=None,
marker=None, sort_key=None,
sort_dir=None):
"""Returns a list of the PTP associations for a given interface.
:param interface_id: The id or uuid of an interface.
:param limit: Maximum number of PTP associations to return.
:param marker: The last item of the previous page; we return the next
result set.
:param sort_key: Attribute by which results should be sorted
:param sort_dir: direction in which results should be sorted
(asc, desc)
:returns: A list of PTP associations (instances) for the interface.
"""
@abc.abstractmethod
def ptp_interface_destroy(self, ptp_interface_id):
"""Destroys a PTP interface association.
:param ptp_interface_id: The id or uuid of a PTP interface association.
"""
@abc.abstractmethod
def ptp_parameter_create(self, values):
"""Creates a new PTP parameter.
:param values: A dict containing several items used to identify
and track the PTP parameter.
{
'name': 'domain',
'value': '24',
'foreign_uuid': 'c2abca03-2f33-413e-b60d-85133a4a37b6'
}
:returns: A PTP parameter.
"""
@abc.abstractmethod
def ptp_parameter_get(self, ptp_parameter_id):
"""Returns a PTP parameter.
:param ptp_parameter_id: The id or uuid of a PTP parameter.
:returns: A PTP parameter.
"""
@abc.abstractmethod
def ptp_parameter_get_one(self, name=None):
"""Returns exactly one PTP parameter.
:param name: name of PTP parameter.
:returns: A PTP parameter.
"""
@abc.abstractmethod
def ptp_parameters_get_list(self, limit=None, marker=None, sort_key=None,
sort_dir=None):
"""Returns a list of PTP parameters.
:param limit: Maximum number of PTP parameters to return.
:param marker: The last item of the previous page; we return the next
result set.
:param sort_key: Attribute by which results should be sorted.
:param sort_dir: direction in which results should be sorted.
(asc, desc)
:returns: A list of PTP parameters.
"""
@abc.abstractmethod
def ptp_parameters_get_by_foreign_uuid(self, uuid, limit=None, marker=None,
sort_key=None, sort_dir=None):
"""Returns a list of PTP parameters for a given foreign UUID.
:param uuid: The uuid of a PTP instance or PTP interface association.
:param limit: Maximum number of PTP parameters to return.
:param marker: The last item of the previous page; we return the next
result set.
:param sort_key: Attribute by which results should be sorted
:param sort_dir: direction in which results should be sorted
(asc, desc)
:returns: A list of PTP parameters.
"""
@abc.abstractmethod
def ptp_parameter_update(self, ptp_parameter_id, values):
"""Updates properties of a PTP parameter.
:param ptp_parameter_id: The id or uuid of a PTP parameter.
:param values: May be a partial dict containing the items to update
{
'value': '12' # new value for 'domain'
}
:returns: A PTP parameter.
"""
@abc.abstractmethod
def ptp_parameter_destroy(self, ptp_parameter_id):
"""Destroys a PTP parameter.
:param ptp_parameter_id: The id or uuid of a PTP parameter.
"""
@abc.abstractmethod
def iextoam_get_one(self):
"""Return exactly one iextoam.

View File

@ -3788,6 +3788,235 @@ class Connection(api.Connection):
query = query.filter_by(system_id=None)
query.update(values, synchronize_session='fetch')
def _ptp_instance_get(self, ptp_instance_id):
query = model_query(models.PtpInstances)
query = add_identity_filter(query, ptp_instance_id)
try:
return query.one()
except NoResultFound:
raise exception.PtpInstanceNotFound(uuid=ptp_instance_id)
@objects.objectify(objects.ptp_instance)
def ptp_instance_create(self, values):
if not values.get('uuid'):
values['uuid'] = uuidutils.generate_uuid()
ptp_instance = models.PtpInstances(**values)
with _session_for_write() as session:
try:
session.add(ptp_instance)
session.flush()
except db_exc.DBDuplicateEntry:
raise exception.PtpInstanceAlreadyExists(uuid=values['uuid'])
return self._ptp_instance_get(values['uuid'])
@objects.objectify(objects.ptp_instance)
def ptp_instance_get(self, ptp_instance_id):
return self._ptp_instance_get(ptp_instance_id)
@objects.objectify(objects.ptp_instance)
def ptp_instance_get_one(self, name=None, service=None):
query = model_query(models.PtpInstances)
if name is not None:
query = query.filter_by(name=name)
if service is not None:
query = query.filter_by(service=service)
try:
return query.one()
except NoResultFound:
raise exception.NotFound()
@objects.objectify(objects.ptp_instance)
def ptp_instances_get_list(self, limit=None, marker=None,
sort_key=None, sort_dir=None):
query = model_query(models.PtpInstances)
return _paginate_query(models.PtpInstances, limit, marker,
sort_key, sort_dir, query)
@objects.objectify(objects.ptp_instance)
def ptp_instances_get_by_ihost(self, ihost_id, limit=None, marker=None,
sort_key=None, sort_dir=None):
# ihost_get() to raise an exception if the ihost is not found
ihost_obj = self.ihost_get(ihost_id)
query = model_query(models.PtpInstances)
query = query.filter_by(host_id=ihost_obj.id)
return _paginate_query(models.PtpInstances, limit, marker,
sort_key, sort_dir, query)
@objects.objectify(objects.ptp_instance)
def ptp_instance_update(self, ptp_instance_id, values):
with _session_for_write() as session:
query = model_query(models.PtpInstances, session=session)
query = add_identity_filter(query, ptp_instance_id)
count = query.update(values, synchronize_session='fetch')
if count != 1:
raise exception.PtpInstanceNotFound(uuid=ptp_instance_id)
return query.one()
def ptp_instance_destroy(self, ptp_instance_id):
with _session_for_write() as session:
query = model_query(models.PtpInstances, session=session)
query = add_identity_filter(query, ptp_instance_id)
try:
query.one()
except NoResultFound:
raise exception.PtpInstanceNotFound(uuid=ptp_instance_id)
query.delete()
def ptp_instance_destroy_by_name(self, name):
with _session_for_write() as session:
query = model_query(models.PtpInstances, session=session)
query = query.filter_by(name=name)
try:
query.one()
except NoResultFound:
raise exception.NotFound()
query.delete()
def _ptp_interface_get(self, ptp_interface_id):
query = model_query(models.PtpInterfaces)
query = add_identity_filter(query, ptp_interface_id)
try:
return query.one()
except NoResultFound:
raise exception.PtpInterfaceNotFound(uuid=ptp_interface_id)
@objects.objectify(objects.ptp_interface)
def ptp_interface_create(self, values):
if not values.get('uuid'):
values['uuid'] = uuidutils.generate_uuid()
ptp_interface = models.PtpInterfaces(**values)
with _session_for_write() as session:
try:
session.add(ptp_interface)
session.flush()
except db_exc.DBDuplicateEntry:
raise exception.PtpInterfaceAlreadyExists(uuid=values['uuid'])
return self._ptp_interface_get(values['uuid'])
@objects.objectify(objects.ptp_interface)
def ptp_interface_get(self, ptp_interface_id):
return self._ptp_interface_get(ptp_interface_id)
@objects.objectify(objects.ptp_interface)
def ptp_interface_get_one(self):
query = model_query(models.PtpInterfaces)
try:
return query.one()
except NoResultFound:
raise exception.NotFound()
@objects.objectify(objects.ptp_interface)
def ptp_interfaces_get_list(self, limit=None, marker=None, sort_key=None,
sort_dir=None):
query = model_query(models.PtpInterfaces)
return _paginate_query(models.PtpInterfaces, limit, marker,
sort_key, sort_dir, query)
@objects.objectify(objects.ptp_interface)
def ptp_interfaces_get_by_interface(self, interface_id, limit=None,
marker=None, sort_key=None,
sort_dir=None):
# NOTE: iinterface_get() to raise an exception if the interface is
# not found or multiple results found
iface_obj = self.iinterface_get(interface_id)
query = model_query(models.PtpInterfaces)
query = query.filter_by(interface_id=iface_obj.id)
return _paginate_query(models.PtpInterfaces, limit, marker,
sort_key, sort_dir, query)
def ptp_interface_destroy(self, ptp_interface_id):
with _session_for_write() as session:
query = model_query(models.PtpInterfaces, session=session)
query = add_identity_filter(query, ptp_interface_id)
try:
query.one()
except NoResultFound:
raise exception.PtpInterfaceNotFound(uuid=ptp_interface_id)
query.delete()
def _ptp_parameter_get(self, ptp_parameter_id):
query = model_query(models.PtpParameters)
query = add_identity_filter(query, ptp_parameter_id)
try:
return query.one()
except NoResultFound:
raise exception.PtpParameterNotFound(uuid=ptp_parameter_id)
@objects.objectify(objects.ptp_parameter)
def ptp_parameter_create(self, values):
if not values.get('uuid'):
values['uuid'] = uuidutils.generate_uuid()
ptp_parameter = models.PtpParameters(**values)
with _session_for_write() as session:
try:
session.add(ptp_parameter)
session.flush()
except db_exc.DBDuplicateEntry:
raise exception.PtpParameterAlreadyExists(uuid=values['uuid'])
return self._ptp_parameter_get(values['uuid'])
@objects.objectify(objects.ptp_parameter)
def ptp_parameter_get(self, ptp_parameter_id):
return self._ptp_parameter_get(ptp_parameter_id)
@objects.objectify(objects.ptp_parameter)
def ptp_parameter_get_one(self, name=None):
query = model_query(models.PtpParameters)
if name is not None:
query = query.filter_by(name=name)
try:
return query.one()
except NoResultFound:
raise exception.NotFound()
@objects.objectify(objects.ptp_parameter)
def ptp_parameters_get_list(self, limit=None, marker=None, sort_key=None,
sort_dir=None):
query = model_query(models.PtpParameters)
return _paginate_query(models.PtpParameters, limit, marker,
sort_key, sort_dir, query)
@objects.objectify(objects.ptp_parameter)
def ptp_parameters_get_by_foreign_uuid(self, uuid, limit=None, marker=None,
sort_key=None, sort_dir=None):
# Look for foreign UUID in PTP instances first, then in PTP interfaces
# if not found
try:
foreign_obj = self.ptp_instance_get(uuid)
except exception.PtpInstanceNotFound:
try:
foreign_obj = self.ptp_interface_get(uuid)
except exception.PtpInterfaceNotFound:
raise exception.NotFound()
query = model_query(models.PtpParameters)
query = query.filter_by(foreign_uuid=foreign_obj.uuid)
return _paginate_query(models.PtpParameters, limit, marker,
sort_key, sort_dir, query)
@objects.objectify(objects.ptp_parameter)
def ptp_parameter_update(self, ptp_parameter_id, values):
with _session_for_write() as session:
query = model_query(models.PtpParameters, session=session)
query = add_identity_filter(query, ptp_parameter_id)
count = query.update(values, synchronize_session='fetch')
if count != 1:
raise exception.PtpParameterNotFound(uuid=ptp_parameter_id)
return query.one()
def ptp_parameter_destroy(self, ptp_parameter_id):
with _session_for_write() as session:
query = model_query(models.PtpParameters, session=session)
query = add_identity_filter(query, ptp_parameter_id)
try:
query.one()
except NoResultFound:
raise exception.PtpParameterNotFound(uuid=ptp_parameter_id)
query.delete()
# NOTE: method is deprecated and provided for API compatibility.
# object class will convert Network entity to an iextoam object
@objects.objectify(objects.oam_network)

View File

@ -0,0 +1,126 @@
########################################################################
#
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
########################################################################
# TODO: restore imports
# Story: 2009248
# Task: 43497
# import uuid
# from datetime import datetime
from sqlalchemy import Integer, String, DateTime
from sqlalchemy import Column, MetaData, Table, ForeignKey
from sysinv.db.sqlalchemy.models import UUID_LENGTH
ENGINE = 'InnoDB'
CHARSET = 'utf8'
def _populate_ptp_tables(meta, ptp_instances, ptp_interfaces,
ptp_parameters, i_host, interfaces):
"""This function moves PTP configuration from other tables:
- If advanced (specialized) ptp4l configuration is found in
'service_parameter' table, it inserts a 'ptp4l' entry in
'ptp_instances' table and inserts the corresponding entry(ies) in
'ptp_parameters';
- If phc2sys configuration is found in 'service_parameter' table, it
inserts a 'phc2sys' entry in 'ptp_instances' table and inserts the
corresponding entry(ies) in 'ptp_parameters';
- If any interface has 'ptp_role' not equal to 'none', it inserts a
'ptp4l' entry in 'ptp_instances' and inserts the corresponding entry
in 'ptp_parameters'.
"""
# TODO: implementation
# Story: 2009248
# Task: 43497
pass
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
i_host = Table('i_host', meta, autoload=True)
ptp_instances = Table(
'ptp_instances',
meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('id', Integer, primary_key=True, nullable=False),
Column('uuid', String(UUID_LENGTH), unique=True),
Column('name', String(255), unique=True),
Column('service', String(255)),
Column('host_id', Integer,
ForeignKey('i_host.id', ondelete="CASCADE")),
mysql_engine=ENGINE,
mysql_charset=CHARSET,
)
ptp_instances.create()
interfaces = Table('interfaces', meta, autoload=True)
ptp_interfaces = Table(
'ptp_interfaces',
meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('id', Integer, primary_key=True, nullable=False),
Column('uuid', String(UUID_LENGTH), unique=True),
Column('interface_id', Integer,
ForeignKey('interfaces.id', ondelete="CASCADE")),
Column('ptp_instance_id', Integer,
ForeignKey('ptp_instances.id', ondelete="CASCADE")),
mysql_engine=ENGINE,
mysql_charset=CHARSET,
)
ptp_interfaces.create()
ptp_parameters = Table(
'ptp_parameters',
meta,
Column('created_at', DateTime),
Column('updated_at', DateTime),
Column('deleted_at', DateTime),
Column('id', Integer, primary_key=True, nullable=False),
Column('uuid', String(UUID_LENGTH), unique=True),
Column('name', String(255)),
Column('value', String(255)),
Column('foreign_uuid', String(UUID_LENGTH)),
mysql_engine=ENGINE,
mysql_charset=CHARSET,
)
ptp_parameters.create()
_populate_ptp_tables(meta, ptp_instances, ptp_interfaces, ptp_parameters,
i_host, interfaces)
def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
ptp_parameters = Table('ptp_parameters', meta, autoload=True)
ptp_parameters.drop()
ptp_interfaces = Table('ptp_interfaces', meta, autoload=True)
ptp_interfaces.drop()
ptp_instances = Table('ptp_instances', meta, autoload=True)
ptp_instances.drop()

View File

@ -39,6 +39,8 @@ from sqlalchemy.orm import relationship, backref
from sysinv.common import constants
UUID_LENGTH = 36
sql_opts = [
cfg.StrOpt('mysql_engine',
default='InnoDB',
@ -784,6 +786,51 @@ class PTP(Base):
system = relationship("isystem", lazy="joined", join_depth=1)
class PtpInstances(Base):
__tablename__ = "ptp_instances"
id = Column(Integer, primary_key=True, nullable=False)
uuid = Column(String(UUID_LENGTH), unique=True)
name = Column(String(255), unique=True)
service = Column(String(255))
host_id = Column(Integer, ForeignKey('i_host.id', ondelete='CASCADE'),
nullable=True)
host = relationship("ihost", backref="ptp_instances", lazy="joined",
join_depth=1)
class PtpInterfaces(Base):
__tablename__ = "ptp_interfaces"
id = Column(Integer, primary_key=True, nullable=False)
uuid = Column(String(UUID_LENGTH), unique=True)
interface_id = Column(Integer,
ForeignKey('interfaces.id', ondelete='CASCADE'))
ptp_instance_id = Column(Integer,
ForeignKey('ptp_instances.id', ondelete='CASCADE'))
interface = relationship("Interfaces", backref="ptp_interfaces",
lazy="joined", join_depth=1)
ptp_instance = relationship("PtpInstances", backref="ptp_interfaces",
lazy="joined", join_depth=1)
class PtpParameters(Base):
__tablename__ = "ptp_parameters"
id = Column(Integer, primary_key=True, nullable=False)
uuid = Column(String(UUID_LENGTH), unique=True)
name = Column(String(255), nullable=False)
value = Column(String(255), nullable=False)
# Either a "PtpInstance" or "PtpInterface" uuid:
foreign_uuid = Column(String(UUID_LENGTH))
class StorageTier(Base):
__tablename__ = 'storage_tiers'

View File

@ -71,6 +71,9 @@ from sysinv.objects import peer
from sysinv.objects import port
from sysinv.objects import profile
from sysinv.objects import ptp
from sysinv.objects import ptp_instance
from sysinv.objects import ptp_interface
from sysinv.objects import ptp_parameter
from sysinv.objects import pv
from sysinv.objects import remote_logging
from sysinv.objects import route
@ -156,6 +159,9 @@ user = user.User
dns = dns.DNS
ntp = ntp.NTP
ptp = ptp.PTP
ptp_instance = ptp_instance.PtpInstance
ptp_interface = ptp_interface.PtpInterface
ptp_parameter = ptp_parameter.PtpParameter
oam_network = network_oam.OAMNetwork
storage_backend = storage_backend.StorageBackend
storage_ceph = storage_ceph.StorageCeph
@ -236,6 +242,9 @@ __all__ = ("system",
"dns",
"ntp",
"ptp",
"ptp_instance",
"ptp_interface",
"ptp_parameter",
"oam_network",
"storage_backend",
"storage_ceph",

View File

@ -0,0 +1,39 @@
########################################################################
#
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
########################################################################
from sysinv.db import api as db_api
from sysinv.objects import base
from sysinv.objects import utils
class PtpInstance(base.SysinvObject):
dbapi = db_api.get_instance()
fields = {
'id': int,
'uuid': utils.str_or_none,
'name': utils.str_or_none,
'service': utils.str_or_none,
'host_uuid': utils.str_or_none,
'host_id': utils.int_or_none
}
_foreign_fields = {
'host_uuid': 'host:uuid'
}
@base.remotable_classmethod
def get_by_uuid(cls, context, uuid):
return cls.dbapi.ptp_instance_get(uuid)
def save_changes(self, context, updates):
self.dbapi.ptp_instance_update(self.uuid, # pylint: disable=no-member
updates)

View File

@ -0,0 +1,36 @@
########################################################################
#
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
########################################################################
from sysinv.db import api as db_api
from sysinv.objects import base
from sysinv.objects import utils
class PtpInterface(base.SysinvObject):
dbapi = db_api.get_instance()
fields = {
'id': int,
'uuid': utils.str_or_none,
'interface_uuid': utils.str_or_none,
'interface_id': utils.int_or_none,
'ptp_instance_uuid': utils.str_or_none,
'ptp_instance_id': utils.int_or_none
}
_foreign_fields = {
'interface_uuid': 'interface:uuid',
'ptp_instance_uuid': 'ptp_instance:uuid'
}
@base.remotable_classmethod
def get_by_uuid(cls, context, uuid):
return cls.dbapi.ptp_get_interface(uuid)

View File

@ -0,0 +1,37 @@
########################################################################
#
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
########################################################################
from sysinv.db import api as db_api
from sysinv.objects import base
from sysinv.objects import utils
class PtpParameter(base.SysinvObject):
dbapi = db_api.get_instance()
fields = {
'id': int,
'uuid': utils.str_or_none,
'name': utils.str_or_none,
'value': utils.str_or_none,
'foreign_uuid': utils.str_or_none
}
_foreign_fields = {
}
@base.remotable_classmethod
def get_by_uuid(cls, context, uuid):
return cls.dbapi.ptp_parameter_get(uuid)
def save_changes(self, context, updates):
self.dbapi.ptp_parameter_update(self.uuid, # pylint: disable=no-member
updates)

View File

@ -1986,3 +1986,51 @@ class TestMigrations(BaseMigrationTestCase, WalkVersionsMixin):
for col, coltype in devices_col.items():
self.assertTrue(isinstance(devices.c[col].type,
getattr(sqlalchemy.types, coltype)))
def _check_120(self, engine, data):
ptp_instances = db_utils.get_table(engine, 'ptp_instances')
ptp_instance_columns = {
'created_at': 'DateTime',
'updated_at': 'DateTime',
'deleted_at': 'DateTime',
'id': 'Integer',
'uuid': 'String',
'name': 'String',
'service': 'String',
'host_id': 'Integer',
}
for column, column_type in ptp_instance_columns.items():
self.assertTrue(
isinstance(ptp_instances.c[column].type,
getattr(sqlalchemy.types, column_type)))
ptp_interfaces = db_utils.get_table(engine, 'ptp_interfaces')
ptp_interface_columns = {
'created_at': 'DateTime',
'updated_at': 'DateTime',
'deleted_at': 'DateTime',
'id': 'Integer',
'uuid': 'String',
'interface_id': 'Integer',
'ptp_instance_id': 'Integer',
}
for column, column_type in ptp_interface_columns.items():
self.assertTrue(
isinstance(ptp_interfaces.c[column].type,
getattr(sqlalchemy.types, column_type)))
ptp_parameters = db_utils.get_table(engine, 'ptp_parameters')
ptp_parameters_columns = {
'created_at': 'DateTime',
'updated_at': 'DateTime',
'deleted_at': 'DateTime',
'id': 'Integer',
'uuid': 'String',
'name': 'String',
'value': 'String',
'foreign_uuid': 'String',
}
for column, column_type in ptp_parameters_columns.items():
self.assertTrue(
isinstance(ptp_parameters.c[column].type,
getattr(sqlalchemy.types, column_type)))