datastore

package
v0.0.0-...-476269e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func (ds *Datastore) AddBlockDevice(device types.BlockData) error

AddBlockDevice will store information about new BlockData into the datastore.

func (*Datastore) AddCNCIIP

func (ds *Datastore) AddCNCIIP(cnciMAC string, ip string) error

AddCNCIIP will associate a new IP address with an existing CNCI via the mac address

func (*Datastore) AddExternalIPs

func (ds *Datastore) AddExternalIPs(poolID string, IPs []string) error

AddExternalIPs will add a list of individual IPs to an existing pool.

func (*Datastore) AddExternalSubnet

func (ds *Datastore) AddExternalSubnet(poolID string, subnet string) error

AddExternalSubnet will add a new subnet to an existing pool.

func (*Datastore) AddInstance

func (ds *Datastore) AddInstance(instance *types.Instance) error

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

func (ds *Datastore) AddNode(nodeID string, nodeType payloads.Resource)

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) AddPool

func (ds *Datastore) AddPool(pool types.Pool) error

AddPool will add a brand new pool to our datastore.

func (*Datastore) AddTenant

func (ds *Datastore) AddTenant(id string) (*types.Tenant, error)

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

func (ds *Datastore) AddTenantCNCI(tenantID string, instanceID string, mac string) error

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

func (ds *Datastore) AddTenantChan(c chan bool, tenantID string)

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

func (ds *Datastore) AddWorkload(w types.Workload) error

AddWorkload is used to add a new workload to the datastore. Both cache and persistent store are updated.

func (*Datastore) AllocateTenantIP

func (ds *Datastore) AllocateTenantIP(tenantID string) (net.IP, error)

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) ClearLog

func (ds *Datastore) ClearLog() error

ClearLog will remove all the event entries from the event log

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

func (ds *Datastore) DeleteBlockDevice(ID string) error

DeleteBlockDevice will delete a volume from the datastore. It also deletes it from the tenant's list of devices.

func (*Datastore) DeleteExternalIP

func (ds *Datastore) DeleteExternalIP(poolID string, addrID string) error

DeleteExternalIP will remove an individual IP address from a pool.

func (*Datastore) DeleteInstance

func (ds *Datastore) DeleteInstance(instanceID string) error

DeleteInstance removes an instance from the datastore.

func (*Datastore) DeleteNode

func (ds *Datastore) DeleteNode(nodeID string) error

DeleteNode removes a node from the node cache.

func (*Datastore) DeletePool

func (ds *Datastore) DeletePool(ID string) error

DeletePool will delete an unused pool from our datastore.

func (*Datastore) DeleteStorageAttachment

func (ds *Datastore) DeleteStorageAttachment(ID string) error

DeleteStorageAttachment will delete the attachment with the associated ID from the datastore.

func (*Datastore) DeleteSubnet

func (ds *Datastore) DeleteSubnet(poolID string, subnetID string) error

DeleteSubnet will remove an unused subnet from an existing pool.

func (*Datastore) DeleteWorkload

func (ds *Datastore) DeleteWorkload(tenantID string, workloadID string) error

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) Exit

func (ds *Datastore) Exit()

Exit will disconnect the backing database.

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

func (ds *Datastore) GetAllInstances() ([]*types.Instance, error)

GetAllInstances retrieves all instances out of the datastore.

func (*Datastore) GetAllInstancesByNode

func (ds *Datastore) GetAllInstancesByNode(nodeID string) ([]*types.Instance, error)

GetAllInstancesByNode will retrieve all the instances running on a specific compute Node.

func (*Datastore) GetAllInstancesFromTenant

func (ds *Datastore) GetAllInstancesFromTenant(tenantID string) ([]*types.Instance, error)

GetAllInstancesFromTenant will retrieve all instances belonging to a specific tenant

func (*Datastore) GetAllTenants

func (ds *Datastore) GetAllTenants() ([]*types.Tenant, error)

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

func (ds *Datastore) GetBlockDevice(ID string) (types.BlockData, error)

GetBlockDevice will return information about a block device from the datastore.

func (*Datastore) GetBlockDevices

func (ds *Datastore) GetBlockDevices(tenant string) ([]types.BlockData, error)

GetBlockDevices will return all the BlockDevices associated with a tenant.

func (*Datastore) GetCNCIWorkloadID

func (ds *Datastore) GetCNCIWorkloadID() (string, error)

GetCNCIWorkloadID returns the UUID of the workload template for the CNCI workload

func (*Datastore) GetEventLog

func (ds *Datastore) GetEventLog() ([]*types.LogEntry, error)

GetEventLog retrieves all the log entries stored in the datastore.

func (*Datastore) GetInstance

func (ds *Datastore) GetInstance(id string) (*types.Instance, error)

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

func (ds *Datastore) GetMappedIP(address string) (types.MappedIP, error)

GetMappedIP will return a MappedIP struct for the given address.

func (*Datastore) GetMappedIPs

func (ds *Datastore) GetMappedIPs(tenant *string) []types.MappedIP

GetMappedIPs will return a list of mapped external IPs by tenant.

func (*Datastore) GetNode

func (ds *Datastore) GetNode(nodeID string) (types.Node, error)

GetNode retrieves a node in the node cache.

func (*Datastore) GetNodeLastStats

func (ds *Datastore) GetNodeLastStats() types.CiaoNodes

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) GetPool

func (ds *Datastore) GetPool(ID string) (types.Pool, error)

GetPool will return an external IP Pool

func (*Datastore) GetPools

func (ds *Datastore) GetPools() ([]types.Pool, error)

GetPools will return a list of external IP Pools

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) GetTenant

func (ds *Datastore) GetTenant(id string) (*types.Tenant, error)

GetTenant returns details about a tenant referenced by the uuid

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

func (ds *Datastore) GetTenantInstance(tenantID string, instanceID string) (*types.Instance, error)

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

func (ds *Datastore) GetWorkload(tenantID string, ID string) (types.Workload, error)

GetWorkload returns details about a specific workload referenced by id

func (*Datastore) GetWorkloads

func (ds *Datastore) GetWorkloads(tenantID string) ([]types.Workload, error)

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

func (ds *Datastore) HandleStats(stat payloads.Stat) error

HandleStats makes sure that the data from the stat payload is stored.

func (*Datastore) HandleTraceReport

func (ds *Datastore) HandleTraceReport(trace payloads.Trace) error

HandleTraceReport stores the provided trace data in the datastore.

func (*Datastore) Init

func (ds *Datastore) Init(config Config) error

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

func (ds *Datastore) InstanceRestarting(instanceID string) error

InstanceRestarting resets a restarting instance's state to pending.

func (*Datastore) InstanceStopped

func (ds *Datastore) InstanceStopped(instanceID string) error

InstanceStopped removes the link between an instance and its node

func (*Datastore) LogError

func (ds *Datastore) LogError(tenant string, msg string) error

LogError will add a message to the persistent event log as an error

func (*Datastore) LogEvent

func (ds *Datastore) LogEvent(tenant string, msg string) error

LogEvent will add a message to the persistent event log.

func (*Datastore) MapExternalIP

func (ds *Datastore) MapExternalIP(poolID string, instanceID string) (types.MappedIP, error)

MapExternalIP will allocate an external IP to an instance from a given pool.

func (*Datastore) ReleaseTenantIP

func (ds *Datastore) ReleaseTenantIP(tenantID string, ip string) error

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

func (ds *Datastore) ResolveInstance(tenantID string, name string) (string, error)

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

func (ds *Datastore) UnMapExternalIP(address string) error

UnMapExternalIP will stop associating a given address with an instance.

func (*Datastore) UpdateBlockDevice

func (ds *Datastore) UpdateBlockDevice(data types.BlockData) error

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.

type MemoryDB

type MemoryDB struct {
	// contains filtered or unexported fields
}

MemoryDB is a memory backed persistentStore implementation for unit testing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL