cmlclient

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 20 Imported by: 0

README

Go Reference CodeQL Go Coverage Status Go Report Card

gocmlclient

A CML2 Client in Golang

(c) Ralph Schmieder 2022

Documentation

Index

Constants

View Source
const (
	IfaceStateDefined = "DEFINED_ON_CORE"
	IfaceStateStopped = "STOPPED"
	IfaceStateStarted = "STARTED"

	IfaceTypePhysical = "physical"
	IfaceTypeLoopback = "loopback"
)
View Source
const (
	LabStateDefined = "DEFINED_ON_CORE"
	LabStateStopped = "STOPPED"
	LabStateStarted = "STARTED"
	LabStateBooted  = "BOOTED"
)
View Source
const (
	LinkStateDefined = "DEFINED_ON_CORE"
	LinkStateStopped = "STOPPED"
	LinkStateStarted = "STARTED"
)
View Source
const (
	NodeStateDefined = "DEFINED_ON_CORE"
	NodeStateStopped = "STOPPED"
	NodeStateStarted = "STARTED"
	NodeStateBooted  = "BOOTED"
)

Variables

View Source
var (
	ErrSystemNotReady  = errors.New("system not ready")
	ErrElementNotFound = errors.New("element not found")
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Token    string `json:"token"`
	Admin    bool   `json:"admin"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(host string, insecure, useCache bool) *Client

func (*Client) GetImageDefs

func (c *Client) GetImageDefs(ctx context.Context) ([]ImageDefinition, error)

func (*Client) GetNodeDefs

func (c *Client) GetNodeDefs(ctx context.Context) (NodeDefinitionMap, error)

func (*Client) HasLabConverged

func (c *Client) HasLabConverged(ctx context.Context, id string) (bool, error)

func (*Client) InterfaceCreate added in v0.0.2

func (c *Client) InterfaceCreate(ctx context.Context, labID, nodeID string, slot *int) (*Interface, error)

InterfaceCreate creates an interface in the given lab and node. If the slot is not nil, the request creates all unallocated slots up to and including that slot.

func (*Client) InterfaceGet added in v0.0.2

func (c *Client) InterfaceGet(ctx context.Context, iface *Interface) (*Interface, error)

func (*Client) LabCreate added in v0.0.2

func (c *Client) LabCreate(ctx context.Context, lab Lab) (*Lab, error)

func (*Client) LabDestroy

func (c *Client) LabDestroy(ctx context.Context, id string) error

func (*Client) LabGet

func (c *Client) LabGet(ctx context.Context, id string, deep bool) (*Lab, error)

func (*Client) LabGetByTitle added in v0.0.2

func (c *Client) LabGetByTitle(ctx context.Context, title string, deep bool) (*Lab, error)

func (*Client) LabImport

func (c *Client) LabImport(ctx context.Context, topo string) (*Lab, error)

func (*Client) LabStart

func (c *Client) LabStart(ctx context.Context, id string) error

func (*Client) LabStop

func (c *Client) LabStop(ctx context.Context, id string) error

func (*Client) LabUpdate added in v0.0.2

func (c *Client) LabUpdate(ctx context.Context, lab Lab) (*Lab, error)

func (*Client) LabWipe

func (c *Client) LabWipe(ctx context.Context, id string) error

func (*Client) LinkCreate added in v0.0.2

func (c *Client) LinkCreate(ctx context.Context, link *Link) (*Link, error)

func (*Client) LinkGet added in v0.0.2

func (c *Client) LinkGet(ctx context.Context, labID, linkID string, deep bool) (*Link, error)

func (*Client) NodeCreate added in v0.0.2

func (c *Client) NodeCreate(ctx context.Context, node *Node) (*Node, error)

NodeCreate creates a new node on the controller

func (*Client) NodeDestroy added in v0.0.2

func (c *Client) NodeDestroy(ctx context.Context, node *Node) error

func (*Client) NodeGet added in v0.0.2

func (c *Client) NodeGet(ctx context.Context, node *Node, nocache bool) (*Node, error)

func (*Client) NodeSetConfig

func (c *Client) NodeSetConfig(ctx context.Context, node *Node, configuration string) error

func (*Client) NodeStart

func (c *Client) NodeStart(ctx context.Context, node *Node) error

NodeStart the given node

func (*Client) NodeStop

func (c *Client) NodeStop(ctx context.Context, node *Node) error

NodeStop the given node

func (*Client) NodeUpdate added in v0.0.2

func (c *Client) NodeUpdate(ctx context.Context, node *Node) (*Node, error)

func (*Client) NodeWipe added in v0.0.2

func (c *Client) NodeWipe(ctx context.Context, node *Node) error

func (*Client) SetCACert

func (c *Client) SetCACert(cert []byte) error

func (*Client) SetToken

func (c *Client) SetToken(token string)

func (*Client) SetUsernamePassword

func (c *Client) SetUsernamePassword(username, password string)

type Group added in v0.0.2

type Group struct {
	ID         string `json:"id"`
	Permission string `json:"permission"`
}

type IDlist

type IDlist []string

type ImageDefinition

type ImageDefinition struct {
	ID            string `json:"id"`
	NodeDefID     string `json:"node_definition_id"`
	Description   string `json:"description"`
	Label         string `json:"label"`
	DiskImage     string `json:"disk_image"`
	ReadOnly      bool   `json:"read_only"`
	RAM           *int   `json:"ram"`
	CPUs          *int   `json:"cpus"`
	CPUlimit      *int   `json:"cpu_limit"`
	DataVolume    *int   `json:"data_volume"`
	BootDiskSize  *int   `json:"boot_disk_size"`
	DiskSubfolder string `json:"disk_subfolder"`
	SchemaVersion string `json:"schema_version"`
}

type Interface

type Interface struct {
	ID          string `json:"id"`
	LabID       string `json:"lab_id"`
	Node        string `json:"node"`
	Label       string `json:"label"`
	Slot        int    `json:"slot"`
	Type        string `json:"type"`
	DeviceName  string `json:"device_name"`
	SrcUDPport  int    `json:"src_udp_port"`
	DstUDPport  int    `json:"dst_udp_port"`
	MACaddress  string `json:"mac_address"`
	IsConnected bool   `json:"is_connected"`
	State       string `json:"state"`

	// extra
	IP4 []string `json:"ip4"`
	IP6 []string `json:"ip6"`
	// contains filtered or unexported fields
}

func (Interface) Exists

func (iface Interface) Exists() bool

func (Interface) IsPhysical added in v0.0.2

func (iface Interface) IsPhysical() bool

func (Interface) Runs

func (iface Interface) Runs() bool

type InterfaceList added in v0.0.2

type InterfaceList []*Interface

type Lab

type Lab struct {
	ID          string    `json:"id"`
	State       string    `json:"state"`
	Created     string    `json:"created"`
	Modified    string    `json:"modified"`
	Title       string    `json:"lab_title"`
	Description string    `json:"lab_description"`
	Notes       string    `json:"lab_notes"`
	Owner       *User     `json:"owner"`
	NodeCount   int       `json:"node_count"`
	LinkCount   int       `json:"link_count"`
	Nodes       NodeMap   `json:"nodes"`
	Links       linkList  `json:"links"`
	Groups      groupList `json:"groups"`
}

func (*Lab) Booted

func (l *Lab) Booted() bool

func (*Lab) CanBeWiped

func (l *Lab) CanBeWiped() bool

func (*Lab) NodeByLabel

func (l *Lab) NodeByLabel(ctx context.Context, label string) (*Node, error)

func (*Lab) Running

func (l *Lab) Running() bool

type LabImport

type LabImport struct {
	ID       string   `json:"id"`
	Warnings []string `json:"warnings"`
}
type Link struct {
	ID      string `json:"id"`
	LabID   string `json:"lab_id"`
	State   string `json:"state"`
	Label   string `json:"label"`
	PCAPkey string `json:"link_capture_key"`
	SrcID   string `json:"interface_a"`
	DstID   string `json:"interface_b"`
	SrcNode string `json:"node_a"`
	DstNode string `json:"node_b"`
	SrcSlot *int   `json:"slot_a"`
	DstSlot *int   `json:"slot_b"`
	// contains filtered or unexported fields
}

type Node

type Node struct {
	ID              string         `json:"id"`
	LabID           string         `json:"lab_id"`
	Label           string         `json:"label"`
	X               int            `json:"x"`
	Y               int            `json:"y"`
	NodeDefinition  string         `json:"node_definition"`
	ImageDefinition string         `json:"image_definition"`
	Configuration   string         `json:"configuration"`
	CPUs            int            `json:"cpus"`
	CPUlimit        int            `json:"cpu_limit"`
	RAM             int            `json:"ram"`
	State           string         `json:"state"`
	DataVolume      int            `json:"data_volume"`
	BootDiskSize    int            `json:"boot_disk_size"`
	Interfaces      InterfaceList  `json:"interfaces,omitempty"`
	Tags            []string       `json:"tags"`
	VNCkey          string         `json:"vnc_key"`
	SerialDevices   []SerialDevice `json:"serial_devices"`
	ComputeID       string         `json:"compute_id"`
	// contains filtered or unexported fields
}

type NodeDefinition

type NodeDefinition struct {
	ID      definitionID   `json:"id"`
	General map[string]any `json:"general"`
	Device  deviceData     `json:"device"`
	UI      map[string]any `json:"ui"`
	Sim     simData        `json:"sim"`
	Images  []string       `json:"image_definitions"`
}

type NodeDefinitionMap added in v0.0.5

type NodeDefinitionMap map[definitionID]NodeDefinition

type NodeMap

type NodeMap map[string]*Node

func (NodeMap) MarshalJSON

func (nmap NodeMap) MarshalJSON() ([]byte, error)

type SerialDevice added in v0.0.2

type SerialDevice struct {
	ConsoleKey   string `json:"console_key"`
	DeviceNumber int    `json:"device_number"`
}

type User

type User struct {
	ID          string `json:"id"`
	Created     string `json:"created"`
	Modified    string `json:"modified"`
	Username    string `json:"username"`
	Fullname    string `json:"fullname"`
	Email       string `json:"email"`
	Description string `json:"lab_description"`
	IsAdmin     bool   `json:"admin"`
	DirectoryDN string `json:"directory_dn"`
}

Directories

Path Synopsis
cmd
ctest command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL