resources

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Proof of Concepts for the Cloud-Barista Multi-Cloud Project.

EC2 Hander (AWS SDK GO Version 1.16.26, Thanks AWS.)

by CB-Spider Team, 2019.03.

Index

Constants

View Source
const CBCloudInitFilePath string = "/cloud-driver-libs/.cloud-init-tencent/cloud-init"
View Source
const CBDefaultCidrBlock string = "192.168.0.0/16" // CB Default CidrBlock
View Source
const CBDefaultSubnetName string = "CB-VNet-Subnet" // CB Default Subnet Name
View Source
const CBDefaultVNetName string = "CB-VNet" // CB Default Virtual Network Name
View Source
const CBDefaultVmUserName string = "cb-user" // default VM User Name
View Source
const CBKeyPairPath string = "/cloud-driver-libs/.ssh-tencent/"
View Source
const CUSTOM_ERR_CODE_NOTFOUND string = "404" //awserr.New("404", "XXX 정보가 존재하지 않습니다.", nil)
View Source
const CUSTOM_ERR_CODE_TOOMANY string = "600" //awserr.New("600", "n개 이상의 xxxx 정보가 존재합니다.", nil)

Variables

This section is empty.

Functions

func ConvertJsonString

func ConvertJsonString(v interface{}) (string, error)

Cloud Object를 JSON String 타입으로 변환

func ConvertJsonStringNoEscape

func ConvertJsonStringNoEscape(v interface{}) (string, error)

Cloud Object를 JSON String 타입으로 변환

func ConvertKeyValueList

func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error)

Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용

func ConvertToString

func ConvertToString(value interface{}) (string, error)

CB-KeyValue 등을 위해 String 타입으로 변환

func ConvertVMStatusString

func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error)

func CreateHashString

func CreateHashString(credentialInfo idrv.CredentialInfo, Region idrv.RegionInfo) (string, error)

@TODO - PK 이슈 처리해야 함. (A User / B User / User 하위의 IAM 계정간의 호환성에 이슈가 없어야 하는데 현재는 안 됨.)

  • 따라서 AWS는 대안으로 KeyPair의 FingerPrint를 이용하도록 변경 - 필요시 리전및 키 이름과 혼용해서 만들어야할 듯.

KeyPair 해시 생성 함수 (PK 이슈로 현재는 사용하지 않음)

func ExtractImageDescribeInfo

func ExtractImageDescribeInfo(image *cvm.Image) irs.ImageInfo

func ExtractKeyPairDescribeInfo

func ExtractKeyPairDescribeInfo(keyPair *cvm.KeyPair) (irs.KeyPairInfo, error)

KeyPair 정보를 추출함

func ExtractVMSpecInfo

func ExtractVMSpecInfo(instanceTypeInfo *cvm.InstanceTypeConfig) irs.VMSpecInfo

인스턴스 스펙 정보를 추출함

func ExtractVpcDescribeInfo

func ExtractVpcDescribeInfo(vpcInfo *vpc.Vpc) irs.VPCInfo

VPC 정보를 추출함

func GetCBDefaultCidrBlock

func GetCBDefaultCidrBlock() string

func GetCBDefaultSubnetName

func GetCBDefaultSubnetName() string

Subnet

func GetCBDefaultVNetName

func GetCBDefaultVNetName() string

VPC

func JSONMarshal

func JSONMarshal(t interface{}) ([]byte, error)

func SetNameTag

func SetNameTag(Client *ec2.EC2, Id string, value string) bool

Name Tag 설정

Types

type TencentCBNetworkInfo

type TencentCBNetworkInfo struct {
	VpcName   string
	VpcId     string
	CidrBlock string
	IsDefault bool
	State     string

	SubnetName string
	SubnetId   string
}

type TencentImageHandler

type TencentImageHandler struct {
	Region idrv.RegionInfo
	Client *cvm.Client
}

func (*TencentImageHandler) CreateImage

func (imageHandler *TencentImageHandler) CreateImage(imageReqInfo irs.ImageReqInfo) (irs.ImageInfo, error)

@TODO - 이미지 생성에 따른 구조체 정의 필요 - 현재는 IID뿐이 없어서 이미지 이름으로만 생성하도록 했음.(인스턴스Id가 없어서 에러 발생함.)

func (*TencentImageHandler) DeleteImage

func (imageHandler *TencentImageHandler) DeleteImage(imageIID irs.IID) (bool, error)

func (*TencentImageHandler) GetImage

func (imageHandler *TencentImageHandler) GetImage(imageIID irs.IID) (irs.ImageInfo, error)

func (*TencentImageHandler) ListImage

func (imageHandler *TencentImageHandler) ListImage() ([]*irs.ImageInfo, error)

type TencentKeyPairHandler

type TencentKeyPairHandler struct {
	Region idrv.RegionInfo
	Client *cvm.Client
}

func (*TencentKeyPairHandler) CheckKeyPairFolder

func (keyPairHandler *TencentKeyPairHandler) CheckKeyPairFolder(keyPairPath string) error

================================= 공개 키 변환 및 키 정보 로컬 보관 로직 추가 =================================

func (*TencentKeyPairHandler) CreateKey

func (keyPairHandler *TencentKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error)

KeyPair 생성시 이름은 알파벳, 숫자 또는 밑줄 "_"만 지원

func (*TencentKeyPairHandler) DeleteKey

func (keyPairHandler *TencentKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error)

func (*TencentKeyPairHandler) GetKey

func (keyPairHandler *TencentKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo, error)

func (*TencentKeyPairHandler) GetLocalKeyId

func (keyPairHandler *TencentKeyPairHandler) GetLocalKeyId(keyIID irs.IID) (string, error)

Tencent의 경우 FingerPrint같은 고유 값을 조회할 수 없기 때문에 KeyId를 로컬 파일의 고유 키 값으로 이용함.

func (*TencentKeyPairHandler) ListKey

func (keyPairHandler *TencentKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error)

type TencentSecurityHandler

type TencentSecurityHandler struct {
	Region idrv.RegionInfo
	Client *vpc.Client
}

func (*TencentSecurityHandler) CreateSecurity

func (securityHandler *TencentSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error)

https://intl.cloud.tencent.com/document/product/213/34272 https://intl.cloud.tencent.com/ko/document/api/215/36083

@TODO 포트 다양하게 처리 가능해야 함. - 현재는 콤머는 에러 처리

사용가능 포트 규칙 : 콤머(,) / 대쉬(-) / ALL(전체)

Port: A single port number, or a port range in the format of “8000-8010”. The Port field is accepted only if the value of the Protocol field is TCP or UDP. Otherwise Protocol and Port are mutually exclusive. Action : ACCEPT or DROP

func (*TencentSecurityHandler) DeleteSecurity

func (securityHandler *TencentSecurityHandler) DeleteSecurity(securityIID irs.IID) (bool, error)

func (*TencentSecurityHandler) ExtractPolicyGroups

func (securityHandler *TencentSecurityHandler) ExtractPolicyGroups(policyGroups []*vpc.SecurityGroupPolicy, direction string) ([]irs.SecurityRuleInfo, error)

@TODO Port에 콤머가 사용된 정책 처리해야 함. direction : inbound / outbound

func (*TencentSecurityHandler) GetSecurity

func (securityHandler *TencentSecurityHandler) GetSecurity(securityIID irs.IID) (irs.SecurityInfo, error)

func (*TencentSecurityHandler) GetSecurityRuleInfo

func (securityHandler *TencentSecurityHandler) GetSecurityRuleInfo(securityIID irs.IID) (*[]irs.SecurityRuleInfo, error)

func (*TencentSecurityHandler) ListSecurity

func (securityHandler *TencentSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, error)

type TencentVMHandler

type TencentVMHandler struct {
	Region idrv.RegionInfo
	Client *cvm.Client
}

func (*TencentVMHandler) ExtractDescribeInstances

func (vmHandler *TencentVMHandler) ExtractDescribeInstances(curVm *cvm.Instance) (irs.VMInfo, error)

func (*TencentVMHandler) GetVM

func (vmHandler *TencentVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error)

func (*TencentVMHandler) GetVMStatus

func (vmHandler *TencentVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, error)

func (*TencentVMHandler) ListVM

func (vmHandler *TencentVMHandler) ListVM() ([]*irs.VMInfo, error)

func (*TencentVMHandler) ListVMStatus

func (vmHandler *TencentVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)

func (*TencentVMHandler) RebootVM

func (vmHandler *TencentVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error)

func (*TencentVMHandler) ResumeVM

func (vmHandler *TencentVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error)

func (*TencentVMHandler) StartVM

func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error)

VM생성 시 Zone이 필수라서 Credential의 Zone에만 생성함.

func (*TencentVMHandler) SuspendVM

func (vmHandler *TencentVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error)

func (*TencentVMHandler) TerminateVM

func (vmHandler *TencentVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, error)

func (*TencentVMHandler) WaitForRun

func (vmHandler *TencentVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error)

VM 정보를 조회할 수 있을 때까지 최대 30초간 대기

type TencentVPCHandler

type TencentVPCHandler struct {
	Region idrv.RegionInfo
	Client *vpc.Client
}

func (*TencentVPCHandler) AddSubnet

func (VPCHandler *TencentVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.SubnetInfo) (irs.VPCInfo, error)

func (*TencentVPCHandler) CreateVPC

func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error)

func (*TencentVPCHandler) DeleteVPC

func (VPCHandler *TencentVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error)

func (*TencentVPCHandler) GetVPC

func (VPCHandler *TencentVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error)

func (*TencentVPCHandler) ListSubnet

func (VPCHandler *TencentVPCHandler) ListSubnet(reqVpcId string) ([]irs.SubnetInfo, error)

func (*TencentVPCHandler) ListVPC

func (VPCHandler *TencentVPCHandler) ListVPC() ([]*irs.VPCInfo, error)

func (*TencentVPCHandler) RemoveSubnet

func (VPCHandler *TencentVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID) (bool, error)

type TencentVmSpecHandler

type TencentVmSpecHandler struct {
	Region idrv.RegionInfo
	Client *cvm.Client
}

https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeInstanceTypes

func (*TencentVmSpecHandler) GetOrgVMSpec

func (vmSpecHandler *TencentVmSpecHandler) GetOrgVMSpec(Region string, Name string) (string, error)

func (*TencentVmSpecHandler) GetVMSpec

func (vmSpecHandler *TencentVmSpecHandler) GetVMSpec(Region string, Name string) (irs.VMSpecInfo, error)

func (*TencentVmSpecHandler) ListOrgVMSpec

func (vmSpecHandler *TencentVmSpecHandler) ListOrgVMSpec(Region string) (string, error)

func (*TencentVmSpecHandler) ListVMSpec

func (vmSpecHandler *TencentVmSpecHandler) ListVMSpec(Region string) ([]*irs.VMSpecInfo, error)

@TODO : Region : zone id(Region이 아닌 zone id로 조회해야 함.)

Jump to

Keyboard shortcuts

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