common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 26 Imported by: 1

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

View Source
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"
	StrSecurityGroup              string = "securityGroup"
	StrSpec                       string = "spec"
	StrVNet                       string = "vNet"
	StrSubnet                     string = "subnet"
	StrDefaultResourceName        string = "-systemdefault-"
)

Variables

View Source
var AutocontrolDurationMs string

CB-Store

View Source
var CBStore icbs.Store
View Source
var DBDatabase string
View Source
var DBPassword string
View Source
var DBUrl string
View Source
var DBUser string
View Source
var DragonflyRestUrl string
View Source
var MyDB *sql.DB
View Source
var SpiderRestUrl string
View Source
var StartTime string

Functions

func AppendIfMissing added in v0.3.11

func AppendIfMissing(slice []string, i string) []string

func CheckConfig added in v0.3.1

func CheckConfig(id string) (bool, error)

func CheckNs added in v0.3.1

func CheckNs(id string) (bool, error)

func CheckString added in v0.3.7

func CheckString(name string) error

CheckString is func to check string by the given rule `[a-z]([-a-z0-9]*[a-z0-9])?`

func ConvGrpcStatusErr

func ConvGrpcStatusErr(err error, tag string, method string) error

ConvGrpcStatusErr is func to convert error code into GRPC status code

func ConvertToMessage

func ConvertToMessage(inType string, inData string, obj interface{}) error

ConvertToMessage is func to change input data to gRPC message

func ConvertToOutput

func ConvertToOutput(outType string, obj interface{}) (string, error)

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 DelAllNs

func DelAllNs() error

func DelNs

func DelNs(id string) error

func DeleteObject added in v0.3.3

func DeleteObject(key string) error

DeleteObject is func to delete the object

func DeleteObjects added in v0.3.3

func DeleteObjects(key string) error

DeleteObjects is func to delete objects

func GenChildResourceKey added in v0.4.10

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

func GenMcisKey(nsId string, mcisId string, vmId string) string

GenMcisKey is func to generate a key used in keyValue store

func GenMcisPolicyKey added in v0.2.8

func GenMcisPolicyKey(nsId string, mcisId string, vmId string) string

GenMcisPolicyKey is func to generate Mcis policy key

func GenMcisVmGroupKey added in v0.3.3

func GenMcisVmGroupKey(nsId string, mcisId string, groupId string) string

GenMcisVmGroupKey is func to generate a key from vmGroupId used in keyValue store

func GenResourceKey

func GenResourceKey(nsId string, resourceType string, resourceId string) string

GenResourceKey is func to generate a key from resource type and id

func GenUid added in v0.4.10

func GenUid() string

GenUid is func to return a UUID string

func GetChildIdList

func GetChildIdList(key string) []string

GetChildIdList is func to get child id list from given key

func GetCspResourceId

func GetCspResourceId(nsId string, resourceType string, resourceId string) (string, error)

GetCspResourceId is func to retrieve CSP native resource ID

func GetNativeRegion added in v0.4.12

func GetNativeRegion(connectionName string) (string, error)

GetRegion is func to get NativRegion from file

func GetObjectList added in v0.3.3

func GetObjectList(key string) []string

GetObjectList is func to return IDs of each child objects that has the same key

func GetObjectValue added in v0.3.3

func GetObjectValue(key string) (string, error)

GetObjectValue is func to return the object value

func InitAllConfig added in v0.3.9

func InitAllConfig() error

func InitConfig added in v0.3.9

func InitConfig(id string) error

func ListConfigId

func ListConfigId() []string

func ListNsId

func ListNsId() ([]string, error)

func LookupKeyValueList

func LookupKeyValueList(kvl []KeyValue, key string) string

LookupKeyValueList is func to lookup KeyValue list

func NVL

func NVL(str string, def string) string

NVL is func for null value logic

func NewGrpcStatusErr

func NewGrpcStatusErr(msg string, tag string, method string) error

NewGrpcStatusErr is func to generate GRPC status error code

func NsValidation

func NsValidation() echo.MiddlewareFunc

func OpenSQL

func OpenSQL(path string) error

func PrintJsonPretty

func PrintJsonPretty(v interface{})

PrintJsonPretty is func to print JSON pretty with indent

func RandomSleep added in v0.4.10

func RandomSleep(t int)

RandomSleep is func to make a caller waits for during random time seconds

func SelectDatabase

func SelectDatabase(database string) error

func ToLower added in v0.3.1

func ToLower(name string) string

ToLower is func to change strings (_ to -, " " to -, to lower string ) (deprecated soon)

func UpdateGlobalVariable added in v0.3.9

func UpdateGlobalVariable(id string) error

Types

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 added in v0.4.12

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 added in v0.4.12

func GetCloudLocation(cloudType string, nativeRegion string) GeoLocation

GetCloudLocation is to get location of clouds (need error handling)

type IID

type IID struct {
	NameId   string // NameID by user
	SystemId string // SystemID by CloudOS
}

Spider 2020-03-30 https://github.com/cloud-barista/cb-spider/blob/master/cloud-control-manager/cloud-driver/interfaces/resources/IId.go

type IdList added in v0.3.10

type IdList struct {
	IdList []string `json:"output"`
}

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

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

func CreateNs

func CreateNs(u *NsReq) (NsInfo, error)

func GetNs

func GetNs(id string) (NsInfo, error)

func ListNs

func ListNs() ([]NsInfo, error)

type NsReq

type NsReq struct {
	Name        string `json:"name" example:"ns01"`
	Description string `json:"description" example:"Description for this namespace"`
}

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

func GetRegion

func GetRegion(RegionName string) (Region, error)

GetRegion is func to get region from 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 SimpleMsg

type SimpleMsg struct {
	Message string `json:"message" example:"Any message"`
}

SimpleMsg is struct for JSON Simple message

type SpiderConnectionName added in v0.3.7

type SpiderConnectionName struct {
	ConnectionName string `json:"ConnectionName"`
}

Jump to

Keyboard shortcuts

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