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 Connect(region string) *ec2.EC2
- 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 ExtractGpuInfo(gpuDeviceInfo *ec2.GpuDeviceInfo) irs.GpuInfo
- func ExtractImageDescribeInfo(image *ec2.Image) irs.ImageInfo
- func ExtractIpPermissionCommon(ip *ec2.IpPermission, securityRuleInfo *irs.SecurityRuleInfo)
- func ExtractIpPermissions(ipPermissions []*ec2.IpPermission, direction string) []irs.SecurityRuleInfo
- func ExtractKeyPairDescribeInfo(keyPair *ec2.KeyPairInfo) irs.KeyPairInfo
- func ExtractSecurityInfo(securityGroupResult *ec2.SecurityGroup) irs.SecurityInfo
- func ExtractSubnetDescribeInfo(subnetInfo *ec2.Subnet) irs.SubnetInfo
- func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) irs.VMSpecInfo
- func ExtractVmName(Tags []*ec2.Tag) string
- func ExtractVpcDescribeInfo(vpcInfo *ec2.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
- func WaitForRun(svc *ec2.EC2, instanceID string)
- type AwsCBNetworkInfo
- type AwsImageHandler
- func (imageHandler *AwsImageHandler) CreateImage(imageReqInfo irs.ImageReqInfo) (irs.ImageInfo, error)
- func (imageHandler *AwsImageHandler) DeleteImage(imageIID irs.IID) (bool, error)
- func (imageHandler *AwsImageHandler) GetImage(imageIID irs.IID) (irs.ImageInfo, error)
- func (imageHandler *AwsImageHandler) ListImage() ([]*irs.ImageInfo, error)
- type AwsKeyPairHandler
- func (keyPairHandler *AwsKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error)
- func (keyPairHandler *AwsKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error)
- func (keyPairHandler *AwsKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo, error)
- func (keyPairHandler *AwsKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error)
- type AwsSecurityHandler
- func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error)
- func (securityHandler *AwsSecurityHandler) DeleteSecurity(securityIID irs.IID) (bool, error)
- func (securityHandler *AwsSecurityHandler) GetSecurity(securityIID irs.IID) (irs.SecurityInfo, error)
- func (securityHandler *AwsSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, error)
- type AwsVMHandler
- func (vmHandler *AwsVMHandler) AssociatePublicIP(allocationId string, instanceId string) (bool, error)
- func (vmHandler *AwsVMHandler) AttachNetworkInterface(vNicId string, instanceId string) (bool, error)
- func (vmHandler *AwsVMHandler) ExtractDescribeInstances(reservation *ec2.Reservation) irs.VMInfo
- func (vmHandler *AwsVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error)
- func (vmHandler *AwsVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *AwsVMHandler) ListVM() ([]*irs.VMInfo, error)
- func (vmHandler *AwsVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)
- func (vmHandler *AwsVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *AwsVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error)
- func (vmHandler *AwsVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error)
- func (vmHandler *AwsVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, error)
- type AwsVPCHandler
- func (VPCHandler *AwsVPCHandler) AssociateRouteTable(vpcId string, subnetId string) error
- func (VPCHandler *AwsVPCHandler) CreateRouteIGW(vpcId string, igwId string) error
- func (VPCHandler *AwsVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.SubnetInfo) (irs.SubnetInfo, error)
- func (VPCHandler *AwsVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error)
- func (VPCHandler *AwsVPCHandler) DeleteAllIGW(vpcId string) error
- func (VPCHandler *AwsVPCHandler) DeleteIGW(igwId string) error
- func (VPCHandler *AwsVPCHandler) DeleteRouteIGW(vpcId string) error
- func (VPCHandler *AwsVPCHandler) DeleteSubnet(subnetIID irs.IID) (bool, error)
- func (VPCHandler *AwsVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error)
- func (VPCHandler *AwsVPCHandler) DetachInternetGateway(vpcId string, igwId string) error
- func (VPCHandler *AwsVPCHandler) GetDefaultRouteTable(vpcId string) (string, error)
- func (VPCHandler *AwsVPCHandler) GetSubnet(reqSubnetId string) (irs.SubnetInfo, error)
- func (VPCHandler *AwsVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error)
- func (VPCHandler *AwsVPCHandler) ListSubnet(vpcId string) ([]irs.SubnetInfo, error)
- func (VPCHandler *AwsVPCHandler) ListVPC() ([]*irs.VPCInfo, error)
- type AwsVmSpecHandler
- func (vmSpecHandler *AwsVmSpecHandler) GetOrgVMSpec(Region string, Name string) (string, error)
- func (vmSpecHandler *AwsVmSpecHandler) GetVMSpec(Region string, Name string) (irs.VMSpecInfo, error)
- func (vmSpecHandler *AwsVmSpecHandler) ListOrgVMSpec(Region string) (string, error)
- func (vmSpecHandler *AwsVmSpecHandler) ListVMSpec(Region string) ([]*irs.VMSpecInfo, error)
Constants ¶
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 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 ¶ added in v0.1.2
Cloud Object를 JSON String 타입으로 변환
func ConvertKeyValueList ¶
Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용
func ConvertToString ¶
CB-KeyValue 등을 위해 String 타입으로 변환
func ExtractGpuInfo ¶
func ExtractGpuInfo(gpuDeviceInfo *ec2.GpuDeviceInfo) irs.GpuInfo
func ExtractImageDescribeInfo ¶
Image 정보를 추출함 @TODO : GuestOS 쳌크할 것
func ExtractIpPermissionCommon ¶
func ExtractIpPermissionCommon(ip *ec2.IpPermission, securityRuleInfo *irs.SecurityRuleInfo)
IpPermission에서 공통정보 추출
func ExtractIpPermissions ¶
func ExtractIpPermissions(ipPermissions []*ec2.IpPermission, direction string) []irs.SecurityRuleInfo
func ExtractKeyPairDescribeInfo ¶
func ExtractKeyPairDescribeInfo(keyPair *ec2.KeyPairInfo) irs.KeyPairInfo
KeyPair 정보를 추출함
func ExtractSecurityInfo ¶
func ExtractSecurityInfo(securityGroupResult *ec2.SecurityGroup) irs.SecurityInfo
func ExtractSubnetDescribeInfo ¶
func ExtractSubnetDescribeInfo(subnetInfo *ec2.Subnet) irs.SubnetInfo
Subnet 정보를 추출함
func ExtractVMSpecInfo ¶
func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) irs.VMSpecInfo
인스턴스 스펙 정보를 추출함
func ExtractVmName ¶
func ExtractVpcDescribeInfo ¶
type VPCInfo struct { IId IID // {NameId, SystemId} IPv4_CIDR string SubnetInfoList []SubnetInfo KeyValueList []KeyValue }
VPC 정보를 추출함
func GetCBDefaultCidrBlock ¶
func GetCBDefaultCidrBlock() string
func JSONMarshal ¶ added in v0.1.2
Types ¶
type AwsCBNetworkInfo ¶
type AwsImageHandler ¶
type AwsImageHandler struct { Region idrv.RegionInfo Client *ec2.EC2 }
func (*AwsImageHandler) CreateImage ¶
func (imageHandler *AwsImageHandler) CreateImage(imageReqInfo irs.ImageReqInfo) (irs.ImageInfo, error)
@TODO : 작업해야 함.
func (*AwsImageHandler) DeleteImage ¶
func (imageHandler *AwsImageHandler) DeleteImage(imageIID irs.IID) (bool, error)
@TODO : 삭제 API 찾아야 함.
type AwsKeyPairHandler ¶
type AwsKeyPairHandler struct { Region idrv.RegionInfo Client *ec2.EC2 }
func (*AwsKeyPairHandler) CreateKey ¶
func (keyPairHandler *AwsKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error)
func (*AwsKeyPairHandler) DeleteKey ¶
func (keyPairHandler *AwsKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error)
func (*AwsKeyPairHandler) GetKey ¶
func (keyPairHandler *AwsKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo, error)
혼선을 피하기 위해 keyPairID 대신 keyName으로 변경 함.
func (*AwsKeyPairHandler) ListKey ¶
func (keyPairHandler *AwsKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error)
type AwsSecurityHandler ¶
type AwsSecurityHandler struct { Region idrv.RegionInfo Client *ec2.EC2 }
func (*AwsSecurityHandler) CreateSecurity ¶
func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error)
2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. (보안 그룹은 그룹명으로 처리 가능하기 때문에 Name 태깅시 에러는 무시함) @TODO : 존재하는 보안 그룹에 정책 추가하는 기능 필요 VPC 생략 시 활성화된 세션의 기본 VPC를 이용 함.
func (*AwsSecurityHandler) DeleteSecurity ¶
func (securityHandler *AwsSecurityHandler) DeleteSecurity(securityIID irs.IID) (bool, error)
2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. func (securityHandler *AwsSecurityHandler) DeleteSecurity(securityNameId string) (bool, error) {
func (*AwsSecurityHandler) GetSecurity ¶
func (securityHandler *AwsSecurityHandler) GetSecurity(securityIID irs.IID) (irs.SecurityInfo, error)
2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. func (securityHandler *AwsSecurityHandler) GetSecurity(securityNameId string) (irs.SecurityInfo, error) {
func (*AwsSecurityHandler) ListSecurity ¶
func (securityHandler *AwsSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, error)
type AwsVMHandler ¶
type AwsVMHandler struct { Region idrv.RegionInfo Client *ec2.EC2 }
func (*AwsVMHandler) AssociatePublicIP ¶
func (vmHandler *AwsVMHandler) AssociatePublicIP(allocationId string, instanceId string) (bool, error)
AssociationId 대신 PublicIP로도 가능 함.
func (*AwsVMHandler) AttachNetworkInterface ¶
func (vmHandler *AwsVMHandler) AttachNetworkInterface(vNicId string, instanceId string) (bool, error)
전달 받은 vNic을 VM에 추가함.
func (*AwsVMHandler) ExtractDescribeInstances ¶
func (vmHandler *AwsVMHandler) ExtractDescribeInstances(reservation *ec2.Reservation) irs.VMInfo
DescribeInstances결과에서 EC2 세부 정보 추출 VM 생성 시에는 Running 이전 상태의 정보가 넘어오기 때문에 최종 정보 기반으로 리턴 받고 싶으면 GetVM에 통합해야 할 듯.
func (*AwsVMHandler) GetVM ¶
2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. func (vmHandler *AwsVMHandler) GetVM(vmNameId string) (irs.VMInfo, error) {
func (*AwsVMHandler) GetVMStatus ¶
SHUTTING-DOWN / TERMINATED func (vmHandler *AwsVMHandler) GetVMStatus(vmNameId string) (irs.VMStatus, error) {
func (*AwsVMHandler) ListVMStatus ¶
func (vmHandler *AwsVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)
func (*AwsVMHandler) RebootVM ¶
func (vmHandler *AwsVMHandler) RebootVM(vmNameId string) (irs.VMStatus, error) {
func (*AwsVMHandler) ResumeVM ¶
func (vmHandler *AwsVMHandler) ResumeVM(vmNameId string) (irs.VMStatus, error) {
func (*AwsVMHandler) StartVM ¶
1개의 VM만 생성되도록 수정 (MinCount / MaxCount 이용 안 함) 키페어 이름(예:mcloud-barista)은 아래 URL에 나오는 목록 중 "키페어 이름"의 값을 적으면 됨. https://ap-northeast-2.console.aws.amazon.com/ec2/v2/home?region=ap-northeast-2#KeyPairs:sort=keyName
func (*AwsVMHandler) SuspendVM ¶
func (vmHandler *AwsVMHandler) SuspendVM(vmNameId string) (irs.VMStatus, error) {
func (*AwsVMHandler) TerminateVM ¶
func (vmHandler *AwsVMHandler) TerminateVM(vmNameId string) (irs.VMStatus, error) {
type AwsVPCHandler ¶ added in v0.1.3
type AwsVPCHandler struct { Region idrv.RegionInfo Client *ec2.EC2 }
func (*AwsVPCHandler) AssociateRouteTable ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) AssociateRouteTable(vpcId string, subnetId string) error
VPC의 라우팅 테이블에 생성된 Subnet을 연결 함.
func (*AwsVPCHandler) CreateRouteIGW ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) CreateRouteIGW(vpcId string, igwId string) error
생성된 VPC의 라우팅 테이블에 IGW(Internet Gateway) 라우팅 정보를 생성함 (AWS 콘솔의 라우팅 테이블의 [라우팅] Tab 처리)
func (*AwsVPCHandler) CreateSubnet ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.SubnetInfo) (irs.SubnetInfo, error)
func (*AwsVPCHandler) CreateVPC ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error)
func (*AwsVPCHandler) DeleteAllIGW ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) DeleteAllIGW(vpcId string) error
VPC에 연결된 모든 IGW를 삭제함.
func (*AwsVPCHandler) DeleteIGW ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) DeleteIGW(igwId string) error
IGW를 삭제 함.
func (*AwsVPCHandler) DeleteRouteIGW ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) DeleteRouteIGW(vpcId string) error
VPC에 설정된 0.0.0.0/0 라우터를 제거 함.
func (*AwsVPCHandler) DeleteSubnet ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) DeleteSubnet(subnetIID irs.IID) (bool, error)
func (*AwsVPCHandler) DeleteVPC ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error)
func (*AwsVPCHandler) DetachInternetGateway ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) DetachInternetGateway(vpcId string, igwId string) error
VPC에 연결된 IGW의 연결을 해제함.
func (*AwsVPCHandler) GetDefaultRouteTable ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) GetDefaultRouteTable(vpcId string) (string, error)
자동 생성된 VPC의 기본 라우팅 테이블 정보를 찾음
func (*AwsVPCHandler) GetSubnet ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) GetSubnet(reqSubnetId string) (irs.SubnetInfo, error)
func (*AwsVPCHandler) ListSubnet ¶ added in v0.1.3
func (VPCHandler *AwsVPCHandler) ListSubnet(vpcId string) ([]irs.SubnetInfo, error)
VPC의 하위 서브넷 목록을 조회함.
type AwsVmSpecHandler ¶
type AwsVmSpecHandler struct { Region idrv.RegionInfo Client *ec2.EC2 }
https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeInstanceTypes
func (*AwsVmSpecHandler) GetOrgVMSpec ¶
func (vmSpecHandler *AwsVmSpecHandler) GetOrgVMSpec(Region string, Name string) (string, error)
AWS의 정보 그대로를 가공 없이 JSON으로 리턴 함.
func (*AwsVmSpecHandler) GetVMSpec ¶
func (vmSpecHandler *AwsVmSpecHandler) GetVMSpec(Region string, Name string) (irs.VMSpecInfo, error)
func (*AwsVmSpecHandler) ListOrgVMSpec ¶
func (vmSpecHandler *AwsVmSpecHandler) ListOrgVMSpec(Region string) (string, error)
AWS의 정보 그대로를 가공 없이 JSON으로 리턴 함.
func (*AwsVmSpecHandler) ListVMSpec ¶
func (vmSpecHandler *AwsVmSpecHandler) ListVMSpec(Region string) ([]*irs.VMSpecInfo, error)