Documentation ¶
Overview ¶
Package common is to include common methods for managing multi-cloud infra
Package common is to include common methods for managing multi-cloud infra ¶
Package common is to include common methods for managing multi-cloud infra ¶
Package common is to include common methods for managing multi-cloud infra
Index ¶
- Constants
- Variables
- func AppendIfMissing(slice []string, i string) []string
- func ChangeIdString(name string) string
- func CheckConfig(id string) (bool, error)
- func CheckElement(a string, list []string) bool
- func CheckNs(id string) (bool, error)
- func CheckString(name string) error
- func ConvertToMessage(inType string, inData string, obj interface{}) error
- func ConvertToOutput(outType string, obj interface{}) (string, error)
- func CopySrcToDest(src interface{}, dest interface{}) error
- func DelAllNs() error
- func DelNs(id string) error
- func DeleteObject(key string) error
- func DeleteObjects(key string) error
- func GenChildResourceKey(nsId string, resourceType string, parentResourceId string, resourceId string) string
- func GenMcisKey(nsId string, mcisId string, vmId string) string
- func GenMcisPolicyKey(nsId string, mcisId string, vmId string) string
- func GenMcisSubGroupKey(nsId string, mcisId string, groupId string) string
- func GenRandomPassword(length int) string
- func GenResourceKey(nsId string, resourceType string, resourceId string) string
- func GenUid() string
- func GenerateNewRandomString(n int) string
- func GetChildIdList(key string) []string
- func GetCspResourceId(nsId string, resourceType string, resourceId string) (string, error)
- func GetFuncName() string
- func GetNativeRegion(connectionName string) (string, error)
- func GetObjectList(key string) []string
- func GetObjectValue(key string) (string, error)
- func InitAllConfig() error
- func InitConfig(id string) error
- func ListConfigId() []string
- func ListNsId() ([]string, error)
- func LookupKeyValueList(kvl []KeyValue, key string) string
- func NVL(str string, def string) string
- func NsValidation() echo.MiddlewareFunc
- func OpenSQL(path string) error
- func PrintJsonPretty(v interface{})
- func RandomSleep(from int, to int)
- func SelectDatabase(database string) error
- func ToLower(name string) string
- func UpdateGlobalVariable(id string) error
- type Cloud
- type CloudSetting
- type ConfigInfo
- type ConfigReq
- type ConnConfig
- type ConnConfigList
- type GeoLocation
- type IID
- type IdList
- type KeyValue
- type NlbSetting
- type Nlbsw
- type NsInfo
- type NsReq
- type Region
- type RegionList
- type RuntimeConfig
- type SimpleMsg
- type SpiderConnectionName
Constants ¶
const ( StrSpiderRestUrl string = "SPIDER_REST_URL" StrDragonflyRestUrl string = "DRAGONFLY_REST_URL" StrDBUrl string = "DB_URL" StrDBDatabase string = "DB_DATABASE" StrDBUser string = "DB_USER" StrDBPassword string = "DB_PASSWORD" StrAutocontrolDurationMs string = "AUTOCONTROL_DURATION_MS" CbStoreKeyNotFoundErrorString string = "key not found" StrAdd string = "add" StrDelete string = "delete" StrSSHKey string = "sshKey" StrImage string = "image" StrCustomImage string = "customImage" StrSecurityGroup string = "securityGroup" StrSpec string = "spec" StrVNet string = "vNet" StrSubnet string = "subnet" StrDataDisk string = "dataDisk" StrNLB string = "nlb" StrVM string = "vm" StrMCIS string = "mcis" StrDefaultResourceName string = "-systemdefault-" // SystemCommonNs is const for SystemCommon NameSpace ID SystemCommonNs string = "system-purpose-common-ns" )
Variables ¶
var AutocontrolDurationMs string
var CBLog *logrus.Logger
CB-Store
var CBStore icbs.Store
var DBDatabase string
var DBPassword string
var DBUrl string
var DBUser string
var DragonflyRestUrl string
var MyDB *sql.DB
var ORM *xorm.Engine
var RuntimeConf = RuntimeConfig{}
RuntimeConf is global variable for cloud config
var RuntimeLatancyMap = [][]string{}
RuntimeLatancyMap is global variable for LatancyMap
var RuntimeLatancyMapIndex = make(map[string]int)
RuntimeLatancyMapIndex is global variable for LatancyMap (index)
var SpiderRestUrl string
var StartTime string
Functions ¶
func AppendIfMissing ¶
func ChangeIdString ¶
ChangeIdString is func to change strings in id or name (special chars to -, to lower string )
func CheckConfig ¶
func CheckElement ¶
func CheckString ¶
CheckString is func to check string by the given rule `[a-z]([-a-z0-9]*[a-z0-9])?`
func ConvertToMessage ¶
ConvertToMessage is func to change input data to gRPC message
func ConvertToOutput ¶
ConvertToOutput is func to convert gRPC message to print format
func CopySrcToDest ¶
func CopySrcToDest(src interface{}, dest interface{}) error
CopySrcToDest is func to copy data from source to target
func GenChildResourceKey ¶
func GenChildResourceKey(nsId string, resourceType string, parentResourceId string, resourceId string) string
GenChildResourceKey is func to generate a key from resource type and id
func GenMcisKey ¶
GenMcisKey is func to generate a key used in keyValue store
func GenMcisPolicyKey ¶
GenMcisPolicyKey is func to generate Mcis policy key
func GenMcisSubGroupKey ¶
GenMcisSubGroupKey is func to generate a key from subGroupId used in keyValue store
func GenRandomPassword ¶
GenRandomPassword is func to return a RandomPassword
func GenResourceKey ¶
GenResourceKey is func to generate a key from resource type and id
func GenerateNewRandomString ¶
generate a random string (from CB-MCKS source code)
func GetChildIdList ¶
GetChildIdList is func to get child id list from given key
func GetCspResourceId ¶
GetCspResourceId is func to retrieve CSP native resource ID
func GetFuncName ¶
func GetFuncName() string
GetFuncName is func to get the name of the running function
func GetNativeRegion ¶
GetRegion is func to get NativRegion from file
func GetObjectList ¶
GetObjectList is func to return IDs of each child objects that has the same key
func GetObjectValue ¶
GetObjectValue is func to return the object value
func InitAllConfig ¶
func InitAllConfig() error
func InitConfig ¶
func ListConfigId ¶
func ListConfigId() []string
func LookupKeyValueList ¶
LookupKeyValueList is func to lookup KeyValue list
func NsValidation ¶
func NsValidation() echo.MiddlewareFunc
func PrintJsonPretty ¶
func PrintJsonPretty(v interface{})
PrintJsonPretty is func to print JSON pretty with indent
func RandomSleep ¶
RandomSleep is func to make a caller waits for during random time seconds (random value within x~y)
func SelectDatabase ¶
func ToLower ¶
ToLower is func to change strings (_ to -, " " to -, to lower string ) (deprecated soon)
func UpdateGlobalVariable ¶
Types ¶
type Cloud ¶
type Cloud struct { Common CloudSetting `yaml:"common"` Aws CloudSetting `yaml:"aws"` Azure CloudSetting `yaml:"azure"` Gcp CloudSetting `yaml:"gcp"` Alibaba CloudSetting `yaml:"alibaba"` Tencent CloudSetting `yaml:"tencent"` Ibm CloudSetting `yaml:"ibm"` Openstack CloudSetting `yaml:"openstack"` Cloudit CloudSetting `yaml:"cloudit"` }
Cloud is structure for cloud settings per CSP
type CloudSetting ¶
type CloudSetting struct { Enable string `yaml:"enable"` Nlb NlbSetting `yaml:"nlb"` }
CloudSetting is structure for cloud settings per CSP in details
type ConfigInfo ¶
type ConfigInfo struct { Id string `json:"id" example:"SPIDER_REST_URL"` Name string `json:"name" example:"SPIDER_REST_URL"` Value string `json:"value" example:"http://localhost:1024/spider"` }
swagger:response ConfigInfo
func GetConfig ¶
func GetConfig(id string) (ConfigInfo, error)
func ListConfig ¶
func ListConfig() ([]ConfigInfo, error)
func UpdateConfig ¶
func UpdateConfig(u *ConfigReq) (ConfigInfo, error)
type ConfigReq ¶
type ConfigReq struct { Name string `json:"name" example:"SPIDER_REST_URL"` Value string `json:"value" example:"http://localhost:1024/spider"` }
swagger:request ConfigReq
type ConnConfig ¶
type ConnConfig struct { ConfigName string ProviderName string DriverName string CredentialName string RegionName string Location GeoLocation }
ConnConfig is struct for containing a CB-Spider struct for connection config
func GetConnConfig ¶
func GetConnConfig(ConnConfigName string) (ConnConfig, error)
GetConnConfig is func to get connection config from CB-Spider
type ConnConfigList ¶
type ConnConfigList struct {
Connectionconfig []ConnConfig `json:"connectionconfig"`
}
ConnConfigList is struct for containing a CB-Spider struct for connection config list
func GetConnConfigList ¶
func GetConnConfigList() (ConnConfigList, error)
GetConnConfigList is func to list connection configs from CB-Spider
type GeoLocation ¶
type GeoLocation struct { Latitude string `json:"latitude"` Longitude string `json:"longitude"` BriefAddr string `json:"briefAddr"` CloudType string `json:"cloudType"` NativeRegion string `json:"nativeRegion"` }
GeoLocation is struct for geographical location
func GetCloudLocation ¶
func GetCloudLocation(cloudType string, nativeRegion string) GeoLocation
GetCloudLocation is to get location of clouds (need error handling)
type IID ¶
Spider 2020-03-30 https://github.com/cloud-barista/cb-spider/blob/master/cloud-control-manager/cloud-driver/interfaces/resources/IId.go
type NlbSetting ¶
type NlbSetting struct { Enable string `yaml:"enable"` Interval string `yaml:"interval"` Timeout string `yaml:"timeout"` Threshold string `yaml:"threshold"` }
NlbSetting is structure for NLB setting
type Nlbsw ¶
type Nlbsw struct { Sw string `yaml:"sw"` Version string `yaml:"version"` CommandNlbPrepare string `yaml:"commandNlbPrepare"` CommandNlbDeploy string `yaml:"commandNlbDeploy"` CommandNlbAddTargetNode string `yaml:"commandNlbAddTargetNode"` CommandNlbApplyConfig string `yaml:"commandNlbApplyConfig"` NlbMcisCommonSpec string `yaml:"nlbMcisCommonSpec"` NlbMcisCommonImage string `yaml:"nlbMcisCommonImage"` NlbMcisSubGroupSize string `yaml:"nlbMcisSubGroupSize"` }
Nlbsw is structure for NLB setting
type NsInfo ¶
type NsInfo struct { Id string `json:"id" example:"ns01"` Name string `json:"name" example:"ns01"` Description string `json:"description" example:"Description for this namespace"` }
swagger:response NsInfo
type Region ¶
type Region struct { RegionName string // ex) "region01" ProviderName string // ex) "GCP" KeyValueInfoList []KeyValue // ex) { {region, us-east1}, {zone, us-east1-c} } }
Region is struct for containing region struct of CB-Spider
type RegionList ¶
type RegionList struct {
Region []Region `json:"region"`
}
RegionList is array struct for Region
func GetRegionList ¶
func GetRegionList() (RegionList, error)
GetRegionList is func to retrieve region list
type RuntimeConfig ¶
RuntimeConfig is structure for global variable for cloud config
type SimpleMsg ¶
type SimpleMsg struct {
Message string `json:"message" example:"Any message"`
}
SimpleMsg is struct for JSON Simple message
type SpiderConnectionName ¶
type SpiderConnectionName struct {
ConnectionName string `json:"ConnectionName"`
}