-
Notifications
You must be signed in to change notification settings - Fork 232
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
base: main
Are you sure you want to change the base?
Add pd daemon service #2360
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
There was a problem hiding this 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!
@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": |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
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:
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 [
]