Skip to content

feat : Implement a new separated CLI app [#327]#356

Merged
youngtaekiim merged 8 commits into
eclipse-pullpiri:mainfrom
LGSI-KarumuriHari:main
Oct 24, 2025
Merged

feat : Implement a new separated CLI app [#327]#356
youngtaekiim merged 8 commits into
eclipse-pullpiri:mainfrom
LGSI-KarumuriHari:main

Conversation

@LGSI-KarumuriHari
Copy link
Copy Markdown
Contributor

@LGSI-KarumuriHari LGSI-KarumuriHari commented Oct 23, 2025

Closes #327

Features

  • Metrics Operations: Get system metrics and board information
  • Board Management: List and inspect board configurations
  • Node Management: Monitor and manage individual nodes
  • SoC Management: Handle System-on-Chip resource management
  • Container Management: List and inspect container configurations and stats
  • YAML Artifact Management: Apply and withdraw YAML artifacts to/from the system
  • Health Checks: Verify SettingsService connectivity
  • Flexible Output: Support for both formatted and raw JSON output
  • Comprehensive Help: Built-in help system for all commands

Usage

Basic Syntax

settingscli [OPTIONS] <COMMAND>

Global Options

  • -u, --url <URL>: SettingsService URL (default: http://localhost:8080)
  • -t, --timeout <SECONDS>: Request timeout in seconds (default: 30)
  • -v, --verbose: Enable verbose output
  • -h, --help: Print help information
  • -V, --version: Print version information

Commands

Health Check

Test connection to SettingsService:

settingscli health

Note: Presently health is not supported in settingservice .

Metrics

Get system metrics:

# Get formatted metrics
settingscli metrics get

# Get raw JSON metrics
settingscli metrics raw

Board Operations

# List all boards
settingscli board list

# Get specific board information
settingscli board get <BOARD_ID>

# Get raw board data
settingscli board raw [BOARD_ID]

Node Operations

# List all nodes
settingscli node list

# Get specific node information
settingscli node get <NODE_ID>

# Get raw node data
settingscli node raw [NODE_ID]

SoC Operations

# List all SoCs
settingscli soc list

# Get specific SoC information
settingscli soc get <SOC_ID>

# Get raw SoC data
settingscli soc raw [SOC_ID]

Container Operations

# List all containers
settingscli container list

# Get specific container information
settingscli container get <CONTAINER_ID>

# Get raw container data
settingscli container raw

YAML Artifact Management

# Apply YAML artifact from file
settingscli yaml apply <FILE_PATH>

# Apply YAML artifact from stdin
settingscli yaml apply -

# Withdraw YAML artifact from file
settingscli yaml withdraw <FILE_PATH>

# Withdraw YAML artifact from stdin
settingscli yaml withdraw -

Error Handling

The CLI provides clear error messages for common issues:

  • Connection errors: When SettingsService is unreachable
  • Timeout errors: When requests take too long
  • JSON parsing errors: When response format is unexpected
  • HTTP errors: When API endpoints return error status codes
  • File errors: When YAML files cannot be read or parsed
  • YAML validation errors: When YAML artifacts are missing required kinds

Common Error Scenarios

# Service unreachable
$ settingscli health
✗ Failed to connect to SettingsService: Connection refused

# Invalid container ID
$ settingscli container get invalid-id
✗ Failed to fetch container invalid-id: Request failed with status: 404 Not Found

# Missing YAML file
$ settingscli yaml apply nonexistent.yaml
✗ Failed to apply YAML artifact: File not found: nonexistent.yaml

# Server error during container retrieval
$ settingscli container get <container-id>
✗ Failed to fetch container <container-id>: Request failed with status: 500 Internal Server Error

Development

Project Structure

src/tools/settingscli/
├── Cargo.toml          # Dependencies and metadata
├── src/
│   ├── main.rs         # CLI entry point
│   ├── lib.rs          # Library exports
│   ├── client.rs       # HTTP client implementation
│   ├── error.rs        # Error handling
│   └── commands/       # Command implementations
│       ├── mod.rs      # Command utilities
│       ├── metrics.rs  # Metrics operations
│       ├── board.rs    # Board operations
│       ├── node.rs     # Node operations
│       ├── soc.rs      # SoC operations
│       ├── container.rs # Container operations
│       └── yaml.rs     # YAML artifact management
└── tests/              # Integration tests
    ├── integration_test.rs
    └── cli_test.rs

Adding New Commands

  1. Create a new file in src/commands/
  2. Implement the command logic with appropriate error handling
  3. Add the command to the main CLI enum in main.rs
  4. Update the command dispatcher
  5. Add tests for the new functionality

API Endpoints

The CLI interacts with the following SettingsService REST API endpoints:

Resource Management APIs

Command HTTP Method Endpoint Description
metrics get GET /api/v1/metrics Get all system metrics
metrics raw GET /api/v1/metrics Get raw metrics data
board list GET /api/v1/boards List all boards
board get <id> GET /api/v1/boards/{id} Get specific board
board raw GET /api/v1/boards Get raw board data
node list GET /api/v1/nodes List all nodes
node get <name> GET /api/v1/nodes/{name} Get specific node
node raw GET /api/v1/nodes Get raw node data
soc list GET /api/v1/socs List all SoCs
soc get <id> GET /api/v1/socs/{id} Get specific SoC
soc raw GET /api/v1/socs Get raw SoC data
container list GET /api/v1/containers List all containers
container get <id> GET /api/v1/containers/{id} Get specific container
container raw GET /api/v1/containers Get raw container data

YAML Artifact APIs

Command HTTP Method Endpoint Description
yaml apply <file> POST /api/v1/yaml Apply YAML artifact
yaml withdraw <file> DELETE /api/v1/yaml Withdraw YAML artifact

System APIs

Command HTTP Method Endpoint Description
health GET /api/v1/system/health Health check

Complete Command Reference

Global Commands

# Show help for all commands
settingscli --help

# Show version information
settingscli --version

# Test connectivity to SettingsService
settingscli health
settingscli -u http://custom-host:8080 health

Metrics Commands

# Get formatted system metrics
settingscli metrics get

# Get raw JSON metrics data
settingscli metrics raw

# With custom settings
settingscli -u http://remote-host:8080 -t 30 metrics get

Board Commands

# List all boards (formatted)
settingscli board list

# Get specific board details
settingscli board get 10.221.40.100

# Get raw board data (all boards)
settingscli board raw

# Get raw data for specific board
settingscli board raw 10.221.40.100

Node Commands

# List all nodes (formatted)
settingscli node list

# Get specific node details
settingscli node get lg-OptiPlex-3070

# Get raw node data (all nodes)
settingscli node raw

# Get raw data for specific node
settingscli node raw lg-OptiPlex-3070

SoC Commands

# List all SoCs (formatted)
settingscli soc list

# Get specific SoC details
settingscli soc get 10.221.40.190

# Get raw SoC data (all SoCs)
settingscli soc raw

# Get raw data for specific SoC
settingscli soc raw 10.221.40.190

Container Commands

# List all containers (formatted)
settingscli container list

# Get specific container details (may return 500 error - known issue)
settingscli container get 2a465a2ea2d8ce9d35ab5eaae729067267ec09377edf89d02daa6c78d3787d2e

# Get raw container data (recommended for detailed info)
settingscli container raw

YAML Artifact Commands

# Apply YAML artifact from file
settingscli yaml apply /path/to/artifact.yaml
settingscli yaml apply ./examples/helloworld.yaml

# Apply YAML from stdin
cat artifact.yaml | settingscli yaml apply -
echo "apiVersion: v1..." | settingscli yaml apply -

# Withdraw YAML artifact from file
settingscli yaml withdraw /path/to/artifact.yaml

# Withdraw YAML from stdin
cat artifact.yaml | settingscli yaml withdraw -

Service Architecture

┌─────────────────┐    HTTP/REST    ┌─────────────────┐
│   SettingsCLI   │◄──────────────► │ SettingsService │
│                 │                 │   (port 8080)   │
└─────────────────┘                 └─────────────────┘
                                            │
                                            │ ETCD
                                            ▼
                                    ┌─────────────────┐
                                    │      ETCD       │
                                    │  (2379, 2380)   │
                                    └─────────────────┘
                                            ▲
                    ┌───────────────────────┼───────────────────────┐
                    │                       │                       │
            ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
            │ MonitoringServer│    │   StateManager  │    │    NodeAgent    │
            │   (gRPC/REST)   │    │   (gRPC/REST)   │    │   (gRPC/REST)   │
            └─────────────────┘    └─────────────────┘    └─────────────────┘

Screen shots

image image image image

@LGSI-KarumuriHari
Copy link
Copy Markdown
Contributor Author

@daeyoung-jeong-lge please check this pr , Thanks

Copy link
Copy Markdown
Contributor

@daeyoung-jeong-lge daeyoung-jeong-lge left a comment

Choose a reason for hiding this comment

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

looks good

Comment thread src/tools/deny.toml
@daeyoung-jeong-lge
Copy link
Copy Markdown
Contributor

@youngtaekiim 이 PR은 우리가 예전에 개발회의 때 논의했었던, 어디에서든 동작할 수 있는 CLI app입니다. SettingsService의 REST API를 통해 데이터를 수신해서 CLI 위에 뿌려줍니다. 저는 review를 완료했고, 영태 책임님께서 보시기에도 문제 없다면 merge 부탁드립니다.

@youngtaekiim youngtaekiim merged commit 7f21ec5 into eclipse-pullpiri:main Oct 24, 2025
6 checks passed
eunhyeYu pushed a commit to eunhyeYu/pullpiri that referenced this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Implement a new separated CLI app

3 participants