data

package
v0.0.0-...-a17d9bd Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Resources []VirtualResource

Resources is the in-memory representation of the cloud environment

Functions

func AddToTerminationPlan

func AddToTerminationPlan(t TerminationItem)

func AddVirtualResource

func AddVirtualResource(resource VirtualResource)

AddVirtualResource adds a new VirtualResource

func ClearTerminationPlan

func ClearTerminationPlan()

func CostBetween

func CostBetween(c []CostItem, t1 time.Time, t2 time.Time) float64

CostBetween returns sums all costItems between t1 and t2

func CurrentTerminationPlanToString

func CurrentTerminationPlanToString() string

CurrentTerminationPlanToString renders the current TerminationPlan to string

func FilterNonOT3C

func FilterNonOT3C()

FilterNonOT3C removes all VRs that have no ot3c_prio tag

func GetCostTillBillingEnd

func GetCostTillBillingEnd(vr VirtualResource) float64

GetCostTillBillingEnd calculates the rest cost for this cost month

func GetCurrentCost

func GetCurrentCost(vr VirtualResource) float64

GetCurrentCost calculates the current cost in this cost month

func GetPrio

func GetPrio(vr VirtualResource) int

GetPrio returns a prio for a vr if available. If not then it returns -1

func ParseTerminationPlanFromString

func ParseTerminationPlanFromString(str string) error

func RemoveResourceWithID

func RemoveResourceWithID(id string) bool

RemoveResourceWithID removes a VR based on its ID. Returns true on found and removed. Caution ... destroys order

func RenderTerminationPlanToYAMLFile

func RenderTerminationPlanToYAMLFile() (string, error)

RenderTerminationPlanToYAMLFile encodes the TerminationPlan to a String writable to a YAML file

func SetTerminationItems

func SetTerminationItems(t []TerminationItem)

func SortResourcesByPriority

func SortResourcesByPriority()

SortResourcesByPriority rearranges the VRs in the Resource List based on Priority decending.

func UpdateTerminationPlan

func UpdateTerminationPlan()

UpdateTerminationPlan creates new TerminationPlan based upon current Termination Items

Types

type CostItem

type CostItem struct {
	Cost float64
	Time time.Time
}

CostItem is an item that pairs cost to a single day of a resource

func CostItemBetween

func CostItemBetween(c []CostItem, t1 time.Time, t2 time.Time) []CostItem

CostItemBetween returns all cost items between t1 and t2

type CostSortByDate

type CostSortByDate []CostItem

CostSortByDate is a list for sorting by date

func (CostSortByDate) Len

func (a CostSortByDate) Len() int

func (CostSortByDate) Less

func (a CostSortByDate) Less(i, j int) bool

func (CostSortByDate) Swap

func (a CostSortByDate) Swap(i, j int)

type ECSResource

type ECSResource struct {
	ID string

	OTCServer servers.Server
	PredCost  []CostItem
	Tags      map[string]string
	// contains filtered or unexported fields
}

ECSResource ECSResource

func (ECSResource) GetCostItems

func (c ECSResource) GetCostItems() []CostItem

func (ECSResource) GetDescription

func (c ECSResource) GetDescription() string

func (ECSResource) GetID

func (c ECSResource) GetID() string

func (ECSResource) GetPredCostItems

func (c ECSResource) GetPredCostItems() []CostItem

func (ECSResource) GetTags

func (c ECSResource) GetTags() map[string]string

func (*ECSResource) SetPastCostItems

func (c *ECSResource) SetPastCostItems(cost []enterprise.Consumption)

SetPastCostItems build past cost items

func (*ECSResource) SetPredCostItems

func (c *ECSResource) SetPredCostItems(cost []CostItem)

func (ECSResource) Terminate

func (c ECSResource) Terminate(client *golangsdk.ProviderClient) error

type EVSResource

type EVSResource struct {
	ID string

	OTCEVS   hVolumes.Volume
	PredCost []CostItem
	// contains filtered or unexported fields
}

ECSResource ECSResource

func (*EVSResource) BuildPastCostItems

func (c *EVSResource) BuildPastCostItems(cost []enterprise.Consumption)

func (EVSResource) GetCostItems

func (c EVSResource) GetCostItems() []CostItem

func (EVSResource) GetDescription

func (c EVSResource) GetDescription() string

func (EVSResource) GetID

func (c EVSResource) GetID() string

func (EVSResource) GetPredCostItems

func (c EVSResource) GetPredCostItems() []CostItem

func (EVSResource) GetTags

func (c EVSResource) GetTags() map[string]string

func (*EVSResource) SetPredCostItems

func (c *EVSResource) SetPredCostItems(cost []CostItem)

func (EVSResource) Terminate

func (c EVSResource) Terminate(client *golangsdk.ProviderClient) error

type GhostResource

type GhostResource struct {
	ID string
	// contains filtered or unexported fields
}

GhostResource are VRs that once where a real VR but are now terminated and no longer produce any future costs. They are still needet for current cost calculation.

func (*GhostResource) BuildPastCostItems

func (c *GhostResource) BuildPastCostItems(cost []enterprise.Consumption)

func (GhostResource) GetCostItems

func (c GhostResource) GetCostItems() []CostItem

func (GhostResource) GetDescription

func (c GhostResource) GetDescription() string

func (GhostResource) GetID

func (c GhostResource) GetID() string

func (GhostResource) GetPredCostItems

func (c GhostResource) GetPredCostItems() []CostItem

func (GhostResource) GetTags

func (c GhostResource) GetTags() map[string]string

func (GhostResource) Terminate

func (c GhostResource) Terminate(client *golangsdk.ProviderClient) error

type GroupResource

type GroupResource struct {
	List []VirtualResource
	Tags map[string]string
}

GroupResource is a grouped resource. IDs should start with GR_

func (GroupResource) GetCostItems

func (g GroupResource) GetCostItems() []CostItem

func (GroupResource) GetDescription

func (g GroupResource) GetDescription() string

func (GroupResource) GetID

func (g GroupResource) GetID() string

func (GroupResource) GetPredCostItems

func (g GroupResource) GetPredCostItems() []CostItem

func (GroupResource) GetTags

func (g GroupResource) GetTags() map[string]string

func (GroupResource) PatchGroup

func (g GroupResource) PatchGroup()

PatchGroup searches through all the VRs and patches different tags on the group Set highest prio. Searches through all VRs, gets the highes prio and sets it for the group.

func (GroupResource) Terminate

func (g GroupResource) Terminate(client *golangsdk.ProviderClient) error

type SortByPrio

type SortByPrio []VirtualResource

func (SortByPrio) Len

func (a SortByPrio) Len() int

func (SortByPrio) Less

func (a SortByPrio) Less(i, j int) bool

func (SortByPrio) Swap

func (a SortByPrio) Swap(i, j int)

type TerminationItem

type TerminationItem struct {
	TVR   VirtualResource
	TDate time.Time
	//TSave is the amount of money saved by this termination
	TSave float64
	//TASAP determines if this termination is a ASAP Termination
	TASAP bool
}

TerminationItem is an item on the Termination list

type TerminationPlan

type TerminationPlan struct {
	CreatedAt time.Time
	Items     []TerminationItem
}
var ActiveTerminationPlan TerminationPlan

type VirtualResource

type VirtualResource interface {
	//GetID returns a unique ID for the VR
	GetID() string
	//GetDescription returns a description for the VR
	GetDescription() string
	//GetCostItems returns all past costs up to the current date
	GetCostItems() []CostItem
	//GetPredCostItems returns future costs. Length can be 0 if no prediction has been done yet.
	GetPredCostItems() []CostItem
	//GetTags returns the VRs Tags
	GetTags() map[string]string
	//Terminate terminates the VR
	Terminate(*golangsdk.ProviderClient) error
}

VirtualResource is the internal representation of a resource

func FindVRByID

func FindVRByID(id string) VirtualResource

FindVRByID returns a VR that contains the id in question . Works also on grouped VRs.

Jump to

Keyboard shortcuts

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