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

Add pd daemon service #2360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sherysheng
Copy link
Contributor

@sherysheng sherysheng commented Jul 4, 2024

Subscribe Dhcp6PdState signal, start dhcpcd when state change to running,recover default dhcpcd.conf when state is stopped

local test log:
Terminal #1:
sherys@raspberrypi:~ $ python3 dhcp6_pd_daemon.py
2024-07-06 03:35:31,718 - INFO - Connected to D-Bus signal.
2024-07-06 03:35:41,577 - INFO - Dhcp6PdState changed to: running
2024-07-06 03:35:42,182 - INFO - Successfully restarted dhcpcd service.

Terminal #2:

br pd enable
Done
br pd state
running
Done
br pd disable
Done
br pd state
disabled
Done

Terminal #3:
signal time=1719724170.782791 sender=:1.32 -> destination=(null destination) serial=14 path=/io/openthread/BorderRouter/wpan0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "io.openthread.BorderRouter"
array [
dict entry(
string "Dhcp6PdState"
variant string "running"
)
]
array [
]
signal time=1719724369.495711 sender=:1.32 -> destination=(null destination) serial=16 path=/io/openthread/BorderRouter/wpan0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "io.openthread.BorderRouter"
array [
dict entry(
string "Dhcp6PdState"
variant string "disabled"
)
]
array [
]

Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.41%. Comparing base (2b41187) to head (d8a1c25).
Report is 715 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2360       +/-   ##
===========================================
- Coverage   55.77%   45.41%   -10.37%     
===========================================
  Files          87       94        +7     
  Lines        6890     9914     +3024     
  Branches        0      749      +749     
===========================================
+ Hits         3843     4502      +659     
- Misses       3047     5193     +2146     
- Partials        0      219      +219     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sherysheng sherysheng requested review from erjiaqing, alinlazar, Irving-cl and superwhd and removed request for alinlazar July 5, 2024 05:28
Copy link
Contributor

@erjiaqing erjiaqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, a few comments for code style.

Thanks!

script/reference-device/dhcp6_pd_daemon.py Outdated Show resolved Hide resolved
script/reference-device/dhcp6_pd_daemon.py Outdated Show resolved Hide resolved
script/reference-device/dhcp6_pd_daemon.py Outdated Show resolved Hide resolved
script/reference-device/dhcp6_pd_daemon.py Outdated Show resolved Hide resolved
script/reference-device/dhcp6_pd_daemon.py Show resolved Hide resolved
script/reference-device/dhcp6_pd_daemon.py Outdated Show resolved Hide resolved
script/reference-device/dhcp6_pd_daemon.py Show resolved Hide resolved
@suveshpratapa
Copy link
Member

@jwhui @sherysheng Can we prioritize getting this change in soon? It appears we're waiting on this for some PD client qualifying tests in certification.

logging.info("Successfully restarted dhcpcd service.")
except subprocess.CalledProcessError as e:
logging.error(f"Error restarting dhcpcd service: {e}")
elif new_state == "stopped":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also consider disabled?

elif new_state == "stopped":
if os.path.isfile("/etc/dhcpcd.conf.orig"):
try:
subprocess.run(["sudo", "cp", "/etc/dhcpcd.conf.orig", "/etc/dhcpcd.conf"], check=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you create /etc/dhcpcd.conf.orig?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please consider use shutil.

Would suggest:

  • cp /etc/dhcpcd.conf.orig /etc/dhcpcd.conf.tmp
  • mv /etc/dhcpcd.conf.tmp /etc/dhcpcd.conf

To make use of the atomic feature of move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants