mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-23 19:57:09 +00:00
feat: add version column to node tables
- Shows PVE/PBS version in node summary tables - Helps quickly identify nodes needing updates - Extracts just version number from PVE (e.g. 9.0.5) - Also improved mock mode system for local development
This commit is contained in:
+92
-51
@@ -1,64 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Pure mock mode toggle - disables real nodes completely
|
||||
# This is a workaround until we properly integrate mock mode to skip node initialization
|
||||
# Pure mock mode toggle - completely disables real nodes when mock is enabled
|
||||
# This ensures no mixing of real and mock data
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
MODE="${1:-status}"
|
||||
MOCK_ENV="/opt/pulse/mock.env"
|
||||
SERVICE_DIR="/etc/systemd/system/pulse-backend.service.d"
|
||||
MOCK_CONF="$SERVICE_DIR/mock.conf"
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[1;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
RESET='\033[0m'
|
||||
|
||||
NODES_FILE="/etc/pulse/nodes.enc"
|
||||
NODES_BACKUP="/etc/pulse/nodes.enc.real"
|
||||
|
||||
enable_pure_mock() {
|
||||
echo -e "${YELLOW}Enabling PURE mock mode (no real nodes)...${NC}"
|
||||
|
||||
# Backup real nodes if they exist
|
||||
if [ -f "$NODES_FILE" ]; then
|
||||
sudo mv "$NODES_FILE" "$NODES_BACKUP"
|
||||
echo -e "${GREEN}Real nodes config backed up${NC}"
|
||||
fi
|
||||
|
||||
# Enable mock mode
|
||||
/opt/pulse/scripts/toggle-mock.sh on
|
||||
|
||||
echo -e "${GREEN}✓ Pure mock mode enabled!${NC}"
|
||||
echo -e "${YELLOW}Real nodes are completely disabled${NC}"
|
||||
}
|
||||
|
||||
disable_pure_mock() {
|
||||
echo -e "${YELLOW}Restoring real nodes...${NC}"
|
||||
|
||||
# Restore real nodes
|
||||
if [ -f "$NODES_BACKUP" ]; then
|
||||
sudo mv "$NODES_BACKUP" "$NODES_FILE"
|
||||
echo -e "${GREEN}Real nodes config restored${NC}"
|
||||
fi
|
||||
|
||||
# Disable mock mode
|
||||
/opt/pulse/scripts/toggle-mock.sh off
|
||||
|
||||
echo -e "${GREEN}✓ Back to real nodes!${NC}"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
case "$MODE" in
|
||||
on)
|
||||
enable_pure_mock
|
||||
echo -e "${YELLOW}Enabling PURE mock mode (disabling all real nodes)...${RESET}"
|
||||
|
||||
# Create the service override directory if it doesn't exist
|
||||
sudo mkdir -p "$SERVICE_DIR"
|
||||
|
||||
# Create override to set mock mode and disable real nodes
|
||||
sudo tee "$MOCK_CONF" > /dev/null <<EOF
|
||||
[Service]
|
||||
Environment="PULSE_MOCK_MODE=true"
|
||||
Environment="PULSE_DISABLE_REAL_NODES=true"
|
||||
EnvironmentFile=-/opt/pulse/mock.env
|
||||
EOF
|
||||
|
||||
# Ensure mock.env exists with good defaults
|
||||
if [ ! -f "$MOCK_ENV" ]; then
|
||||
cat > "$MOCK_ENV" <<'EOF'
|
||||
# Mock Mode Configuration
|
||||
PULSE_MOCK_MODE=true
|
||||
PULSE_MOCK_NODES=7
|
||||
PULSE_MOCK_VMS_PER_NODE=5
|
||||
PULSE_MOCK_LXCS_PER_NODE=8
|
||||
PULSE_MOCK_RANDOM_METRICS=true
|
||||
PULSE_MOCK_STOPPED_PERCENT=20
|
||||
EOF
|
||||
else
|
||||
# Ensure mock mode is enabled in the file
|
||||
sed -i 's/PULSE_MOCK_MODE=false/PULSE_MOCK_MODE=true/' "$MOCK_ENV"
|
||||
fi
|
||||
|
||||
# Build with mock support
|
||||
echo -e "${YELLOW}Building Pulse with mock support...${RESET}"
|
||||
cd /opt/pulse
|
||||
go build -tags "mock" -o bin/pulse ./cmd/pulse
|
||||
|
||||
# Reload and restart
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart pulse-backend
|
||||
|
||||
echo -e "${GREEN}✓ PURE mock mode enabled!${RESET}"
|
||||
echo -e "Real nodes are completely disabled."
|
||||
echo -e "Access Pulse at: ${GREEN}http://localhost:7655${RESET}"
|
||||
;;
|
||||
|
||||
off)
|
||||
disable_pure_mock
|
||||
echo -e "${YELLOW}Disabling mock mode (restoring real nodes)...${RESET}"
|
||||
|
||||
# Remove the mock override
|
||||
sudo rm -f "$MOCK_CONF"
|
||||
|
||||
# Update mock.env to disable mock mode
|
||||
if [ -f "$MOCK_ENV" ]; then
|
||||
sed -i 's/PULSE_MOCK_MODE=true/PULSE_MOCK_MODE=false/' "$MOCK_ENV"
|
||||
fi
|
||||
|
||||
# Build without mock support for production
|
||||
echo -e "${YELLOW}Building Pulse for production...${RESET}"
|
||||
cd /opt/pulse
|
||||
go build -o bin/pulse ./cmd/pulse
|
||||
|
||||
# Reload and restart
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart pulse-backend
|
||||
|
||||
echo -e "${GREEN}✓ Mock mode disabled!${RESET}"
|
||||
echo -e "Real nodes are now active."
|
||||
;;
|
||||
|
||||
status)
|
||||
if [ -f "$MOCK_CONF" ] && grep -q "PULSE_MOCK_MODE=true" "$MOCK_CONF" 2>/dev/null; then
|
||||
echo -e "${GREEN}Mock mode: ENABLED (Pure mode - real nodes disabled)${RESET}"
|
||||
if [ -f "$MOCK_ENV" ]; then
|
||||
echo "Mock configuration:"
|
||||
grep -E "PULSE_MOCK" "$MOCK_ENV" | grep -v "^#"
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}Mock mode: DISABLED (using real nodes)${RESET}"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Pure Mock Mode Toggle"
|
||||
echo "====================="
|
||||
echo "Usage: $0 {on|off|status}"
|
||||
echo ""
|
||||
echo "This completely disables real nodes for pure mock testing"
|
||||
echo ""
|
||||
echo "Usage: $0 {on|off}"
|
||||
echo ""
|
||||
echo " on - Enable pure mock mode (no real nodes)"
|
||||
echo " off - Restore real nodes"
|
||||
echo " on - Enable PURE mock mode (no real nodes)"
|
||||
echo " off - Disable mock mode (use real nodes)"
|
||||
echo " status - Show current mode"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user