models

package
v0.0.0-...-4e46751 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EXPIRE_INTERVAL  = 5 * time.Minute
	CLEANUP_INTERVAL = 1 * time.Minute
)
View Source
const (
	CONFIG_TEMPLATE = `
{{ range $k, $v := .Config }}
{{printf "%s = salt['pillar.get']('%s', '%s')" $k $k $v }}
{{ end }}
`
)
View Source
const (
	MINION_TEMPLATE = `` /* 195-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func DelTemplFile

func DelTemplFile(name string) error

*

  • DelTemplFile delete the corresponding config template file

func GenerateRSAKey

func GenerateRSAKey() (string, string, error)

func InitConfig

func InitConfig(svr *Server, args ...string) *util.ExecResult

InitConfig is used to init the server's salt minion config

func SetServer

func SetServer(svr *Server) error

SetServer generate saltstack config for minion server and restart saltstack minion.

func SetTemplate

func SetTemplate(templ *Template) error

*

  • SetTemplate edit exits template or add new template into gosalt

func SyncConfig

func SyncConfig(svr *Server, args ...string) *util.ExecResult

SyncConfig is used to sync config info into minion

func SyncSaltConfig

func SyncSaltConfig(svr *Server) error

*

  • SyncSaltConfig use salt ssh to sync salt minion config into minion

func SyncServerConfig

func SyncServerConfig() error

func SyncTemplFile

func SyncTemplFile(templ *Template) error

*

  • SyncTemplFile sync template data into config template file

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}
var (
	ConfigsCache *Cache
)
var (
	ServerCache *Cache
)
var (
	TemplateCache *Cache
)

func NewCache

func NewCache(name string, h CacheHandler, load, expire bool) (*Cache, error)

func NewConfigCache

func NewConfigCache() (*Cache, error)

func NewServerCache

func NewServerCache() (*Cache, error)

func NewTemplateCache

func NewTemplateCache() (*Cache, error)

func (*Cache) Delete

func (c *Cache) Delete(key string) error

func (*Cache) Get

func (c *Cache) Get(key string) interface{}

func (*Cache) Set

func (c *Cache) Set(key string, value interface{}) error

type CacheHandler

type CacheHandler interface {
	Key(v interface{}) (string, bool)        // parse key from obj
	SetKey(v interface{}, key string) error  // set key for obj
	Get(key string) (interface{}, error)     // Get data
	Set(key string, value interface{}) error // set data
	All() ([]interface{}, error)             // load all data
	Delete(key string) error                 // delete data
}

type Config

type Config struct {
	ID      string            `bson:"_id"`
	Name    string            `bson:"name"`
	Version string            `bson:"version"`
	Env     string            `bson:"env"`
	Config  map[string]string `bson:"config"`
}

type ConfigHandler

type ConfigHandler struct {
	*DefaultHandler
}

func (*ConfigHandler) Key

func (h *ConfigHandler) Key(v interface{}) (string, bool)

func (*ConfigHandler) SetKey

func (h *ConfigHandler) SetKey(v interface{}, key string) error

type DefaultHandler

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

func (*DefaultHandler) All

func (h *DefaultHandler) All() ([]interface{}, error)

func (*DefaultHandler) Delete

func (h *DefaultHandler) Delete(key string) error

func (*DefaultHandler) Get

func (h *DefaultHandler) Get(key string) (interface{}, error)

func (*DefaultHandler) Set

func (h *DefaultHandler) Set(key string, value interface{}) error

type Server

type Server struct {
	Name     string `json:"name"     bson:"_id"`
	IPAddr   string `json:"ipaddr"   bson:"ipaddr"`
	SshPort  int    `json:"sshport"  bson:"sshport"`
	UserName string `json:"username" bson:"username"`
	Passwd   string `json:"passwd"   bson:"passwd"`
	Env      string `json:"env"      bson:"env"`
	Version  string `json:"version" bson:"version"`
}

type ServerHandler

type ServerHandler struct {
	*DefaultHandler
}

func (*ServerHandler) Key

func (h *ServerHandler) Key(value interface{}) (string, bool)

func (*ServerHandler) SetKey

func (h *ServerHandler) SetKey(v interface{}, key string) error

type Template

type Template struct {
	Name    string            `json:"name"    bson:"_id"`
	Env     string            `json:"env"     bson:"env"`
	Version string            `json:"version" bson:"version"`
	Config  map[string]string `json:"config"  bson:"config"`
}

type TemplateHandler

type TemplateHandler struct {
	*DefaultHandler
}

func (*TemplateHandler) Key

func (h *TemplateHandler) Key(v interface{}) (string, bool)

func (*TemplateHandler) SetKey

func (h *TemplateHandler) SetKey(v interface{}, key string) error

Jump to

Keyboard shortcuts

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