[hostcfgd] Convert to Python 3; Add to sonic-host-services package (#5713)
To consolidate host services and install via packages instead of file-by-file, also as part of migrating all of SONiC to Python 3, as Python 2 is no longer supported.
This commit is contained in:
parent
9e7e092610
commit
04d0e8ab00
@ -324,12 +324,6 @@ sudo cp files/dhcp/90-dhcp6-systcl.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMP
|
||||
sudo cp $IMAGE_CONFIGS/interfaces/init_interfaces $FILESYSTEM_ROOT/etc/network/interfaces
|
||||
sudo mkdir -p $FILESYSTEM_ROOT/etc/network/interfaces.d
|
||||
|
||||
# Copy hostcfgd files
|
||||
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "hostcfgd.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd $FILESYSTEM_ROOT/usr/bin/
|
||||
sudo cp $IMAGE_CONFIGS/hostcfgd/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
||||
|
||||
# copy core file uploader files
|
||||
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_uploader.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable core_uploader.service
|
||||
|
@ -1,4 +1,4 @@
|
||||
# This file describes the maintainers for sonic-device-data
|
||||
# This file describes the maintainers for sonic-host-services-data
|
||||
# See the SONiC project governance document for more information
|
||||
|
||||
Name = "Joe LeVeque"
|
||||
|
@ -0,0 +1 @@
|
||||
templates/*.j2 /usr/share/sonic/templates/
|
@ -7,4 +7,5 @@ build:
|
||||
|
||||
override_dh_installsystemd:
|
||||
dh_installsystemd --no-start --name=caclmgrd
|
||||
dh_installsystemd --no-start --name=hostcfgd
|
||||
dh_installsystemd --no-start --name=procdockerstatsd
|
||||
|
@ -5,7 +5,7 @@ After=updategraph.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/hostcfgd
|
||||
ExecStart=/usr/local/bin/hostcfgd
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
1
src/sonic-host-services/.gitignore
vendored
1
src/sonic-host-services/.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
# Compiled Python files
|
||||
*.pyc
|
||||
scripts/caclmgrdc
|
||||
scripts/hostcfgdc
|
||||
scripts/procdockerstatsdc
|
||||
|
||||
# Generated by packaging
|
||||
|
@ -1,16 +1,15 @@
|
||||
#!/usr/bin/python -u
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import ast
|
||||
import copy
|
||||
import ipaddress
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import syslog
|
||||
import copy
|
||||
|
||||
import jinja2
|
||||
import ipaddr as ipaddress
|
||||
from swsssdk import ConfigDBConnector
|
||||
from sonic_py_common import device_info
|
||||
from swsssdk import ConfigDBConnector
|
||||
|
||||
# FILE
|
||||
PAM_AUTH_CONF = "/etc/pam.d/common-auth-sonic"
|
||||
@ -80,7 +79,7 @@ class Iptables(object):
|
||||
|
||||
iface, ip = key
|
||||
ip_str = ip.split("/")[0]
|
||||
ip_addr = ipaddress.IPAddress(ip_str)
|
||||
ip_addr = ipaddress.ip_address(ip_str)
|
||||
if isinstance(ip_addr, ipaddress.IPv6Address):
|
||||
ver = '6'
|
||||
else:
|
||||
@ -313,7 +312,7 @@ class HostConfigDaemon:
|
||||
|
||||
def update_all_feature_states(self):
|
||||
feature_table = self.config_db.get_table('FEATURE')
|
||||
for feature_name in feature_table.keys():
|
||||
for feature_name in feature_table:
|
||||
if not feature_name:
|
||||
syslog.syslog(syslog.LOG_WARNING, "Feature is None")
|
||||
continue
|
||||
@ -359,7 +358,7 @@ class HostConfigDaemon:
|
||||
def feature_state_handler(self, key, data):
|
||||
feature_name = key
|
||||
feature_table = self.config_db.get_table('FEATURE')
|
||||
if feature_name not in feature_table.keys():
|
||||
if feature_name not in feature_table:
|
||||
syslog.syslog(syslog.LOG_WARNING, "Feature '{}' not in FEATURE table".format(feature_name))
|
||||
return
|
||||
|
@ -12,9 +12,11 @@ setup(
|
||||
maintainer_email = 'jolevequ@microsoft.com',
|
||||
scripts = [
|
||||
'scripts/caclmgrd',
|
||||
'scripts/hostcfgd',
|
||||
'scripts/procdockerstatsd',
|
||||
],
|
||||
install_requires = [
|
||||
'Jinja2>=2.10',
|
||||
'sonic-py-common',
|
||||
'swsssdk>=2.0.1',
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user