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.Volume) error
- func (ds *Datastore) AddExternalIPs(poolID string, IPs []string) error
- func (ds *Datastore) AddExternalSubnet(poolID string, subnet string) error
- func (ds *Datastore) AddImage(i types.Image) 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, config types.TenantConfig) (*types.Tenant, error)
- func (ds *Datastore) AddWorkload(w types.Workload) error
- func (ds *Datastore) AllocateTenantIP(tenantID string) (net.IP, error)
- func (ds *Datastore) AllocateTenantIPPool(tenantID string, num int) ([]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) DeleteImage(ID 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) DeleteTenant(ID string) error
- func (ds *Datastore) DeleteWorkload(workloadID string) error
- func (ds *Datastore) Exit()
- func (ds *Datastore) GenerateCNCIWorkload(vcpus int, memMB int, diskMB int, key string)
- func (ds *Datastore) GetAllCNCIInstances() ([]*types.Instance, error)
- 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.Volume, error)
- func (ds *Datastore) GetBlockDevices(tenant string) ([]types.Volume, error)
- func (ds *Datastore) GetCNCIWorkloadID() (string, error)
- func (ds *Datastore) GetEventLog() ([]*types.LogEntry, error)
- func (ds *Datastore) GetImage(ID string) (types.Image, error)
- func (ds *Datastore) GetImages(tenantID string, admin bool) ([]types.Image, 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(cnciID string) ([]types.TenantCNCI, error)
- func (ds *Datastore) GetTenantCNCIs(tenantID string) ([]*types.Instance, 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) GetTenantWorkloads(tenantID string) ([]types.Workload, error)
- func (ds *Datastore) GetVolumeAttachments(volume string) ([]types.StorageAttachment, error)
- func (ds *Datastore) GetWorkload(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) JSONPatchTenant(ID string, patch []byte) 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) ResolveImage(tenantID string, name string) (string, error)
- func (ds *Datastore) ResolveInstance(tenantID string, name string) (string, error)
- func (ds *Datastore) StartFailure(instanceID string, reason payloads.StartFailureReason, migration bool, ...) error
- func (ds *Datastore) UnMapExternalIP(address string) error
- func (ds *Datastore) UpdateBlockDevice(data types.Volume) error
- func (ds *Datastore) UpdateImage(i types.Image) error
- func (ds *Datastore) UpdateInstance(instance *types.Instance) 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 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) 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. and makes sure that this new tenant is cached.
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 allocate a single IP address for a tenant.
func (*Datastore) AllocateTenantIPPool ¶
AllocateTenantIPPool will reserve a pool of IP addresses for the caller.
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) DeleteImage ¶
DeleteImage deleted the image from the datastore and the database
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) DeleteTenant ¶
DeleteTenant removes a tenant from the datastore. It is the responsibility of the caller to ensure all tenant artifacts are removed first.
func (*Datastore) DeleteWorkload ¶
DeleteWorkload will delete an unused workload from the datastore. workload ID out of the datastore.
func (*Datastore) GenerateCNCIWorkload ¶
GenerateCNCIWorkload is used to create a workload definition for the CNCI. This function should be called prior to any workload launch.
func (*Datastore) GetAllCNCIInstances ¶
GetAllCNCIInstances retrieves all CNCI instances out of the datastore.
func (*Datastore) GetAllInstances ¶
GetAllInstances retrieves all tenant 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. This will exclude any CNCI instances.
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) GetImages ¶
GetImages obtains the images available for the optional tenantID/admin combo
func (*Datastore) GetInstance ¶
GetInstance retrieves an instance out of the datastore. The CNCI could be retrieved this way.
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(cnciID 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) GetTenantCNCIs ¶
GetTenantCNCIs will retrieve all CNCI instances belonging to a tenant
func (*Datastore) GetTenantInstance ¶
GetTenantInstance retrieves a tenant instance out of the datastore. the CNCI will be excluded from this search.
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) GetTenantWorkloads ¶
GetTenantWorkloads retrieves a list of private workloads.
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) JSONPatchTenant ¶
JSONPatchTenant will update a tenant with changes from a json merge patch.
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) ResolveImage ¶
ResolveImage retrieves an image by name or ID
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) StartFailure ¶
func (ds *Datastore) StartFailure(instanceID string, reason payloads.StartFailureReason, migration bool, nodeID string) 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) 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) UpdateImage ¶
UpdateImage updates the image metadate in the datastore and database
func (*Datastore) UpdateInstance ¶
UpdateInstance will update certain fields of an instance
func (*Datastore) UpdateQuotas ¶
func (ds *Datastore) UpdateQuotas(tenantID string, qds []types.QuotaDetails) error
UpdateQuotas updates the quotas for a tenant in the database.