From ac899f3062049354102279422c4d0f37ab0c1253 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Sat, 4 Mar 2017 00:24:29 +0000 Subject: [PATCH 1/3] Move DHCP, rsyslog, and NTP server information into minigraph --- dockers/docker-dhcp-relay/config.sh | 2 +- .../build_templates/sonic_debian_extension.j2 | 2 -- files/image_config/ntp/ntp-config.sh | 2 +- files/image_config/ntp/ntp.yml | 6 ----- files/image_config/rsyslog/rsyslog-config.sh | 2 +- files/image_config/rsyslog/rsyslog.yml | 1 - src/sonic-config-engine/minigraph.py | 27 +++++++++++++++++++ 7 files changed, 30 insertions(+), 12 deletions(-) delete mode 100644 files/image_config/ntp/ntp.yml delete mode 100644 files/image_config/rsyslog/rsyslog.yml diff --git a/dockers/docker-dhcp-relay/config.sh b/dockers/docker-dhcp-relay/config.sh index f0a861cfb997..99df251572d5 100755 --- a/dockers/docker-dhcp-relay/config.sh +++ b/dockers/docker-dhcp-relay/config.sh @@ -1,4 +1,4 @@ #!/bin/bash -sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/dhcp_relay.yml -t /usr/share/sonic/templates/isc-dhcp-relay.j2 > /etc/default/isc-dhcp-relay +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isc-dhcp-relay.j2 > /etc/default/isc-dhcp-relay diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index c84518576f17..5d079ea35c7d 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -83,14 +83,12 @@ sudo cp $IMAGE_CONFIGS/ntp/ntp-config.service $FILESYSTEM_ROOT/etc/systemd/syste sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable ntp-config.service sudo cp $IMAGE_CONFIGS/ntp/ntp-config.sh $FILESYSTEM_ROOT/usr/bin/ sudo cp $IMAGE_CONFIGS/ntp/ntp.conf.j2 $FILESYSTEM_ROOT/usr/share/sonic/templates/ -sudo cp $IMAGE_CONFIGS/ntp/ntp.yml $FILESYSTEM_ROOT/etc/sonic/ # Copy rsyslog configuration files and templates sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT/etc/systemd/system/ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable rsyslog-config.service sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/ sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT/usr/share/sonic/templates/ -sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.yml $FILESYSTEM_ROOT/etc/sonic/ sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/ # Copy interfaces configuration files and templates diff --git a/files/image_config/ntp/ntp-config.sh b/files/image_config/ntp/ntp-config.sh index 55a048a71328..2465058ba021 100755 --- a/files/image_config/ntp/ntp-config.sh +++ b/files/image_config/ntp/ntp-config.sh @@ -1,3 +1,3 @@ #!/bin/bash -sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/ntp.yml -t /usr/share/sonic/templates/ntp.conf.j2 >/etc/ntp.conf +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ntp.conf.j2 >/etc/ntp.conf diff --git a/files/image_config/ntp/ntp.yml b/files/image_config/ntp/ntp.yml deleted file mode 100644 index efb3a5272fcc..000000000000 --- a/files/image_config/ntp/ntp.yml +++ /dev/null @@ -1,6 +0,0 @@ -ntp_servers: - - 0.debian.pool.ntp.org - - 1.debian.pool.ntp.org - - 2.debian.pool.ntp.org - - 3.debian.pool.ntp.org - diff --git a/files/image_config/rsyslog/rsyslog-config.sh b/files/image_config/rsyslog/rsyslog-config.sh index 8c14b9adce9f..044888029686 100755 --- a/files/image_config/rsyslog/rsyslog-config.sh +++ b/files/image_config/rsyslog/rsyslog-config.sh @@ -1,3 +1,3 @@ #!/bin/bash -sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/rsyslog.yml -t /usr/share/sonic/templates/rsyslog.conf.j2 >/etc/rsyslog.conf +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/rsyslog.conf.j2 >/etc/rsyslog.conf diff --git a/files/image_config/rsyslog/rsyslog.yml b/files/image_config/rsyslog/rsyslog.yml deleted file mode 100644 index 006271123b9d..000000000000 --- a/files/image_config/rsyslog/rsyslog.yml +++ /dev/null @@ -1 +0,0 @@ -syslog_servers: [] diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index aece9dee8a50..afd4538f1346 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -266,6 +266,25 @@ def parse_cpg(cpg, hname): return bgp_sessions, myasn +def parse_meta(meta, hname): + syslog_servers = [] + dhcp_servers = [] + ntp_servers = [] + device_metas = meta.find(str(QName(ns, "Devices"))) + for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))): + if device.find(str(QName(ns1, "Name"))).text == hname: + properties = device.find(str(QName(ns1, "Properties"))) + for device_property in properties.findall(str(QName(ns1, "DeviceProperty"))): + name = device_property.find(str(QName(ns1, "Name"))).text + value = device_property.find(str(QName(ns1, "Value"))).text + value_group = value.split(';') if value and value != "" else [] + if name == "DhcpResources": + dhcp_servers = value_group + elif name == "NtpResources": + ntp_servers = value_group + elif name == "SyslogResources": + syslog_servers = value_group + return syslog_servers, dhcp_servers, ntp_servers def get_console_info(devices, dev, port): for k, v in devices.items(): @@ -340,6 +359,9 @@ def parse_xml(filename, platform=None): neighbors = None devices = None hostname = None + syslog_servers = [] + dhcp_servers = [] + ntp_servers = [] hwsku_qn = QName(ns, "HwSku") hostname_qn = QName(ns, "Hostname") @@ -363,6 +385,8 @@ def parse_xml(filename, platform=None): (neighbors, devices, console_dev, console_port, mgmt_dev, mgmt_port) = parse_png(child, hostname) elif child.tag == str(QName(ns, "UngDec")): (u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname) + elif child.tag == str(QName(ns, "MetadataDeclaration")): + (syslog_servers, dhcp_servers, ntp_servers) = parse_meta(child, hostname) Tree = lambda: defaultdict(Tree) @@ -389,6 +413,9 @@ def parse_xml(filename, platform=None): results['minigraph_mgmt'] = get_mgmt_info(devices, mgmt_dev, mgmt_port) results['minigraph_hostname'] = hostname results['inventory_hostname'] = hostname + results['syslog_servers'] = syslog_servers + results['dhcp_servers'] = dhcp_servers + results['ntp_servers'] = ntp_servers results['alias_map'] = alias_map_list return results From ecb41fcf46b70781247c68f142c8d5f3763ebd43 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Sat, 4 Mar 2017 00:37:43 +0000 Subject: [PATCH 2/3] Add default NTP server values to default minigraphs --- .../x86_64-accton_as7512_32x-r0/minigraph.xml | 25 ++++++++++++++ .../x86_64-arista_7050_qx32/minigraph.xml | 25 ++++++++++++++ .../x86_64-arista_7060_cx32s/minigraph.xml | 25 ++++++++++++++ .../x86_64-dell_s6000_s1220-r0/minigraph.xml | 25 ++++++++++++++ .../x86_64-dell_s6100_c2538-r0/minigraph.xml | 25 ++++++++++++++ .../x86_64-dell_z9100_c2538-r0/minigraph.xml | 25 ++++++++++++++ .../x86_64-ingrasys_s9100-r0/minigraph.xml | 33 ++++++++++++++++++- .../x86_64-mlnx_msn2700-r0/minigraph.xml | 25 ++++++++++++++ 8 files changed, 207 insertions(+), 1 deletion(-) diff --git a/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml b/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml index 42bb951add3a..f2326c44aae3 100644 --- a/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml +++ b/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml @@ -1044,6 +1044,31 @@ + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + switch1 AS7512 diff --git a/device/arista/x86_64-arista_7050_qx32/minigraph.xml b/device/arista/x86_64-arista_7050_qx32/minigraph.xml index 26bf46132a25..f2ef7b0b8bc2 100644 --- a/device/arista/x86_64-arista_7050_qx32/minigraph.xml +++ b/device/arista/x86_64-arista_7050_qx32/minigraph.xml @@ -1044,6 +1044,31 @@ + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + switch1 Arista-7050-QX32 diff --git a/device/arista/x86_64-arista_7060_cx32s/minigraph.xml b/device/arista/x86_64-arista_7060_cx32s/minigraph.xml index 3fcd713cbc79..5d7dcea980ff 100644 --- a/device/arista/x86_64-arista_7060_cx32s/minigraph.xml +++ b/device/arista/x86_64-arista_7060_cx32s/minigraph.xml @@ -1044,6 +1044,31 @@ + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + switch1 Arista-7060-CX32S diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml b/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml index 436f6880da4f..0fd1f49ab868 100644 --- a/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml +++ b/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml @@ -1044,6 +1044,31 @@ + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + switch1 Force10-S6000 diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml b/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml index e07ec53e18e9..3ae8e77f8024 100644 --- a/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml +++ b/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml @@ -739,6 +739,31 @@ + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + switch1 Force10-S6100 diff --git a/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml b/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml index 44cffcdd4378..ab1ce20a69a8 100644 --- a/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml +++ b/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml @@ -1044,6 +1044,31 @@ + + + + switch1 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + switch1 Force10-Z9100 diff --git a/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml b/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml index c67990fc7305..154c1847eb20 100644 --- a/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml +++ b/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml @@ -109,7 +109,38 @@ Ethernet4 - + + + OCPSCH01040GGLF + ingrasys-s9100 + + + + + + + OCPSCH01040GGLF + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + OCPSCH01040GGLF ingrasys-s9100 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml b/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml index 0fa570c7a0a8..4942e64be5e9 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml @@ -1044,6 +1044,31 @@ ` + + + + switch2 + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + + + + switch2 ACS-MSN2700 From 7895f186d360a216b8ce2470b88d82675c823ae3 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Sat, 4 Mar 2017 01:39:57 +0000 Subject: [PATCH 3/3] Fix dhcp relay template according to CR --- dockers/docker-dhcp-relay/isc-dhcp-relay.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 b/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 index 07df5e1f9a76..812e2bb8e1e4 100644 --- a/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 +++ b/dockers/docker-dhcp-relay/isc-dhcp-relay.j2 @@ -1,4 +1,4 @@ -SERVERS="{{ dhcp_servers }}" +SERVERS="{{ dhcp_servers | join(' ') }}" INTERFACES="{{ minigraph_vlan_interfaces[0]['name'] }}"