Skip to content
Open
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
9 changes: 8 additions & 1 deletion fboss-image/image_builder/templates/centos-09.0/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ echo "--- Executing $0 ---"
sed -i 's/^PRETTY_NAME=.*/PRETTY_NAME="FBOSS Distro Image"/' /usr/lib/os-release
sed -i 's/^NAME=.*/NAME="FBOSS Distro Image"/' /usr/lib/os-release

# All dnf invocations with an invalid RPM repo configured will fail. Create the
# metadata for the local_rpm_repo now to prevent that.
createrepo /usr/local/share/local_rpm_repo

# 1. Install our custom kernel RPMs
#
# On purpose we don't install any kernel rpms as part of
Expand Down Expand Up @@ -53,13 +57,16 @@ env -i \

# 5. Enable systemd services
echo "Enabling FBOSS systemd services..."
systemctl enable fboss_init.service
systemctl enable local_rpm_repo.service
systemctl enable platform_manager.service
systemctl enable data_corral_service.service
systemctl enable fan_service.service
systemctl enable sensor_service.service
systemctl enable fsdb.service
systemctl enable qsfp_service.service
systemctl enable wedge_agent.service
systemctl enable fboss_sw_agent.service
systemctl enable fboss_hw_agents.target

# 6. Use system GRUB 2.06 from packages
# The grub2-efi-x64 package already provides grubx64.efi with all necessary modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<package name="vim"/>
<package name="vi"/>
<package name="btrfs-progs"/>
<package name="createrepo"/>
<package name="libnl3"/>
<package name="python3.12"/>
<package name="nvme-cli"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[local_rpm_repo]
name=Local Platform RPM repo
baseurl=file:///usr/local/share/local_rpm_repo
gpgcheck=0
metadata_expire=6h
enabled=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# /usr/lib/systemd/system/fboss_hw_agent@.service
[Unit]
Description=FBOSS HW Agent %i
PartOf=fboss_hw_agents.target
After=platform_manager.service
After=qsfp_service.service
After=rc-local.service
Wants=fboss_init.service
After=fboss_init.service

[Service]
Type=simple
LimitNOFILE=10000000
LimitCORE=32G
MemoryMax=3.75G
MemorySwapMax=0

Environment="PATH=/opt/fboss/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
Environment="LD_LIBRARY_PATH=/opt/fboss/lib"
WorkingDirectory=/opt/fboss
ExecStart=/bin/bash -c 'source /opt/fboss/bin/setup_fboss_env && exec /opt/fboss/bin/fboss_hw_agent-sai_impl --switchIndex %i'
Copy link

Choose a reason for hiding this comment

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

How do we decide on mutli selection of sai sdk's are we going to stick with the assumption there is only 1 sai_impl on the target distro device?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now Distro Image is designed with the assumption that any particular image will only be built with one ASIC SAI. That is the logic implemented here.

When multi-SAI SDK support is added, the logic here would be extended to use whatever the new choice mechanism is.


Restart=always
RestartSec=30
TimeoutStartSec=180s
TimeoutStopSec=30s

# Logging to journald
StandardOutput=journal
StandardError=journal
SyslogIdentifier=fboss_hw_agent%i

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=FBOSS HW Agents Target
Wants=fboss_hw_agent@0.service fboss_hw_agent@1.service fboss_hw_agent@2.service fboss_hw_agent@3.service

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# /usr/lib/systemd/system/fboss_init.service
[Unit]
Description=FBOSS Initialization
DefaultDependencies=no
Before=platform_manager.service
After=local-fs.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/fboss_init.sh

# Logging to journald
StandardOutput=journal
StandardError=journal
SyslogIdentifier=fboss_init

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# /usr/lib/systemd/system/fboss_sw_agent.service
[Unit]
Description=FBOSS SW Agent
After=platform_manager.service
After=qsfp_service.service
After=rc-local.service
StartLimitIntervalSec=600
StartLimitBurst=5

[Service]
Type=notify
LimitNOFILE=10000000
LimitCORE=32G
MemoryMax=3.75G
MemorySwapMax=0

Environment="PATH=/opt/fboss/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
Environment="LD_LIBRARY_PATH=/opt/fboss/lib"
WorkingDirectory=/opt/fboss
ExecStart=/bin/bash -c 'source /opt/fboss/bin/setup_fboss_env && exec /opt/fboss/bin/fboss_sw_agent'

Restart=always
RestartSec=30
TimeoutStartSec=180s
TimeoutStopSec=30s

# Logging to journald
StandardOutput=journal
StandardError=journal
SyslogIdentifier=fboss_sw_agent

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Enable local_rpm_repo

[Service]
Type=oneshot
ExecStart=/usr/bin/createrepo /usr/local/share/local_rpm_repo
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Before=led_service.service
Before=qsfp_service.service
Before=fruid.service
After=rc-local.service
After=fboss_init.service
Wants=local_rpm_repo.service
Wants=fboss_init.service

StartLimitIntervalSec=600
StartLimitBurst=5

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/bash
# Initialize FBOSS configuration based on platform detection

set -e

FBOSS_SHARE="/opt/fboss/share"
COOP_DIR="/etc/coop"
FRUID_FILE="/var/facebook/fboss/fruid.json"

log() {
echo "[fboss_init] $1" >&2
}

error() {
echo "[fboss_init] ERROR: $1" >&2
}

get_platform_dir() {
local platform
# convert the platform name to lowercase and delete spaces
platform=$(dmidecode -s system-product-name 2>/dev/null | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]-_')
if [[ -z $platform ]]; then
error "Failed to get system-product-name from dmidecode"
return 1
fi
log "Detected platform: $platform"

local platform_dir="${FBOSS_SHARE}/default_configs/${platform}"
if [[ ! -d $platform_dir ]]; then
error "Platform config directory not found: $platform_dir"
return 1
fi
log "Using platform config directory: $platform_dir"

echo "$platform_dir"
}

copy_config() {
local src="$1"
local dst="$2"
local name="$3"

if [[ -e $dst ]]; then
log "$name already exists at $dst (skipping)"
return
fi

if [[ -f $src ]]; then
cp "$src" "$dst"
log "Copied $name: $src -> $dst"
else
log "No $name found at $src (skipping)"
fi
}

generate_fruid() {
if [[ -e $FRUID_FILE ]]; then
log "fruid.json already exists at $FRUID_FILE (skipping)"
return
fi

mkdir -p "$(dirname "$FRUID_FILE")"

if /opt/fboss/bin/weutil --json >"$FRUID_FILE" 2>/dev/null; then
log "Generated fruid.json: $FRUID_FILE"
else
error "Failed to generate fruid.json"
rm -f "$FRUID_FILE"
fi
}

setup_coop_configs() {
local platform_dir="$1"
mkdir -p "$COOP_DIR"
copy_config "${platform_dir}/agent.conf" "${COOP_DIR}/agent.conf" "agent.conf"
copy_config "${platform_dir}/qsfp.conf" "${COOP_DIR}/qsfp.conf" "qsfp.conf"
}

enable_hw_agents() {
local platform_dir="$1"
local num_hw_agents
if [ ! -f "${platform_dir}/num_hw_agents" ]; then
num_hw_agents=1
else
num_hw_agents=$(cat "${platform_dir}/num_hw_agents")
fi
for i in $(seq ${num_hw_agents}); do
systemctl enable "fboss_hw_agent@$((i - 1)).service"
# Calling systemctl start inside a starting systemd service deadlocks
systemctl start "fboss_hw_agent@$((i - 1)).service" &
done
}

main() {
log "Starting FBOSS initialization"

local platform_dir
if ! platform_dir=$(get_platform_dir); then
exit 1
fi

setup_coop_configs "$platform_dir"
generate_fruid
enable_hw_agents "$platform_dir"

log "FBOSS initialization complete"
}

main "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains RPMs which need to be installed at run-time, mostly by
platform_manager. Common contents include BSP kmods RPMs, SAI kmods RPMs, and
dependencies of those types of RPMs.
1 change: 1 addition & 0 deletions fboss/oss/scripts/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
RUN_SCRIPTS_DIR / "setup.py": "bin/setup.py",
RUN_SCRIPTS_DIR / "setup_fboss_env": "bin/setup_fboss_env",
RUN_SCRIPTS_DIR / "topology.cdf": "bin/topology.cdf",
RUN_CONFIGS_DIR / "default_configs": "share/default_configs",
RUN_CONFIGS_DIR / "j2cp": "share/j2cp",
RUN_CONFIGS_DIR / "j3b": "share/j3b",
RUN_CONFIGS_DIR / "janga800bic": "share/janga800bic",
Expand Down
Loading
Loading