Documentation ¶
Overview ¶
Package bat contains a number of helper functions that can be used to perform various operations on a ciao cluster such as creating an instance or retrieving a list of all the defined workloads, etc. All of these helper functions are implemented by calling ciao-cli rather than by using ciao's REST APIs. This package is mainly intended for use by BAT tests. Manipulating the cluster via ciao-cli, rather than through the REST APIs, allows us to test a little bit more of ciao.
Index ¶
- func DeleteAllInstances(ctx context.Context, tenant string) error
- func DeleteInstance(ctx context.Context, tenant string, instance string) error
- func DeleteInstances(ctx context.Context, tenant string, instances []string) ([]error, error)
- func GetAllInstances(ctx context.Context, tenant string) (map[string]*Instance, error)
- func GetCNCIs(ctx context.Context) (map[string]*CNCI, error)
- func LaunchInstances(ctx context.Context, tenant string, workload string, num int) ([]string, error)
- func RetrieveInstanceStatus(ctx context.Context, tenant string, instance string) (string, error)
- func RetrieveInstancesStatuses(ctx context.Context, tenant string) (map[string]string, error)
- func RunCIAOCLI(ctx context.Context, tenant string, args []string) ([]byte, error)
- func RunCIAOCLIAsAdmin(ctx context.Context, tenant string, args []string) ([]byte, error)
- func RunCIAOCLIAsAdminJS(ctx context.Context, tenant string, args []string, jsdata interface{}) error
- func RunCIAOCLIJS(ctx context.Context, tenant string, args []string, jsdata interface{}) error
- func StartRandomInstances(ctx context.Context, tenant string, num int) ([]string, error)
- func WaitForInstancesLaunch(ctx context.Context, tenant string, instances []string, mustBeActive bool) ([]string, error)
- type CNCI
- type ClusterStatus
- type Instance
- type Tenant
- type Workload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteAllInstances ¶
DeleteAllInstances deletes all the instances created for the specified tenant by calling ciao-cli instance delete -all. It returns an error if the ciao-cli command fails. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func DeleteInstance ¶
DeleteInstance deletes a specific instance from the cluster. It deletes the instance using ciao-cli instance delete. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func DeleteInstances ¶
DeleteInstances deletes a set of instances provided by the instances slice. If the function encounters an error deleting an instance it records the error and proceeds to the delete the next instance. The function returns two values, an error and a slice of errors. A single error value is set if any of the instance deletion attempts failed. A slice of errors is also returned so that the caller can determine which of the deletion attempts failed. The indices in the error slice match the indicies in the instances slice, i.e., a non nil value in the first element of the error slice indicates that there was an error deleting the first instance in the instances slice. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func GetAllInstances ¶
GetAllInstances returns information about all instances in the specified tenant in a map. The key of the map is the instance uuid. The information is retrieved by calling ciao-cli instance list. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func GetCNCIs ¶
GetCNCIs returns a map of the CNCIs present in the cluster. The key of the map is the CNCI ID. The CNCI information is retrieved using ciao-cli list -cnci command. An error will be returned if the following environment are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.
func LaunchInstances ¶
func LaunchInstances(ctx context.Context, tenant string, workload string, num int) ([]string, error)
LaunchInstances launches num instances of the specified workload. On success the function returns a slice of UUIDs of the new instances. The instances are launched using ciao-cli instance add. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func RetrieveInstanceStatus ¶
RetrieveInstanceStatus retrieve the status of a specific instance. This information is retrieved using ciao-cli instance show. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func RetrieveInstancesStatuses ¶
RetrieveInstancesStatuses retrieves the statuses of a slice of specific instances. This information is retrieved using ciao-cli instance list. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func RunCIAOCLI ¶
RunCIAOCLI execs the ciao-cli command with a set of arguments. The ciao-cli process will be killed if the context is Done. An error will be returned if the following environment are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD. On success the data written to ciao-cli on stdout will be returned.
func RunCIAOCLIAsAdmin ¶
RunCIAOCLIAsAdmin execs the ciao-cli command as the admin user with a set of provided arguments. The ciao-cli process will be killed if the context is Done. An error will be returned if the following environment are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD. On success the data written to ciao-cli on stdout will be returned.
func RunCIAOCLIAsAdminJS ¶
func RunCIAOCLIAsAdminJS(ctx context.Context, tenant string, args []string, jsdata interface{}) error
RunCIAOCLIAsAdminJS is similar to RunCIAOCLIAsAdmin with the exception that the output of the ciao-cli command is expected to be in json format. The json is decoded into the jsdata parameter which should be a pointer to a type that corresponds to the json output.
func RunCIAOCLIJS ¶
RunCIAOCLIJS is similar to RunCIAOCLI with the exception that the output of the ciao-cli command is expected to be in json format. The json is decoded into the jsdata parameter which should be a pointer to a type that corresponds to the json output.
func StartRandomInstances ¶
StartRandomInstances starts a specified number of instances using a random workload. The UUIDs of the started instances are returned to the user. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func WaitForInstancesLaunch ¶
func WaitForInstancesLaunch(ctx context.Context, tenant string, instances []string, mustBeActive bool) ([]string, error)
WaitForInstancesLaunch waits for a slice of newly created instances to be scheduled. An instance is scheduled when its status changes from pending to exited or active. If mustBeActive is set to true, the function will fail if it sees an instance that has been scheduled but whose status is exited. The function returns a slice of instance UUIDs and an error. In the case of success, the returned slice of UUIDs will equal the instances array. In the case of error, these two slices may be different. This can happen if one or more of the instances has failed to launch. If errors are detected with multiple instances, e.g., mustBeActive is true and two instances have a status of 'exited' the error returned will refers to the first instance only. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
Types ¶
type CNCI ¶
type CNCI struct { TenantID string `json:"tenant_id"` IPv4 string `json:"ip"` Geography string `json:"geo"` Subnets []string `json:"subnets"` }
CNCI contains information about a CNCI
type ClusterStatus ¶
type ClusterStatus struct { TotalNodes int `json:"nodes"` TotalNodesReady int `json:"ready"` TotalNodesFull int `json:"full"` TotalNodesOffline int `json:"offline"` TotalNodesMaintenance int `json:"maintenance"` }
ClusterStatus contains information about the status of a ciao cluster
func GetClusterStatus ¶
func GetClusterStatus(ctx context.Context) (*ClusterStatus, error)
GetClusterStatus returns the status of the ciao cluster. The information is retrieved by calling ciao-cli node status. An error will be returned if the following environment are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.
type Instance ¶
type Instance struct { HostID string `json:"host_id"` TenantID string `json:"tenant_id"` FlavorID string `json:"flavor_id"` ImageID string `json:"image_id"` Status string `json:"status"` PrivateIP string `json:"private_ip"` MacAddress string `json:"mac_address"` SSHIP string `json:"ssh_ip"` SSHPort int `json:"ssh_port"` }
Instance contains detailed information about an instance
func GetInstance ¶
GetInstance returns an Instance structure that contains information about a specific instance. The informaion is retrieved by calling ciao-cli show --instance. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
type Tenant ¶
Tenant contains basic information about a tenant
func GetAllTenants ¶
GetAllTenants retrieves a list of all tenants in the cluster by calling ciao-cli tenant list -all. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.
type Workload ¶
type Workload struct { ID string `json:"id"` Name string `json:"name"` ImageUUID string `json:"image_uuid"` CPUs int `json:"cpus"` Mem int `json:"mem"` }
Workload contains detailed information about a workload
func GetAllWorkloads ¶
GetAllWorkloads retrieves a list of all workloads in the cluster by calling ciao-cli workload list. An error will be returned if the following environment variables are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.