service

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 70 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DcimInterface                = "DcimInterface"
	DcimRearport                 = "DcimRearport"
	DcimFrontport                = "DcimFrontport"
	DcimDevice                   = "DcimDevice"
	VirtualizationCluster        = "VirtualizationCluster"
	SdnController                = "SdnController"
	VirtualizationVirtualmachine = "VirtualizationVirtualmachine"
	DcimInputDevice              = "DcimInputDevice"
	DeviceAndVirtualmachine      = "deviceAndVirtualmachine"
)

Variables

View Source
var (
	DEFAULT_SERVICE_FILE    = "../config/service.yaml"
	Config                  = &ServiceConfig{}
	DEFAULT_SSH_CMD_TIMEOUT = 5
	// DEFAULT_NEWL2SERVICE_FILE = "../internal/app/service/l2service/service.yaml.back"
	DEFAULT_NEWL2SERVICE_FILE = "../config/service.yaml"
)

Functions

func CheckRedfishSerial

func CheckRedfishSerial(remote *structs.L2DeviceRemoteInfo) (result string)

func CheckRedfishSerial2

func CheckRedfishSerial2(remote *structs.L2DeviceRemoteInfo) (result string, err error)

func CheckRedfishVersion

func CheckRedfishVersion(remote *structs.L2DeviceRemoteInfo) (result string)

func CheckRedfishVersion2

func CheckRedfishVersion2(remote *structs.L2DeviceRemoteInfo) (result string, err error)

func ConfigPathCheck

func ConfigPathCheck(filePath, mode string) (file string)

func DeleteYaml

func DeleteYaml(fileName string, logger *log.Logger)

func Exec

func Exec(cmdStr string) (string, error)

func NewInstance

func NewInstance(mode string, isRedfish bool, localDataPath string) structs.L2NodemapInstanceInterface

L2NodemapInstanceInterface包含Process方法,该方法是不同类型设备的处理入口

func Playbook_Task

func Playbook_Task(file string, info *structs.RepoResult, logger *log.Logger) (error, *structs.AnsibleTaskResult)

func ServiceConfigViper

func ServiceConfigViper(path string)

func WriteContent

func WriteContent(filePath string, content []byte, logger *log.Logger) (err error)

func WriteYaml

func WriteYaml(fileName string, info *structs.RepoResult, logger *log.Logger)

Types

type ANSIBLE

type ANSIBLE struct{}

func (*ANSIBLE) ActiveMonitorPushSetting

func (ts *ANSIBLE) ActiveMonitorPushSetting(ctx context.Context, args *structs.Args, reply *structs.RepoResultTaskReplay) error

func (*ANSIBLE) AnsibleCMD

func (ts *ANSIBLE) AnsibleCMD(ctx context.Context, info *structs.RepoResult, reply *structs.RepoResultTaskReplay) error

func (*ANSIBLE) CategrafSnmpConfig

func (ts *ANSIBLE) CategrafSnmpConfig(ctx context.Context, args *structs.Args, reply *structs.RepoResultTaskReplay) error

func (*ANSIBLE) TelegrafPushSetting

func (ts *ANSIBLE) TelegrafPushSetting(ctx context.Context, args *structs.Args, reply *structs.RepoResultTaskReplay) error

func (*ANSIBLE) TelegrafPushSetting2

func (ts *ANSIBLE) TelegrafPushSetting2(ctx context.Context, args *structs.Args, reply *structs.RepoResultTaskReplay) error

type BaseTaskConfig

type BaseTaskConfig struct {
	Version []string `yaml:"version" mapstructure:"version"`
	Method  string   `yaml:"method" mapstructure:"method"`
	Type    []string `yaml:"type" mapstructure:"type"`

	Pretty bool `yaml:"pretty" mapstructure:"pretty"`
	// contains filtered or unexported fields
}

func (BaseTaskConfig) GetMainConfig

func (BaseTaskConfig) GetMethod

func (s BaseTaskConfig) GetMethod() string

func (BaseTaskConfig) IsPretty

func (s BaseTaskConfig) IsPretty() bool

func (BaseTaskConfig) IsSelected

func (s BaseTaskConfig) IsSelected(version, deviceType string) bool

func (BaseTaskConfig) SupportVersion

func (s BaseTaskConfig) SupportVersion() []string

func (*BaseTaskConfig) WithMainConfig

type CheckTaskConfig

type CheckTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (CheckTaskConfig) GetSubOid

func (s CheckTaskConfig) GetSubOid(key string) string

func (CheckTaskConfig) NewExecutor

func (s CheckTaskConfig) NewExecutor(remote *structs.L2DeviceRemoteInfo) (clitask.Executor, error)

type CmdPair

type CmdPair struct {
	Key     string `yaml:"key" mapstructure:"key"`
	Cmd     string `yaml:"cmd" mapstructure:"cmd"`
	Timeout int    `yaml:"timeout" mapstructure:"timeout"`
}

type Controller

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

func NewController

func NewController(list []*structs.L2DeviceRemoteInfo, conn net.Conn, namedPipe string) *Controller

func (*Controller) Loop

func (c *Controller) Loop()

func (*Controller) OnMessage

func (c *Controller) OnMessage() (chan jsonp.Message, chan error)

type GPON

type GPON struct{}

func (*GPON) OnuCollect

func (ts *GPON) OnuCollect(ctx context.Context, arg *structs.Args, reply *structs.Reply) (err error)

type GofishTaskConfig

type GofishTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (GofishTaskConfig) GetSubOid

func (s GofishTaskConfig) GetSubOid(key string) string

func (GofishTaskConfig) NewExecutor

type INFINIBAND

type INFINIBAND struct{}

func (*INFINIBAND) IbNetDiscover

func (ts *INFINIBAND) IbNetDiscover(ctx context.Context, arg *structs.Args, reply *structs.Reply) (err error)

type IPMITaskConfig

type IPMITaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (IPMITaskConfig) GetSubOid

func (s IPMITaskConfig) GetSubOid(key string) string

func (IPMITaskConfig) NewExecutor

func (s IPMITaskConfig) NewExecutor(remote *structs.L2DeviceRemoteInfo) (clitask.Executor, error)

type KwArgs

type KwArgs struct {
	ServiceType SSHServerType
	Ip          string
	Community   string
	Oid         string
	Username    string
	PassWord    string
	AuthPass    string
	Tp          string
	Telnet      bool
}

type LinuxTaskConfig

type LinuxTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (LinuxTaskConfig) GetSubOid

func (s LinuxTaskConfig) GetSubOid(key string) string

func (LinuxTaskConfig) NewExecutor

func (s LinuxTaskConfig) NewExecutor(remote *model.L2DeviceRemoteInfo) (clitask.Executor, error)

type Option

type Option func(*ServiceModeConfig)

type RedfishTaskConfig

type RedfishTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (RedfishTaskConfig) GetSubOid

func (s RedfishTaskConfig) GetSubOid(key string) string

func (RedfishTaskConfig) NewExecutor

type RedfisnInfoTaskConfig

type RedfisnInfoTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (RedfisnInfoTaskConfig) GetSubOid

func (s RedfisnInfoTaskConfig) GetSubOid(key string) string

func (RedfisnInfoTaskConfig) NewExecutor

type RestfulTaskConfig

type RestfulTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (RestfulTaskConfig) GetSubOid

func (s RestfulTaskConfig) GetSubOid(key string) string

func (RestfulTaskConfig) NewExecutor

type RshellTaskConfig

type RshellTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (RshellTaskConfig) GetSubOid

func (s RshellTaskConfig) GetSubOid(key string) string

func (RshellTaskConfig) NewExecutor

type SDN

type SDN struct{}

func (*SDN) SdnMainService

func (sdn *SDN) SdnMainService(ctx context.Context, args *structs.Args, reply *structs.Reply) error

type SERVEROOB

type SERVEROOB struct{}

func (*SERVEROOB) IsAlive

func (ts *SERVEROOB) IsAlive(ctx context.Context, arg *structs.Args, reply *structs.Reply) (err error)

func (*SERVEROOB) OOBGPU

func (ts *SERVEROOB) OOBGPU(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) OOBSerialNumber

func (ts *SERVEROOB) OOBSerialNumber(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) OOBSerialNumberSNMPANDREDFISH

func (ts *SERVEROOB) OOBSerialNumberSNMPANDREDFISH(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) OOBVersion

func (ts *SERVEROOB) OOBVersion(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) OOBVersionSNMPANDREDFISH

func (ts *SERVEROOB) OOBVersionSNMPANDREDFISH(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishBaseInfo

func (ts *SERVEROOB) RedfishBaseInfo(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishBmc

func (ts *SERVEROOB) RedfishBmc(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishCpu

func (ts *SERVEROOB) RedfishCpu(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishDisk

func (ts *SERVEROOB) RedfishDisk(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishMem

func (ts *SERVEROOB) RedfishMem(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishMeta

func (ts *SERVEROOB) RedfishMeta(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishNetwork

func (ts *SERVEROOB) RedfishNetwork(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishNetworkinterface

func (ts *SERVEROOB) RedfishNetworkinterface(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishPower

func (ts *SERVEROOB) RedfishPower(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishPowerControl

func (ts *SERVEROOB) RedfishPowerControl(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*SERVEROOB) RedfishVersion

func (ts *SERVEROOB) RedfishVersion(ctx context.Context, args *structs.Args, reply *structs.Reply) error

type SSHServerType

type SSHServerType int

type SSHTaskConfig

type SSHTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
	Commands       []*CmdPair `yaml:"commands" mapstructure:"commands"`
	ConfigMode     bool       `yaml:"config_mode" mapstructure:"config_mode"`
}

func (SSHTaskConfig) GetSubOid

func (s SSHTaskConfig) GetSubOid(key string) string

func (SSHTaskConfig) NewExecutor

func (s SSHTaskConfig) NewExecutor(remote *structs.L2DeviceRemoteInfo) (clitask.Executor, error)

func (s SSHTaskConfig) NewSSHTask(remote *structs.L2DeviceRemoteInfo) (*terminal.Execute, error) {

type STREAM

type STREAM struct {
}

func (*STREAM) Stream

func (ts *STREAM) Stream(conn net.Conn, args *share.StreamServiceArgs)

type SdnTaskConfig

type SdnTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (SdnTaskConfig) GetSubOid

func (s SdnTaskConfig) GetSubOid(key string) string

func (SdnTaskConfig) NewExecutor

func (s SdnTaskConfig) NewExecutor(remote *structs.L2DeviceRemoteInfo) (clitask.Executor, error)

type Service

type Service struct {
	Name    string               `yaml:"name" json:"name" mapstructure:"name"`
	Snmp    []*SnmpTaskConfig    `yaml:"snmp" json:"snmp" mapstructure:"snmp"`
	Restful []*RestfulTaskConfig `yaml:"restful" json:"restful" mapstructure:"restful"`
	SSH     []*SSHTaskConfig     `yaml:"ssh" json:"ssh" mapstructure:"ssh"`
	Redfish []*RedfishTaskConfig `yaml:"redfish" json:"redfish" mapstructure:"redfish"`
	Gofish  []*GofishTaskConfig  `yaml:"gofish" mapstructure:"gofish" json:"gofish"`
	Sdn     []*SdnTaskConfig     `yaml:"sdn" mapstructure:"sdn" json:"sdn"`
	Rshell  []*RshellTaskConfig  `yaml:"rshell" mapstructure:"rshell" json:"rshell"`
	Vmware  []*VmwareTaskConfig  `yaml:"vmware" json:"vmware" mapstructure:"vmware"`
	Excel   []*CheckTaskConfig   `yaml:"excel" json:"excel" mapstructure:"excel"`
	IPMI    []*IPMITaskConfig    `yaml:"ipmi" json:"ipmi" mapstructure:"ipmi"`
	// contains filtered or unexported fields
}

选择器中具体的服务列表

func (Service) Run

func (s Service) Run(remote *structs.L2DeviceRemoteInfo, options ...interface{}) (resultTable *clitask.Table, err error)

func (Service) ServiceName

func (s Service) ServiceName() string

func (*Service) WithInstance

func (s *Service) WithInstance(instance structs.L2NodemapInstanceInterface)

type ServiceConfig

type ServiceConfig struct {
	Service []*ServiceModeConfig
}

func (ServiceConfig) Select

type ServiceModeConfig

type ServiceModeConfig struct {
	Platform     string
	Manufacturer string
	Catalog      string
	Service      []*Service
	// contains filtered or unexported fields
}

选择器

type SnmpServiceType

type SnmpServiceType int

type SnmpTaskConfig

type SnmpTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
	Oid            string `yaml:"oid" mapstructure:"oid"`

	OidMap    map[string]string `yaml:"oidmap"  mapstructure:"oidmap"`
	IndexAll  []int             `yaml:"indexall" mapstructure:"indexall"`
	Prefix    []int             `yaml:"prefix" mapstructure:"prefix"`
	PrefixMap map[string]string `yaml:"prefixmap" mapstructure:"prefixmap"`
}

func (SnmpTaskConfig) GetSubOid

func (s SnmpTaskConfig) GetSubOid(key string) string

func (SnmpTaskConfig) NewExecutor

func (s SnmpTaskConfig) NewExecutor(remote *structs.L2DeviceRemoteInfo) (clitask.Executor, error)

type TOPO

type TOPO struct {
	Data string
}

func (*TOPO) InbandSerialNumber

func (ts *TOPO) InbandSerialNumber(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (*TOPO) TopoMainService

func (ts *TOPO) TopoMainService(ctx context.Context, args *structs.Args, reply *structs.Reply) error

func (a *structs.Args) Device() (DeviceWithPlatform, error) { var err error switch a.StructType { case DcimDevice: var d model.DcimDevice tx := global.GVA_DB1.Where("id = ?", a.Id).Preload("DcimPlatform").Preload("DcimDevicetype.DcimManufacturer").Preload("DcimCatalog").Find(&d) err = tx.Error return &d, err case VirtualizationCluster: var d model.VirtualizationCluster tx := global.GVA_DB1.Where("id = ?", a.Id).Preload("DcimPlatform").Preload("DcimCatalog").Find(&d) err = tx.Error return &d, err case SdnController: var d model.SdnController tx := global.GVA_DB1.Where("id = ?", a.Id).Preload("DcimPlatform").Preload("DcimCatalog").Find(&d) err = tx.Error return &d, err case VirtualizationVirtualmachine: var d model.VirtualizationVirtualmachine tx := global.GVA_DB1.Where("id = ?", a.Id).Preload("DcimPlatform").Preload("DcimCatalog").Find(&d) err = tx.Error return &d, err }

return nil, fmt.Errorf("unsupport struct type: %s", a.StructType) }

type VMWARE

type VMWARE struct{}

func (*VMWARE) VmwareMainService

func (vm *VMWARE) VmwareMainService(ctx context.Context, args *structs.Args, reply *structs.Reply) error

type VmwareTaskConfig

type VmwareTaskConfig struct {
	BaseTaskConfig `mapstructure:",squash"`
}

func (VmwareTaskConfig) GetSubOid

func (s VmwareTaskConfig) GetSubOid(key string) string

func (VmwareTaskConfig) NewExecutor

type WorkContext

type WorkContext struct {
	Uuid    string
	Service interface{}
}

func NewWorkContext

func NewWorkContext(ts interface{}, arg interface{}) *WorkContext

Directories

Path Synopsis
sdn

Jump to

Keyboard shortcuts

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