-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add get_graph service to fetch minigraph automatically #288
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
Changes from 7 commits
128d31a
9678062
71dfb98
64942c8
dd8a3ff
4c4b8e7
e79ea20
aad5f39
3a972f6
02d8676
33277c4
fb0c25c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Configuration file for /sbin/dhclient, which is included in Debian's | ||
# dhcp3-client package. | ||
# | ||
# This is a sample configuration file for dhclient. See dhclient.conf's | ||
# man page for more information about the syntax of this file | ||
# and a more comprehensive list of the parameters understood by | ||
# dhclient. | ||
# | ||
# Normally, if the DHCP server provides reasonable information and does | ||
# not leave anything out (like the domain name, for example), then | ||
# few changes must be made to this file, if any. | ||
# | ||
|
||
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; | ||
option snmp-community code 224 = text; | ||
option minigraph-service-url code 225 = text; | ||
|
||
send host-name = gethostname(); | ||
request subnet-mask, broadcast-address, time-offset, routers, | ||
domain-name, domain-name-servers, domain-search, host-name, | ||
dhcp6.name-servers, dhcp6.domain-search, | ||
netbios-name-servers, netbios-scope, interface-mtu, | ||
rfc3442-classless-static-routes, ntp-servers, snmp-community, minigraph-service-url; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
case $reason in | ||
BOUND|RENEW|REBIND|REBOOT) | ||
if [ -f "/etc/sonic/graph_service_url" ] && [ -n `cat /etc/sonic/graph_service_url` ]; then | ||
exit 0 | ||
elif [ -n "$new_minigraph_service_url" ]; then | ||
echo $new_minigraph_service_url > /etc/sonic/graph_service_url | ||
else | ||
echo "disabled" > /etc/sonic/graph_service_url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
rename to updategraph.conf since it is the configuration file for the upgradegraph srevice. also the conf file format needs to defined. usually something like below whether to enable/disable update graph serviceenable=true|false urlurl = xxx xxx xxx it is possible that the dhcp provide you multiple url to download. #Resolved |
||
fi | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
#!/bin/bash | ||
# This script is to update hostname of the system. | ||
case $reason in | ||
BOUND|RENEW|REBIND|REBOOT) | ||
current_host_name=`hostname -s` | ||
if [ "$current_host_name" != "$new_host_name" ] && [ -n "$new_host_name" ] | ||
then | ||
echo $new_host_name > /etc/hostname | ||
hostname -F /etc/hostname | ||
sed -i "/\s$current_host_name$/d" /etc/hosts | ||
echo "127.0.0.1 $new_host_name" >> /etc/hosts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this will likely introduce duplicate entry for 127.0.0.1 if there is already one with current host name. The previous line will replace with new_host_name, and this line will add a new one. #ByDesign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make make sure the indent is matching other lines. In reply to: 100711735 [](ancestors = 100711735) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No the previous line is deleting the old entry instead of replace one. In reply to: 100711735 [](ancestors = 100711735) |
||
fi | ||
;; | ||
esac | ||
|
||
if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \ | ||
&& [ "$reason" != REBIND ] && [ "$reason" != REBOOT ] | ||
then | ||
exit 0 | ||
fi | ||
|
||
current_host_name=`hostname -s` | ||
|
||
if [ "$current_host_name" != "$new_host_name" ] | ||
then | ||
echo $new_host_name > /etc/hostname | ||
line_to_replace=`grep 127.0.0.1.*$current_host_name /etc/hosts` | ||
new_line=`echo $line_to_replace | sed "s/$current_host_name/$new_host_name/"` | ||
sed -i "s/$line_to_replace/$new_line/" /etc/hosts | ||
|
||
hostname -F /etc/hostname | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
case $reason in | ||
BOUND|RENEW|REBIND|REBOOT) | ||
if [ -n "${new_snmp_community}" ]; then | ||
if [ -f /etc/sonic/snmp.yml ]; then | ||
sed -i "s/^snmp_rocommunity:.*/snmp_rocommunity: $new_snmp_community/g" /etc/sonic/snmp.yml | ||
else | ||
echo "snmp_rocommunity: "$new_snmp_community > /etc/sonic/snmp.yml | ||
fi | ||
fi | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=download minigraph from graph service | ||
Before=ntp-config.service | ||
Before=rsyslog-config.service | ||
Before=interfaces-config.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/updategraph | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you also change the get_graph.service name to updategraph.service? #Resolved |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
while [ ! -f /etc/sonic/graph_service_url ]; do | ||
echo "No graph service url speficied, waiting for DHCP response..." | ||
sleep 1 | ||
done | ||
|
||
if [ `cat /etc/sonic/graph_service_url` = "disabled" ]; then | ||
echo "Graph service url not included in DHCP response, skip minigraph downloading" | ||
exit 0 | ||
fi | ||
|
||
if [ -f /etc/sonic/minigraph.xml ]; then | ||
echo "Renaming minigraph.xml to minigraph.old" | ||
mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.old | ||
fi | ||
|
||
HOSTNAME=`hostname -s` | ||
GRAPH_URL=`sed "s/{{\s*hostname\s*}}/$HOSTNAME/g" /etc/sonic/graph_service_url` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use config-engine to do that #Resolved |
||
echo "Getting minigraph from $GRAPH_URL" | ||
|
||
while true; do | ||
curl -f $GRAPH_URL -o /etc/sonic/minigraph.xml --connect-timeout 15 && break | ||
sleep 5 | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Initial /etc/network/interface file for first boot | ||
# Will be overwritten based on minigraph information by interfaces-config service | ||
|
||
# The loopback network interface | ||
auto lo | ||
iface lo inet loopback | ||
# | ||
# The management network interface | ||
auto eth0 | ||
iface eth0 inet dhcp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this the default debian behavior? do we need to override? #WontFix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite sure whether this is the default behavior. Why not override it explicitly to make things clearer though? In reply to: 100564200 [](ancestors = 100564200) |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,10 @@ USERNAME = admin | |
|
||
# PASSWORD - password for installer build | ||
PASSWORD = YourPaSsWoRd | ||
|
||
# ENABLE_DHCP_GRAPH_SERVICE - specify the source of minigraph to generate configuration file. | ||
# If set to y SONiC will get the minigraph from graph service. Graph service URL need to be | ||
# passed through DHCP option 225. | ||
# If not set (default behavior) the default minigraph built into the image will be used. | ||
# ENABLE_DHCP_GRAPH_SERVICE = y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make the default behavior to n. #WontFix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all our other configs are using y vs commented. I guess we'd better make them consistent? In reply to: 100705528 [](ancestors = 100705528) |
||
|
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.
to simplify the name, we can use minigraph-url #Resolved