Documentation ¶
Overview ¶
Proof of Concepts for the Cloud-Barista Multi-Cloud Project.
- Cloud-Barista: https://github.com/cloud-barista
EC2 Hander (AWS SDK GO Version 1.16.26, Thanks AWS.)
by CB-Spider Team, 2019.03.
Index ¶
- Constants
- func ConvertJsonString(v interface{}) (string, error)
- func ConvertJsonStringNoEscape(v interface{}) (string, error)
- func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error)
- func ConvertToString(value interface{}) (string, error)
- func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error)
- func CreateHashString(credentialInfo idrv.CredentialInfo, Region idrv.RegionInfo) (string, error)
- func ExtractImageDescribeInfo(image *cvm.Image) irs.ImageInfo
- func ExtractKeyPairDescribeInfo(keyPair *cvm.KeyPair) (irs.KeyPairInfo, error)
- func ExtractVMSpecInfo(instanceTypeInfo *cvm.InstanceTypeConfig) irs.VMSpecInfo
- func ExtractVpcDescribeInfo(vpcInfo *vpc.Vpc) irs.VPCInfo
- func GetCBDefaultCidrBlock() string
- func GetCBDefaultSubnetName() string
- func GetCBDefaultVNetName() string
- func JSONMarshal(t interface{}) ([]byte, error)
- func SetNameTag(Client *ec2.EC2, Id string, value string) bool
- type TencentCBNetworkInfo
- type TencentImageHandler
- func (imageHandler *TencentImageHandler) CreateImage(imageReqInfo irs.ImageReqInfo) (irs.ImageInfo, error)
- func (imageHandler *TencentImageHandler) DeleteImage(imageIID irs.IID) (bool, error)
- func (imageHandler *TencentImageHandler) GetImage(imageIID irs.IID) (irs.ImageInfo, error)
- func (imageHandler *TencentImageHandler) ListImage() ([]*irs.ImageInfo, error)
- type TencentKeyPairHandler
- func (keyPairHandler *TencentKeyPairHandler) CheckKeyPairFolder(keyPairPath string) error
- func (keyPairHandler *TencentKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error)
- func (keyPairHandler *TencentKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error)
- func (keyPairHandler *TencentKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo, error)
- func (keyPairHandler *TencentKeyPairHandler) GetLocalKeyId(keyIID irs.IID) (string, error)
- func (keyPairHandler *TencentKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error)
- type TencentSecurityHandler
- func (securityHandler *TencentSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error)
- func (securityHandler *TencentSecurityHandler) DeleteSecurity(securityIID irs.IID) (bool, error)
- func (securityHandler *TencentSecurityHandler) ExtractPolicyGroups(policyGroups []*vpc.SecurityGroupPolicy, direction string) ([]irs.SecurityRuleInfo, error)
- func (securityHandler *TencentSecurityHandler) GetSecurity(securityIID irs.IID) (irs.SecurityInfo, error)
- func (securityHandler *TencentSecurityHandler) GetSecurityRuleInfo(securityIID irs.IID) (*[]irs.SecurityRuleInfo, error)
- func (securityHandler *TencentSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, error)
- type TencentVMHandler
- func (vmHandler *TencentVMHandler) ExtractDescribeInstances(curVm *cvm.Instance) (irs.VMInfo, error)
- func (vmHandler *TencentVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error)
- func (vmHandler *TencentVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *TencentVMHandler) ListVM() ([]*irs.VMInfo, error)
- func (vmHandler *TencentVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)
- func (vmHandler *TencentVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *TencentVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error)
- func (vmHandler *TencentVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *TencentVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *TencentVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error)
- type TencentVPCHandler
- func (VPCHandler *TencentVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.SubnetInfo) (irs.VPCInfo, error)
- func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error)
- func (VPCHandler *TencentVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error)
- func (VPCHandler *TencentVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error)
- func (VPCHandler *TencentVPCHandler) ListSubnet(reqVpcId string) ([]irs.SubnetInfo, error)
- func (VPCHandler *TencentVPCHandler) ListVPC() ([]*irs.VPCInfo, error)
- func (VPCHandler *TencentVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID) (bool, error)
- type TencentVmSpecHandler
- func (vmSpecHandler *TencentVmSpecHandler) GetOrgVMSpec(Region string, Name string) (string, error)
- func (vmSpecHandler *TencentVmSpecHandler) GetVMSpec(Region string, Name string) (irs.VMSpecInfo, error)
- func (vmSpecHandler *TencentVmSpecHandler) ListOrgVMSpec(Region string) (string, error)
- func (vmSpecHandler *TencentVmSpecHandler) ListVMSpec(Region string) ([]*irs.VMSpecInfo, error)
Constants ¶
const CBCloudInitFilePath string = "/cloud-driver-libs/.cloud-init-tencent/cloud-init"
const CBDefaultCidrBlock string = "192.168.0.0/16" // CB Default CidrBlock
const CBDefaultSubnetName string = "CB-VNet-Subnet" // CB Default Subnet Name
const CBDefaultVNetName string = "CB-VNet" // CB Default Virtual Network Name
const CBDefaultVmUserName string = "cb-user" // default VM User Name
const CBKeyPairPath string = "/cloud-driver-libs/.ssh-tencent/"
const CUSTOM_ERR_CODE_NOTFOUND string = "404" //awserr.New("404", "XXX 정보가 존재하지 않습니다.", nil)
const CUSTOM_ERR_CODE_TOOMANY string = "600" //awserr.New("600", "n개 이상의 xxxx 정보가 존재합니다.", nil)
Variables ¶
This section is empty.
Functions ¶
func ConvertJsonString ¶
Cloud Object를 JSON String 타입으로 변환
func ConvertJsonStringNoEscape ¶
Cloud Object를 JSON String 타입으로 변환
func ConvertKeyValueList ¶
Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용
func ConvertToString ¶
CB-KeyValue 등을 위해 String 타입으로 변환
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 ExtractKeyPairDescribeInfo ¶
func ExtractKeyPairDescribeInfo(keyPair *cvm.KeyPair) (irs.KeyPairInfo, error)
KeyPair 정보를 추출함
func ExtractVMSpecInfo ¶
func ExtractVMSpecInfo(instanceTypeInfo *cvm.InstanceTypeConfig) irs.VMSpecInfo
인스턴스 스펙 정보를 추출함
func GetCBDefaultCidrBlock ¶
func GetCBDefaultCidrBlock() string
func JSONMarshal ¶
Types ¶
type TencentCBNetworkInfo ¶
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)
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 (*TencentVMHandler) GetVMStatus ¶
func (*TencentVMHandler) ListVM ¶
func (vmHandler *TencentVMHandler) ListVM() ([]*irs.VMInfo, error)
func (*TencentVMHandler) ListVMStatus ¶
func (vmHandler *TencentVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)
func (*TencentVMHandler) TerminateVM ¶
func (*TencentVMHandler) WaitForRun ¶
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) ListSubnet ¶
func (VPCHandler *TencentVPCHandler) ListSubnet(reqVpcId string) ([]irs.SubnetInfo, error)
func (*TencentVPCHandler) ListVPC ¶
func (VPCHandler *TencentVPCHandler) ListVPC() ([]*irs.VPCInfo, error)
func (*TencentVPCHandler) RemoveSubnet ¶
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로 조회해야 함.)