Documentation ¶
Index ¶
- Constants
- Variables
- type Auth
- type Client
- func (c *Client) ExtConnGet(ctx context.Context, extConnID string) (*ExtConn, error)
- func (c *Client) ExtConnectors(ctx context.Context) ([]*ExtConn, error)
- func (c *Client) GroupByName(ctx context.Context, name string) (*Group, error)
- func (c *Client) GroupCreate(ctx context.Context, group *Group) (*Group, error)
- func (c *Client) GroupDestroy(ctx context.Context, id string) error
- func (c *Client) GroupGet(ctx context.Context, id string) (*Group, error)
- func (c *Client) GroupUpdate(ctx context.Context, group *Group) (*Group, error)
- func (c *Client) Groups(ctx context.Context) (GroupList, error)
- func (c *Client) HasLabConverged(ctx context.Context, id string) (bool, error)
- func (c *Client) ImageDefinitions(ctx context.Context) ([]ImageDefinition, error)
- func (c *Client) InterfaceCreate(ctx context.Context, labID, nodeID string, slot int) (*Interface, error)
- func (c *Client) InterfaceGet(ctx context.Context, iface *Interface) (*Interface, error)
- func (c *Client) LabCreate(ctx context.Context, lab Lab) (*Lab, error)
- func (c *Client) LabDestroy(ctx context.Context, id string) error
- func (c *Client) LabGet(ctx context.Context, id string, deep bool) (*Lab, error)
- func (c *Client) LabGetByTitle(ctx context.Context, title string, deep bool) (*Lab, error)
- func (c *Client) LabImport(ctx context.Context, topo string) (*Lab, error)
- func (c *Client) LabStart(ctx context.Context, id string) error
- func (c *Client) LabStop(ctx context.Context, id string) error
- func (c *Client) LabUpdate(ctx context.Context, lab Lab) (*Lab, error)
- func (c *Client) LabWipe(ctx context.Context, id string) error
- func (c *Client) LinkCreate(ctx context.Context, link *Link) (*Link, error)
- func (c *Client) LinkGet(ctx context.Context, labID, linkID string, deep bool) (*Link, error)
- func (c *Client) NodeCreate(ctx context.Context, node *Node) (*Node, error)
- func (c *Client) NodeDefinitions(ctx context.Context) (NodeDefinitionMap, error)
- func (c *Client) NodeDestroy(ctx context.Context, node *Node) error
- func (c *Client) NodeGet(ctx context.Context, node *Node, nocache bool) (*Node, error)
- func (c *Client) NodeSetConfig(ctx context.Context, node *Node, configuration string) error
- func (c *Client) NodeStart(ctx context.Context, node *Node) error
- func (c *Client) NodeStop(ctx context.Context, node *Node) error
- func (c *Client) NodeUpdate(ctx context.Context, node *Node) (*Node, error)
- func (c *Client) NodeWipe(ctx context.Context, node *Node) error
- func (c *Client) Ready(ctx context.Context) error
- func (c *Client) SetCACert(cert []byte) error
- func (c *Client) SetToken(token string)
- func (c *Client) SetUsernamePassword(username, password string)
- func (c *Client) UserByName(ctx context.Context, name string) (*User, error)
- func (c *Client) UserCreate(ctx context.Context, user *User) (*User, error)
- func (c *Client) UserDestroy(ctx context.Context, id string) error
- func (c *Client) UserGet(ctx context.Context, id string) (*User, error)
- func (c *Client) UserGroups(ctx context.Context, id string) (GroupList, error)
- func (c *Client) UserUpdate(ctx context.Context, user *User) (*User, error)
- func (c *Client) Users(ctx context.Context) (UserList, error)
- func (c *Client) Version() string
- type ExtConn
- type Group
- type GroupLab
- type GroupList
- type IDlist
- type ImageDefinition
- type Interface
- type InterfaceList
- type Lab
- type LabGroup
- type LabGroupList
- type LabImport
- type Link
- type Node
- type NodeDefinition
- type NodeDefinitionMap
- type NodeMap
- type SerialDevice
- type User
- type UserList
Constants ¶
const ( IfaceStateDefined = "DEFINED_ON_CORE" IfaceStateStopped = "STOPPED" IfaceStateStarted = "STARTED" IfaceTypePhysical = "physical" IfaceTypeLoopback = "loopback" )
const ( LabStateDefined = "DEFINED_ON_CORE" LabStateStopped = "STOPPED" LabStateStarted = "STARTED" LabStateBooted = "BOOTED" )
const ( LinkStateDefined = "DEFINED_ON_CORE" LinkStateStopped = "STOPPED" LinkStateStarted = "STARTED" )
const ( NodeStateDefined = "DEFINED_ON_CORE" NodeStateStopped = "STOPPED" NodeStateStarted = "STARTED" NodeStateBooted = "BOOTED" )
Variables ¶
var ( ErrSystemNotReady = errors.New("system not ready") ErrElementNotFound = errors.New("element not found") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.0.14
New returns a new CML client instance. The host must be a valid URL including scheme (https://).
func (*Client) ExtConnGet ¶ added in v0.0.22
ExtConnGet returns the external connector specified by the ID given
func (*Client) ExtConnectors ¶ added in v0.0.22
ExtConnectors returns all external connectors on the system
func (*Client) GroupByName ¶ added in v0.0.16
GroupByName tries to get the group with the provided `name`.
func (*Client) GroupCreate ¶ added in v0.0.16
GroupCreate creates a new group on the controller based on the data provided in the passed group parameter.
func (*Client) GroupDestroy ¶ added in v0.0.16
GroupDestroy deletes the group identified by the `id` (a UUIDv4).
func (*Client) GroupGet ¶ added in v0.0.16
GroupGet retrieves the group with the provided `id` (a UUIDv4).
func (*Client) GroupUpdate ¶ added in v0.0.16
GroupUpdate updates the given group which must exist.
func (*Client) Groups ¶ added in v0.0.16
Groups retrieves the list of all groups which exist on the controller.
func (*Client) HasLabConverged ¶
HasLabConverged checks if all nodes of the lab identified by the `id` (a UUIDv4) have converged e.g. are in state "BOOTED".
func (*Client) ImageDefinitions ¶ added in v0.0.16
func (c *Client) ImageDefinitions(ctx context.Context) ([]ImageDefinition, error)
ImageDefinitions returns a list of image definitions known to the controller.
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 >= 0, the request creates all unallocated slots up to and including that slot. Conversely, if the slot is < 0 (e.g. -1), the next free slot is used.
func (*Client) InterfaceGet ¶ added in v0.0.2
InterfaceGet returns the interface identified by its `ID` (iface.ID).
func (*Client) LabDestroy ¶
LabDestroy deletes the lab identified by the `id` (a UUIDv4).
func (*Client) LabGet ¶
LabGet returns the lab identified by `id` (a UUIDv4). If `deep` is provided, then the nodes, their interfaces and links are also fetched from the controller. Also, with `deep`, the L3 IP address info is fetched for the given lab.
func (*Client) LabGetByTitle ¶ added in v0.0.2
LabGetByTitle returns the lab identified by its `title`. For the use of `deep` see LabGet().
func (*Client) LabImport ¶
LabImport imports a lab topology into the controller. This is expected to be in CML YAML topology file format.
func (*Client) LabUpdate ¶ added in v0.0.2
LabUpdate updates specific fields of a lab (title, description and notes).
func (*Client) LinkCreate ¶ added in v0.0.2
LinkCreate creates a link based on the the data passed in `link`. Required fields are the `LabID` and either a pair of interfaces `SrcID` / `DstID` or a pair of nodes `SrcNode` / `DstNode`. With nodes it's also possible to provide specific slots in `SrcSlot` / `DstSlot` where the link should be created. If one or both of the provided slots aren't available, then new interfaces will be craeted. If interface creation fails or the provided Interface IDs can't be found, the API returns an error, otherwise the returned Link variable has the updated link data. Node: -1 for a slot means: use next free slot. Specific slots run from 0 to the maximum slot number -1 per the node definition of the node type.
func (*Client) LinkGet ¶ added in v0.0.2
LinkGet returns the link data for the given `labID` and `linkID`. If `deep` is set to `true` then bot interface and node data for the given link are also fetched from the controller.
func (*Client) NodeCreate ¶ added in v0.0.2
NodeCreate creates a new node on the controller based on the data provided in `node`. Label, node definition and image definition must be provided.
func (*Client) NodeDefinitions ¶ added in v0.0.16
func (c *Client) NodeDefinitions(ctx context.Context) (NodeDefinitionMap, error)
NodeDefinitions returns the list of node definitions available on the CML controller. The key of the map is the definition type name (e.g. "alpine" or "ios"). The node def data structure is incomplete, only essential fields are populated.
func (*Client) NodeDestroy ¶ added in v0.0.2
NodeDestroy deletes the node from the controller.
func (*Client) NodeGet ¶ added in v0.0.2
NodeGet returns the node identified by its `ID` and `LabID` in the provided node.
func (*Client) NodeSetConfig ¶
NodeSetConfig sets a configuration for the specified node. At least the `ID` of the node and the `labID` must be provided in `node`. The `node` instance will be updated with the current values for the node as provided by the controller.
func (*Client) NodeUpdate ¶ added in v0.0.2
NodeUpdate updates the node specified by data in `node` (e.g. ID and LabID) with the other data provided. It returns the udpated node.
func (*Client) NodeWipe ¶ added in v0.0.2
NodeWipe removes all runtime data from a node on the controller/compute. E.g. it will remove the actual VM and its associated disks.
func (*Client) SetCACert ¶
SetCACert sets a specific X.509 CA certificate to use with the client. If no cert is set, the system trust anchors are used for cert verification.
func (*Client) SetToken ¶
SetToken sets a specific API token to be used. A token takes precedence over a username/password. However, if the token expires, the username/password are used to authorize the client again. An error is raised if no token and no username/password are provided or if the token expires when no username/password are set.
func (*Client) SetUsernamePassword ¶
SetUsernamePassword sets the username and the password to be used with the client for all authentications.
func (*Client) UserByName ¶ added in v0.0.16
UserByName returns the user with the given username `name`.
func (*Client) UserCreate ¶ added in v0.0.16
UserCreate creates a new user on the controller based on the data provided in the passed user parameter.
func (*Client) UserDestroy ¶ added in v0.0.16
UserDestroy deletes the user identified by the `id` (a UUIDv4).
func (*Client) UserGroups ¶ added in v0.0.16
UserGroups retrieves the list of all groups the user belongs to.
func (*Client) UserUpdate ¶ added in v0.0.16
UserUpdate updates the given user which must exist.
type ExtConn ¶ added in v0.0.22
type ExtConn struct { ID string `json:"id"` DeviceName string `json:"device_name"` Label string `json:"label"` Protected bool `json:"protected"` Snooped bool `json:"snooped"` Tags []string `json:"tags"` Operational opdata `json:"operational"` }
ExtConn defines the data structure for a CML external connector
type ImageDefinition ¶
type ImageDefinition struct { ID string `json:"id"` SchemaVersion string `json:"schema_version"` NodeDefID string `json:"node_definition_id"` Description string `json:"description"` Label string `json:"label"` DiskImage1 string `json:"disk_image"` DiskImage2 string `json:"disk_image_2"` DiskImage3 string `json:"disk_image_3"` ReadOnly bool `json:"read_only"` DiskSubfolder string `json:"disk_subfolder"` RAM *int `json:"ram"` CPUs *int `json:"cpus"` CPUlimit *int `json:"cpu_limit"` DataVolume *int `json:"data_volume"` BootDiskSize *int `json:"boot_disk_size"` }
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) IsPhysical ¶ added in v0.0.2
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 LabGroupList `json:"groups"` }
func (*Lab) CanBeWiped ¶
CanBeWiped returns `true` when all nodes in the lab are wiped.
func (*Lab) NodeByLabel ¶
NodeByLabel returns the node of a lab identified by its `label“ or an error if not found.
type LabGroupList ¶ added in v0.0.16
type LabGroupList []*LabGroup
type Link ¶
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 }
Link defines the data structure for a CML link between nodes.
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"` HideLinks bool `json:"hide_links"` 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"` Configuration map[string]any `json:"configuration"` Device deviceData `json:"device"` Inherited map[string]any `json:"inherited"` SchemaVersion string `json:"schema_version"` Sim simData `json:"sim"` Boot map[string]any `json:"boot"` PyATS map[string]any `json:"pyats"` General map[string]any `json:"general"` UI map[string]any `json:"ui"` }
type NodeDefinitionMap ¶ added in v0.0.5
type NodeDefinitionMap map[definitionID]NodeDefinition
type NodeMap ¶
func (NodeMap) MarshalJSON ¶
type SerialDevice ¶ added in v0.0.2
type User ¶
type User struct { ID string `json:"id,omitempty"` Created string `json:"created,omitempty"` Modified string `json:"modified,omitempty"` Username string `json:"username"` Password string `json:"password"` Fullname string `json:"fullname"` Email string `json:"email"` Description string `json:"description"` IsAdmin bool `json:"admin"` DirectoryDN string `json:"directory_dn,omitempty"` Groups []string `json:"groups,omitempty"` Labs []string `json:"labs,omitempty"` OptIn bool `json:"opt_in"` // with 2.5.0 ResourcePool *string `json:"resource_pool,omitempty"` // with 2.5.0 }