Files
ols-ucentral-client/tests/tools/fetch-schema.sh
Mike Hansen 04edeb90e4 [OLS-915] Schema-based property generation and platform testing │
Schema-based property database:                                                                                                                                                    │
- Extract 398 properties from schema (vs config files)                                                                                                                             │
- Generate base DB (proto.c: 102 found, 296 unimplemented)                                                                                                                         │
- Generate platform DB (plat-gnma.c: 141 found, 257 unimplemented)                                                                                                                 │
- Support JSON schema (included) and YAML (external repo)                                                                                                                          │

Platform testing framework:                                                                                                                                                        │
- Stub hardware layer (gNMI/gNOI), test real platform logic                                                                                                                        │
- Dual tracking: base parsing + platform application                                                                                                                               │
- Platform mocks for brcm-sonic and example platforms                                                                                                                              │

Changes:                                                                                                                                                                           │
- New: extract-schema-properties.py (JSON/YAML support)                                                                                                                            │
- New: generate-database-from-schema.py, generate-platform-database-from-schema.py                                                                                                 │
- New: Platform mocks and property databases                                                                                                                                       │
- Remove: 4 legacy config-based generation tools                                                                                                                                   │
- Remove: unused ucentral.schema.full.json                                                                                                                                         │
- Update: Simplified fetch-schema.sh, updated MAINTENANCE.md                                                                                                                       │

Tests: 24/24 pass (stub and platform modes)

Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
2026-01-05 10:00:54 -05:00

89 lines
2.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
#
# Schema Repository Helper
#
# Simple helper script to fetch the uCentral schema from GitHub.
# This repository includes default schema files in config-samples/, so fetching
# is optional and only needed when updating to a newer schema version.
#
# Usage:
# ./fetch-schema.sh [BRANCH]
#
# Examples:
# ./fetch-schema.sh # Clone using 'main' branch
# ./fetch-schema.sh release-1.0 # Clone specific branch
# ./fetch-schema.sh --help # Show this help
#
set -e
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
SCHEMA_REPO="https://github.com/Telecominfraproject/ols-ucentral-schema.git"
SCHEMA_DIR="../../ols-ucentral-schema"
DEFAULT_BRANCH="main"
# Show help
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
grep '^#' "$0" | sed 's/^# \?//'
echo ""
echo -e "${BLUE}Repository Information:${NC}"
echo " Location: $SCHEMA_REPO"
echo " Clone to: $SCHEMA_DIR"
echo ""
echo -e "${BLUE}Manual Alternative:${NC}"
echo " cd tests/tools"
echo " git clone $SCHEMA_REPO"
echo " cd ols-ucentral-schema && git checkout <branch>"
echo ""
exit 0
fi
# Determine branch
BRANCH="${1:-$DEFAULT_BRANCH}"
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}uCentral Schema Fetcher${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo -e "${BLUE}Repository:${NC} $SCHEMA_REPO"
echo -e "${BLUE}Branch:${NC} $BRANCH"
echo -e "${BLUE}Target:${NC} $SCHEMA_DIR"
echo ""
# Check if directory exists
if [[ -d "$SCHEMA_DIR" ]]; then
echo -e "${YELLOW}⚠️ Schema directory already exists: $SCHEMA_DIR${NC}"
echo ""
echo "Options:"
echo " 1. Update existing clone: cd $SCHEMA_DIR && git pull"
echo " 2. Switch branch: cd $SCHEMA_DIR && git checkout <branch>"
echo " 3. Remove and re-clone: rm -rf $SCHEMA_DIR && ./fetch-schema.sh $BRANCH"
echo ""
exit 1
fi
# Clone the repository
echo -e "${BLUE} Cloning schema repository...${NC}"
git clone --branch "$BRANCH" --depth 1 "$SCHEMA_REPO" "$SCHEMA_DIR"
echo ""
echo -e "${GREEN}✓ Schema cloned successfully${NC}"
echo ""
echo -e "${BLUE}Schema location:${NC} $SCHEMA_DIR"
echo -e "${BLUE}Branch:${NC} $(cd "$SCHEMA_DIR" && git rev-parse --abbrev-ref HEAD)"
echo -e "${BLUE}Commit:${NC} $(cd "$SCHEMA_DIR" && git rev-parse --short HEAD)"
echo ""
echo -e "${BLUE}Next steps:${NC}"
echo " # Extract properties from schema"
echo " python3 extract-schema-properties.py $SCHEMA_DIR/schema ucentral.yml"
echo ""
echo " # See full workflow in documentation"
echo " cat ../MAINTENANCE.md"
echo ""