common

package
v0.0.0-...-0f49ba3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS = "SUCCESS"

	DEFAULT_ENCRYPTION_PASSWORD = "******"
)

Variables

View Source
var (
	DefaultTimeout = time.Duration(time.Second * 30)
)
View Source
var RESOURCE_TYPES = []string{
	"SubDomains", "Regions", "AZs", "Hosts", "VMs", "VPCs", "Networks", "Subnets", "VRouters",
	"RoutingTables", "DHCPPorts", "SecurityGroups", "SecurityGroupRules", "VMSecurityGroups",
	"NATGateways", "NATRules", "NATVMConnections", "LBs", "LBListeners", "LBTargetServers",
	"LBVMConnections", "PeerConnections", "CENs", "RedisInstances", "RDSInstances", "VInterfaces",
	"IPs", "FloatingIPs", "PodClusters", "PodNodes", "VMPodNodeConnections", "PodNamespaces",
	"PodGroups", "PodReplicaSets", "Pods", "PodServices", "PodServicePorts", "PodGroupPorts",
	"PodIngresses", "PodIngressRules", "PodIngressRuleBackends", "Processes", "PrometheusTargets", "VIPs",
}

Functions

func CURLPerform

func CURLPerform(method string, url string, body map[string]interface{}, strBody string, opts ...HTTPOption) (*simplejson.Json, error)

功能:调用其他模块API并获取返回结果

func CURLPostFormData

func CURLPostFormData(url, contentType string, body *bytes.Buffer, opts ...HTTPOption) (*simplejson.Json, error)

func CURLResponseRawJson

func CURLResponseRawJson(method string, url string, opts ...HTTPOption) (*simplejson.Json, error)

func ConvertControllerAddrToPodIP

func ConvertControllerAddrToPodIP(controllerIP string, controllerPort uint32) (string, error)

func GetByFilter

func GetByFilter(url string, body, filters map[string]interface{}, opts ...HTTPOption) (*simplejson.Json, error)

GetByFilter 通过 Get 方法获取数据,自动拼接 url param 参数

func GetDefaultRouteIP

func GetDefaultRouteIP() string

func GetTimeout

func GetTimeout(cmd *cobra.Command) time.Duration

func GetURLInfo

func GetURLInfo(cmd *cobra.Command, urlPath string, opts ...HTTPOption)

func IsChineseChar

func IsChineseChar(str string) bool

func JsonFormat

func JsonFormat(jsonByte []byte) (string, error)

func PrettyPrint

func PrettyPrint(data interface{})

Types

type DomainEnabled

type DomainEnabled int
const (
	// attention: following line comments are used by `stringer`
	DOMAIN_ENABLED_DISABLE DomainEnabled = iota
	DOMAIN_ENABLED_ENABLE
)

type DomainState

type DomainState int
const (
	// attention: following line comments are used by `stringer`
	DOMAIN_STATE_NORMAL DomainState = iota + 1

	DOMAIN_STATE_EXCEPTION
	DOMAIN_STATE_WARN
)

type DomainType

type DomainType int
const (
	// attention: following line comments are used by `stringer`
	DOMAIN_TYPE_UNKNOWN           DomainType = -1
	DOMAIN_TYPE_OPENSTACK         DomainType = 1  // openstack
	DOMAIN_TYPE_VSPHERE           DomainType = 2  // vsphere
	DOMAIN_TYPE_TENCENT           DomainType = 4  // tencent
	DOMAIN_TYPE_FILEREADER        DomainType = 5  // filereader
	DOMAIN_TYPE_AWS               DomainType = 6  // aws
	DOMAIN_TYPE_ALIYUN            DomainType = 9  // aliyun
	DOMAIN_TYPE_HUAWEI_PRIVATE    DomainType = 10 // huawei_private
	DOMAIN_TYPE_KUBERNETES        DomainType = 11 // kubernetes
	DOMAIN_TYPE_SIMULATION        DomainType = 12 // simulation
	DOMAIN_TYPE_HUAWEI            DomainType = 13 // huawei
	DOMAIN_TYPE_QINGCLOUD         DomainType = 14 // qingcloud
	DOMAIN_TYPE_QINGCLOUD_PRIVATE DomainType = 15 // qingcloud_private
	DOMAIN_TYPE_AZURE             DomainType = 18 // azure
	DOMAIN_TYPE_APSARA_STACK      DomainType = 19 // apsara_stack
	DOMAIN_TYPE_TENCENT_TCE       DomainType = 20 // tencent_tce
	DOMAIN_TYPE_AGENT_SYNC        DomainType = 23 // agent_sync
	DOMAIN_TYPE_MICROSOFT_ACS     DomainType = 24 // microsoft_acs
	DOMAIN_TYPE_BAIDU_BCE         DomainType = 25 // baidu_bce
	DOMAIN_TYPE_ESHORE            DomainType = 26 // eshore
	DOMAIN_TYPE_CLOUD_TOWER       DomainType = 27 // cloudtower
	DOMAIN_TYPE_NFVO              DomainType = 28 // nfvo
)

func GetDomainTypeByName

func GetDomainTypeByName(domainTypeName string) DomainType

type Filter

type Filter map[string]interface{}

Filter query string parameters

type HTTPConf

type HTTPConf struct {
	Timeout time.Duration
}

type HTTPOption

type HTTPOption func(*HTTPConf)

func WithTimeout

func WithTimeout(t time.Duration) HTTPOption

type PluginType

type PluginType int
const (
	// attention: following line comments are used by `stringer`
	PLUGIN_TYPE_WASM PluginType = 1 + iota
	PLUGIN_TYPE_SO
)

type Server

type Server struct {
	IP      string
	Port    uint32
	RpcPort uint32
	SvcPort uint32
}

func GetServerInfo

func GetServerInfo(cmd *cobra.Command) *Server

type VtapException

type VtapException uint64
const (
	// attention: following line comments are used by `stringer`
	VTAP_EXCEPTION_LICENSE_NOT_ENGOUTH     VtapException = 0x10000000
	VTAP_EXCEPTION_ALLOC_ANALYZER_FAILED   VtapException = 0x40000000
	VTAP_EXCEPTION_ALLOC_CONTROLLER_FAILED VtapException = 0x80000000
)

need synchronized update with the server

type VtapState

type VtapState int
const (
	// attention: following line comments are used by `stringer`
	VTAP_STATE_NOT_CONNECTED VtapState = iota // LOST
	VTAP_STATE_NORMAL
	VTAP_STATE_DISABLE
	VTAP_STATE_PENDING
)

type VtapTapMode

type VtapTapMode int
const (
	// attention: following line comments are used by `stringer`
	VTAP_TAP_MODE_LOCAL     VtapTapMode = iota // local
	VTAP_TAP_MODE_MIRROR                       //mirror
	VTAP_TAP_MODE_DEDICATED                    // dedicated
)

func GetVtapTapModeByName

func GetVtapTapModeByName(tapModeName string) VtapTapMode

type VtapType

type VtapType int
const (
	// attention: following line comments are used by `stringer`
	VTAP_TYPE_KVM VtapType = 1 + iota
	VTAP_TYPE_ESXI
	VTAP_TYPE_WORKLOAD_V // CHOST_VM

	VTAP_TYPE_WORKLOAD_P // CHOST_BM
	VTAP_TYPE_DEDICATED
	VTAP_TYPE_POD_HOST             // K8S_BM
	VTAP_TYPE_POD_VM               // K8S_VM
	VTAP_TYPE_TUNNEL_DECAPSULATION // TUN_DECAP
	VTAP_TYPE_HYPER_V

	VTAP_TYPE_K8S_SIDECAR
)

Directories

Path Synopsis
Package printutil for output styling.
Package printutil for output styling.

Jump to

Keyboard shortcuts

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