Skip to content

Commit

Permalink
개선 기능및 이슈 #348에 의한 AWS RootDisk 설정 기능 추가 및 테스트
Browse files Browse the repository at this point in the history
사용 가능 디스크 타입 : standard/io1/io2/gp2/sc1/st1/gp3
Default 스토리지 : 8GB
AWS는 디스크 타입 및 디스크 사이즈 개별 지정 가능
ap-northeast-1a리전에서 t2.micro 스펙으로 테스트 했음.
VMSpecName: "t2.micro"
RootDiskType: ""
RootDiskSize: ""
--> gp2, 8GB

VMSpecName: "t2.micro"
RootDiskType: "standard"
--> standard, 8GB

VMSpecName: "t2.micro"
RootDiskSize: "12"
--> gp2, 12GB

VMSpecName: "t2.micro"
RootDiskSize: "default"
--> gp2, 8GB

VMSpecName: "t2.micro"
RootDiskType: "gp3",
RootDiskSize: "Default",
--> gp3, 8GB

VMSpecName: "t2.micro"
RootDiskType: "standard",
RootDiskSize: "6", //Image Size(8GB) 보다 작으면 에러 남
--> Volume of size 6GB is smaller than  snapshot 'snap-095f9b3409e0b354e', expect size >= 8GB

VMSpecName: "t2.micro"
RootDiskType: "standard",
RootDiskSize: "60",
--> standard, 60GB
  • Loading branch information
dev4unet committed Nov 10, 2021
1 parent 89c9dc1 commit 80a30f5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,11 @@ func handleVM() {
VMSpecName: "t2.micro",
KeyPairIID: irs.IID{SystemId: "japan-test"},

//RootDiskType: "pd-ssd", //standard/io1/io2/gp2/sc1/st1/gp3
//RootDiskType: "pd-balanced", //pd-standard/pd-balanced/pd-ssd/pd-extreme
RootDiskSize: "15", //최소 10GB 이상이어야 함.
//RootDiskSize: "default", //10GB
RootDiskType: "standard", //gp2/standard/io1/io2/sc1/st1/gp3
//RootDiskType: "gp2", //gp2/standard/io1/io2/sc1/st1/gp3
//RootDiskType: "gp3", //gp2/standard/io1/io2/sc1/st1/gp3
RootDiskSize: "60", //최소 8GB 이상이어야 함.
//RootDiskSize: "Default", //8GB
}

vmInfo, err := vmHandler.StartVM(vmReqInfo)
Expand All @@ -921,6 +922,7 @@ func handleVM() {
} else {
cblogger.Info("VM 생성 완료!!", vmInfo)
spew.Dump(vmInfo)
VmID = vmInfo.IId
}
//cblogger.Info(vm)

Expand Down Expand Up @@ -1132,11 +1134,11 @@ func main() {
//handleKeyPair()
//handlePublicIP() // PublicIP 생성 후 conf
//handleSecurity()
//handleVM()
handleVM()

//handleImage() //AMI
//handleVNic() //Lancard
handleVMSpec()
//handleVMSpec()
}

//handlerType : resources폴더의 xxxHandler.go에서 Handler이전까지의 문자열
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"io/ioutil"
"os"
"reflect"
"strconv"
"strings"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -191,7 +192,52 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err
//ec2.InstanceNetworkInterfaceSpecification
UserData: userDataBase64,
}
cblogger.Info(input)

//=============================
// SystemDisk 처리 - 이슈 #348에 의해 RootDisk 기능 지원
//=============================
if vmReqInfo.RootDiskType != "" || vmReqInfo.RootDiskSize != "" {
blockDeviceMappings := []*ec2.BlockDeviceMapping{
{
DeviceName: aws.String("/dev/sda1"),
//DeviceName: aws.String("/dev/sdh"),
Ebs: &ec2.EbsBlockDevice{
//RootDeviceName
//VolumeType: aws.String(diskType),
//VolumeSize: diskSize,
},
},
}
input.SetBlockDeviceMappings(blockDeviceMappings)

//=============================
// Root Disk Type 변경
//=============================
if vmReqInfo.RootDiskType != "" {
//diskType = vmReqInfo.RootDiskType
input.BlockDeviceMappings[0].Ebs.VolumeType = aws.String(vmReqInfo.RootDiskType)
}

//=============================
// Root Disk Size 변경
//=============================
if vmReqInfo.RootDiskSize != "" {
if strings.EqualFold(vmReqInfo.RootDiskSize, "default") {
input.BlockDeviceMappings[0].Ebs.VolumeSize = aws.Int64(8)
} else {
iDiskSize, err := strconv.ParseInt(vmReqInfo.RootDiskSize, 10, 64)
if err != nil {
cblogger.Error(err)
return irs.VMInfo{}, err
}
//diskSize = aws.Int64(iDiskSize)
//input.BlockDeviceMappings[0].Ebs.VolumeSize = diskSize
input.BlockDeviceMappings[0].Ebs.VolumeSize = aws.Int64(iDiskSize)
}
}
}

cblogger.Debug(input)

// logger for HisCall
callogger := call.GetLogger("HISCALL")
Expand Down

0 comments on commit 80a30f5

Please sign in to comment.