resources

package
v0.0.0-...-c4c28c6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2016 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package resources provides the resource framework and idempotent primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResToB64

func ResToB64(res Res) (string, error)

ResToB64 encodes a resource to a base64 encoded string (after serialization)

func ReturnSvcInFileList

func ReturnSvcInFileList(fileList []string) []string

ReturnSvcInFileList returns a list of svc names for matches like: `/usr/lib/systemd/system/*.service`.

func UIDExistsInUIDs

func UIDExistsInUIDs(uid ResUID, uids []ResUID) bool

UIDExistsInUIDs wraps the IFF method when used with a list of UID's.

Types

type AutoEdge

type AutoEdge interface {
	Next() []ResUID   // call to get list of edges to add
	Test([]bool) bool // call until false
}

The AutoEdge interface is used to implement the autoedges feature.

type Base

type Base interface {
	GetName() string // can't be named "Name()" because of struct field
	SetName(string)
	SetKind(string)
	Kind() string
	Meta() *MetaParams
	Events() chan event.Event
	AssociateData(converger.Converger)
	IsWatching() bool
	SetWatching(bool)
	GetState() ResState
	SetState(ResState)
	DoSend(chan event.Event, string) (bool, error)
	SendEvent(event.EventName, bool, bool) bool
	ReadEvent(*event.Event) (bool, bool) // TODO: optional here?
	GroupCmp(Res) bool                   // TODO: is there a better name for this?
	GroupRes(Res) error                  // group resource (arg) into self
	IsGrouped() bool                     // am I grouped?
	SetGrouped(bool)                     // set grouped bool
	GetGroup() []Res                     // return everyone grouped inside me
	SetGroup([]Res)
}

The Base interface is everything that is common to all resources. Everything here only needs to be implemented once, in the BaseRes.

type BaseRes

type BaseRes struct {
	Name       string     `yaml:"name"`
	MetaParams MetaParams `yaml:"meta"` // struct of all the metaparams
	// contains filtered or unexported fields
}

BaseRes is the base struct that gets used in every resource.

func (*BaseRes) AssociateData

func (obj *BaseRes) AssociateData(converger converger.Converger)

AssociateData associates some data with the object in question.

func (*BaseRes) CollectPattern

func (obj *BaseRes) CollectPattern(pattern string)

CollectPattern is used for resource collection.

func (*BaseRes) Compare

func (obj *BaseRes) Compare(res Res) bool

Compare is the base compare method, which also handles the metaparams cmp

func (*BaseRes) DoSend

func (obj *BaseRes) DoSend(processChan chan event.Event, comment string) (bool, error)

DoSend sends off an event, but doesn't block the incoming event queue. It can also recursively call itself when events need processing during the wait. I'm not completely comfortable with this fn, but it will have to do for now.

func (*BaseRes) Events

func (obj *BaseRes) Events() chan event.Event

Events returns the channel of events to listen on.

func (*BaseRes) GetGroup

func (obj *BaseRes) GetGroup() []Res

GetGroup returns everyone grouped inside me.

func (*BaseRes) GetName

func (obj *BaseRes) GetName() string

GetName is used by all the resources to Get the name.

func (*BaseRes) GetState

func (obj *BaseRes) GetState() ResState

GetState returns the state of the resource.

func (*BaseRes) GroupCmp

func (obj *BaseRes) GroupCmp(res Res) bool

GroupCmp compares two resources and decides if they're suitable for grouping You'll probably want to override this method when implementing a resource...

func (*BaseRes) GroupRes

func (obj *BaseRes) GroupRes(res Res) error

GroupRes groups resource (arg) into self.

func (*BaseRes) Init

func (obj *BaseRes) Init() error

Init initializes structures like channels if created without New constructor.

func (*BaseRes) IsGrouped

func (obj *BaseRes) IsGrouped() bool

IsGrouped determines if we are grouped.

func (*BaseRes) IsWatching

func (obj *BaseRes) IsWatching() bool

IsWatching tells us if the Watch() function is running.

func (*BaseRes) Kind

func (obj *BaseRes) Kind() string

Kind returns the kind of resource this is.

func (*BaseRes) Meta

func (obj *BaseRes) Meta() *MetaParams

Meta returns the MetaParams as a reference, which we can then get/set on.

func (*BaseRes) ReadEvent

func (obj *BaseRes) ReadEvent(ev *event.Event) (exit, poke bool)

ReadEvent processes events when a select gets one, and handles the pause code too! The return values specify if we should exit and poke respectively.

func (*BaseRes) SendEvent

func (obj *BaseRes) SendEvent(ev event.EventName, sync bool, activity bool) bool

SendEvent pushes an event into the message queue for a particular vertex

func (*BaseRes) SetGroup

func (obj *BaseRes) SetGroup(g []Res)

SetGroup sets the grouped resources into me.

func (*BaseRes) SetGrouped

func (obj *BaseRes) SetGrouped(b bool)

SetGrouped sets a flag to tell if we are grouped.

func (*BaseRes) SetKind

func (obj *BaseRes) SetKind(kind string)

SetKind sets the kind. This is used internally for exported resources.

func (*BaseRes) SetName

func (obj *BaseRes) SetName(name string)

SetName is used to set the name of the resource.

func (*BaseRes) SetState

func (obj *BaseRes) SetState(state ResState)

SetState sets the state of the resource.

func (*BaseRes) SetWatching

func (obj *BaseRes) SetWatching(b bool)

SetWatching stores the status of if the Watch() function is running.

type BaseUID

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

The BaseUID struct is used to provide a unique resource identifier.

func (*BaseUID) GetName

func (obj *BaseUID) GetName() string

GetName returns the name of the resource.

func (*BaseUID) IFF

func (obj *BaseUID) IFF(uid ResUID) bool

IFF looks at two UID's and if and only if they are equivalent, returns true. If they are not equivalent, it returns false. Most resources will want to override this method, since it does the important work of actually discerning if two resources are identical in function.

func (*BaseUID) Kind

func (obj *BaseUID) Kind() string

Kind returns the kind of resource.

func (*BaseUID) Reversed

func (obj *BaseUID) Reversed() bool

Reversed is part of the ResUID interface, and true means this resource happens before the generator.

type ExecRes

type ExecRes struct {
	BaseRes    `yaml:",inline"`
	State      string `yaml:"state"`      // state: exists/present?, absent, (undefined?)
	Cmd        string `yaml:"cmd"`        // the command to run
	Shell      string `yaml:"shell"`      // the (optional) shell to use to run the cmd
	Timeout    int    `yaml:"timeout"`    // the cmd timeout in seconds
	WatchCmd   string `yaml:"watchcmd"`   // the watch command to run
	WatchShell string `yaml:"watchshell"` // the (optional) shell to use to run the watch cmd
	IfCmd      string `yaml:"ifcmd"`      // the if command to run
	IfShell    string `yaml:"ifshell"`    // the (optional) shell to use to run the if cmd
	PollInt    int    `yaml:"pollint"`    // the poll interval for the ifcmd
}

ExecRes is an exec resource for running commands.

func NewExecRes

func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcmd, ifshell string, pollint int, state string) *ExecRes

NewExecRes is a constructor for this resource. It also calls Init() for you.

func (*ExecRes) AutoEdges

func (obj *ExecRes) AutoEdges() AutoEdge

AutoEdges returns the AutoEdge interface. In this case no autoedges are used.

func (*ExecRes) BufioChanScanner

func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan error)

BufioChanScanner wraps the scanner output in a channel.

func (*ExecRes) CheckApply

func (obj *ExecRes) CheckApply(apply bool) (checkok bool, err error)

CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not. TODO: expand the IfCmd to be a list of commands

func (*ExecRes) Compare

func (obj *ExecRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*ExecRes) GetUIDs

func (obj *ExecRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*ExecRes) GroupCmp

func (obj *ExecRes) GroupCmp(r Res) bool

GroupCmp returns whether two resources can be grouped together or not.

func (*ExecRes) Init

func (obj *ExecRes) Init() error

Init runs some startup code for this resource.

func (*ExecRes) Validate

func (obj *ExecRes) Validate() error

Validate if the params passed in are valid data. FIXME: where should this get called ?

func (*ExecRes) Watch

func (obj *ExecRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events.

type ExecUID

type ExecUID struct {
	BaseUID
	Cmd   string
	IfCmd string
}

ExecUID is the UID struct for ExecRes.

func (*ExecUID) IFF

func (obj *ExecUID) IFF(uid ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type FileInfo

type FileInfo struct {
	os.FileInfo        // embed
	AbsPath     string // smart variant
	RelPath     string // smart variant
}

FileInfo is an enhanced variant of the traditional os.FileInfo struct. It can store both the absolute and the relative paths (when built from our ReadDir), and those two paths contain a trailing slash when they refer to a directory.

func ReadDir

func ReadDir(path string) ([]FileInfo, error)

ReadDir reads a directory path, and returns a list of enhanced FileInfo's.

type FileRes

type FileRes struct {
	BaseRes  `yaml:",inline"`
	Path     string `yaml:"path"` // path variable (should default to name)
	Dirname  string `yaml:"dirname"`
	Basename string `yaml:"basename"`
	Content  string `yaml:"content"` // FIXME: how do you describe: "leave content alone" - state = "create" ?
	Source   string `yaml:"source"`  // file path for source content
	State    string `yaml:"state"`   // state: exists/present?, absent, (undefined?)
	Recurse  bool   `yaml:"recurse"`
	Force    bool   `yaml:"force"`
	// contains filtered or unexported fields
}

FileRes is a file and directory resource.

func NewFileRes

func NewFileRes(name, path, dirname, basename, content, source, state string, recurse, force bool) *FileRes

NewFileRes is a constructor for this resource. It also calls Init() for you.

func (*FileRes) AutoEdges

func (obj *FileRes) AutoEdges() AutoEdge

AutoEdges generates a simple linear sequence of each parent directory from the bottom up!

func (*FileRes) CheckApply

func (obj *FileRes) CheckApply(apply bool) (checkOK bool, _ error)

CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.

func (*FileRes) CollectPattern

func (obj *FileRes) CollectPattern(pattern string)

CollectPattern applies the pattern for collection resources.

func (*FileRes) Compare

func (obj *FileRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*FileRes) GetPath

func (obj *FileRes) GetPath() string

GetPath returns the actual path to use for this resource. It computes this after analysis of the Path, Dirname and Basename values. Dirs end with slash.

func (*FileRes) GetUIDs

func (obj *FileRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*FileRes) GroupCmp

func (obj *FileRes) GroupCmp(r Res) bool

GroupCmp returns whether two resources can be grouped together or not.

func (*FileRes) Init

func (obj *FileRes) Init() error

Init runs some startup code for this resource.

func (*FileRes) Validate

func (obj *FileRes) Validate() error

Validate reports any problems with the struct definition.

func (*FileRes) Watch

func (obj *FileRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events. This one is a file watcher for files and directories. Modify with caution, it is probably important to write some test cases first! If the Watch returns an error, it means that something has gone wrong, and it must be restarted. On a clean exit it returns nil. FIXME: Also watch the source directory when using obj.Source !!!

type FileResAutoEdges

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

FileResAutoEdges holds the state of the auto edge generator.

func (*FileResAutoEdges) Next

func (obj *FileResAutoEdges) Next() []ResUID

Next returns the next automatic edge.

func (*FileResAutoEdges) Test

func (obj *FileResAutoEdges) Test(input []bool) bool

Test gets results of the earlier Next() call, & returns if we should continue!

type FileUID

type FileUID struct {
	BaseUID
	// contains filtered or unexported fields
}

FileUID is the UID struct for FileRes.

func (*FileUID) IFF

func (obj *FileUID) IFF(uid ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type MetaParams

type MetaParams struct {
	AutoEdge  bool `yaml:"autoedge"`  // metaparam, should we generate auto edges? // XXX: should default to true
	AutoGroup bool `yaml:"autogroup"` // metaparam, should we auto group? // XXX: should default to true
	Noop      bool `yaml:"noop"`
	// NOTE: there are separate Watch and CheckApply retry and delay values,
	// but I've decided to use the same ones for both until there's a proper
	// reason to want to do something differently for the Watch errors.
	Retry int16  `yaml:"retry"` // metaparam, number of times to retry on error. -1 for infinite
	Delay uint64 `yaml:"delay"` // metaparam, number of milliseconds to wait between retries
}

MetaParams is a struct will all params that apply to every resource.

type MsgRes

type MsgRes struct {
	BaseRes  `yaml:",inline"`
	Body     string            `yaml:"body"`
	Priority string            `yaml:"priority"`
	Fields   map[string]string `yaml:"fields"`
	Journal  bool              `yaml:"journal"` // enable systemd journal output
	Syslog   bool              `yaml:"syslog"`  // enable syslog output
	// contains filtered or unexported fields
}

MsgRes is a resource that writes messages to logs.

func NewMsgRes

func NewMsgRes(name, body, priority string, journal, syslog bool, fields map[string]string) *MsgRes

NewMsgRes is a constructor for this resource.

func (*MsgRes) AutoEdges

func (obj *MsgRes) AutoEdges() AutoEdge

AutoEdges returns the AutoEdges. In this case none are used.

func (*MsgRes) CheckApply

func (obj *MsgRes) CheckApply(apply bool) (bool, error)

CheckApply method for Msg resource. Every check leads to an apply, meaning that the message is flushed to the journal.

func (*MsgRes) Compare

func (obj *MsgRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*MsgRes) GetUIDs

func (obj *MsgRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*MsgRes) Init

func (obj *MsgRes) Init() error

Init runs some startup code for this resource.

func (*MsgRes) Validate

func (obj *MsgRes) Validate() error

Validate the params that are passed to MsgRes

func (*MsgRes) Watch

func (obj *MsgRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events.

type MsgUID

type MsgUID struct {
	BaseUID
	// contains filtered or unexported fields
}

MsgUID is a unique representation for a MsgRes object.

type NoopRes

type NoopRes struct {
	BaseRes `yaml:",inline"`
	Comment string `yaml:"comment"` // extra field for example purposes
}

NoopRes is a no-op resource that does nothing.

func NewNoopRes

func NewNoopRes(name string) *NoopRes

NewNoopRes is a constructor for this resource. It also calls Init() for you.

func (*NoopRes) AutoEdges

func (obj *NoopRes) AutoEdges() AutoEdge

AutoEdges returns the AutoEdge interface. In this case no autoedges are used.

func (*NoopRes) CheckApply

func (obj *NoopRes) CheckApply(apply bool) (checkok bool, err error)

CheckApply method for Noop resource. Does nothing, returns happy!

func (*NoopRes) Compare

func (obj *NoopRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*NoopRes) GetUIDs

func (obj *NoopRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*NoopRes) GroupCmp

func (obj *NoopRes) GroupCmp(r Res) bool

GroupCmp returns whether two resources can be grouped together or not.

func (*NoopRes) Init

func (obj *NoopRes) Init() error

Init runs some startup code for this resource.

func (*NoopRes) Validate

func (obj *NoopRes) Validate() error

Validate if the params passed in are valid data. FIXME: where should this get called ?

func (*NoopRes) Watch

func (obj *NoopRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events.

type NoopUID

type NoopUID struct {
	BaseUID
	// contains filtered or unexported fields
}

NoopUID is the UID struct for NoopRes.

type PkgRes

type PkgRes struct {
	BaseRes          `yaml:",inline"`
	State            string `yaml:"state"`            // state: installed, uninstalled, newest, <version>
	AllowUntrusted   bool   `yaml:"allowuntrusted"`   // allow untrusted packages to be installed?
	AllowNonFree     bool   `yaml:"allownonfree"`     // allow nonfree packages to be found?
	AllowUnsupported bool   `yaml:"allowunsupported"` // allow unsupported packages to be found?
	// contains filtered or unexported fields
}

PkgRes is a package resource for packagekit.

func NewPkgRes

func NewPkgRes(name, state string, allowuntrusted, allownonfree, allowunsupported bool) *PkgRes

NewPkgRes is a constructor for this resource. It also calls Init() for you.

func (*PkgRes) AutoEdges

func (obj *PkgRes) AutoEdges() AutoEdge

AutoEdges produces an object which generates a minimal pkg file optimization sequence of edges.

func (*PkgRes) CheckApply

func (obj *PkgRes) CheckApply(apply bool) (checkok bool, err error)

CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.

func (*PkgRes) Compare

func (obj *PkgRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*PkgRes) GetUIDs

func (obj *PkgRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*PkgRes) GroupCmp

func (obj *PkgRes) GroupCmp(r Res) bool

GroupCmp returns whether two resources can be grouped together or not. can these two resources be merged ? (aka does this resource support doing so?) will resource allow itself to be grouped _into_ this obj?

func (*PkgRes) Init

func (obj *PkgRes) Init() error

Init runs some startup code for this resource.

func (*PkgRes) Validate

func (obj *PkgRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*PkgRes) Watch

func (obj *PkgRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events. It uses the PackageKit UpdatesChanged signal to watch for changes. TODO: https://github.com/hughsie/PackageKit/issues/109 TODO: https://github.com/hughsie/PackageKit/issues/110

type PkgResAutoEdges

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

PkgResAutoEdges holds the state of the auto edge generator.

func (*PkgResAutoEdges) Next

func (obj *PkgResAutoEdges) Next() []ResUID

Next returns the next automatic edge.

func (*PkgResAutoEdges) Test

func (obj *PkgResAutoEdges) Test(input []bool) bool

Test gets results of the earlier Next() call, & returns if we should continue!

type PkgUID

type PkgUID struct {
	BaseUID
	// contains filtered or unexported fields
}

PkgUID is the UID struct for PkgRes.

func (*PkgUID) IFF

func (obj *PkgUID) IFF(uid ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type Res

type Res interface {
	Base // include everything from the Base interface
	Init() error
	//Validate() error    // TODO: this might one day be added
	GetUIDs() []ResUID            // most resources only return one
	Watch(chan event.Event) error // send on channel to signal process() events
	CheckApply(apply bool) (checkOK bool, err error)
	AutoEdges() AutoEdge
	Compare(Res) bool
	CollectPattern(string) // XXX: temporary until Res collection is more advanced
}

Res is the minimum interface you need to implement to define a new resource.

func B64ToRes

func B64ToRes(str string) (Res, error)

B64ToRes decodes a resource from a base64 encoded string (after deserialization)

type ResState

type ResState int

The ResState type represents the current activity state of each resource.

const (
	ResStateNil ResState = iota
	ResStateWatching
	ResStateEvent // an event has happened, but we haven't poked yet
	ResStateCheckApply
	ResStatePoking
)

Each ResState should be set properly in the relevant part of the resource.

type ResUID

type ResUID interface {
	GetName() string
	Kind() string
	IFF(ResUID) bool

	Reversed() bool // true means this resource happens before the generator
}

ResUID is a unique identifier for a resource, namely it's name, and the kind ("type").

type SvcRes

type SvcRes struct {
	BaseRes `yaml:",inline"`
	State   string `yaml:"state"`   // state: running, stopped, undefined
	Startup string `yaml:"startup"` // enabled, disabled, undefined
}

SvcRes is a service resource for systemd units.

func NewSvcRes

func NewSvcRes(name, state, startup string) *SvcRes

NewSvcRes is a constructor for this resource. It also calls Init() for you.

func (*SvcRes) AutoEdges

func (obj *SvcRes) AutoEdges() AutoEdge

AutoEdges returns the AutoEdge interface. In this case the systemd units.

func (*SvcRes) CheckApply

func (obj *SvcRes) CheckApply(apply bool) (checkok bool, err error)

CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.

func (*SvcRes) Compare

func (obj *SvcRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*SvcRes) GetUIDs

func (obj *SvcRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*SvcRes) GroupCmp

func (obj *SvcRes) GroupCmp(r Res) bool

GroupCmp returns whether two resources can be grouped together or not.

func (*SvcRes) Init

func (obj *SvcRes) Init() error

Init runs some startup code for this resource.

func (*SvcRes) Validate

func (obj *SvcRes) Validate() error

Validate checks if the resource data structure was populated correctly.

func (*SvcRes) Watch

func (obj *SvcRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events.

type SvcResAutoEdges

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

SvcResAutoEdges holds the state of the auto edge generator.

func (*SvcResAutoEdges) Next

func (obj *SvcResAutoEdges) Next() []ResUID

Next returns the next automatic edge.

func (*SvcResAutoEdges) Test

func (obj *SvcResAutoEdges) Test(input []bool) bool

Test gets results of the earlier Next() call, & returns if we should continue!

type SvcUID

type SvcUID struct {
	// NOTE: there is also a name variable in the BaseUID struct, this is
	// information about where this UID came from, and is unrelated to the
	// information about the resource we're matching. That data which is
	// used in the IFF function, is what you see in the struct fields here.
	BaseUID
	// contains filtered or unexported fields
}

SvcUID is the UID struct for SvcRes.

func (*SvcUID) IFF

func (obj *SvcUID) IFF(uid ResUID) bool

IFF aka if and only if they are equivalent, return true. If not, false.

type TimerRes

type TimerRes struct {
	BaseRes  `yaml:",inline"`
	Interval int `yaml:"interval"` // Interval : Interval between runs
}

TimerRes is a timer resource for time based events.

func NewTimerRes

func NewTimerRes(name string, interval int) *TimerRes

NewTimerRes is a constructor for this resource. It also calls Init() for you.

func (*TimerRes) AutoEdges

func (obj *TimerRes) AutoEdges() AutoEdge

AutoEdges returns the AutoEdge interface. In this case no autoedges are used.

func (*TimerRes) CheckApply

func (obj *TimerRes) CheckApply(apply bool) (bool, error)

CheckApply method for Timer resource. Does nothing, returns happy!

func (*TimerRes) Compare

func (obj *TimerRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*TimerRes) GetUIDs

func (obj *TimerRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*TimerRes) Init

func (obj *TimerRes) Init() error

Init runs some startup code for this resource.

func (*TimerRes) Validate

func (obj *TimerRes) Validate() error

Validate the params that are passed to TimerRes Currently we are getting only an interval in seconds which gets validated by go compiler

func (*TimerRes) Watch

func (obj *TimerRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events.

type TimerUID

type TimerUID struct {
	BaseUID
	// contains filtered or unexported fields
}

TimerUID is the UID struct for TimerRes.

type VirtRes

type VirtRes struct {
	BaseRes    `yaml:",inline"`
	URI        string             `yaml:"uri"`       // connection uri, eg: qemu:///session
	State      string             `yaml:"state"`     // running, paused, shutoff
	Transient  bool               `yaml:"transient"` // defined (false) or undefined (true)
	CPUs       uint               `yaml:"cpus"`
	Memory     uint64             `yaml:"memory"` // in KBytes
	Boot       []string           `yaml:"boot"`   // boot order. values: fd, hd, cdrom, network
	Disk       []diskDevice       `yaml:"disk"`
	CDRom      []cdRomDevice      `yaml:"cdrom"`
	Network    []networkDevice    `yaml:"network"`
	Filesystem []filesystemDevice `yaml:"filesystem"`
	// contains filtered or unexported fields
}

VirtRes is a libvirt resource. A transient virt resource, which has its state set to `shutoff` is one which does not exist. The parallel equivalent is a file resource which removes a particular path.

func NewVirtRes

func NewVirtRes(name string, uri, state string, transient bool, cpus uint, memory uint64) *VirtRes

NewVirtRes is a constructor for this resource. It also calls Init() for you.

func (*VirtRes) AutoEdges

func (obj *VirtRes) AutoEdges() AutoEdge

AutoEdges returns the AutoEdge interface. In this case no autoedges are used.

func (*VirtRes) CheckApply

func (obj *VirtRes) CheckApply(apply bool) (bool, error)

CheckApply checks the resource state and applies the resource if the bool input is true. It returns error info and if the state check passed or not.

func (*VirtRes) CollectPattern

func (obj *VirtRes) CollectPattern(string)

CollectPattern applies the pattern for collection resources.

func (*VirtRes) Compare

func (obj *VirtRes) Compare(res Res) bool

Compare two resources and return if they are equivalent.

func (*VirtRes) GetUIDs

func (obj *VirtRes) GetUIDs() []ResUID

GetUIDs includes all params to make a unique identification of this object. Most resources only return one, although some resources can return multiple.

func (*VirtRes) GroupCmp

func (obj *VirtRes) GroupCmp(r Res) bool

GroupCmp returns whether two resources can be grouped together or not.

func (*VirtRes) Init

func (obj *VirtRes) Init() error

Init runs some startup code for this resource.

func (*VirtRes) Validate

func (obj *VirtRes) Validate() error

Validate if the params passed in are valid data.

func (*VirtRes) Watch

func (obj *VirtRes) Watch(processChan chan event.Event) error

Watch is the primary listener for this resource and it outputs events.

type VirtUID

type VirtUID struct {
	BaseUID
}

VirtUID is the UID struct for FileRes.

Directories

Path Synopsis
Package packagekit provides an interface to interact with packagekit.
Package packagekit provides an interface to interact with packagekit.

Jump to

Keyboard shortcuts

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