From 07eabfd08d5d450fe18b0a7da1f60908079efc9e Mon Sep 17 00:00:00 2001 From: zshi Date: Mon, 7 Aug 2017 11:11:44 +0800 Subject: [PATCH] Add PTP service Precision Time Protocol (PTP) is a protocol used to synchronize clocks throughout a network. When used in conjunction with hardware support, PTP is capable of sub-microsecond accuracy which is far better than is normally obtainable with NTP. Change-Id: Idc78df3a90b73be504480bc9d33a3f0041d2d84f --- Puppetfile_extras | 4 ++ manifests/profile/base/time/ptp.pp | 52 ++++++++++++++++++++ releasenotes/notes/ptp-062b1d1f2d9f2275.yaml | 6 +++ 3 files changed, 62 insertions(+) create mode 100644 manifests/profile/base/time/ptp.pp create mode 100644 releasenotes/notes/ptp-062b1d1f2d9f2275.yaml diff --git a/Puppetfile_extras b/Puppetfile_extras index fbc084444..c9e155c38 100644 --- a/Puppetfile_extras +++ b/Puppetfile_extras @@ -45,6 +45,10 @@ mod 'ntp', :git => 'https://github.com/puppetlabs/puppetlabs-ntp', :ref => '4.2.x' +mod 'ptp', + :git => 'https://github.com/redhat-nfvpe/ptp', + :ref => 'master' + mod 'systemd', :git => 'https://github.com/camptocamp/puppet-systemd', :ref => 'master' diff --git a/manifests/profile/base/time/ptp.pp b/manifests/profile/base/time/ptp.pp new file mode 100644 index 000000000..753f96cd8 --- /dev/null +++ b/manifests/profile/base/time/ptp.pp @@ -0,0 +1,52 @@ +# Copyright 2017 Red Hat, 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. +# +# == Class: tripleo::profile::base::time::ptp +# +# PTP base profile for tripleo. +# +# === Parameters +# +# [*ptp4l_interface*] +# The physical interface name where PTP service is configured on +# Defaults to 'eth0' +# +# [*ptp4l_conf_slaveonly*] +# Whether to configure PTP service in slave mode +# Defaults to 1 +# +# [*ptp4l_conf_network_transport*] +# PTP message transport protocol +# Defaults to 'UDPv4' + +class tripleo::profile::base::time::ptp ( + $ptp4l_interface = 'eth0', + $ptp4l_conf_slaveonly = 1, + $ptp4l_conf_network_transport = 'UDPv4', +) { + + $interface_mapping = generate('/bin/os-net-config', '-i', $ptp4l_interface) + $ptp4l_interface_name = $interface_mapping[$ptp4l_interface] + + ptp::instance_ptp4l { "ptp4l-${title}-${ptp4l_interface_name}": + ptp4l_interface => $ptp4l_interface_name, + ptp4l_conf_slaveonly => $ptp4l_conf_slaveonly, + ptp4l_conf_network_transport => $ptp4l_conf_network_transport, + } + + ptp::instance_phc2sys { "phc2sys-${title}-${ptp4l_interface_name}": + auto_sync => true, + } +} diff --git a/releasenotes/notes/ptp-062b1d1f2d9f2275.yaml b/releasenotes/notes/ptp-062b1d1f2d9f2275.yaml new file mode 100644 index 000000000..fd0ee5418 --- /dev/null +++ b/releasenotes/notes/ptp-062b1d1f2d9f2275.yaml @@ -0,0 +1,6 @@ +--- +features: + - Precision Time Protocol (PTP) is a protocol used to synchronize clocks + throughout a network. When used in conjunction with hardware support, + PTP is capable of sub-microsecond accuracy which is far better than is + normally obtainable with NTP.