Skip to content

Go implementation of the Turing Pi CLI for controlling and managing Turing Pi boards.

Notifications You must be signed in to change notification settings

davidroman0O/tpi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turing Pi Control Tools

This repository contains tools for controlling Turing Pi boards, split into two components:

Components

A Go library for programmatically controlling Turing Pi boards via their BMC API.

go get github.com/davidroman0O/tpi

Learn more about the client library →

A command-line interface for controlling Turing Pi boards.

# Install pre-built binary (see releases)
# or build from source:
cd cli && go build

Learn more about the CLI tool →

Repository Structure

tpi/
├── client/           # Client library (minimal dependencies)
│   ├── *.go          # Core functionality files
│   └── testdata/     # Test data
├── cli/              # Command-line interface 
│   ├── commands/     # CLI command implementations
│   └── main.go       # CLI entry point
└── .github/          # GitHub workflows and config

Quick Start

Using the CLI

# Power on node 1
./cli/tpi power on 1 --host=192.168.1.91

# Get power status
./cli/tpi power status --host=192.168.1.91

Using the Client Library

package main

import (
	"fmt"
	"os"

	"github.com/davidroman0O/tpi/client"
)

func main() {
	// Create a client
	c, err := client.NewClient(
		client.WithHost("192.168.1.91"),
		client.WithCredentials("root", "turing"),
	)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	// Power on node 1
	if err := c.PowerOn(1); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	fmt.Println("Node 1 powered on!")
}

Using the Agent Client

package main

import (
	"fmt"
	"os"

	"github.com/davidroman0O/tpi/client/agent"
)

func main() {
	// Create an agent client to connect to a remote agent server
	c, err := agent.NewAgentClient(
		agent.WithAgentHost("192.168.1.91"),
		agent.WithAgentPort(9977),
		agent.WithAgentSecret("mysecret"),
	)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	// Power on node 1 remotely
	if err := c.PowerOn(1); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	fmt.Println("Node 1 powered on remotely!")
}

Agent Mode

The library and CLI now support an Agent Mode that allows you to control a Turing Pi board remotely without direct access to the BMC. This works by running an agent server on a machine with direct access to the Turing Pi board, and connecting to it from a remote machine.

Learn more about Agent Mode →

License

Apache License 2.0

About

Go implementation of the Turing Pi CLI for controlling and managing Turing Pi boards.

Topics

Resources

Stars

Watchers

Forks

Languages