model

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 19 Imported by: 49

Documentation

Index

Constants

View Source
const (
	EntityTypeModel     = "model"
	EntityTypeRegion    = "region"
	EntityTypeHost      = "host"
	EntityTypeComponent = "component"
)
View Source
const (
	SelectorTagPrefix = "."
	SelectorIdPrefix  = "#"
)
View Source
const (
	InheritTagPrefix = "^"
)
View Source
const Version = "0.3.6 (sp1r4l)"

Variables

This section is empty.

Functions

func ActiveInstanceId

func ActiveInstanceId() string

func ActiveInstancePath

func ActiveInstancePath() string

func AddBootstrapExtension

func AddBootstrapExtension(ext BootstrapExtension)

func AllocateDump

func AllocateDump(run string) string

func AllocateForensicScenario

func AllocateForensicScenario(run, scenario string) string

func Bootstrap

func Bootstrap() error

func BootstrapBindings

func BootstrapBindings() error

func BootstrapInstance

func BootstrapInstance() error

func ClearActiveInstance

func ClearActiveInstance() error

func ConfigBuild

func ConfigBuild() string

func ConfigSrc

func ConfigSrc() string

func CreateLabel

func CreateLabel(instanceId, modelName string) error

func FablabRoot

func FablabRoot() string

func InitInstanceId

func InitInstanceId(newInstanceId string)

func KitBuild

func KitBuild() string

func ListDumps

func ListDumps() ([]string, error)

func ListInstances

func ListInstances() ([]string, error)

func ListModels

func ListModels() []string

func NewInstance

func NewInstance() (string, error)

func NewNamedInstance

func NewNamedInstance(name string) error

func PkiBuild

func PkiBuild() string

func RegisterModel

func RegisterModel(name string, m *Model)

func RemoveInstance

func RemoveInstance(instanceId string) error

func ScriptBuild

func ScriptBuild() string

func ScriptSrc

func ScriptSrc() string

func Selector

func Selector(levels ...string) string

func SetActiveInstance

func SetActiveInstance(newInstanceId string) error

func ValidateModelName

func ValidateModelName(modelName string) error

Types

type Action

type Action interface {
	Execute(m *Model) error
}

type ActionBinder

type ActionBinder func(m *Model) Action

type ActionBinders

type ActionBinders map[string]ActionBinder

type ActionFunc

type ActionFunc func(m *Model) error

func (ActionFunc) Execute

func (f ActionFunc) Execute(m *Model) error

type ActivationStage

type ActivationStage interface {
	Activate(run Run) error
}

type ActivationStages

type ActivationStages []ActivationStage

type Bindings

type Bindings map[interface{}]interface{}

func GetBindings

func GetBindings() Bindings

func (Bindings) Get

func (bindings Bindings) Get(name ...string) (interface{}, bool)

func (Bindings) GetBool

func (bindings Bindings) GetBool(name ...string) (bool, bool)

func (Bindings) GetString

func (bindings Bindings) GetString(name ...string) (string, bool)

func (Bindings) Has

func (bindings Bindings) Has(name ...string) bool

func (Bindings) Must

func (bindings Bindings) Must(name ...string) interface{}

func (Bindings) Put

func (bindings Bindings) Put(value interface{}, rootKey string, rest ...string)

type BootstrapExtension

type BootstrapExtension interface {
	Bootstrap(m *Model) error
}

type Component

type Component struct {
	Scope
	Id              string
	Host            *Host
	ScriptSrc       string
	ScriptName      string
	ConfigSrc       string
	ConfigName      string
	BinaryName      string
	PublicIdentity  string
	PrivateIdentity string
	Index           int
}

func (*Component) Accept

func (component *Component) Accept(visitor EntityVisitor)

func (*Component) GetChildren

func (component *Component) GetChildren() []Entity

func (*Component) GetHost

func (component *Component) GetHost() *Host

func (*Component) GetId

func (component *Component) GetId() string

func (*Component) GetModel

func (component *Component) GetModel() *Model

func (*Component) GetParentEntity

func (component *Component) GetParentEntity() Entity

func (*Component) GetPath

func (component *Component) GetPath() string

func (*Component) GetRegion

func (component *Component) GetRegion() *Region

func (*Component) GetScope

func (component *Component) GetScope() *Scope

func (*Component) GetType

func (component *Component) GetType() string

func (*Component) Matches

func (component *Component) Matches(entityType string, matcher EntityMatcher) bool

func (*Component) Merge

func (c *Component) Merge(parent *Component) (*Component, error)

func (*Component) Region

func (component *Component) Region() *Region

type ComponentDump

type ComponentDump struct {
	Scope           *ScopeDump `json:"scope,omitempty"`
	ScriptSrc       string     `json:"script_src,omitempty"`
	ScriptName      string     `json:"script_name,omitempty"`
	ConfigSrc       string     `json:"config_src,omitempty"`
	ConfigName      string     `json:"config_name,omitempty"`
	BinaryName      string     `json:"binary_name,omitempty"`
	PublicIdentity  string     `json:"public_identity,omitempty`
	PrivateIdentity string     `json:"private_identity,omitempty"`
}

type Components

type Components map[string]*Component

func (Components) Merge

func (c Components) Merge(parent Components) (Components, error)

type ConfigurationStage

type ConfigurationStage interface {
	Configure(run Run) error
}

type ConfigurationStages

type ConfigurationStages []ConfigurationStage

type CpuTimeslice

type CpuTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	PercentUser   float64 `json:"percent_user"`
	PercentNice   float64 `json:"percent_nice"`
	PercentSystem float64 `json:"percent_system"`
	PercentIowait float64 `json:"percent_iowait"`
	PercentSteal  float64 `json:"percent_steal"`
	PercentIdle   float64 `json:"percent_idle"`
}

type Data

type Data map[string]interface{}

type DataMetricsWriter

type DataMetricsWriter struct {
}

func (DataMetricsWriter) AcceptHostMetrics

func (DataMetricsWriter) AcceptHostMetrics(host *Host, event *MetricsEvent)

type DisposalStage

type DisposalStage interface {
	Dispose(run Run) error
}

type DisposalStages

type DisposalStages []DisposalStage

type DistributionStage

type DistributionStage interface {
	Distribute(run Run) error
}

type DistributionStages

type DistributionStages []DistributionStage

type Dump

type Dump struct {
	Scope   *ScopeDump             `json:"scope,omitempty"`
	Regions map[string]*RegionDump `json:"regions"`
}

type Entity

type Entity interface {
	GetModel() *Model
	GetType() string
	GetId() string
	GetScope() *Scope
	GetParentEntity() Entity
	Accept(EntityVisitor)
	GetChildren() []Entity
	Matches(entityType string, matcher EntityMatcher) bool
}

type EntityMatcher

type EntityMatcher func(Entity) bool

func (EntityMatcher) And

func (EntityMatcher) Or

type EntityVisitor

type EntityVisitor func(Entity)

type Factory

type Factory interface {
	Build(m *Model) error
}

Factory builds model instances.

type Host

type Host struct {
	Scope
	Id                   string
	Region               *Region
	PublicIp             string
	PrivateIp            string
	InstanceType         string
	InstanceResourceType string
	SpotPrice            string
	SpotType             string
	Components           Components
	Index                int
}

func (*Host) Accept

func (host *Host) Accept(visitor EntityVisitor)

func (*Host) GetChildren

func (host *Host) GetChildren() []Entity

func (*Host) GetId

func (host *Host) GetId() string

func (*Host) GetModel

func (host *Host) GetModel() *Model

func (*Host) GetParentEntity

func (host *Host) GetParentEntity() Entity

func (*Host) GetPath

func (host *Host) GetPath() string

func (*Host) GetRegion

func (host *Host) GetRegion() *Region

func (*Host) GetScope

func (host *Host) GetScope() *Scope

func (*Host) GetType

func (host *Host) GetType() string

func (*Host) Matches

func (host *Host) Matches(entityType string, matcher EntityMatcher) bool

func (*Host) Merge

func (h *Host) Merge(parent *Host) (*Host, error)

type HostDump

type HostDump struct {
	Scope                *ScopeDump                `json:"scope,omitempty"`
	PublicIp             string                    `json:"public_ip,omitempty"`
	PrivateIp            string                    `json:"private_ip,omitempty"`
	InstanceType         string                    `json:"instance_type,omitempty"`
	InstanceResourceType string                    `json:"instance_resource_type,omitempty"`
	SpotPrice            string                    `json:"spot_price,omitempty"`
	SpotType             string                    `json:"spot_type,omitempty"`
	Components           map[string]*ComponentDump `json:"components,omitempty"`
}

func DumpHost

func DumpHost(h *Host) *HostDump

type HostSummary

type HostSummary struct {
	Cpu     []*CpuTimeslice     `json:"cpu,omitempty"`
	Memory  []*MemoryTimeslice  `json:"memory,omitempty"`
	Process []*ProcessTimeslice `json:"process,omitempty"`
}

func (*HostSummary) ToMetricsEvents

func (hs *HostSummary) ToMetricsEvents() (events []*MetricsEvent)

type Hosts

type Hosts map[string]*Host

func (Hosts) Merge

func (h Hosts) Merge(parent Hosts) (Hosts, error)

type InfrastructureStage

type InfrastructureStage interface {
	Express(run Run) error
}

type InfrastructureStages

type InfrastructureStages []InfrastructureStage

type InstanceState

type InstanceState int
const (
	Created InstanceState = iota
	Expressed
	Configured
	Kitted
	Distributed
	Activated
	Operating
	Disposed
)

func (InstanceState) String

func (instanceState InstanceState) String() string

type IperfSummary

type IperfSummary struct {
	Timeslices    []*IperfTimeslice `json:"timeslices"`
	Bytes         float64           `json:"bytes"`
	BitsPerSecond float64           `json:"bits_per_second"`
}

type IperfTimeslice

type IperfTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	BitsPerSecond float64 `json:"bits_per_second"`
}

type IperfUdpSummary

type IperfUdpSummary struct {
	Timeslices    []*IperfUdpTimeslice `json:"timeslices"`
	Bytes         float64              `json:"bytes"`
	BitsPerSecond float64              `json:"bits_per_second"`
	JitterMs      float64              `json:"jitter_ms"`
	LostPackets   float64              `json:"lost_packets"`
}

type IperfUdpTimeslice

type IperfUdpTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	BitsPerSecond float64 `json:"bits_per_second"`
	Packets       float64 `json:"packets"`
}

type Label

type Label struct {
	Model    string        `yaml:"model"`
	State    InstanceState `yaml:"state"`
	Bindings Bindings      `yaml:"bindings"`
	// contains filtered or unexported fields
}

func GetLabel

func GetLabel() *Label

func LoadLabel

func LoadLabel(path string) (*Label, error)

func LoadLabelForInstance

func LoadLabelForInstance(instanceId string) (*Label, error)

func (*Label) Get

func (label *Label) Get(name ...string) (interface{}, bool)

func (*Label) GetFilePath

func (label *Label) GetFilePath(fileName string) string

func (*Label) Has

func (label *Label) Has(name ...string) bool

func (*Label) Must

func (label *Label) Must(name ...string) interface{}

func (*Label) Save

func (label *Label) Save() error

func (*Label) SaveAtPath

func (label *Label) SaveAtPath(path string) error

type MemoryTimeslice

type MemoryTimeslice struct {
	TimestampMs   int64   `json:"timestamp_ms"`
	MemFreeK      int64   `json:"free_k"`
	AvailK        int64   `json:"avail_k"`
	UsedK         int64   `json:"used_k"`
	UsedPercent   float64 `json:"used_percent"`
	BuffersK      int64   `json:"buffers_k"`
	CachedK       int64   `json:"cached_k"`
	CommitK       int64   `json:"commit_k"`
	CommitPercent float64 `json:"commit_percent"`
	ActiveK       int64   `json:"active_k"`
	InactiveK     int64   `json:"inactive_k"`
	DirtyK        int64   `json:"dirty_k"`
}

type MetricSet

type MetricSet map[string]interface{}

func (MetricSet) AddGroupedMetric

func (s MetricSet) AddGroupedMetric(group, name string, val interface{})

func (MetricSet) VisitGroupedMetrics

func (s MetricSet) VisitGroupedMetrics(f func(name string, group MetricSet))

func (MetricSet) VisitUngroupedMetrics

func (s MetricSet) VisitUngroupedMetrics(f func(name string, val interface{}))

type MetricsEvent

type MetricsEvent struct {
	Timestamp time.Time
	Metrics   MetricSet
}

type MetricsHandler

type MetricsHandler interface {
	AcceptHostMetrics(host *Host, event *MetricsEvent)
}

type Model

type Model struct {
	Parent *Model

	Scope
	Regions             Regions
	Factories           []Factory
	BootstrapExtensions []BootstrapExtension
	Actions             map[string]ActionBinder
	Infrastructure      InfrastructureStages
	Configuration       ConfigurationStages
	Distribution        DistributionStages
	Activation          ActivationStages
	Operation           OperatingStages
	Disposal            DisposalStages
	MetricsHandlers     []MetricsHandler
	// contains filtered or unexported fields
}

func GetModel

func GetModel(name string) (*Model, bool)

func (*Model) Accept

func (m *Model) Accept(visitor EntityVisitor)

func (*Model) AcceptHostMetrics

func (m *Model) AcceptHostMetrics(host *Host, event *MetricsEvent)

func (*Model) Activate

func (m *Model) Activate(run Run) error

func (*Model) AddActivationActions

func (m *Model) AddActivationActions(actions ...string)

func (*Model) AddActivationStage

func (m *Model) AddActivationStage(stage ActivationStage)

func (*Model) AddActivationStages

func (m *Model) AddActivationStages(stage ...ActivationStage)

func (*Model) AddOperatingActions

func (m *Model) AddOperatingActions(actions ...string)

func (*Model) AddOperatingStage

func (m *Model) AddOperatingStage(stage OperatingStage)

func (*Model) AddOperatingStages

func (m *Model) AddOperatingStages(stages ...OperatingStage)

func (*Model) BindBindings

func (m *Model) BindBindings(bindings Bindings) error

func (*Model) BindLabel

func (m *Model) BindLabel(l *Label)

func (*Model) Build

func (m *Model) Build(run Run) error

func (*Model) Dispose

func (m *Model) Dispose(run Run) error

func (*Model) Dump

func (m *Model) Dump() *Dump

func (*Model) Express

func (m *Model) Express(run Run) error

func (*Model) ForEachComponent

func (m *Model) ForEachComponent(spec string, concurrency int, f func(c *Component) error) error

func (*Model) ForEachHost

func (m *Model) ForEachHost(spec string, concurrency int, f func(host *Host) error) error

func (*Model) GetAction

func (m *Model) GetAction(name string) (Action, bool)

func (*Model) GetChildren

func (m *Model) GetChildren() []Entity

func (*Model) GetId

func (m *Model) GetId() string

func (*Model) GetModel

func (m *Model) GetModel() *Model

func (*Model) GetParentEntity

func (m *Model) GetParentEntity() Entity

func (*Model) GetRequiredStringVariable

func (m *Model) GetRequiredStringVariable(holder errorz.ErrorHolder, name ...string) string

func (*Model) GetScope

func (m *Model) GetScope() *Scope

func (*Model) GetType

func (m *Model) GetType() string

func (*Model) GetVariable

func (m *Model) GetVariable(name ...string) (interface{}, bool)

func (*Model) IsBound

func (m *Model) IsBound() bool

func (*Model) IterateScopes

func (m *Model) IterateScopes(f func(i interface{}, path ...string))

func (*Model) Matches

func (m *Model) Matches(entityType string, matcher EntityMatcher) bool

func (*Model) Merge

func (m *Model) Merge(parent *Model) error

func (*Model) MustSelectHost

func (m *Model) MustSelectHost(spec string) *Host

func (*Model) MustSelectHosts

func (m *Model) MustSelectHosts(spec string, minCount int) ([]*Host, error)

func (*Model) MustSelectRegion

func (m *Model) MustSelectRegion(spec string) *Region

func (*Model) MustStringVariable

func (m *Model) MustStringVariable(name ...string) string

func (*Model) MustVariable

func (m *Model) MustVariable(name ...string) interface{}

func (*Model) Operate

func (m *Model) Operate(run Run) error

func (*Model) SelectComponent

func (m *Model) SelectComponent(spec string) (*Component, error)

func (*Model) SelectComponents

func (m *Model) SelectComponents(spec string) []*Component

func (*Model) SelectHost

func (m *Model) SelectHost(spec string) (*Host, error)

func (*Model) SelectHosts

func (m *Model) SelectHosts(spec string) []*Host

func (*Model) SelectRegion

func (m *Model) SelectRegion(spec string) (*Region, error)

func (*Model) SelectRegions

func (m *Model) SelectRegions(spec string) []*Region

func (*Model) Sync

func (m *Model) Sync(run Run) error

type OperatingStage

type OperatingStage interface {
	Operate(run Run) error
}

type OperatingStages

type OperatingStages []OperatingStage

type ProcessTimeslice

type ProcessTimeslice struct {
	TimestampMs     int64   `json:"timestamp_ms"`
	RunQueueSize    int64   `json:"run_queue_size"`
	ProcessListSize int64   `json:"process_list_size"`
	LoadAverage1m   float64 `json:"load_average_1m"`
	LoadAverage5m   float64 `json:"load_average_5m`
	LoadAverage15m  float64 `json:"load_average_15m"`
	Blocked         int64   `json:"blocked"`
}

type Region

type Region struct {
	Scope
	Model  *Model
	Id     string
	Region string
	Site   string
	Hosts  Hosts
	Index  int
}

func (*Region) Accept

func (region *Region) Accept(visitor EntityVisitor)

func (*Region) GetChildren

func (region *Region) GetChildren() []Entity

func (*Region) GetId

func (region *Region) GetId() string

func (*Region) GetModel

func (region *Region) GetModel() *Model

func (*Region) GetParentEntity

func (region *Region) GetParentEntity() Entity

func (*Region) GetScope

func (region *Region) GetScope() *Scope

func (*Region) GetType

func (region *Region) GetType() string

func (*Region) Matches

func (region *Region) Matches(entityType string, matcher EntityMatcher) bool

func (*Region) Merge

func (r *Region) Merge(parent *Region) (*Region, error)

func (*Region) SelectHosts

func (region *Region) SelectHosts(hostSpec string) map[string]*Host

type RegionDump

type RegionDump struct {
	Scope *ScopeDump           `json:"scope,omitempty"`
	Id    string               `json:"id,omitempty"`
	Az    string               `json:"az,omitempty"`
	Hosts map[string]*HostDump `json:"hosts,omitempty"`
}

type Regions

type Regions map[string]*Region

func (Regions) Merge

func (r Regions) Merge(parent Regions) (Regions, error)

type Run

type Run interface {
	GetModel() *Model
	GetLabel() *Label
	GetId() string
}

func NewRun

func NewRun(label *Label, model *Model) Run

type Scope

type Scope struct {
	Variables Variables
	Data      Data
	Tags      Tags
	// contains filtered or unexported fields
}

func (*Scope) HasTag

func (scope *Scope) HasTag(tag string) bool

func (Scope) Merge

func (s Scope) Merge(parent Scope) (Scope, error)

func (*Scope) WithTags

func (scope *Scope) WithTags(tags ...string) *Scope

type ScopeDump

type ScopeDump struct {
	Variables map[string]interface{} `json:"variables,omitempty"`
	Data      map[string]interface{} `json:"data,omitempty"`
	Tags      []string               `json:"tags,omitempty"`
}

type StdOutMetricsWriter

type StdOutMetricsWriter struct {
}

func (StdOutMetricsWriter) AcceptHostMetrics

func (StdOutMetricsWriter) AcceptHostMetrics(host *Host, event *MetricsEvent)

type Tags

type Tags []string

type Variable

type Variable struct {
	Description    string
	Default        interface{}
	Required       bool
	Scoped         bool
	GlobalFallback bool
	Sensitive      bool
	Binder         func(v *Variable, i interface{}, path ...string)
	Value          interface{}
	// contains filtered or unexported fields
}

type VariableDump

type VariableDump struct {
	Description    string `json:"description,omitempty"`
	Default        string `json:"default,omitempty"`
	Required       bool   `json:"required"`
	Scoped         bool   `json:"scoped"`
	GlobalFallback bool   `json:"global_fallback"`
	Sensitive      bool   `json:"sensitive"`
	Binder         string `json:"binder,omitempty"`
	Value          string `json:"value,omitempty"`
	Bound          bool   `json:"bound"`
}

type Variables

type Variables map[interface{}]interface{}

func (Variables) Get

func (v Variables) Get(name ...string) (interface{}, bool)

func (Variables) Must

func (v Variables) Must(name ...string) interface{}

func (Variables) Put

func (v Variables) Put(newValue interface{}, name ...string) error

type ZitiFabricLinkMetricsSummary

type ZitiFabricLinkMetricsSummary struct {
	LinkId        string  `json:"link_id"`
	LatencyP9999  float64 `json:"latency_p9999"`
	RxBytesRateM1 float64 `json:"rx_bytes_rate_m1"`
	TxBytesRateM1 float64 `json:"tx_bytes_rate_m1"`
}

type ZitiFabricLinkSummary

type ZitiFabricLinkSummary struct {
	LinkId      string  `json:"link_id"`
	State       string  `json:"state"`
	SrcRouterId string  `json:"src_router_id"`
	SrcLatency  float64 `json:"src_latency"`
	DstRouterId string  `json:"dst_router_id"`
	DstLatency  float64 `json:"dst_latency"`
}

type ZitiFabricMeshSummary

type ZitiFabricMeshSummary struct {
	TimestampMs int64                   `json:"timestamp_ms"`
	RouterIds   []string                `json:"router_ids"`
	Links       []ZitiFabricLinkSummary `json:"links,omitempty"`
}

type ZitiFabricRouterMetricsSummary

type ZitiFabricRouterMetricsSummary struct {
	SourceId             string                         `json:"source_id"`
	TimestampMs          int64                          `json:"timestamp_ms"`
	FabricRxBytesRateM1  float64                        `json:"fabric_rx_bytes_rate_m1"`
	FabricTxBytesRateM1  float64                        `json:"fabric_tx_bytes_rate_m1"`
	IngressRxBytesRateM1 float64                        `json:"ingress_rx_bytes_rate_m1"`
	IngressTxBytesRateM1 float64                        `json:"ingress_tx_bytes_rate_m1"`
	EgressRxBytesRateM1  float64                        `json:"egress_rx_bytes_rate_m1"`
	EgressTxBytesRateM1  float64                        `json:"egress_tx_bytes_rate_m1"`
	Links                []ZitiFabricLinkMetricsSummary `json:"links,omitempty"`
}

Jump to

Keyboard shortcuts

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