common

package
v1.6.65 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLOUD_SYNC_TIMER_DEFAULT = 60
	CLOUD_SYNC_TIMER_MIN     = 1
	CLOUD_SYNC_TIMER_MAX     = 86400
)
View Source
const (
	PORT_RANGE_ALL = "0-65535"
	PROTOCOL_ALL   = "ALL"
)
View Source
const (
	SUBNET_DEFAULT_CIDR_IPV4 = "0.0.0.0/0"
	SUBNET_DEFAULT_CIDR_IPV6 = "::/0"
)
View Source
const (
	NAT_RULE_TYPE_DNAT = "DNAT"
	NAT_RULE_TYPE_SNAT = "SNAT"
)
View Source
const (
	LB_MODEL_INTERNAL = 1 + iota
	LB_MODEL_EXTERNAL
)
View Source
const (
	K8S_VPC_NAME       = "kubernetes_vpc"
	K8S_VERSION_PREFIX = "Kubernetes"
)
View Source
const (
	SVC_RULE_RESOURCE_NAME = "virtual-kubelet.io/provider-resource-name"
)

Variables

This section is empty.

Functions

func AggregateCIDR

func AggregateCIDR(ips []netaddr.IPPrefix, maxMask int) (cirdsString []string)

func BKDRHash

func BKDRHash(str string) uint32

func CheckJsonAttributes

func CheckJsonAttributes(json *simplejson.Json, requiredAttrs []string) bool

func CheckMapAttributes

func CheckMapAttributes(data map[string]interface{}, requiredAttrs []string) bool

func ContainsIP

func ContainsIP(cidrs []string, ip string) bool

func DiffMap

func DiffMap(base, newTags map[string]string) bool

func EliminateEmptyAZs

func EliminateEmptyAZs(azs []model.AZ, azLcuuidToResourceNum map[string]int) []model.AZ

func EliminateEmptyRegions

func EliminateEmptyRegions(regions []model.Region, regionLcuuidToResourceNum map[string]int) []model.Region

func GenerateCIDR

func GenerateCIDR(ips []netaddr.IPPrefix, maxMask int) (cirds []netaddr.IPPrefix)

func GenerateCustomTag

func GenerateCustomTag(dataMap map[string]interface{}, keyRegex *regexp.Regexp, valueMaxLength int, sep string) []string

func GenerateIPMask

func GenerateIPMask(ip string) int

func GenerateWANVInterfaceMac

func GenerateWANVInterfaceMac(mac string) string

TODO add reason

func GetAZLcuuidFromUUIDGenerate

func GetAZLcuuidFromUUIDGenerate(orgID int, uuidGenerate string) string

func GetBasicNetworkLcuuid

func GetBasicNetworkLcuuid(vpcLcuuid string) string

func GetBasicVPCAndNetworks

func GetBasicVPCAndNetworks(orgID int, regions []model.Region, regionLcuuid, domainName, uuidGenerate string) ([]model.VPC, []model.Network)

func GetBasicVPCLcuuid

func GetBasicVPCLcuuid(uuidGenerate, regionLcuuid string) string

针对各私有云平台,每个区域生成一个基础VPC和子网 宿主机及管理节点的接口和IP属于基础VPC和子网

func GetHostAndVmHostNameByDomain

func GetHostAndVmHostNameByDomain(domain string, db *gorm.DB) (map[string]string, map[string]string, error)

func GetHostIPByName

func GetHostIPByName(name string) (string, error)

根据主机名获取主机IP 不同方式优先级:DNS > file > Hash

func GetHostNics

func GetHostNics(orgID int, hosts []model.Host, domainName, uuidGenerate, portNameRegex string, excludeIPs []string) (
	[]model.Subnet, []model.VInterface, []model.IP, map[string][]model.Subnet, error,
)

根据采集器上报的接口信息,生成宿主机的接口和IP信息

func GetNodeHostNameByDomain

func GetNodeHostNameByDomain(lcuuid string, isSubDomain bool, db *gorm.DB) (map[string]string, error)

func GetUnverifyHTTPClient

func GetUnverifyHTTPClient(timeout time.Duration) *http.Client

func GetVPCLcuuidFromUUIDGenerate

func GetVPCLcuuidFromUUIDGenerate(orgID int, uuidGenerate string) string

func GetVTapSubDomainMappingByDomain

func GetVTapSubDomainMappingByDomain(domain string, db *gorm.DB) (map[int]string, error)

func IPAndMaskToCIDR

func IPAndMaskToCIDR(ip string, mask int) (string, error)

func InetNToA

func InetNToA(ip uint32) string

func IsIPInCIDR

func IsIPInCIDR(ip, cidr string) bool

func ReadJSONFile

func ReadJSONFile(path string) (*simplejson.Json, error)

func ReadLineJSONFile

func ReadLineJSONFile(path string) (js []*simplejson.Json, err error)

func RequestGet

func RequestGet(url, token string, timeout time.Duration) (jsonResp *simplejson.Json, err error)

func RequestPost

func RequestPost(url string, timeout time.Duration, body map[string]interface{}) (jsonResp *simplejson.Json, err error)

func StringInterfaceMapKeys

func StringInterfaceMapKeys(m map[string]interface{}) (keys []string)

func StringSliceStringMapKeys

func StringSliceStringMapKeys(m map[string][]string) (keys []string)

func StringStringMapKeys

func StringStringMapKeys(m map[string]string) (keys []string)

func StringStringMapValues

func StringStringMapValues(m map[string]string) (values []string)

func TidyIPString

func TidyIPString(ipsString []string) (v4Prefix, v6Prefix []netaddr.IPPrefix, err error)

func UnionMapStringInt

func UnionMapStringInt(m, n map[string]int) map[string]int

func UnionMapStringSet

func UnionMapStringSet(m, n map[string]mapset.Set) map[string]mapset.Set

func UnionMapStringString

func UnionMapStringString(m, n map[string]string) map[string]string

func UniqRegions added in v1.6.65

func UniqRegions(regionStrings string) map[string]bool

Types

type Debugger

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

func NewDebugger

func NewDebugger(domainName string) *Debugger

func (*Debugger) Clear

func (d *Debugger) Clear()

func (*Debugger) Refresh

func (d *Debugger) Refresh()

func (*Debugger) WriteJson

func (d *Debugger) WriteJson(filename, dividingLine string, data []*simplejson.Json)

Jump to

Keyboard shortcuts

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