common

package
v0.0.0-...-78eb850 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEFAULT     = "default"
	TABLE       = "table"
	TABLE_LIGHT = "table-light"
	JSON        = "json"
	YAML        = "yaml"
)

Variables

View Source
var (
	CONF      ConfGroup
	CONF_FILE string
)
View Source
var (
	FORMAT_TABLE_LIGHT        = "table-light"
	FORMAT_TABLE              = "table"
	DEFAULT_TOKEN_EXPIRE_TIME = 60 * 30
)
View Source
var (
	DEFAULT_GUEST_CONNECT_TIMEOUT = 60 * 5
	DEFAULT_QGA_CONNECT_TIMEOUT   = 60 * 10
	DEFAULT_PING_INTERVAL         = float32(1.0)
)
View Source
var CONF_FILES = []string{
	"etc/skyman.yaml",
	"/etc/skyman/skyman.yaml",
}
View Source
var (
	STYLE_LIGHT = "light"
)

Functions

func GetOutputFormats

func GetOutputFormats() []string

func GetYaml

func GetYaml(v interface{}) (string, error)

func LastItems

func LastItems(items []interface{}, last int) []interface{}

func LoadConfig

func LoadConfig(configFile string) error

func LoadTaskConfig

func LoadTaskConfig(taskFile string) error

func MarshalModel

func MarshalModel(obj interface{}, indent bool) string

func PathExtSplit

func PathExtSplit(file string) (string, string)

func PrintAggregate

func PrintAggregate(aggregate nova.Aggregate)

func PrintPrettyItemTable

func PrintPrettyItemTable(table PrettyItemTable) string

func PrintPrettyTable

func PrintPrettyTable(table PrettyTable, long bool) string

func PrintPrettyTableFormat

func PrintPrettyTableFormat(table PrettyTable, long bool, format string) string

func RegistryLongFlag

func RegistryLongFlag(cmd ...*cobra.Command)

func RepeatFunc

func RepeatFunc(nums int, function func())

func SplitKeyValue

func SplitKeyValue(kv string) ([]string, error)

func ValidIpv4

func ValidIpv4(cidr string, maxMask ...int) bool

Types

type Api

type Api struct {
	Version string `yaml:"version"`
}

type Auth

type Auth struct {
	Url             string          `yaml:"url"`
	Region          keystone.Region `yaml:"region"`
	User            auth.User       `yaml:"user"`
	Project         auth.Project    `yaml:"project"`
	TokenExpireTime int             `yaml:"tokenExpireTime"`
}

type Column

type Column struct {
	Name string
	Text string
	// 只有 Table.Style 等于 light 是才会生效
	AutoColor  bool
	ForceColor bool
	Slot       func(item interface{}) interface{}
	SlotColumn func(item interface{}, column Column) interface{}
	Sort       bool
	SortMode   table.SortMode
	Filters    []string
	Marshal    bool
	WidthMax   int
	Align      text.Align
}

type ConfGroup

type ConfGroup struct {
	Debug          bool   `yaml:"debug"`
	Format         string `yaml:"format"`
	Language       string `yaml:"language"`
	HttpTimeout    int    `yaml:"httpTimeout"`
	LogFile        string `yaml:"logFile"`
	EnableLogColor bool   `yaml:"enableLogColor"`

	Auth     Auth        `yaml:"auth"`
	Identity Identity    `yaml:"identity"`
	Neutron  NeutronConf `yaml:"neutron"`
}

type Identity

type Identity struct {
	Api Api `yaml:"api"`
}

type InterfaceHotplug

type InterfaceHotplug struct {
	Nums int `yaml:"nums"`
}

type LiveMigrateOptions

type LiveMigrateOptions struct {
	PingEnabled  bool    `yaml:"pingEnabled"`
	PingInterval float32 `yaml:"pingInterval"`
	MaxLoss      int     `yaml:"maxLoss"`
}

type NeutronConf

type NeutronConf struct {
	Endpoint string `yaml:"endpoint"`
}

type PrettyItemTable

type PrettyItemTable struct {
	ShortFields     []Column
	LongFields      []Column
	Item            interface{}
	Title           string
	Style           string
	Number2WidthMax int
}

func (PrettyItemTable) Print

func (pt PrettyItemTable) Print(long bool) string

func (PrettyItemTable) PrintJson

func (dt PrettyItemTable) PrintJson() string

func (PrettyItemTable) PrintYaml

func (dt PrettyItemTable) PrintYaml() string

type PrettyTable

type PrettyTable struct {
	Title             string
	ShortColumns      []Column
	LongColumns       []Column
	Items             []interface{}
	ColumnConfigs     []table.ColumnConfig
	Style             string
	StyleSeparateRows bool
	HideTotalItems    bool

	Filters       map[string]string
	Search        string
	DisplayFields []string
	// contains filtered or unexported fields
}

func (*PrettyTable) AddDisplayFields

func (pt *PrettyTable) AddDisplayFields(fields ...string)

func (*PrettyTable) AddItems

func (pt *PrettyTable) AddItems(items interface{})

func (*PrettyTable) CleanItems

func (pt *PrettyTable) CleanItems()

func (PrettyTable) GetLongColumnIndex

func (pt PrettyTable) GetLongColumnIndex(column string) int

func (PrettyTable) GetShortColumnIndex

func (pt PrettyTable) GetShortColumnIndex(column string) int

func (PrettyTable) Print

func (pt PrettyTable) Print(long bool) string

func (PrettyTable) PrintJson

func (pt PrettyTable) PrintJson() string

func (PrettyTable) PrintYaml

func (pt PrettyTable) PrintYaml() string

func (*PrettyTable) ReInit

func (pt *PrettyTable) ReInit()

func (PrettyTable) RenderToJson

func (pt PrettyTable) RenderToJson() (string, error)

func (PrettyTable) RenderToTable

func (pt PrettyTable) RenderToTable(long bool) string

func (PrettyTable) RenderToYaml

func (pt PrettyTable) RenderToYaml() (string, error)

func (*PrettyTable) SetStyleLight

func (pt *PrettyTable) SetStyleLight()

type QGAChecker

type QGAChecker struct {
	Enabled             bool `yaml:"enabled"`
	GuestConnectTimeout int  `yaml:"guestConnectTimeout"`
	QgaConnectTimeout   int  `yaml:"qgaConnectTimeout"`
}

type ServerActionsTestConf

type ServerActionsTestConf struct {
	Total            int                `yaml:"total"`
	Workers          int                `yaml:"workers"`
	Web              Web                `yaml:"web"`
	ActionTasks      []string           `yaml:"actionTasks"`
	DeleteIfError    bool               `yaml:"deleteIfError"`
	AvailabilityZone string             `yaml:"availabilityZone"`
	BootFromVolume   bool               `yaml:"bootFromVolume"`
	BootVolumeSize   uint16             `yaml:"bootVolumeSize"`
	BootVolumeType   string             `yaml:"bootVolumeType"`
	BootWithSG       string             `yaml:"bootWithSG"`
	Flavors          []string           `yaml:"flavors"`
	Images           []string           `yaml:"images"`
	Networks         []string           `yaml:"networks"`
	VolumeType       string             `yaml:"volumeType"`
	VolumeSize       int                `yaml:"volumeSize"`
	InterfaceHotplug InterfaceHotplug   `yaml:"interfaceHotplug"`
	VolumeHotplug    VolumeHotplug      `yaml:"volumeHotplug"`
	UseServers       []string           `yaml:"userServers"`
	ActionInterval   int                `yaml:"actionInterval"`
	QGAChecker       QGAChecker         `yaml:"qgaChecker"`
	LiveMigrate      LiveMigrateOptions `yaml:"liveMigrate"`
}
var (
	TASK_CONF ServerActionsTestConf
)

type VolumeHotplug

type VolumeHotplug struct {
	Nums int `yaml:"nums"`
}

type Web

type Web struct {
	Port int `yaml:"port"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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