[PTP dual NIC config] Enable ptpinstance functionality
This commit provides the API and CLI updates to enable ptpinstance functionality and runtime manifest application. A new CLI command is provided to apply the ptpinstance configuration: system ptp-instance-apply Tests: Pass: Build and install on hardware lab Pass: multi instance ptp can be configured and applied Regression: Pass: Single instance ptp is unaffected Story: 2009248 Task: 44292 Depends-on: https://review.opendev.org/c/starlingx/stx-puppet/+/824800 Signed-off-by: Cole Walker <cole.walker@windriver.com> Change-Id: I095a000989af9c3c002b6bde5f899c0671860e66
This commit is contained in:
parent
a37c216b8f
commit
5b1a1018f8
|
@ -56,6 +56,9 @@ class PtpInstanceManager(base.Manager):
|
||||||
def delete(self, ptp_instance_id):
|
def delete(self, ptp_instance_id):
|
||||||
return self._delete(self._path(ptp_instance_id))
|
return self._delete(self._path(ptp_instance_id))
|
||||||
|
|
||||||
|
def apply(self):
|
||||||
|
return self.api.json_request('POST', self._path() + "/apply")
|
||||||
|
|
||||||
|
|
||||||
def _find_ptp_instance(cc, key):
|
def _find_ptp_instance(cc, key):
|
||||||
if key.isdigit() or utils.is_uuid_like(key):
|
if key.isdigit() or utils.is_uuid_like(key):
|
||||||
|
|
|
@ -184,3 +184,11 @@ def do_host_ptp_instance_remove(cc, args):
|
||||||
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
|
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
|
||||||
_host_ptp_instance_op(cc, op='remove', uuid=ihost.uuid,
|
_host_ptp_instance_op(cc, op='remove', uuid=ihost.uuid,
|
||||||
instance=args.nameoruuid)
|
instance=args.nameoruuid)
|
||||||
|
|
||||||
|
|
||||||
|
def do_ptp_instance_apply(cc, args):
|
||||||
|
"""Apply the PTP Instance config."""
|
||||||
|
|
||||||
|
cc.ptp_instance.apply()
|
||||||
|
|
||||||
|
print('Applying the PTP Instance configuration')
|
||||||
|
|
|
@ -6467,9 +6467,12 @@ class HostController(rest.RestController):
|
||||||
if interface.ptp_role != constants.INTERFACE_PTP_ROLE_NONE:
|
if interface.ptp_role != constants.INTERFACE_PTP_ROLE_NONE:
|
||||||
ptp_ifaces.append(interface)
|
ptp_ifaces.append(interface)
|
||||||
|
|
||||||
if not ptp_ifaces:
|
ptp_instances = pecan.request.dbapi.ptp_instances_get_list(host_uuid)
|
||||||
|
if not (ptp_ifaces or ptp_instances):
|
||||||
raise wsme.exc.ClientSideError(
|
raise wsme.exc.ClientSideError(
|
||||||
_("Hosts with PTP clock synchronization must have at least one PTP interface configured"))
|
_("Hosts with PTP clock synchronization "
|
||||||
|
"must have at least one PTP "
|
||||||
|
"interface or instance configured"))
|
||||||
|
|
||||||
# Check that interfaces have addresses assigned if PTP transport is UDP
|
# Check that interfaces have addresses assigned if PTP transport is UDP
|
||||||
system_ptp = pecan.request.dbapi.ptp_get_one()
|
system_ptp = pecan.request.dbapi.ptp_get_one()
|
||||||
|
|
|
@ -133,6 +133,10 @@ LOCK_NAME = 'PtpInstanceController'
|
||||||
class PtpInstanceController(rest.RestController):
|
class PtpInstanceController(rest.RestController):
|
||||||
"""REST controller for PTP instance."""
|
"""REST controller for PTP instance."""
|
||||||
|
|
||||||
|
_custom_actions = {
|
||||||
|
'apply': ['POST']
|
||||||
|
}
|
||||||
|
|
||||||
ptp_parameters = ptp_parameter.PtpParameterController(
|
ptp_parameters = ptp_parameter.PtpParameterController(
|
||||||
parent="ptp_instance")
|
parent="ptp_instance")
|
||||||
"Expose PTP parameters as a sub-element of PTP instances"
|
"Expose PTP parameters as a sub-element of PTP instances"
|
||||||
|
@ -281,3 +285,13 @@ class PtpInstanceController(rest.RestController):
|
||||||
LOG.debug("PtpInstanceController.delete: all clear for %s" %
|
LOG.debug("PtpInstanceController.delete: all clear for %s" %
|
||||||
ptp_instance_uuid)
|
ptp_instance_uuid)
|
||||||
pecan.request.dbapi.ptp_instance_destroy(ptp_instance_uuid)
|
pecan.request.dbapi.ptp_instance_destroy(ptp_instance_uuid)
|
||||||
|
|
||||||
|
@cutils.synchronized(LOCK_NAME)
|
||||||
|
@wsme_pecan.wsexpose(None, status_code=204)
|
||||||
|
def apply(self):
|
||||||
|
"""Apply the ptp instance configuration."""
|
||||||
|
try:
|
||||||
|
pecan.request.rpcapi.update_ptp_instances_config(pecan.request.context)
|
||||||
|
except exception.HTTPNotFound:
|
||||||
|
msg = ("PTP Instance apply failed")
|
||||||
|
raise wsme.exc.ClientSideError(msg)
|
||||||
|
|
|
@ -7174,18 +7174,27 @@ class ConductorManager(service.PeriodicService):
|
||||||
}
|
}
|
||||||
self._config_apply_runtime_manifest(context, config_uuid, config_dict)
|
self._config_apply_runtime_manifest(context, config_uuid, config_dict)
|
||||||
|
|
||||||
def update_ptp_instances_config(self, context, host_uuid,
|
def update_ptp_instances_config(self, context):
|
||||||
ptp_instances_dict):
|
personalities = [constants.CONTROLLER,
|
||||||
try:
|
constants.WORKER,
|
||||||
host = self.dbapi.ihost_get(host_uuid)
|
constants.STORAGE]
|
||||||
if host: # TODO: put here to make variable used; remove it later
|
hosts = self.dbapi.ihost_get_list()
|
||||||
pass
|
runtime_hosts = []
|
||||||
except exception.ServerNotFound:
|
for host in hosts:
|
||||||
LOG.error("Cannot find host by id %s" % host_uuid)
|
if (host.clock_synchronization == constants.PTP and
|
||||||
return
|
host.administrative == constants.ADMIN_UNLOCKED and
|
||||||
# TODO: apply configuration of PTP instance to host (will probably go
|
host.operational == constants.OPERATIONAL_ENABLED):
|
||||||
# through PTP parameters instead to set the 'conf' files for services)
|
runtime_hosts.append(host.uuid)
|
||||||
pass
|
|
||||||
|
if runtime_hosts:
|
||||||
|
config_dict = {
|
||||||
|
"personalities": personalities,
|
||||||
|
"classes": ['platform::ptpinstance::runtime'],
|
||||||
|
"host_uuids": runtime_hosts
|
||||||
|
}
|
||||||
|
config_uuid = self._config_update_hosts(context, personalities,
|
||||||
|
host_uuids=runtime_hosts)
|
||||||
|
self._config_apply_runtime_manifest(context, config_uuid, config_dict)
|
||||||
|
|
||||||
def update_system_mode_config(self, context):
|
def update_system_mode_config(self, context):
|
||||||
"""Update the system mode configuration"""
|
"""Update the system mode configuration"""
|
||||||
|
|
|
@ -808,18 +808,13 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy):
|
||||||
"""
|
"""
|
||||||
return self.call(context, self.make_msg('update_ptp_config', do_apply=do_apply))
|
return self.call(context, self.make_msg('update_ptp_config', do_apply=do_apply))
|
||||||
|
|
||||||
def update_ptp_instances_config(self, context, host_uuid,
|
def update_ptp_instances_config(self, context):
|
||||||
ptp_instances_dict):
|
|
||||||
"""Synchronously, have the conductor update PTP instance(s).
|
"""Synchronously, have the conductor update PTP instance(s).
|
||||||
|
|
||||||
:param context: request context.
|
:param context: request context.
|
||||||
:param host_uuid: uuid or id of the host
|
|
||||||
:param ptp_instances_dict: a dictionary {name:service} of PTP instances
|
|
||||||
"""
|
"""
|
||||||
return self.call(context,
|
return self.call(context,
|
||||||
self.make_msg('update_ptp_instances_config',
|
self.make_msg('update_ptp_instances_config'))
|
||||||
host_uuid=host_uuid,
|
|
||||||
ptp_instances_dict=ptp_instances_dict))
|
|
||||||
|
|
||||||
def update_system_mode_config(self, context):
|
def update_system_mode_config(self, context):
|
||||||
"""Synchronously, have the conductor update the system mode
|
"""Synchronously, have the conductor update the system mode
|
||||||
|
|
|
@ -292,15 +292,11 @@ class NetworkingPuppet(base.BasePuppet):
|
||||||
|
|
||||||
def _get_instance_ptp_config(self, host):
|
def _get_instance_ptp_config(self, host):
|
||||||
|
|
||||||
if host.clock_synchronization == constants.PTP:
|
if (host.clock_synchronization != constants.PTP):
|
||||||
ptp_enabled = True
|
ptpinstance_enabled = False
|
||||||
|
return {'platform::ptpinstance::enabled': ptpinstance_enabled}
|
||||||
else:
|
else:
|
||||||
ptp_enabled = False
|
ptpinstance_enabled = True
|
||||||
|
|
||||||
# Returning here because ptp instance functionality is not enabled at this time
|
|
||||||
# Subsequent code is inactive until this return statement is removed and ptp instance
|
|
||||||
# functionality is turned on
|
|
||||||
return {'platform::ptpinstance::enabled': ptp_enabled}
|
|
||||||
|
|
||||||
# Get the database entries for instances, interfaces and parameters
|
# Get the database entries for instances, interfaces and parameters
|
||||||
ptp_instances = self.dbapi.ptp_instances_get_list(host=host.id)
|
ptp_instances = self.dbapi.ptp_instances_get_list(host=host.id)
|
||||||
|
@ -327,7 +323,7 @@ class NetworkingPuppet(base.BasePuppet):
|
||||||
ptp_parameters_interface)
|
ptp_parameters_interface)
|
||||||
|
|
||||||
return {'platform::ptpinstance::config': ptp_config,
|
return {'platform::ptpinstance::config': ptp_config,
|
||||||
'platform::ptpinstance::enabled': ptp_enabled}
|
'platform::ptpinstance::enabled': ptpinstance_enabled}
|
||||||
|
|
||||||
def _get_ptp_interface_config(self):
|
def _get_ptp_interface_config(self):
|
||||||
config = {}
|
config = {}
|
||||||
|
|
Loading…
Reference in New Issue