resources

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 16 Imported by: 1

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 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 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 Connect

func Connect(region string) *ec2.EC2

func ConvertJsonString

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

Cloud Object를 JSON String 타입으로 변환

func ConvertJsonStringNoEscape added in v0.1.2

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 ExtractGpuInfo

func ExtractGpuInfo(gpuDeviceInfo *ec2.GpuDeviceInfo) irs.GpuInfo

func ExtractImageDescribeInfo

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

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 ExtractVmName(Tags []*ec2.Tag) string

func ExtractVpcDescribeInfo

func ExtractVpcDescribeInfo(vpcInfo *ec2.Vpc) irs.VPCInfo
type VPCInfo struct {
	IId   IID       // {NameId, SystemId}
	IPv4_CIDR string
	SubnetInfoList []SubnetInfo

	KeyValueList []KeyValue
}

VPC 정보를 추출함

func GetCBDefaultCidrBlock

func GetCBDefaultCidrBlock() string

func GetCBDefaultSubnetName

func GetCBDefaultSubnetName() string

Subnet

func GetCBDefaultVNetName

func GetCBDefaultVNetName() string

VPC

func JSONMarshal added in v0.1.2

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

func SetNameTag

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

Name Tag 설정

func WaitForRun

func WaitForRun(svc *ec2.EC2, instanceID string)

VM이 Running 상태일때까지 대기 함.

Types

type AwsCBNetworkInfo

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

	SubnetName string
	SubnetId   string
}

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 찾아야 함.

func (*AwsImageHandler) GetImage

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

func (imageHandler *AwsImageHandler) GetImage(imageID string) (irs.ImageInfo, error) {

func (*AwsImageHandler) ListImage

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

@TODO : 목록이 너무 많기 때문에 amazon 계정으로 공유된 퍼블릭 이미지중 AMI만 조회 함.

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

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

2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. func (vmHandler *AwsVMHandler) GetVM(vmNameId string) (irs.VMInfo, error) {

func (*AwsVMHandler) GetVMStatus

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

SHUTTING-DOWN / TERMINATED func (vmHandler *AwsVMHandler) GetVMStatus(vmNameId string) (irs.VMStatus, error) {

func (*AwsVMHandler) ListVM

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

func (*AwsVMHandler) ListVMStatus

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

func (*AwsVMHandler) RebootVM

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

func (vmHandler *AwsVMHandler) RebootVM(vmNameId string) (irs.VMStatus, error) {

func (*AwsVMHandler) ResumeVM

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

func (vmHandler *AwsVMHandler) ResumeVM(vmNameId string) (irs.VMStatus, error) {

func (*AwsVMHandler) StartVM

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

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(vmIID irs.IID) (irs.VMStatus, error)

func (vmHandler *AwsVMHandler) SuspendVM(vmNameId string) (irs.VMStatus, error) {

func (*AwsVMHandler) TerminateVM

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

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) AddSubnet added in v0.2.1

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

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 라우터를 제거 함. #255예외 처리 보완에 따른 라우팅 정보 삭제전 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)

https://docs.aws.amazon.com/ko_kr/vpc/latest/userguide/VPC_Route_Tables.html https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRouteTables.html 자동 생성된 VPC의 기본 라우팅 테이블 정보를 찾음

func (*AwsVPCHandler) GetSubnet added in v0.1.3

func (VPCHandler *AwsVPCHandler) GetSubnet(reqSubnetId string) (irs.SubnetInfo, error)

func (*AwsVPCHandler) GetVPC added in v0.1.3

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

func (*AwsVPCHandler) ListSubnet added in v0.1.3

func (VPCHandler *AwsVPCHandler) ListSubnet(vpcId string) ([]irs.SubnetInfo, error)

VPC의 하위 서브넷 목록을 조회함.

func (*AwsVPCHandler) ListVPC added in v0.1.3

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

func (*AwsVPCHandler) RemoveSubnet added in v0.2.1

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

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) ListOrgVMSpecOld added in v0.2.1

func (vmSpecHandler *AwsVmSpecHandler) ListOrgVMSpecOld(Region string) (string, error)

AWS의 정보 그대로를 가공 없이 JSON으로 리턴 함.

func (*AwsVmSpecHandler) ListVMSpec

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

func (*AwsVmSpecHandler) ListVMSpecAZ added in v0.2.1

func (vmSpecHandler *AwsVmSpecHandler) ListVMSpecAZ(ZoneName string) (map[string]string, error)

해당 Zone의 스펙 ID 목록을 조회함.

Jump to

Keyboard shortcuts

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