datastore

package
v0.0.0-...-3c0cf66 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2016 License: Apache-2.0 Imports: 20 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 {
	PersistentURI     string
	TransientURI      string
	InitTablesPath    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) 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) AddLimit

func (ds *Datastore) AddLimit(tenantID string, resourceID int, limit int) error

AddLimit allows the caller to store a limt for a specific resource for a tenant.

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

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, blockID string, ephemeral bool) (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) 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) DeleteStorageAttachment

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

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

func (*Datastore) DetachVolumeFailure

func (ds *Datastore) DetachVolumeFailure(instanceID string, volumeID string, reason payloads.DetachVolumeFailureReason)

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

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

GetNodeLastStats retrieves the last nodes stats received for this node. 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) GetStorageAttachments

func (ds *Datastore) GetStorageAttachments(instanceID string) ([]types.StorageAttachment, error)

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) 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(id string) (*types.Workload, error)

GetWorkload returns details about a specific workload referenced by id

func (*Datastore) GetWorkloads

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

GetWorkloads returns all known tenant workloads

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

func (*Datastore) StopFailure

func (ds *Datastore) StopFailure(instanceID string, reason payloads.StopFailureReason) error

StopFailure logs a StopFailure in the datastore

func (*Datastore) UpdateBlockDevice

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

UpdateBlockDevice will replace existing information about a block device in the datastore.

Jump to

Keyboard shortcuts

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