Documentation ¶
Overview ¶
Package collins is a client library for our inventory management database Collins (http://tumblr.github.io/collins/) . It covers the full API and allows you to manage your assets and their data from Go applications. It is very much influenced by the beautiful go-github project (https://github.com/google/go-github).
While we do actively use go-collins at Tumblr and will try to maintain a stable interface, for now consider this a work-in-progress in that breaking changes may be made.
Usage ¶
To start querying collins, import go-collins and set up a new `Client` by using `NewClient()` or `NewClientFromYaml()`. The second function will look for a `collins.yml` file and use credentials from it, while `NewClient()` takes credentials as parameters.
import ( "fmt" "gopkg.in/tumblr/go-collins.v0" ) func main() { client, err := collins.NewClient("username", "password", "https://collins.example.com") if err != nil { fmt.Errorf("Could not set up collins client: %s", err) } // Use client to interact with collins }
In the client struct, there are pointers to services that can be used to talk to specific parts of the API. The most common use (at least at Tumblr) is talking to the asset API for things like getting the number of physical CPUs in an asset:
asset, _, err := client.Assets.Get("assettag1") if err != nil { fmt.Errorf("Assets.Get returned error: %s", err) } fmt.Printf("CPUs: %d\n", len(asset.Hardware.CPUs))
Or finding assets that match certain criteria:
opts := collins.AssetFindOpts{ Status: "Unallocated", } assets, _, err := client.Assets.Find(&opts) if err != nil { fmt.Errorf("Assets.Find returned error: %s", err) } fmt.Printf("First unallocated tag: %s\n", assets[0].Metadata.Tag)
Pagination ¶
Some routes in the API (finding assets and fetching logs) are paginated. To support pagination we include pagination information in the Request struct returned by the functions. The members are `PreviousPage`, `CurrentPage`, `NextPage` and `TotalResults`. These together with the `PageOpts` struct can be used to navigate through the pages.
opts := collins.AssetFindOpts{ Status: "Unallocated", PageOpts: collins.PageOpts{Page: 0} } for { assets, resp, err := client.Assets.Find(&opts) if err != nil { fmt.Errorf("Assets.Find returned error: %s", err) } for _, asset := range assets { fmt.Printf("Tag: %s\n", asset.Tag) } if resp.NextPage == resp.CurrentPage { // No more pages break } else { // Fetch next page opts.PageOpts.Page++ } }
Index ¶
- Variables
- type Address
- type AddressAllocateOpts
- type AddressDeleteOpts
- type AddressUpdateOpts
- type Asset
- type AssetCreateEvent
- type AssetCreateOpts
- type AssetDeleteEvent
- type AssetEvent
- type AssetFindOpts
- type AssetFindSimilarOpts
- type AssetPurgeEvent
- type AssetService
- func (s AssetService) Create(tag string, opts *AssetCreateOpts) (*Asset, *Response, error)
- func (s AssetService) Delete(tag, reason string) (*Response, error)
- func (s AssetService) DeleteAttribute(tag, attribute string) (*Response, error)
- func (s AssetService) DeleteAttributeWithDim(tag, attribute string, dimension int) (*Response, error)
- func (a AssetService) Find(opts *AssetFindOpts) ([]Asset, *Response, error)
- func (a AssetService) FindSimilar(tag string, opts *AssetFindSimilarOpts) ([]Asset, *Response, error)
- func (s AssetService) Get(tag string) (*Asset, *Response, error)
- func (s AssetService) GetAttribute(tag, attribute string) (string, error)
- func (s AssetService) GetAttributeWithDim(tag, attribute string, dimension int) (string, error)
- func (s AssetService) SetAttribute(tag, attribute, value string) (*Response, error)
- func (s AssetService) SetAttributeWithDim(tag, attribute, value string, dimension int) (*Response, error)
- func (s AssetService) Update(tag string, opts *AssetUpdateOpts) (*Response, error)
- func (s AssetService) UpdateIpmi(tag string, opts *AssetUpdateIPMIOpts) (*Response, error)
- func (s AssetService) UpdateStatus(tag string, opts *AssetUpdateStatusOpts) (*Response, error)
- type AssetType
- type AssetTypeService
- func (s AssetTypeService) Create(name, label string) (*AssetType, *Response, error)
- func (s AssetTypeService) Delete(assetType string) (*Response, error)
- func (s AssetTypeService) Get(name string) (*AssetType, *Response, error)
- func (s AssetTypeService) List() (*[]AssetType, *Response, error)
- func (s AssetTypeService) Update(oldName, newName, newLabel string) (*AssetType, *Response, error)
- type AssetUpdateEvent
- type AssetUpdateIPMIOpts
- type AssetUpdateOpts
- type AssetUpdateStatusOpts
- type Base
- type CPU
- type Classification
- type Client
- type Container
- type Disk
- type Error
- type FirehoseDecoder
- type FirehoseService
- type GPU
- type Hardware
- type IPAMService
- func (s IPAMService) Allocate(tag string, opts AddressAllocateOpts) ([]Address, *Response, error)
- func (s IPAMService) AssetFromAddress(address string) (*Asset, *Response, error)
- func (s IPAMService) Delete(tag string, opts AddressDeleteOpts) (int, *Response, error)
- func (s IPAMService) Get(tag string) ([]Address, *Response, error)
- func (s IPAMService) IPMIPools() ([]Pool, *Response, error)
- func (s IPAMService) Pools() ([]Pool, *Response, error)
- func (s IPAMService) Update(tag string, opts AddressUpdateOpts) (*Response, error)
- type IPAddressCreateEvent
- type IPAddressDeleteEvent
- type IPAddressUpdateEvent
- type IPMI
- type Interface
- type LLDP
- type Log
- type LogCreateOpts
- type LogGetOpts
- type LogService
- type ManagementService
- func (s ManagementService) GetProvisioningProfiles() ([]Profile, *Response, error)
- func (s ManagementService) HardReboot(tag string) (*Response, error)
- func (s ManagementService) Identify(tag string) (*Response, error)
- func (s ManagementService) PowerOff(tag string) (*Response, error)
- func (s ManagementService) PowerOn(tag string) (*Response, error)
- func (s ManagementService) PowerStatus(tag string) (string, *Response, error)
- func (s ManagementService) Provision(tag, profile, contact string, opts ProvisionOpts) (*Response, error)
- func (s ManagementService) SoftPowerOff(tag string) (*Response, error)
- func (s ManagementService) SoftReboot(tag string) (*Response, error)
- func (s ManagementService) Verify(tag string) (*Response, error)
- type Memory
- type Metadata
- type NIC
- type PageOpts
- type PaginationResponse
- type Pool
- type Power
- type PowerConfig
- type PowerUnit
- type Profile
- type ProvisionOpts
- type Response
- type State
- type StateService
- func (s StateService) Create(name, label, description, status string) (*Response, error)
- func (s StateService) Delete(name string) (*Response, error)
- func (s StateService) Get(name string) (*State, *Response, error)
- func (s StateService) List() ([]State, *Response, error)
- func (s StateService) Update(oldName string, opts StateUpdateOpts) (*Response, error)
- type StateUpdateOpts
- type Tag
- type TagService
Constants ¶
This section is empty.
Variables ¶
var (
VERSION = "0.1.0"
)
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { Gateway string `json:"GATEWAY"` Address string `json:"ADDRESS"` Netmask string `json:"NETMASK"` Pool string `json:"POOL"` }
Address represents an IPv4 address in the collins IPAM system.
type AddressAllocateOpts ¶
type AddressAllocateOpts struct { Count int `url:"count,omitempty"` Pool string `url:"pool,omitempty"` }
AddressAllocateOpts contain options that are available when allocating an address.
type AddressDeleteOpts ¶
type AddressDeleteOpts struct {
Pool string `url:"pool,omitempty"`
}
AddressDeleteOpts contain options that are available when deleting an address.
type AddressUpdateOpts ¶
type AddressUpdateOpts struct { Address string `url:"address,omitempty"` Gateway string `url:"gateway,omitempty"` Netmask string `url:"netmask,omitempty"` Pool string `url:"pool,omitempty"` OldAddress string `url:"old_address,omitempty"` }
AddressUpdateOpts contain options that are available when updating an already allocated address.
type Asset ¶
type Asset struct { Metadata `json:"ASSET"` Hardware `json:"HARDWARE"` Classification `json:"CLASSIFICATION"` Addresses []Address `json:"ADDRESSES"` LLDP `json:"LLDP"` IPMI `json:"IPMI"` Attributes map[string]map[string]string `json:"ATTRIBS"` Power []Power `json:"POWER"` }
The Asset struct contains all the information available about a certain asset.
type AssetCreateEvent ¶
type AssetCreateEvent AssetEvent
func (*AssetCreateEvent) Decode ¶
func (ace *AssetCreateEvent) Decode(name string, data []byte)
type AssetCreateOpts ¶
type AssetCreateOpts struct { GenerateIPMI bool `url:"generate_ipmi,omitempty"` IpmiPool string `url:"ipmi_pool,omitempty"` Status string `url:"status,omitempty"` AssetType string `url:"type,omitempty"` }
AssetCreateOpts are options that must be passed when creating an asset (GenerateIPMI will default to false in the struct)
type AssetDeleteEvent ¶
type AssetDeleteEvent AssetEvent
func (*AssetDeleteEvent) Decode ¶
func (ade *AssetDeleteEvent) Decode(name string, data []byte)
type AssetEvent ¶
AssetEvent represents an event sent by the collins firehose.
type AssetFindOpts ¶
type AssetFindOpts struct { Details bool `url:"details,omitempty"` // True to return full assets, false to return partials. Defaults to false. RemoteLookup bool `url:"remoteLookup,omitempty"` // True to search remote datacenters as well. See the MultiCollins documentation. Operation string `url:"operation,omitempty"` // "AND" or "OR", defaults to "OR". Type string `url:"type,omitempty"` // A valid asset type (e.g. SERVER_NODE) Status string `url:"status,omitempty"` // A valid asset status (e.g. Unallocated) State string `url:"state,omitempty"` // A valid asset state (e.g. RUNNING) Attribute string `url:"attribute,omitempty"` // Specified as tagname;tagvalue. tagname can be a reserved tag such as CPU_COUNT, MEMORY_SIZE_BYTES, etc. Leave tagvalue blank to find assets missing a particular attribute. Query string `url:"query,omitempty"` // Specify a CQL query // These need to be pointers otherwise marshalling them will result in // all time fields being sent as "0001-01-01 00:00:00 +0000 UTC" CreatedBefore *iso8601.Time `url:"createdBefore,omitempty"` // ISO8601 formatted CreatedAfter *iso8601.Time `url:"createdAfter,omitempty"` // ISO8601 formatted UpdatedBefore *iso8601.Time `url:"updatedBefore,omitempty"` // ISO8601 formatted UpdatedAfter *iso8601.Time `url:"updatedAfter,omitempty"` // ISO8601 formatted // Embed pagination options directly in the options PageOpts }
AssetFindOpts contains the various options for find queries to collins. It can be used to query for things like asset type, asset status or arbitrary attributes set on assets. It also provides options for pagination.
type AssetFindSimilarOpts ¶
type AssetFindSimilarOpts struct {
PageOpts
}
AssetFindSimilarOpts contains the options for find similar queries to Collins. It currently only wraps the pagination options struct.
type AssetPurgeEvent ¶
type AssetPurgeEvent AssetEvent
func (*AssetPurgeEvent) Decode ¶
func (ape *AssetPurgeEvent) Decode(name string, data []byte)
type AssetService ¶
type AssetService struct {
// contains filtered or unexported fields
}
The AssetService provides functions to query, modify and manage assets in collins.
http://tumblr.github.io/collins/api.html#asset
func (AssetService) Create ¶
func (s AssetService) Create(tag string, opts *AssetCreateOpts) (*Asset, *Response, error)
AssetService.Create creates an asset with tag `tag`. Unless `generate_ipmi` is false, generate IPMI information. If an `AssetType` is passed in as `asset_type`, use it to determine the type of the asset.
http://tumblr.github.io/collins/api.html#api-asset-asset-create
func (AssetService) Delete ¶
func (s AssetService) Delete(tag, reason string) (*Response, error)
AssetService.Delete deletes an asset with the tag passed as parameter. It also requires a reason for the deletion.
http://tumblr.github.io/collins/api.html#api-asset-asset-delete
func (AssetService) DeleteAttribute ¶
func (s AssetService) DeleteAttribute(tag, attribute string) (*Response, error)
AssetService.DeleteAttribute removes an attribute from an asset, or returns an error if the asset could not be found.
http://tumblr.github.io/collins/api.html#api-asset-asset-delete-tag
func (AssetService) DeleteAttributeWithDim ¶
func (s AssetService) DeleteAttributeWithDim(tag, attribute string, dimension int) (*Response, error)
AssetService.DeleteAttributeWithDim deletes a an attribute with the specified dimension from an asset.
http://tumblr.github.io/collins/api.html#api-asset-asset-delete-tag
func (AssetService) Find ¶
func (a AssetService) Find(opts *AssetFindOpts) ([]Asset, *Response, error)
AssetService.Find searches for assets in collins. See AssetFindOpts for available options.
http://tumblr.github.io/collins/api.html#api-asset-asset-find
func (AssetService) FindSimilar ¶
func (a AssetService) FindSimilar(tag string, opts *AssetFindSimilarOpts) ([]Asset, *Response, error)
AssetService.FindSimilar queries collins for assets that are similar to the asset represented by the tag passed as a parameter. See AssetFindOpts for available options.
http://tumblr.github.io/collins/api.html#api-asset-asset-find-similar
func (AssetService) Get ¶
func (s AssetService) Get(tag string) (*Asset, *Response, error)
AssetService.Get queries collins for an asset corresponding to tag passed as parameter.
http://tumblr.github.io/collins/api.html#api-asset-asset-get
func (AssetService) GetAttribute ¶
func (s AssetService) GetAttribute(tag, attribute string) (string, error)
AssetService.GetAttribute returns the value of the requested attribute, or returns an empty string and an error if the asset does not have the attribute set.
http://tumblr.github.io/collins/api.html#api-asset-asset-get
func (AssetService) GetAttributeWithDim ¶
func (s AssetService) GetAttributeWithDim(tag, attribute string, dimension int) (string, error)
AssetService.GetAttributeWithDim performs the same operation as GetAttribute, but takes a dimension parameter in order to work with multidimensional attributes.
http://tumblr.github.io/collins/api.html#api-asset-asset-get
func (AssetService) SetAttribute ¶
func (s AssetService) SetAttribute(tag, attribute, value string) (*Response, error)
AssetService.SetAttribute sets an attribute on an asset to an arbitrary string.
http://tumblr.github.io/collins/api.html#api-asset-asset-update
func (AssetService) SetAttributeWithDim ¶
func (s AssetService) SetAttributeWithDim(tag, attribute, value string, dimension int) (*Response, error)
AssetService.SetAttributeWithDim sets an attribute with the specified dimension on an asset.
http://tumblr.github.io/collins/api.html#api-asset-asset-update
func (AssetService) Update ¶
func (s AssetService) Update(tag string, opts *AssetUpdateOpts) (*Response, error)
AssetService.Update update an asset with LSHW and LLDP info.
http://tumblr.github.io/collins/api.html#api-asset-asset-update
func (AssetService) UpdateIpmi ¶
func (s AssetService) UpdateIpmi(tag string, opts *AssetUpdateIPMIOpts) (*Response, error)
AssetService.UpdateIpmi takes an asset tag and a AssetUpdateIPMIOpts struct as parameters, and updates the IPMI information accordingly.
http://tumblr.github.io/collins/api.html#api-asset managment-ipmi-managment
func (AssetService) UpdateStatus ¶
func (s AssetService) UpdateStatus(tag string, opts *AssetUpdateStatusOpts) (*Response, error)
AssetService.Update updates the status of an asset.
http://tumblr.github.io/collins/api.html#api-asset-asset-update-status
type AssetType ¶
type AssetType struct { ID int `json:"ID" url:"-"` Name string `json:"NAME" url:"name,omitempty"` Label string `json:"LABEL" url:"label,omitempty"` }
AssetType Represents an asset type in the collins eco system. Examples of asset types are `SERVER_NODE`, `ROUTER` and `DATA_CENTER`. Each asset type has an ID, a name, and a human readable label.
type AssetTypeService ¶
type AssetTypeService struct {
// contains filtered or unexported fields
}
AssetTypeService provides functions to manage asset types in collins.
http://tumblr.github.io/collins/api.html#asset%20type
func (AssetTypeService) Create ¶
func (s AssetTypeService) Create(name, label string) (*AssetType, *Response, error)
AssetTypeService.Create creates a new asset type with the specified name and label.
http://tumblr.github.io/collins/api.html#api-asset%20type-asset-type-create
func (AssetTypeService) Delete ¶
func (s AssetTypeService) Delete(assetType string) (*Response, error)
AssetTypeService.Delete deletes asset type with the name `asset_type`.
http://tumblr.github.io/collins/api.html#api-asset%20type-asset-type-delete
func (AssetTypeService) Get ¶
func (s AssetTypeService) Get(name string) (*AssetType, *Response, error)
AssetTypeService.Get queries the API for a specific asset type with name `name`.
http://tumblr.github.io/collins/api.html#api-asset%20type-asset-type-get
func (AssetTypeService) List ¶
func (s AssetTypeService) List() (*[]AssetType, *Response, error)
AssetTypeService.List queries the API for all available asset types.
http://tumblr.github.io/collins/api.html#api-asset%20type-asset-type-list
func (AssetTypeService) Update ¶
func (s AssetTypeService) Update(oldName, newName, newLabel string) (*AssetType, *Response, error)
AssetTypeService.Update updates and asset type with a new name and label.
http://tumblr.github.io/collins/api.html#api-asset%20type-asset-type-update
type AssetUpdateEvent ¶
type AssetUpdateEvent AssetEvent
AssetUpdateEvent, AssetCreateEvent, AssetDeleteEvent and AssetPurgeEvent are used to be able to tell different asset events apart.
func (*AssetUpdateEvent) Decode ¶
func (aue *AssetUpdateEvent) Decode(name string, data []byte)
Decode fulfills the Event interface for the various asset event structs by unmarshalling the JSON returned by the firehose.
type AssetUpdateIPMIOpts ¶
type AssetUpdateIPMIOpts struct { Username string `url:"username,omitempty"` Password string `url:"password,omitempty"` Address string `url:"address,omitempty"` Gateway string `url:"gateway,omitempty"` Netmask string `url:"netmask,omitempty"` }
AssetUpdateIPMIOpts are options that can be passed when updating the IPMI information about an asset.
type AssetUpdateOpts ¶
type AssetUpdateOpts struct { Attribute string `url:"attribute,omitempty"` ChassisTag string `url:"CHASSIS_TAG,omitempty"` GroupID int `url:"groupId,omitempty"` Lldp string `url:"lldp,omitempty"` Lshw string `url:"lshw,omitempty"` RackPosition string `url:"RACK_POSITION,omitempty"` PowerConfig }
AssetUpdateOpts are options to be passed when updating an asset
type AssetUpdateStatusOpts ¶
type AssetUpdateStatusOpts struct { Reason string `url:"reason"` Status string `url:"status,omitempty"` // Optional arg State string `url:"state,omitempty"` // Optional arg }
AssetUpdateStatusOpts are options to be passed when updating asset status
type Base ¶
type Base struct { Description string `json:"DESCRIPTION"` Product string `json:"PRODUCT"` Vendor string `json:"VENDOR"` Serial string `json:"SERIAL"` }
The Base struct contains information about the vendor and product name of the asset.
type CPU ¶
type CPU struct { Cores int `json:"CORES"` Threads int `json:"THREADS"` SpeedGhz float32 `json:"SPEED_GHZ"` Description string `json:"DESCRIPTION"` Product string `json:"PRODUCT"` Vendor string `json:"VENDOR"` }
CPU represents a single physical CPU on an asset.
type Classification ¶
type Classification struct { ID int `json:"ID"` Tag string `json:"TAG"` State State `json:"STATE"` Status string `json:"STATUS"` Type string `json:"TYPE"` Created string `json:"CREATED"` Updated string `json:"UPDATED"` Deleted string `json:"DELETED"` }
The Classificaton struct contains information about the asset's classification.
type Client ¶
type Client struct { BaseURL *url.URL User string Password string Assets *AssetService AssetTypes *AssetTypeService Logs *LogService States *StateService Tags *TagService Management *ManagementService IPAM *IPAMService Firehose *FirehoseService // contains filtered or unexported fields }
Client represents a client connection to a collins server. Requests to the various APIs are done by calling functions on the various services.
func NewClient ¶
NewClient creates a Client struct and returns a point to it. This client is then used to query the various APIs collins provides.
func NewClientFromFiles ¶
NewClientFromFiles takes an array of paths to look for credentials, and returns a Client based on the first config file that exists and parses correctly. Otherwise, it returns nil and an error.
func NewClientFromYaml ¶
NewClientFromYaml sets up a new Client, but reads the credentials and host from a yaml file on disk. The following paths are searched:
* Path in COLLINS_CLIENT_CONFIG environment variable * ~/.collins.yml * /etc/collins.yml * /var/db/collins.yml
type Container ¶
type Container struct { CollinsStatus string `json:"status"` Data interface{} `json:"data"` }
Container is used to deserialize the JSON reponse from the API.
type Disk ¶
type Disk struct { Size int `json:"SIZE"` SizeHuman string `json:"SIZE_HUMAN"` Type string `json:"TYPE"` Description string `json:"DESCRIPTION"` Product string `json:"PRODUCT"` Vendor string `json:"VENDOR"` }
Disk contains information about a disk drive installed in the asset.
type Error ¶
type Error struct { Status string `json:"status"` Data struct { Message string `json:"message"` } `json:"data"` }
Error represents an error returned from collins. Collins returns errors in JSON format, which we marshal in to this struct.
type FirehoseDecoder ¶
type FirehoseDecoder struct{}
FirehoseDecoder is passed to the SSE client in order to automatically parse the various events received from the firehose. It implements the Decoder interface from the sseclient package.
func (FirehoseDecoder) MakeContainer ¶
func (fd FirehoseDecoder) MakeContainer(str string) (sseclient.Event, error)
MakeContainer takes the event name and returns an instance of the correct container struct for that event.
type FirehoseService ¶
type FirehoseService struct {
// contains filtered or unexported fields
}
FirehoseService provides functions to communicate with the collins firehose.
type GPU ¶
type GPU struct { Description string `json:"DESCRIPTION"` Product string `json:"PRODUCT"` Vendor string `json:"VENDOR"` }
GPU represents a single physical GPU on an asset.
type Hardware ¶
type Hardware struct { CPUs []CPU `json:"CPU"` GPUs []GPU `json:"GPU"` Memory []Memory `json:"MEMORY"` NICs []NIC `json:"NIC"` Disks []Disk `json:"DISK"` Base `json:"BASE"` }
The Hardware struct collects information about the hardware configuration of an asset.
type IPAMService ¶
type IPAMService struct {
// contains filtered or unexported fields
}
The IPAMService provides functions to work with the collins IP allocation manager.
http://tumblr.github.io/collins/api.html#ipam
func (IPAMService) Allocate ¶
func (s IPAMService) Allocate(tag string, opts AddressAllocateOpts) ([]Address, *Response, error)
IPAMService.Allocate allocates one or more address to an asset. Pool can be specified as an option. Returns a list of the allocated addresses on success.
http://tumblr.github.io/collins/api.html#api-ipam-allocate-an-address
func (IPAMService) AssetFromAddress ¶
func (s IPAMService) AssetFromAddress(address string) (*Asset, *Response, error)
IPAMService.AssetFromAddress find the asset associated with the specified tag. Note that this will only return the metadata (tag, name, label etc.) of the asset. For a full asset use Asset.Get.
http://tumblr.github.io/collins/api.html#api-ipam-asset-from-address
func (IPAMService) Delete ¶
func (s IPAMService) Delete(tag string, opts AddressDeleteOpts) (int, *Response, error)
IPAMService.Delete deallocates all the addresses associated with an asset. If a pool name is passed in the options, only addresses in that pool will be deallocated.
http://tumblr.github.io/collins/api.html#api-ipam-delete-an-address
func (IPAMService) Get ¶
func (s IPAMService) Get(tag string) ([]Address, *Response, error)
IPAMService.Get returns the addresses associated with a tag.
http://tumblr.github.io/collins/api.html#api-ipam-asset-addresses
func (IPAMService) IPMIPools ¶
func (s IPAMService) IPMIPools() ([]Pool, *Response, error)
IPAMService.IpmiPools return a list of the available IP pools for IPMI/OOB networks.
http://tumblr.github.io/collins/api.html#api-ipam-get-ipmi-address-pools
func (IPAMService) Pools ¶
func (s IPAMService) Pools() ([]Pool, *Response, error)
IPAMService.Pools return a list of the available IP pools.
http://tumblr.github.io/collins/api.html#api-ipam-get-address-pools
func (IPAMService) Update ¶
func (s IPAMService) Update(tag string, opts AddressUpdateOpts) (*Response, error)
IPAMService.Update updates an address associated with an asset.
http://tumblr.github.io/collins/api.html#api-ipam-update-an-address
type IPAddressCreateEvent ¶
type IPAddressCreateEvent AssetEvent
IPAddressCreateEvent, IPAddressUpdateEvent and IPAddressDeleteEvent are events used when various IPAM actions are performed.
func (*IPAddressCreateEvent) Decode ¶
func (ice *IPAddressCreateEvent) Decode(name string, data []byte)
type IPAddressDeleteEvent ¶
type IPAddressDeleteEvent AssetEvent
func (*IPAddressDeleteEvent) Decode ¶
func (ide *IPAddressDeleteEvent) Decode(name string, data []byte)
type IPAddressUpdateEvent ¶
type IPAddressUpdateEvent AssetEvent
func (*IPAddressUpdateEvent) Decode ¶
func (iue *IPAddressUpdateEvent) Decode(name string, data []byte)
type IPMI ¶
type IPMI struct { ID int `json:"ID"` Username string `json:"IPMI_USERNAME"` Password string `json:"IPMI_PASSWORD"` Gateway string `json:"IPMI_GATEWAY"` Address string `json:"IPMI_ADDRESS"` Netmask string `json:"IPMI_NETMASK"` }
IPMI contains the information the IPMI card on an asset is configured with.
type Interface ¶
type Interface struct { Name string `json:"NAME"` Chassis struct { Name string `json:"NAME"` ID struct { Type string `json:"TYPE"` Value string `json:"VALUE"` } `json:"ID"` Description string `json:"DESCRIPTION"` } `json:"CHASSIS"` Port struct { ID struct { Type string `json:"TYPE"` Value string `json:"VALUE"` } `json:"ID"` Description string `json:"DESCRIPTION"` } `json:"PORT"` Vlans []struct { ID int `json:"ID"` Name string `json:"NAME"` } `json:"VLANS"` }
Interface represents a network interface on the asset, complete with information about the switch it is connected to and the VLAN in use, as collected by LLDP.
type LLDP ¶
type LLDP struct {
Interfaces []Interface `json:"INTERFACES"`
}
The LLDP struct presents information that has been collected from the network interfaces of an asset using the LLDP protocol.
type Log ¶
type Log struct { ID int `json:"ID"` AssetTag string `json:"ASSET_TAG"` Created string `json:"CREATED"` CreatedBy string `json:"CREATED_BY"` Format string `json:"FORMAT"` Source string `json:"SOURCE"` Type string `json:"TYPE"` Message string `json:"MESSAGE"` }
Log represents a single log message along with metadata.
type LogCreateOpts ¶
LogCreateOpts are options to be passed when creating a log entry.
type LogGetOpts ¶
type LogGetOpts struct {
PageOpts
}
LogGetOpts are options to be passed when getting logs.
type LogService ¶
type LogService struct {
// contains filtered or unexported fields
}
The LogService provides functions to add, delete and manage the logs for assets in collins.
http://tumblr.github.io/collins/api.html#asset%20log
func (LogService) Create ¶
func (s LogService) Create(tag string, opts *LogCreateOpts) (*Log, *Response, error)
LogService.Create adds a log message for the asset with tag `tag`.
http://tumblr.github.io/collins/api.html#api-asset%20log-log-create
func (LogService) Get ¶
func (s LogService) Get(tag string, opts *LogGetOpts) ([]Log, *Response, error)
LogService.Get returns logs associated with the asset with asset tag `tag`.
http://tumblr.github.io/collins/api.html#api-asset%20log-log-get
func (LogService) GetAll ¶
func (s LogService) GetAll(opts *LogGetOpts) ([]Log, *Response, error)
LogService.GetAll returns logs for all assets.
http://tumblr.github.io/collins/api.html#api-asset%20log-log-get-all
type ManagementService ¶
type ManagementService struct {
// contains filtered or unexported fields
}
The ManagementService provides functions to use the IPMI functionality in collins, as well as provision servers.
http://tumblr.github.io/collins/api.html#asset
func (ManagementService) GetProvisioningProfiles ¶
func (s ManagementService) GetProvisioningProfiles() ([]Profile, *Response, error)
GetProvisioningProfiles returns all available profiles for provisioning http://tumblr.github.io/collins/api.html#api-asset%20managment-provisioning-profiles
func (ManagementService) HardReboot ¶
func (s ManagementService) HardReboot(tag string) (*Response, error)
ManagementService.HardReboot is equivalent to pressing the reset button.
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-managment
func (ManagementService) Identify ¶
func (s ManagementService) Identify(tag string) (*Response, error)
ManagementService.Identify turns on the IPMI light.
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-managment
func (ManagementService) PowerOff ¶
func (s ManagementService) PowerOff(tag string) (*Response, error)
ManagementService.PowerOff powers off the asset, without grace (like pressing the power button).
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-managment
func (ManagementService) PowerOn ¶
func (s ManagementService) PowerOn(tag string) (*Response, error)
ManagementService.PowerOn powers up an asset.
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-managment
func (ManagementService) PowerStatus ¶
func (s ManagementService) PowerStatus(tag string) (string, *Response, error)
ManagementService.PowerStatus checks the power status of an asset. It returns one of the strings "on", "off" or "unknown".
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-status
func (ManagementService) Provision ¶
func (s ManagementService) Provision(tag, profile, contact string, opts ProvisionOpts) (*Response, error)
ManagementService.Provision provisions an asset according to the profile and options provided.
func (ManagementService) SoftPowerOff ¶
func (s ManagementService) SoftPowerOff(tag string) (*Response, error)
Management.SoftPowerOff initiates soft shutdown of OS via ACPI.
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-managment
func (ManagementService) SoftReboot ¶
func (s ManagementService) SoftReboot(tag string) (*Response, error)
ManagementService.SoftReboot performs a graceful reboot via IPMI, uses ACPI to notify OS.
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-managment
func (ManagementService) Verify ¶
func (s ManagementService) Verify(tag string) (*Response, error)
ManagementService.Verify detects whether the IPMI interface is reachable.
http://tumblr.github.io/collins/api.html#api-asset%20managment-power-managment
type Memory ¶
type Memory struct { Size int `json:"SIZE"` SizeHuman string `json:"SIZE_HUMAN"` Bank int `json:"BANK"` Description string `json:"DESCRIPTION"` Product string `json:"PRODUCT"` Vendor string `json:"VENDOR"` }
Memory represents a single memory module installed in a bank on the asset.
type Metadata ¶
type Metadata struct { ID int `json:"ID"` Tag string `json:"TAG"` Name string `json:"NAME"` Label string `json:"LABEL"` Type string `json:"TYPE"` State State `json:"STATE"` Status string `json:"STATUS"` Created string `json:"CREATED"` Updated string `json:"UPDATED"` Deleted string `json:"DELETED"` }
Metadata contains data about the asset such as asset tag, name, state and when it was last updated, among other things.
type NIC ¶
type NIC struct { Speed int `json:"SPEED"` SpeedHuman string `json:"SPEED_HUMAN"` MacAddress string `json:"MAC_ADDRESS"` Description string `json:"DESCRIPTION"` Product string `json:"PRODUCT"` Vendor string `json:"VENDOR"` }
The NIC struct represents a network interface card installed on the asset.
type PageOpts ¶
type PageOpts struct { Page int `url:"page,omitempty"` Size int `url:"size,omitempty"` Sort string `url:"sort,omitempty"` SortField string `url:"sortField,omitempty"` }
PageOpts allows the caller to specify pagination options. Since Collins takes in pagination options via URL parameters we can use google/go-querystring to describe our pagination opts as structs. This also allows embedding of pagination options directly into other request option structs.
type PaginationResponse ¶
type PaginationResponse struct { PreviousPage int `json:"PreviousPage"` CurrentPage int `json:"CurrentPage"` NextPage int `json:"NextPage"` TotalResults int `json:"TotalResults"` }
PaginationResponse is used to represent the pagination information coming back from the collins server.
type Pool ¶
type Pool struct { Name string `json:"NAME"` Network string `json:"NETWORK"` StartAddress string `json:"START_ADDRESS"` SpecifiedGateway string `json:"SPECIFIED_GATEWAY"` Gateway string `json:"GATEWAY"` Broadcast string `json:"BROADCAST"` PossibleAddresses int `json:"POSSIBLE_ADDRESSES"` }
A Pool represents a set of addresses with some common features and purpose.
type Power ¶
type Power struct {
Units []PowerUnit `json:"UNITS"`
}
The Power struct contains a list of power units detailing where the asset is connected to electrical power.
type PowerConfig ¶
PowerConfig is used in AssetUpdateOpts to describe the power configuration of an asset. Since the keys and values are arbitrary the user are expected to add correct key/value pairs to the PowerConfig map.
func (PowerConfig) EncodeValues ¶
func (pc PowerConfig) EncodeValues(key string, values *url.Values) error
PowerConfig.EncodeValues implements the Encoder interface from go-querystring in order to format the query the way collins expects it
type PowerUnit ¶
type PowerUnit struct { Key string `json:"KEY"` Value string `json:"VALUE"` Type string `json:"TYPE"` Label string `json:"LABEL"` Position int `json:"POSITION"` }
A PowerUnit represents a single PDU on an asset, and where it is connected.
type Profile ¶
type Profile struct { Profile string `json:"PROFILE"` Label string `json:"LABEL"` Prefix string `json:"PREFIX"` SuffixAllowed bool `json:"SUFFIX_ALLOWED"` PrimaryRole string `json:"PRIMARY_ROLE"` RequiresPrimaryRole bool `json:"REQUIRES_PRIMARY_ROLE"` Pool string `json:"POOL"` RequiresPool bool `json:"REQUIRES_POOL"` SecondaryRole string `json:"SECONDARY_ROLE"` RequiresSecondaryRole bool `json:"REQUIRES_SECONDARY_ROLE"` }
Profile contains all info about a specific provisioning profile
type ProvisionOpts ¶
type ProvisionOpts struct { Suffix string `url:"suffix"` PrimaryRole string `url:"primary_role"` SecondaryRole string `url:"secondary_role"` Pool string `url:"pool"` Activate string `url:"activate"` // The following are mandatory and set as parameters to Provision() Tag string `url:"tag"` Profile string `url:"profile"` Contact string `url:"contact"` }
ProvisionOpts are options that can be passed to colllins when provisioning a server.
type Response ¶
type Response struct { *http.Response *Container PreviousPage int CurrentPage int NextPage int TotalResults int }
Response is our custom response type. It has the HTTP response embedded for debugging purposes. It also has embedded the `container` that the JSON response gets decoded into (if the caller to `Do` passes in a struct to decode into). Finally it contains all necessary data for pagination.
type State ¶
type State struct { ID int `json:"ID" url:"id,omitempty"` Name string `json:"NAME" url:"name"` Status struct { ID int `json:"ID" url:",omitempty"` Name string `json:"NAME" url:",omitempty"` Description string `json:"DESCRIPTION" url:",omitempty"` } `json:"STATUS" url:",omitempty"` Label string `json:"LABEL" url:"label"` Description string `json:"DESCRIPTION" url:"description"` CreateStatus string `url:"status,omitempty"` // Only used when creating states associated with a status }
State represents a state which describes a lifecycle specific to a status.
type StateService ¶
type StateService struct {
// contains filtered or unexported fields
}
The StateService provides functions to manage states in collins.
http://tumblr.github.io/collins/api.html#state
func (StateService) Create ¶
func (s StateService) Create(name, label, description, status string) (*Response, error)
StateService.Create creates a state with the supplied name, label and description. If `status` is non-empty, the new state is bound to the status.
http://tumblr.github.io/collins/api.html#api-state-state-create
func (StateService) Delete ¶
func (s StateService) Delete(name string) (*Response, error)
StateService.Delete deletes the state with name `name`.
http://tumblr.github.io/collins/api.html#api-state-state-delete
func (StateService) Get ¶
func (s StateService) Get(name string) (*State, *Response, error)
StateService.Get returns the state with name `name`.
http://tumblr.github.io/collins/api.html#api-state-state-get
func (StateService) List ¶
func (s StateService) List() ([]State, *Response, error)
StateService.List retrieves a list of all states collins knows about.
http://tumblr.github.io/collins/api.html#api-state-state-get-all
func (StateService) Update ¶
func (s StateService) Update(oldName string, opts StateUpdateOpts) (*Response, error)
StateService.Update updates the state with name `old_name` using the information in `opts`. See the StateUpdateOpts for options on what can be updated.
http://tumblr.github.io/collins/api.html#api-state-state-updat
type StateUpdateOpts ¶
type StateUpdateOpts struct { Name string `url:"name,omitempty"` Label string `url:"label,omitempty"` Description string `url:"description,omitempty"` }
StateUpdateOpts is a struct for supplying information to Update(). Each of the struct members are optional, and only those specified will be used for update.
type Tag ¶
type Tag struct { Name string `json:"name"` Label string `json:"label"` Description string `json:"description"` }
Tag represents a tag that can be set on an asset.
type TagService ¶
type TagService struct {
// contains filtered or unexported fields
}
The TagService provides functions to list tags and their values.
http://tumblr.github.io/collins/api.html#tag
func (TagService) List ¶
func (s TagService) List() ([]Tag, *Response, error)
TagService.List lists all system tags that are in use.
func (TagService) Values ¶
func (s TagService) Values(tag string) ([]string, *Response, error)
TagService.Values returns all the unique values that a certain tag has.
http://tumblr.github.io/collins/api.html#api-tag-list-tag-values