Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hostcfgd] Convert to Python 3; Add to sonic-host-services package #5713

Merged
merged 6 commits into from
Nov 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-host-services-data/MAINTAINERS
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/sonic-host-services-data/debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
templates/*.j2 /usr/share/sonic/templates/
1 change: 1 addition & 0 deletions src/sonic-host-services-data/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions src/sonic-host-services/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Compiled Python files
*.pyc
scripts/caclmgrdc
scripts/hostcfgdc
scripts/procdockerstatsdc

# Generated by packaging
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/sonic-host-services/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
maintainer_email = '[email protected]',
scripts = [
'scripts/caclmgrd',
'scripts/hostcfgd',
'scripts/procdockerstatsd',
],
install_requires = [
'Jinja2>=2.10',
'sonic-py-common',
'swsssdk>=2.0.1',
],
Expand Down