Documentation ¶
Overview ¶
Package datastore retrieves stores data for the ciao controller. This package caches most data in memory, and uses a sql database as persistent storage.
Index ¶
- Variables
- type Config
- type Datastore
- func (ds *Datastore) AddBlockDevice(device types.BlockData) error
- func (ds *Datastore) AddCNCIIP(cnciMAC string, ip string) error
- func (ds *Datastore) AddExternalIPs(poolID string, IPs []string) error
- func (ds *Datastore) AddExternalSubnet(poolID string, subnet string) error
- func (ds *Datastore) AddInstance(instance *types.Instance) error
- func (ds *Datastore) AddNode(nodeID string, nodeType payloads.Resource)
- func (ds *Datastore) AddPool(pool types.Pool) error
- func (ds *Datastore) AddTenant(id string) (*types.Tenant, error)
- func (ds *Datastore) AddTenantCNCI(tenantID string, instanceID string, mac string) error
- func (ds *Datastore) AddTenantChan(c chan bool, tenantID string)
- func (ds *Datastore) AddWorkload(w types.Workload) error
- func (ds *Datastore) AllocateTenantIP(tenantID string) (net.IP, error)
- func (ds *Datastore) AttachVolumeFailure(instanceID string, volumeID string, reason payloads.AttachVolumeFailureReason) error
- func (ds *Datastore) ClearLog() error
- func (ds *Datastore) CreateStorageAttachment(instanceID string, volume payloads.StorageResource) (types.StorageAttachment, error)
- func (ds *Datastore) DeleteBlockDevice(ID string) error
- func (ds *Datastore) DeleteExternalIP(poolID string, addrID string) error
- func (ds *Datastore) DeleteInstance(instanceID string) error
- func (ds *Datastore) DeleteNode(nodeID string) error
- func (ds *Datastore) DeletePool(ID string) error
- func (ds *Datastore) DeleteStorageAttachment(ID string) error
- func (ds *Datastore) DeleteSubnet(poolID string, subnetID string) error
- func (ds *Datastore) DeleteWorkload(tenantID string, workloadID string) error
- func (ds *Datastore) DetachVolumeFailure(instanceID string, volumeID string, reason payloads.DetachVolumeFailureReason) error
- func (ds *Datastore) Exit()
- func (ds *Datastore) GenerateCNCIWorkload(vcpus int, memMB int, diskMB int, key string, password string)
- func (ds *Datastore) GetAllInstances() ([]*types.Instance, error)
- func (ds *Datastore) GetAllInstancesByNode(nodeID string) ([]*types.Instance, error)
- func (ds *Datastore) GetAllInstancesFromTenant(tenantID string) ([]*types.Instance, error)
- func (ds *Datastore) GetAllTenants() ([]*types.Tenant, error)
- func (ds *Datastore) GetBatchFrameStatistics(label string) ([]types.BatchFrameStat, error)
- func (ds *Datastore) GetBatchFrameSummary() ([]types.BatchFrameSummary, error)
- func (ds *Datastore) GetBlockDevice(ID string) (types.BlockData, error)
- func (ds *Datastore) GetBlockDevices(tenant string) ([]types.BlockData, error)
- func (ds *Datastore) GetCNCIWorkloadID() (string, error)
- func (ds *Datastore) GetEventLog() ([]*types.LogEntry, error)
- func (ds *Datastore) GetInstance(id string) (*types.Instance, error)
- func (ds *Datastore) GetInstanceLastStats(nodeID string) types.CiaoServersStats
- func (ds *Datastore) GetMappedIP(address string) (types.MappedIP, error)
- func (ds *Datastore) GetMappedIPs(tenant *string) []types.MappedIP
- func (ds *Datastore) GetNode(nodeID string) (types.Node, error)
- func (ds *Datastore) GetNodeLastStats() types.CiaoNodes
- func (ds *Datastore) GetNodeSummary() ([]*types.NodeSummary, error)
- func (ds *Datastore) GetPool(ID string) (types.Pool, error)
- func (ds *Datastore) GetPools() ([]types.Pool, error)
- func (ds *Datastore) GetQuotas(tenantID string) ([]types.QuotaDetails, error)
- func (ds *Datastore) GetStorageAttachments(instanceID string) []types.StorageAttachment
- func (ds *Datastore) GetTenant(id string) (*types.Tenant, error)
- func (ds *Datastore) GetTenantCNCISummary(cnci string) ([]types.TenantCNCI, error)
- func (ds *Datastore) GetTenantInstance(tenantID string, instanceID string) (*types.Instance, error)
- func (ds *Datastore) GetTenantUsage(tenantID string, start time.Time, end time.Time) ([]types.CiaoUsage, error)
- func (ds *Datastore) GetVolumeAttachments(volume string) ([]types.StorageAttachment, error)
- func (ds *Datastore) GetWorkload(tenantID string, ID string) (types.Workload, error)
- func (ds *Datastore) GetWorkloads(tenantID string) ([]types.Workload, error)
- func (ds *Datastore) HandleStats(stat payloads.Stat) error
- func (ds *Datastore) HandleTraceReport(trace payloads.Trace) error
- func (ds *Datastore) Init(config Config) error
- func (ds *Datastore) InstanceRestarting(instanceID string) error
- func (ds *Datastore) InstanceStopped(instanceID string) error
- func (ds *Datastore) LogError(tenant string, msg string) error
- func (ds *Datastore) LogEvent(tenant string, msg string) error
- func (ds *Datastore) MapExternalIP(poolID string, instanceID string) (types.MappedIP, error)
- func (ds *Datastore) ReleaseTenantIP(tenantID string, ip string) error
- func (ds *Datastore) ResolveInstance(tenantID string, name string) (string, error)
- func (ds *Datastore) RestartFailure(instanceID string, reason payloads.RestartFailureReason) error
- func (ds *Datastore) StartFailure(instanceID string, reason payloads.StartFailureReason, migration bool) error
- func (ds *Datastore) StopFailure(instanceID string, reason payloads.StopFailureReason) error
- func (ds *Datastore) UnMapExternalIP(address string) error
- func (ds *Datastore) UpdateBlockDevice(data types.BlockData) error
- func (ds *Datastore) UpdateQuotas(tenantID string, qds []types.QuotaDetails) error
- type MemoryDB
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoTenant = errors.New("Tenant not found") ErrNoBlockData = errors.New("Block Device not found") ErrNoStorageAttachment = errors.New("No Volume Attached") )
custom errors
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { DBBackend persistentStore PersistentURI string TransientURI string InitWorkloadsPath string }
Config contains configuration information for the datastore.
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore provides context for the datastore package.
func (*Datastore) AddBlockDevice ¶
AddBlockDevice will store information about new BlockData into the datastore.
func (*Datastore) AddCNCIIP ¶
AddCNCIIP will associate a new IP address with an existing CNCI via the mac address
func (*Datastore) AddExternalIPs ¶
AddExternalIPs will add a list of individual IPs to an existing pool.
func (*Datastore) AddExternalSubnet ¶
AddExternalSubnet will add a new subnet to an existing pool.
func (*Datastore) AddInstance ¶
AddInstance will store a new instance in the datastore. The instance will be updated both in the cache and in the database
func (*Datastore) AddNode ¶
AddNode adds a node into the node cache, updating the node's tracked role bitmask if the node is already present to be the superset of all reported roles.
func (*Datastore) AddTenant ¶
AddTenant stores information about a tenant into the datastore. it creates a MAC address for the tenant network and makes sure that this new tenant is cached.
func (*Datastore) AddTenantCNCI ¶
AddTenantCNCI will associate a new CNCI instance with a specific tenant. The instanceID of the new CNCI instance and the MAC address of the new instance are stored in the sql database and updated in the cache.
func (*Datastore) AddTenantChan ¶
AddTenantChan allows a caller to pass in a channel for CNCI Launch status. When a CNCI has been added to the datastore and a channel exists, success will be indicated on the channel. If a CNCI failure occurred and a channel exists, failure will be indicated on the channel.
func (*Datastore) AddWorkload ¶
AddWorkload is used to add a new workload to the datastore. Both cache and persistent store are updated.
func (*Datastore) AllocateTenantIP ¶
AllocateTenantIP will find a free IP address within a tenant network. For now we make each tenant have unique subnets even though it isn't actually needed because of a docker issue.
func (*Datastore) AttachVolumeFailure ¶
func (ds *Datastore) AttachVolumeFailure(instanceID string, volumeID string, reason payloads.AttachVolumeFailureReason) error
AttachVolumeFailure will clean up after a failure to attach a volume. The volume state will be changed back to available, and an error message will be logged.
func (*Datastore) CreateStorageAttachment ¶
func (ds *Datastore) CreateStorageAttachment(instanceID string, volume payloads.StorageResource) (types.StorageAttachment, error)
CreateStorageAttachment will associate an instance with a block device in the datastore
func (*Datastore) DeleteBlockDevice ¶
DeleteBlockDevice will delete a volume from the datastore. It also deletes it from the tenant's list of devices.
func (*Datastore) DeleteExternalIP ¶
DeleteExternalIP will remove an individual IP address from a pool.
func (*Datastore) DeleteInstance ¶
DeleteInstance removes an instance from the datastore.
func (*Datastore) DeleteNode ¶
DeleteNode removes a node from the node cache.
func (*Datastore) DeletePool ¶
DeletePool will delete an unused pool from our datastore.
func (*Datastore) DeleteStorageAttachment ¶
DeleteStorageAttachment will delete the attachment with the associated ID from the datastore.
func (*Datastore) DeleteSubnet ¶
DeleteSubnet will remove an unused subnet from an existing pool.
func (*Datastore) DeleteWorkload ¶
DeleteWorkload will delete an unused workload from the datastore. workload ID out of the datastore.
func (*Datastore) DetachVolumeFailure ¶
func (ds *Datastore) DetachVolumeFailure(instanceID string, volumeID string, reason payloads.DetachVolumeFailureReason) error
DetachVolumeFailure will clean up after a failure to detach a volume. The volume state will be changed back to available, and an error message will be logged.
func (*Datastore) GenerateCNCIWorkload ¶
func (ds *Datastore) GenerateCNCIWorkload(vcpus int, memMB int, diskMB int, key string, password string)
GenerateCNCIWorkload is used to create a workload definition for the CNCI. This function should be called prior to any workload launch.
func (*Datastore) GetAllInstances ¶
GetAllInstances retrieves all instances out of the datastore.
func (*Datastore) GetAllInstancesByNode ¶
GetAllInstancesByNode will retrieve all the instances running on a specific compute Node.
func (*Datastore) GetAllInstancesFromTenant ¶
GetAllInstancesFromTenant will retrieve all instances belonging to a specific tenant
func (*Datastore) GetAllTenants ¶
GetAllTenants returns all the tenants from the datastore.
func (*Datastore) GetBatchFrameStatistics ¶
func (ds *Datastore) GetBatchFrameStatistics(label string) ([]types.BatchFrameStat, error)
GetBatchFrameStatistics will show individual trace data per instance for a batch of trace data. The batch is identified by the label.
func (*Datastore) GetBatchFrameSummary ¶
func (ds *Datastore) GetBatchFrameSummary() ([]types.BatchFrameSummary, error)
GetBatchFrameSummary will retieve the count of traces we have for a specific label
func (*Datastore) GetBlockDevice ¶
GetBlockDevice will return information about a block device from the datastore.
func (*Datastore) GetBlockDevices ¶
GetBlockDevices will return all the BlockDevices associated with a tenant.
func (*Datastore) GetCNCIWorkloadID ¶
GetCNCIWorkloadID returns the UUID of the workload template for the CNCI workload
func (*Datastore) GetEventLog ¶
GetEventLog retrieves all the log entries stored in the datastore.
func (*Datastore) GetInstance ¶
GetInstance retrieves an instance out of the datastore.
func (*Datastore) GetInstanceLastStats ¶
func (ds *Datastore) GetInstanceLastStats(nodeID string) types.CiaoServersStats
GetInstanceLastStats retrieves the last instances stats received for this node. It returns it in a format suitable for the compute API.
func (*Datastore) GetMappedIP ¶
GetMappedIP will return a MappedIP struct for the given address.
func (*Datastore) GetMappedIPs ¶
GetMappedIPs will return a list of mapped external IPs by tenant.
func (*Datastore) GetNodeLastStats ¶
GetNodeLastStats retrieves the last nodes' stats received. It returns it in a format suitable for the compute API.
func (*Datastore) GetNodeSummary ¶
func (ds *Datastore) GetNodeSummary() ([]*types.NodeSummary, error)
GetNodeSummary provides a summary the state and count of instances running per node.
func (*Datastore) GetQuotas ¶
func (ds *Datastore) GetQuotas(tenantID string) ([]types.QuotaDetails, error)
GetQuotas returns the set of quotas from the database without any caching.
func (*Datastore) GetStorageAttachments ¶
func (ds *Datastore) GetStorageAttachments(instanceID string) []types.StorageAttachment
GetStorageAttachments returns a list of volumes associated with this instance.
func (*Datastore) GetTenantCNCISummary ¶
func (ds *Datastore) GetTenantCNCISummary(cnci string) ([]types.TenantCNCI, error)
GetTenantCNCISummary retrieves information about a given CNCI id, or all CNCIs If the cnci string is the null string, then this function will retrieve all tenants. If cnci is not null, it will only provide information about a specific cnci.
func (*Datastore) GetTenantInstance ¶
GetTenantInstance retrieves a tenant instance out of the datastore.
func (*Datastore) GetTenantUsage ¶
func (ds *Datastore) GetTenantUsage(tenantID string, start time.Time, end time.Time) ([]types.CiaoUsage, error)
GetTenantUsage provides statistics on actual resource usage. Usage is provided between a specified time period.
func (*Datastore) GetVolumeAttachments ¶
func (ds *Datastore) GetVolumeAttachments(volume string) ([]types.StorageAttachment, error)
GetVolumeAttachments will return a list of attachments associated with this volume ID.
func (*Datastore) GetWorkload ¶
GetWorkload returns details about a specific workload referenced by id
func (*Datastore) GetWorkloads ¶
GetWorkloads retrieves the list of workloads for a particular tenant. if there are any public workloads, they will be included in the returned list.
func (*Datastore) HandleStats ¶
HandleStats makes sure that the data from the stat payload is stored.
func (*Datastore) HandleTraceReport ¶
HandleTraceReport stores the provided trace data in the datastore.
func (*Datastore) Init ¶
Init initializes the private data for the Datastore object. The sql tables are populated with initial data from csv files if this is the first time the database has been created. The datastore caches are also filled.
func (*Datastore) InstanceRestarting ¶
InstanceRestarting resets a restarting instance's state to pending.
func (*Datastore) InstanceStopped ¶
InstanceStopped removes the link between an instance and its node
func (*Datastore) MapExternalIP ¶
MapExternalIP will allocate an external IP to an instance from a given pool.
func (*Datastore) ReleaseTenantIP ¶
ReleaseTenantIP will return an IP address previously allocated to the pool. Once a tenant IP address is released, it can be reassigned to another instance.
func (*Datastore) ResolveInstance ¶
ResolveInstance maps an instance name to an uuid, returning "" if not found TODO: Replace this O(n) algorithm with another name to id map.
func (*Datastore) RestartFailure ¶
func (ds *Datastore) RestartFailure(instanceID string, reason payloads.RestartFailureReason) error
RestartFailure logs a RestartFailure in the datastore
func (*Datastore) StartFailure ¶
func (ds *Datastore) StartFailure(instanceID string, reason payloads.StartFailureReason, migration bool) error
StartFailure will clean up after a failure to start an instance. If an instance was a CNCI, this function will remove the CNCI instance for this tenant. If the instance was a normal tenant instance, the IP address will be released and the instance will be deleted from the datastore.
Only instances whose status is pending are removed when a StartFailure event is received. StartFailure errors may also be generated when restarting an exited instance and we want to make sure that a failure to restart such an instance does not result in it being deleted.
func (*Datastore) StopFailure ¶
func (ds *Datastore) StopFailure(instanceID string, reason payloads.StopFailureReason) error
StopFailure logs a StopFailure in the datastore
func (*Datastore) UnMapExternalIP ¶
UnMapExternalIP will stop associating a given address with an instance.
func (*Datastore) UpdateBlockDevice ¶
UpdateBlockDevice will replace existing information about a block device in the datastore.
func (*Datastore) UpdateQuotas ¶
func (ds *Datastore) UpdateQuotas(tenantID string, qds []types.QuotaDetails) error
UpdateQuotas updates the quotas for a tenant in the database.