diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/AlibabaDriver.go b/cloud-control-manager/cloud-driver/drivers/alibaba/AlibabaDriver.go index 000123373..557b047de 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/AlibabaDriver.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/AlibabaDriver.go @@ -11,13 +11,12 @@ package alibaba import ( - "fmt" - cs2015 "github.com/alibabacloud-go/cs-20151215/v4/client" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" ecs2014 "github.com/alibabacloud-go/ecs-20140526/v4/client" "github.com/alibabacloud-go/tea/tea" vpc2016 "github.com/alibabacloud-go/vpc-20160428/v6/client" + "github.com/sirupsen/logrus" "github.com/aliyun/alibaba-cloud-sdk-go/services/bssopenapi" "github.com/aliyun/alibaba-cloud-sdk-go/services/slb" @@ -28,13 +27,19 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" "github.com/aliyun/alibaba-cloud-sdk-go/services/vpc" + cblogger "github.com/cloud-barista/cb-log" alicon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/alibaba/connect" alirs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/alibaba/resources" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" icon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/connect" - "github.com/davecgh/go-spew/spew" ) +var cblog *logrus.Logger + +func init() { + cblog = cblogger.GetLogger("CLOUD-BARISTA") +} + type AlibabaDriver struct{} func (AlibabaDriver) GetDriverVersion() string { @@ -132,7 +137,7 @@ func (driver *AlibabaDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) (i func getECSClient(connectionInfo idrv.ConnectionInfo) (*ecs.Client, error) { // Region Info - fmt.Println("AlibabaDriver : getECSClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + cblog.Info("AlibabaDriver : getECSClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") /* // Customize config @@ -142,8 +147,6 @@ func getECSClient(connectionInfo idrv.ConnectionInfo) (*ecs.Client, error) { WithMaxTaskQueueSize(1000) // 600*time.Second - //fmt.Println(config) - spew.Dump(config) */ // Create a credential object @@ -169,13 +172,10 @@ func getECSClient(connectionInfo idrv.ConnectionInfo) (*ecs.Client, error) { escClient, err := ecs.NewClientWithOptions(connectionInfo.RegionInfo.Region, config, credential) if err != nil { - fmt.Println("Could not create alibaba's ecs service client", err) - spew.Dump(err) + cblog.Error("Could not create alibaba's ecs service client", err) return nil, err } - //spew.Dump(escClient) - /* escClient, err := sdk.NewClientWithAccessKey("REGION_ID", "ACCESS_KEY_ID", "ACCESS_KEY_SECRET") if err != nil { @@ -190,7 +190,7 @@ func getECSClient(connectionInfo idrv.ConnectionInfo) (*ecs.Client, error) { func getVPCClient(connectionInfo idrv.ConnectionInfo) (*vpc.Client, error) { // Region Info - fmt.Println("AlibabaDriver : getVPCClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + cblog.Info("AlibabaDriver : getVPCClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") /* // Customize config @@ -199,7 +199,7 @@ func getVPCClient(connectionInfo idrv.ConnectionInfo) (*vpc.Client, error) { WithGoRoutinePoolSize(5). WithMaxTaskQueueSize(1000) // 600*time.Second - //fmt.Println(config) + */ // Create a credential object @@ -224,7 +224,7 @@ func getVPCClient(connectionInfo idrv.ConnectionInfo) (*vpc.Client, error) { //vpcClient, err := vpc.NewClientWithAccessKey(connectionInfo.RegionInfo.Region, credential.AccessKeyId, credential.AccessKeySecret) vpcClient, err := vpc.NewClientWithOptions(connectionInfo.RegionInfo.Region, config, credential) if err != nil { - fmt.Println("Could not create alibaba's vpc service client", err) + cblog.Error("Could not create alibaba's vpc service client", err) return nil, err } @@ -234,7 +234,7 @@ func getVPCClient(connectionInfo idrv.ConnectionInfo) (*vpc.Client, error) { func getNLBClient(connectionInfo idrv.ConnectionInfo) (*slb.Client, error) { // Region Info - fmt.Println("AlibabaDriver : getNLBClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + cblog.Info("AlibabaDriver : getNLBClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") credential := &credentials.AccessKeyCredential{ AccessKeyId: connectionInfo.CredentialInfo.ClientId, @@ -249,7 +249,7 @@ func getNLBClient(connectionInfo idrv.ConnectionInfo) (*slb.Client, error) { nlbClient, err := slb.NewClientWithOptions(connectionInfo.RegionInfo.Region, config, credential) if err != nil { - fmt.Println("Could not create alibaba's server loadbalancer service client", err) + cblog.Error("Could not create alibaba's server loadbalancer service client", err) return nil, err } @@ -258,7 +258,7 @@ func getNLBClient(connectionInfo idrv.ConnectionInfo) (*slb.Client, error) { func getBssClient(connectionInfo idrv.ConnectionInfo) (*bssopenapi.Client, error) { // Region Info - fmt.Println("AlibabaDriver : getBssClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + cblog.Info("AlibabaDriver : getBssClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") credential := &credentials.AccessKeyCredential{ AccessKeyId: connectionInfo.CredentialInfo.ClientId, @@ -298,7 +298,7 @@ func getBssClient(connectionInfo idrv.ConnectionInfo) (*bssopenapi.Client, error bssClient, err := bssopenapi.NewClientWithOptions(targetRegion, config, credential) if err != nil { - fmt.Println("Could not create alibaba's server bss open api client", err) + cblog.Error("Could not create alibaba's server bss open api client", err) return nil, err } @@ -308,7 +308,7 @@ func getBssClient(connectionInfo idrv.ConnectionInfo) (*bssopenapi.Client, error func getVpc2016Client(connectionInfo idrv.ConnectionInfo) (*vpc2016.Client, error) { // Region Info - fmt.Println("AlibabaDriver : getVpc2016Client() - Region : [" + connectionInfo.RegionInfo.Region + "]") + cblog.Info("AlibabaDriver : getVpc2016Client() - Region : [" + connectionInfo.RegionInfo.Region + "]") config := &openapi.Config{ AccessKeyId: tea.String(connectionInfo.CredentialInfo.ClientId), @@ -318,7 +318,7 @@ func getVpc2016Client(connectionInfo idrv.ConnectionInfo) (*vpc2016.Client, erro vpcClient, err := vpc2016.NewClient(config) if err != nil { - fmt.Println("Could not create alibaba's vpc service client", err) + cblog.Error("Could not create alibaba's vpc service client", err) return nil, err } @@ -328,7 +328,7 @@ func getVpc2016Client(connectionInfo idrv.ConnectionInfo) (*vpc2016.Client, erro func getCs2015Client(connectionInfo idrv.ConnectionInfo) (*cs2015.Client, error) { // Region Info - fmt.Println("AlibabaDriver : getCs2015Client() - Region : [" + connectionInfo.RegionInfo.Region + "]") + cblog.Info("AlibabaDriver : getCs2015Client() - Region : [" + connectionInfo.RegionInfo.Region + "]") config := &openapi.Config{ AccessKeyId: tea.String(connectionInfo.CredentialInfo.ClientId), @@ -338,7 +338,7 @@ func getCs2015Client(connectionInfo idrv.ConnectionInfo) (*cs2015.Client, error) csClient, err := cs2015.NewClient(config) if err != nil { - fmt.Println("Could not create alibaba's cs service client", err) + cblog.Error("Could not create alibaba's cs service client", err) return nil, err } @@ -348,7 +348,7 @@ func getCs2015Client(connectionInfo idrv.ConnectionInfo) (*cs2015.Client, error) func getEcs2014Client(connectionInfo idrv.ConnectionInfo) (*ecs2014.Client, error) { // Region Info - fmt.Println("AlibabaDriver : getEcs2014Client() - Region : [" + connectionInfo.RegionInfo.Region + "]") + cblog.Info("AlibabaDriver : getEcs2014Client() - Region : [" + connectionInfo.RegionInfo.Region + "]") config := &openapi.Config{ AccessKeyId: tea.String(connectionInfo.CredentialInfo.ClientId), @@ -358,7 +358,7 @@ func getEcs2014Client(connectionInfo idrv.ConnectionInfo) (*ecs2014.Client, erro ecsClient, err := ecs2014.NewClient(config) if err != nil { - fmt.Println("Could not create alibaba's ecs service client", err) + cblog.Error("Could not create alibaba's ecs service client", err) return nil, err } diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonAlibabaFunc.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonAlibabaFunc.go index 04bc023c0..4bcf8a0b7 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonAlibabaFunc.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonAlibabaFunc.go @@ -14,6 +14,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/davecgh/go-spew/spew" "reflect" "strconv" "sync" @@ -24,7 +25,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" "github.com/sirupsen/logrus" ) @@ -153,7 +153,7 @@ func SetNameTag(Client *ecs.Client, resourceId string, resourceType string, valu } _, errtag := Client.AddTags(request) if errtag != nil { - cblogger.Error("Name Tag 설정 실패 : ") + cblogger.Error("Name Tag setting failed: ") cblogger.Error(errtag) return false } @@ -165,7 +165,7 @@ func SetNameTag(Client *ecs.Client, resourceId string, resourceType string, valu func ConvertJsonString(v interface{}) (string, error) { jsonBytes, errJson := json.Marshal(v) if errJson != nil { - cblogger.Error("JSON 변환 실패") + cblogger.Error("JSON conversion failed") cblogger.Error(errJson) return "", errJson } @@ -203,14 +203,16 @@ func ConvertToString(value interface{}) (string, error) { // Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용 func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) { - spew.Dump(v) + if cblogger.Level.String() == "debug" { + spew.Dump(v) + } var keyValueList []irs.KeyValue var i map[string]interface{} jsonBytes, errJson := json.Marshal(v) if errJson != nil { - cblogger.Error("KeyValue 변환 실패") + cblogger.Error("KeyValue conversion failed") cblogger.Error(errJson) return nil, errJson } @@ -230,7 +232,7 @@ func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) { //value := fmt.Sprint(v) value, errString := ConvertToString(v) if errString != nil { - cblogger.Errorf("Key[%s]의 값은 변환 불가 - [%s]", k, errString) + cblogger.Errorf("The value for Key[%s] cannot be converted - [%s]", k, errString) continue } keyValueList = append(keyValueList, irs.KeyValue{k, value}) @@ -244,8 +246,8 @@ func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) { // array에 주어진 string이 있는지 체크 func ContainString(s []string, str string) bool { for _, v := range s { - cblogger.Info(v + " : " + str) - cblogger.Info(v == str) + cblogger.Debug(v + " : " + str) + cblogger.Debug(v == str) if v == str { return true } @@ -260,9 +262,9 @@ json 형태로 출력 func printToJson(class interface{}) { e, err := json.Marshal(class) if err != nil { - cblogger.Info(err) + cblogger.Error(err) } - cblogger.Info(string(e)) + cblogger.Debug(string(e)) } // irs.KeyValue 배열에서 특정 키를 가진 KeyValue 가 있는지 검사 diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonHandler.go index c59983564..9d45a0c24 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/CommonHandler.go @@ -83,7 +83,7 @@ func DescribeDisks(client *ecs.Client, regionInfo idrv.RegionInfo, instanceIID i resultDiskList = append(resultDiskList, result.Disks.Disk...) if CBPageOn { totalCount = len(resultDiskList) - cblogger.Infof("CSP 전체 Disk 갯수 : [%d] - 현재 페이지:[%d] - 누적 결과 개수:[%d]", result.TotalCount, curPage, totalCount) + cblogger.Infof("Total number of disks across CSP: [%d] - Current page: [%d] - Accumulated result count: [%d]", result.TotalCount, curPage, totalCount) if totalCount >= result.TotalCount { break } @@ -93,7 +93,7 @@ func DescribeDisks(client *ecs.Client, regionInfo idrv.RegionInfo, instanceIID i break } } - cblogger.Info(cblogger.Level.String()) + if cblogger.Level.String() == "debug" { spew.Dump(resultDiskList) } @@ -190,7 +190,7 @@ func DescribeAvailableResource(client *ecs.Client, regionId string, zoneId strin //request.DataDiskCategory = "cloud" //spew.Dump(request) result, err := client.DescribeAvailableResource(request) - cblogger.Info(result) + cblogger.Debug(result) if err != nil { cblogger.Errorf("DescribeAvailableResource %v.", err) } @@ -222,7 +222,7 @@ func DescribeAvailableSystemDisksByInstanceType(client *ecs.Client, regionId str request.InstanceType = insTanceType result, err := client.DescribeAvailableResource(request) - cblogger.Info(result) + cblogger.Debug(result) if err != nil { cblogger.Errorf("DescribeAvailableResource %v.", err) } @@ -267,7 +267,7 @@ func AttachDisk(client *ecs.Client, regionInfo idrv.RegionInfo, ownerVM irs.IID, callLogStart := call.Start() result, err := client.AttachDisk(request) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - cblogger.Info(result) + cblogger.Debug(result) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Error(call.String(callLogInfo)) diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/DiskHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/DiskHandler.go index b4fbc0e30..15fa0122a 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/DiskHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/DiskHandler.go @@ -2,7 +2,6 @@ package resources import ( "errors" - "fmt" "strconv" "strings" "time" @@ -284,7 +283,7 @@ func (diskHandler *AlibabaDiskHandler) ChangeDiskSize(diskIID irs.IID, size stri result, err := diskHandler.Client.ResizeDisk(request) hiscallInfo.ElapsedTime = call.Elapsed(start) - cblogger.Info(result) + cblogger.Debug(result) if err != nil { LoggingError(hiscallInfo, err) @@ -312,7 +311,7 @@ func (diskHandler *AlibabaDiskHandler) DeleteDisk(diskIID irs.IID) (bool, error) result, err := diskHandler.Client.DeleteDisk(request) hiscallInfo.ElapsedTime = call.Elapsed(start) - cblogger.Info(result) + cblogger.Debug(result) if err != nil { LoggingError(hiscallInfo, err) @@ -437,7 +436,7 @@ func (diskHandler *AlibabaDiskHandler) DetachDisk(diskIID irs.IID, ownerVM irs.I result, err := diskHandler.Client.DetachDisk(request) hiscallInfo.ElapsedTime = call.Elapsed(start) - cblogger.Info(result) + cblogger.Debug(result) if err != nil { LoggingError(hiscallInfo, err) @@ -531,12 +530,12 @@ func validateCreateDisk(diskReqInfo *irs.DiskInfo) error { } if reqDiskSize < diskSizeValue.diskMinSize { - fmt.Println("Disk Size Error!!: ", reqDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", reqDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be at least the default size (" + strconv.FormatInt(diskSizeValue.diskMinSize, 10) + " GB).") } if reqDiskSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", reqDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", reqDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be smaller than the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } @@ -606,12 +605,12 @@ func validateModifyDisk(diskReqInfo irs.DiskInfo, diskSize string) error { } if targetDiskSize < diskSizeValue.diskMinSize { - fmt.Println("Disk Size Error!!: ", targetDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", targetDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be at least the default size (" + strconv.FormatInt(diskSizeValue.diskMinSize, 10) + " GB).") } if targetDiskSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", targetDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", targetDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be smaller than the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/ImageHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/ImageHandler.go index 990b91126..9f84cb4d7 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/ImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/ImageHandler.go @@ -167,14 +167,14 @@ func (imageHandler *AlibabaImageHandler) ListImage() ([]*irs.ImageInfo, error) { //cnt := 0 for _, cur := range result.Images.Image { - cblogger.Debugf("[%s] Image 정보 처리", cur.ImageId) + cblogger.Debugf("[%s] Processing image information", cur.ImageId) imageInfo := ExtractImageDescribeInfo(&cur) imageInfoList = append(imageInfoList, &imageInfo) } if CBPageOn { totalCount = len(imageInfoList) - cblogger.Infof("CSP 전체 이미지 갯수 : [%d] - 현재 페이지:[%d] - 누적 결과 개수:[%d]", result.TotalCount, curPage, totalCount) + cblogger.Infof("Total number of images across CSP: [%d] - Current page: [%d] - Accumulated result count: [%d]", result.TotalCount, curPage, totalCount) if totalCount >= result.TotalCount { break } @@ -315,7 +315,7 @@ func (imageHandler *AlibabaImageHandler) DeleteImage(imageIID irs.IID) (bool, er callLogStart := call.Start() result, err := imageHandler.Client.DeleteImage(request) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - cblogger.Info(result) + cblogger.Debug(result) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Error(call.String(callLogInfo)) diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/KeyPairHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/KeyPairHandler.go index 2628ebcdf..b704014ac 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/KeyPairHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/KeyPairHandler.go @@ -84,7 +84,7 @@ func (keyPairHandler *AlibabaKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, erro } totalCount = len(keyPairList) - cblogger.Infof("CSP 전체 키페어 갯수 : [%d] - 현재 페이지:[%d] - 누적 결과 개수:[%d]", result.TotalCount, curPage, totalCount) + cblogger.Infof("Total number of key pairs across CSP: [%d] - Current page: [%d] - Accumulated result count: [%d]", result.TotalCount, curPage, totalCount) if totalCount >= result.TotalCount { break } @@ -143,7 +143,9 @@ func (keyPairHandler *AlibabaKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPai callogger.Info(call.String(callLogInfo)) cblogger.Infof("Created key pair %q %s\n%s\n", result.KeyPairName, result.KeyPairFingerPrint, result.PrivateKeyBody) - spew.Dump(result) + if cblogger.Level.String() == "debug" { + spew.Dump(result) + } /* 2021-10-27 이슈#480에 의해 Local Key 로직 제거 cblogger.Info("공개키 생성") @@ -235,9 +237,9 @@ func (keyPairHandler *AlibabaKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPair cblogger.Errorf("Unable to get key pair: %s, %v.", keyIID.SystemId, err) return irs.KeyPairInfo{}, nil } - callogger.Info(call.String(callLogInfo)) + callogger.Debug(call.String(callLogInfo)) - cblogger.Info("result : ", result) + cblogger.Debug("result : ", result) if result.TotalCount < 1 { return irs.KeyPairInfo{}, errors.New("Notfound: '" + keyIID.SystemId + "' KeyPair Not found") } @@ -342,7 +344,7 @@ func (keyPairHandler *AlibabaKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, er } callogger.Info(call.String(callLogInfo)) - cblogger.Info(result) + cblogger.Debug(result) cblogger.Infof("Successfully deleted %q Alibaba Cloud key pair\n", keyIID.SystemId) /* 2021-10-27 이슈#480에 의해 Local Key 로직 제거 diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/MyImageHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/MyImageHandler.go index d2b26c5c0..437c5a2ea 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/MyImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/MyImageHandler.go @@ -85,7 +85,7 @@ func (myImageHandler AlibabaMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyIma } return irs.MyImageInfo{}, errStatus } - cblogger.Info("==>생성된 Image[%s]의 현재 상태[%s]", imageIID, curStatus) + cblogger.Info("==> Current status [%s] of the created image [%s]", imageIID, curStatus) myImageInfo, err := myImageHandler.GetMyImage(imageIID) return myImageInfo, err diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/NLBHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/NLBHandler.go index 32120bc1d..3bc5472a0 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/NLBHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/NLBHandler.go @@ -63,7 +63,7 @@ func (NLBHandler *AlibabaNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI //// validation check area err := NLBHandler.validateCreateNLB(nlbReqInfo) if err != nil { - cblogger.Info("validateCreateNLB ", err) + cblogger.Error("validateCreateNLB ", err) return irs.NLBInfo{}, err } @@ -120,7 +120,7 @@ func (NLBHandler *AlibabaNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI return irs.NLBInfo{}, err } - cblogger.Info(response) + cblogger.Debug(response) nlbIID := irs.IID{NameId: nlbReqInfo.IId.NameId, SystemId: response.LoadBalancerId} @@ -149,7 +149,7 @@ func (NLBHandler *AlibabaNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI // 자원 회수 : Listener delListenerResult, delListenerErr := NLBHandler.deleteLoadBalancerListener(nlbIID, nlbReqInfo) if delListenerErr != nil { - cblogger.Info("deleteLoadBalancerListener err ", delListenerErr) + cblogger.Error("deleteLoadBalancerListener err ", delListenerErr) } cblogger.Info("deleteLoadBalancerListener result ", delListenerResult) @@ -179,12 +179,12 @@ func (NLBHandler *AlibabaNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI } /* - Load balancer 전체 목록 보기 +Load balancer 전체 목록 보기 */ func (NLBHandler *AlibabaNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { //DescribeLoadBalancers - cblogger.Info("Start") + cblogger.Debug("Start") request := slb.CreateDescribeLoadBalancersRequest() request.RegionId = NLBHandler.Region.Region @@ -237,10 +237,10 @@ func (NLBHandler *AlibabaNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) lbAttributeResponse, err := NLBHandler.Client.DescribeLoadBalancerAttribute(request) if err != nil { - cblogger.Info(err.Error()) + cblogger.Error(err.Error()) return irs.NLBInfo{}, err } - cblogger.Info(lbAttributeResponse) + cblogger.Debug(lbAttributeResponse) nlbIID.NameId = lbAttributeResponse.LoadBalancerName nlbInfo.IId = nlbIID @@ -256,10 +256,10 @@ func (NLBHandler *AlibabaNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) // Listener 는 여려개가능하나 CB-SP에서 1개로 fixed. listener := irs.ListenerInfo{} listenerProtocolAndPortList := lbAttributeResponse.ListenerPortsAndProtocol.ListenerPortAndProtocol // 이중으로 되어 있음. - cblogger.Info("listenerProtocolAndPortList") - cblogger.Info(listenerProtocolAndPortList) + cblogger.Debug("listenerProtocolAndPortList") + cblogger.Debug(listenerProtocolAndPortList) for _, listenerProtocolAndPort := range listenerProtocolAndPortList { - cblogger.Info(listenerProtocolAndPort) + cblogger.Debug(listenerProtocolAndPort) listener.Protocol = listenerProtocolAndPort.ListenerProtocol listener.IP = lbAttributeResponse.Address listener.Port = strconv.Itoa(listenerProtocolAndPort.ListenerPort) @@ -297,7 +297,7 @@ func (NLBHandler *AlibabaNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) vmIID := irs.IID{SystemId: backendServer.ServerId} vmInfo, err := vmHandler.GetVM(vmIID) if err != nil { - cblogger.Info(err.Error()) + cblogger.Error(err.Error()) // vm 정보 조회 실패 var inKeyValueList []irs.KeyValue keyValue := irs.KeyValue{"reason", err.Error()} @@ -335,8 +335,8 @@ func (NLBHandler *AlibabaNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) } /* - NLB 삭제 - After you delete an SLB instance, the listeners and tags added to the SLB instance are deleted. +NLB 삭제 +After you delete an SLB instance, the listeners and tags added to the SLB instance are deleted. */ func (NLBHandler *AlibabaNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { request := slb.CreateDeleteLoadBalancerRequest() @@ -345,34 +345,34 @@ func (NLBHandler *AlibabaNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { response, err := NLBHandler.Client.DeleteLoadBalancer(request) if err != nil { - cblogger.Info(err.Error()) + cblogger.Error(err.Error()) return false, err } - cblogger.Info(response) + cblogger.Debug(response) return true, nil } //------ Frontend Control /* - Spider에서 원하는 listener의 변경은 protocol, ip, port 의 변경아나 - ALIBABA에서는 listener의 key 가 loadbalancerId, port 이므로 실제로 변경할 수 있는 parameter가 없음. +Spider에서 원하는 listener의 변경은 protocol, ip, port 의 변경아나 +ALIBABA에서는 listener의 key 가 loadbalancerId, port 이므로 실제로 변경할 수 있는 parameter가 없음. - 수정 가능한 항목은 healthcheck 부분으로 현재버전에서는 error로 return - 향후 필요시 삭제 후 추가 하는 방법 고려. +수정 가능한 항목은 healthcheck 부분으로 현재버전에서는 error로 return +향후 필요시 삭제 후 추가 하는 방법 고려. */ func (NLBHandler *AlibabaNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.ListenerInfo) (irs.ListenerInfo, error) { return irs.ListenerInfo{}, errors.New("ALIBABA_CANNOT_CHANGE_LISTENER") } -//------ Backend Control +// ------ Backend Control func (NLBHandler *AlibabaNLBHandler) ChangeVMGroupInfo(nlbIID irs.IID, vmGroup irs.VMGroupInfo) (irs.VMGroupInfo, error) { return irs.VMGroupInfo{}, errors.New("ALIBABA_CANNOT_CHANGE_VMGROUP") } /* - loadBalancer에 VM추가 - vm만 추가 +loadBalancer에 VM추가 +vm만 추가 */ func (NLBHandler *AlibabaNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs.VMGroupInfo, error) { nlbReqInfo := irs.NLBInfo{} @@ -386,8 +386,8 @@ func (NLBHandler *AlibabaNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) ( } /* - loadBalancer에 VM제거 - vm만 제거 +loadBalancer에 VM제거 +vm만 제거 */ func (NLBHandler *AlibabaNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (bool, error) { nlbReqInfo := irs.NLBInfo{} @@ -413,10 +413,10 @@ func (NLBHandler *AlibabaNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.H response, err := NLBHandler.Client.DescribeHealthStatus(request) if err != nil { - cblogger.Info(err.Error()) + cblogger.Error(err.Error()) return returnHealthInfo, err } - cblogger.Info(response) + cblogger.Debug(response) for _, backendServer := range response.BackendServers.BackendServer { if strings.EqualFold(backendServer.ServerHealthStatus, ServerHealthStatus_NORMAL) { @@ -435,10 +435,9 @@ func (NLBHandler *AlibabaNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.H } /* - HealthChecker 의 정보가 실제로는 listener에 들어있음. - 따라서 nblId, port 에 해당하는 listener를 찾고 - nlbInfo에 모든정보를 set(lb ID, listener protocol,port, healthchecker info)하여 healthchecker정보를 수정 - +HealthChecker 의 정보가 실제로는 listener에 들어있음. +따라서 nblId, port 에 해당하는 listener를 찾고 +nlbInfo에 모든정보를 set(lb ID, listener protocol,port, healthchecker info)하여 healthchecker정보를 수정 */ func (NLBHandler *AlibabaNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthChecker irs.HealthCheckerInfo) (irs.HealthCheckerInfo, error) { returnHealthChecker := irs.HealthCheckerInfo{} @@ -449,16 +448,16 @@ func (NLBHandler *AlibabaNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, hea lbAttributeResponse, err := NLBHandler.Client.DescribeLoadBalancerAttribute(request) if err != nil { - cblogger.Info(err.Error()) + cblogger.Error(err.Error()) return returnHealthChecker, err } - cblogger.Info(lbAttributeResponse) + cblogger.Debug(lbAttributeResponse) // listener 정보 추출 listener := irs.ListenerInfo{} listenerProtocolAndPortList := lbAttributeResponse.ListenerPortsAndProtocol.ListenerPortAndProtocol // 이중으로 되어 있음. for _, listenerProtocolAndPort := range listenerProtocolAndPortList { - cblogger.Info(listenerProtocolAndPort) + cblogger.Debug(listenerProtocolAndPort) listener.Protocol = listenerProtocolAndPort.ListenerProtocol listener.IP = lbAttributeResponse.Address listener.Port = strconv.Itoa(listenerProtocolAndPort.ListenerPort) @@ -543,9 +542,9 @@ func (NLBHandler *AlibabaNLBHandler) AddLoadBalancerListener(nlbIID irs.IID, nlb } /* - 중단된 Listener를 시작 - stop 상태인 경우에만 호출가능 - Listener를 생성하면 중단된 상태이므로 start를 시켜야 함. +중단된 Listener를 시작 +stop 상태인 경우에만 호출가능 +Listener를 생성하면 중단된 상태이므로 start를 시켜야 함. */ func (NLBHandler *AlibabaNLBHandler) startLoadBalancerListener(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (irs.ListenerInfo, error) { listener := nlbReqInfo.Listener @@ -586,6 +585,7 @@ func (NLBHandler *AlibabaNLBHandler) startLoadBalancerListener(nlbIID irs.IID, n /* // Loadbalancer에서 사용할 TCP Listener 등록 + mandatory : loadBalancerId, Bandwidth, ListenerPort, RegionID BackendServerport : vm 추가방식은 필수. vServer Group 방식은 해당 VServerGroupId set */ @@ -594,7 +594,7 @@ func (NLBHandler *AlibabaNLBHandler) addLoadBalancerTcpListener(nlbIID irs.IID, healthChecker := nlbReqInfo.HealthChecker vmGroup := nlbReqInfo.VMGroup - cblogger.Info(listener) + cblogger.Debug(listener) listenerRequest := slb.CreateCreateLoadBalancerTCPListenerRequest() //// set listener area @@ -651,7 +651,7 @@ func (NLBHandler *AlibabaNLBHandler) addLoadBalancerTcpListener(nlbIID irs.IID, ErrorMSG: "", } callLogStart := call.Start() - cblogger.Info(listenerRequest) + cblogger.Debug(listenerRequest) response, err := NLBHandler.Client.CreateLoadBalancerTCPListener(listenerRequest) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { @@ -730,21 +730,22 @@ func (NLBHandler *AlibabaNLBHandler) addLoadBalancerUdpListener(nlbIID irs.IID, /* // Listener 수정 - : Protocol, Port는 수정 불가, IP는 set하지 않음. - 즉, 현재 cb-spider에서 alibaba listener는 수정 불가 - Protocol string - IP string - Port string - DNSName string - CspID string - KeyValueList []KeyValue + : Protocol, Port는 수정 불가, IP는 set하지 않음. + 즉, 현재 cb-spider에서 alibaba listener는 수정 불가 + + Protocol string + IP string + Port string + DNSName string + CspID string + KeyValueList []KeyValue - ps : sting to Integer 는 requests.Integer가 되나, int to Integer는 requests.NewInteger로 + ps : sting to Integer 는 requests.Integer가 되나, int to Integer는 requests.NewInteger로 */ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerTcpListener(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (irs.ListenerInfo, error) { listener := nlbReqInfo.Listener - cblogger.Info(listener) + cblogger.Debug(listener) listenerRequest := slb.CreateSetLoadBalancerTCPListenerAttributeRequest() listenerRequest.LoadBalancerId = nlbIID.SystemId listenerRequest.Bandwidth = requests.NewInteger(-1) //For a pay-by-data-transfer Internet-facing Classic Load Balancer (CLB) instance, set the value to -1. This indicates that the maximum bandwidth value is unlimited. @@ -788,7 +789,7 @@ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerTcpListener(nlbIID irs.II ErrorMSG: "", } callLogStart := call.Start() - cblogger.Info(listenerRequest) + cblogger.Debug(listenerRequest) response, err := NLBHandler.Client.SetLoadBalancerTCPListenerAttribute(listenerRequest) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { @@ -806,12 +807,13 @@ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerTcpListener(nlbIID irs.II /* //modifyLoadBalancerUdpListener + TCP Listener와 호출하는 객체와 function 이름만 다르고 다른 항목이 같음 HTTP.. 등 다른 Listener도 추가될 수 있어 따로 뺌. */ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerUdpListener(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (irs.ListenerInfo, error) { listener := nlbReqInfo.Listener - cblogger.Info(listener) + cblogger.Debug(listener) listenerRequest := slb.CreateSetLoadBalancerUDPListenerAttributeRequest() listenerRequest.LoadBalancerId = nlbIID.SystemId listenerRequest.Bandwidth = requests.NewInteger(-1) //For a pay-by-data-transfer Internet-facing Classic Load Balancer (CLB) instance, set the value to -1. This indicates that the maximum bandwidth value is unlimited. @@ -829,7 +831,7 @@ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerUdpListener(nlbIID irs.II ErrorMSG: "", } callLogStart := call.Start() - cblogger.Info(listenerRequest) + cblogger.Debug(listenerRequest) response, err := NLBHandler.Client.SetLoadBalancerUDPListenerAttribute(listenerRequest) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { @@ -846,12 +848,12 @@ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerUdpListener(nlbIID irs.II } /* - listenerPort : required - listenerProtocol : not required 이나, 동일한 포트를 쓰는 리스너가 여러개면 required +listenerPort : required +listenerProtocol : not required 이나, 동일한 포트를 쓰는 리스너가 여러개면 required */ func (NLBHandler *AlibabaNLBHandler) deleteLoadBalancerListener(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (bool, error) { listener := nlbReqInfo.Listener - cblogger.Info(listener) + cblogger.Debug(listener) listenerRequest := slb.CreateDeleteLoadBalancerListenerRequest() listenerRequest.LoadBalancerId = nlbIID.SystemId listenerRequest.ListenerProtocol = listener.Protocol @@ -869,7 +871,7 @@ func (NLBHandler *AlibabaNLBHandler) deleteLoadBalancerListener(nlbIID irs.IID, ErrorMSG: "", } callLogStart := call.Start() - cblogger.Info(listenerRequest) + cblogger.Debug(listenerRequest) response, err := NLBHandler.Client.DeleteLoadBalancerListener(listenerRequest) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { @@ -888,10 +890,12 @@ func (NLBHandler *AlibabaNLBHandler) deleteLoadBalancerListener(nlbIID irs.IID, /* 현재는 Default ServerGroup 을 사용. VMGroup은 쓰지 않음. // CreateVServerGroup + Examples: - ECS instance: [{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port": "80", "Description": "test-112" }]. - ENI: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" }] - ENI with multiple IP addresses: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" },{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "172.166.**.**", "Port":"80","Description":"test-113" }] + + ECS instance: [{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port": "80", "Description": "test-112" }]. + ENI: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" }] + ENI with multiple IP addresses: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" },{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "172.166.**.**", "Port":"80","Description":"test-113" }] You can add at most 20 backend servers to a CLB instance in each request. */ @@ -978,11 +982,11 @@ func (NLBHandler *AlibabaNLBHandler) addVMGroupInfo(nlbIID irs.IID, nlbReqInfo i /* // Default ServerGroup 으로 Vserver Group 없이 instance만 추가 Examples: - ECS instance: [{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"80","Description":"test-112" }] - ENI: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" }] - ENI with multiple IP addresses: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-113" },{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "172.166.**.**", "Port":"80","Description":"test-113" }] - Elastic container instance: [{ "ServerId": "eci-xxxxxxxxx", "Weight": "100", "Type": "eci", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-114" }] + ECS instance: [{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"80","Description":"test-112" }] + ENI: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" }] + ENI with multiple IP addresses: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-113" },{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "172.166.**.**", "Port":"80","Description":"test-113" }] + Elastic container instance: [{ "ServerId": "eci-xxxxxxxxx", "Weight": "100", "Type": "eci", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-114" }] */ func (NLBHandler *AlibabaNLBHandler) addBackendServer(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (irs.VMGroupInfo, error) { vmGroup := nlbReqInfo.VMGroup @@ -1043,8 +1047,8 @@ func (NLBHandler *AlibabaNLBHandler) addBackendServer(nlbIID irs.IID, nlbReqInfo //vmIId.NameId = vmInfo.IId.NameId } backendServersRequest.BackendServers = "[" + strings.Join(vms, ",") + "]" - cblogger.Info("backendServersRequest---") - cblogger.Info(backendServersRequest) + cblogger.Debug("backendServersRequest---") + cblogger.Debug(backendServersRequest) // The value of this parameter must be a STRING list in the JSON format. You can specify up to 20 elements in each request. //vmGroupRequest.BackendServers @@ -1079,9 +1083,9 @@ func (NLBHandler *AlibabaNLBHandler) addBackendServer(nlbIID irs.IID, nlbReqInfo } /* - ex) 현재는 ecs만 사용 - Remove an ECS instance: [{"ServerId":"i-bp1fq61enf4loa5i****", "Type": "ecs","Weight":"100"}] - Remove an ENI: [{"ServerId":"eni-2ze1sdp5****","Type": "eni","Weight":"100"}] + ex) 현재는 ecs만 사용 + Remove an ECS instance: [{"ServerId":"i-bp1fq61enf4loa5i****", "Type": "ecs","Weight":"100"}] + Remove an ENI: [{"ServerId":"eni-2ze1sdp5****","Type": "eni","Weight":"100"}] */ func (NLBHandler *AlibabaNLBHandler) removeBackendServer(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (bool, error) { vmGroup := nlbReqInfo.VMGroup @@ -1133,13 +1137,13 @@ func (NLBHandler *AlibabaNLBHandler) removeBackendServer(nlbIID irs.IID, nlbReqI } /* - 실제로는 Listener 수정이나, 항목이 healthchecker 부분이라 modify health checker라고 함 - TCP는 protocol 변경 가능( http, tcp 중 택1), UDP는 protocol변경 불가능 +실제로는 Listener 수정이나, 항목이 healthchecker 부분이라 modify health checker라고 함 +TCP는 protocol 변경 가능( http, tcp 중 택1), UDP는 protocol변경 불가능 */ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerTcpHealthChecker(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (irs.HealthCheckerInfo, error) { listener := nlbReqInfo.Listener healthChecker := nlbReqInfo.HealthChecker - cblogger.Info(listener) + cblogger.Debug(listener) listenerRequest := slb.CreateSetLoadBalancerTCPListenerAttributeRequest() // required key @@ -1207,13 +1211,13 @@ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerTcpHealthChecker(nlbIID i } /* - 실제로는 Listener 수정이나, 항목이 healthchecker 부분이라 modify health checker라고 함. - UDP는 Protocol변경 불가. port만 변경 가능 +실제로는 Listener 수정이나, 항목이 healthchecker 부분이라 modify health checker라고 함. +UDP는 Protocol변경 불가. port만 변경 가능 */ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerUdpHealthChecker(nlbIID irs.IID, nlbReqInfo irs.NLBInfo) (irs.HealthCheckerInfo, error) { listener := nlbReqInfo.Listener healthChecker := nlbReqInfo.HealthChecker - cblogger.Info(listener) + cblogger.Debug(listener) listenerRequest := slb.CreateSetLoadBalancerUDPListenerAttributeRequest() // required key @@ -1274,9 +1278,8 @@ func (NLBHandler *AlibabaNLBHandler) modifyLoadBalancerUdpHealthChecker(nlbIID i } /* - TCPListener를 조회하여 CB-Spider의 객체에 맞게 set하여 return - 호출하는 곳에서 원하는 값을 추출하여 사용 - +TCPListener를 조회하여 CB-Spider의 객체에 맞게 set하여 return +호출하는 곳에서 원하는 값을 추출하여 사용 */ func (NLBHandler *AlibabaNLBHandler) describeLoadBalancerTcpListenerAttribute(nlbIID irs.IID, listener irs.ListenerInfo) (irs.NLBInfo, error) { nlbInfo := irs.NLBInfo{} @@ -1291,7 +1294,7 @@ func (NLBHandler *AlibabaNLBHandler) describeLoadBalancerTcpListenerAttribute(nl printToJson(listenerAttributeRequest) listenerAttributeResponse, err := NLBHandler.Client.DescribeLoadBalancerTCPListenerAttribute(listenerAttributeRequest) if err != nil { - cblogger.Info(err.Error()) + cblogger.Error(err.Error()) return irs.NLBInfo{}, err } @@ -1314,9 +1317,8 @@ func (NLBHandler *AlibabaNLBHandler) describeLoadBalancerTcpListenerAttribute(nl } /* - UDP Listener를 조회하여 CB-Spider의 객체에 맞게 set하여 return - 호출하는 곳에서 원하는 값을 추출하여 사용 - +UDP Listener를 조회하여 CB-Spider의 객체에 맞게 set하여 return +호출하는 곳에서 원하는 값을 추출하여 사용 */ func (NLBHandler *AlibabaNLBHandler) describeLoadBalancerUdpListenerAttribute(nlbIID irs.IID, listener irs.ListenerInfo) (irs.NLBInfo, error) { nlbInfo := irs.NLBInfo{} @@ -1331,7 +1333,7 @@ func (NLBHandler *AlibabaNLBHandler) describeLoadBalancerUdpListenerAttribute(nl printToJson(listenerAttributeRequest) listenerAttributeResponse, err := NLBHandler.Client.DescribeLoadBalancerUDPListenerAttribute(listenerAttributeRequest) if err != nil { - cblogger.Info(err.Error()) + cblogger.Error(err.Error()) return irs.NLBInfo{}, err } @@ -1354,9 +1356,9 @@ func (NLBHandler *AlibabaNLBHandler) describeLoadBalancerUdpListenerAttribute(nl } /* - LB 생성 시 validation check +LB 생성 시 validation check - udplistener : You cannot specify ports 250, 4789, or 4790 for UDP listeners. They are system reserved ports. +udplistener : You cannot specify ports 250, 4789, or 4790 for UDP listeners. They are system reserved ports. */ func (NLBHandler *AlibabaNLBHandler) validateCreateNLB(nlbReqInfo irs.NLBInfo) error { // lb diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/PriceInfoHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/PriceInfoHandler.go index 14bc4be86..4c3f46eb4 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/PriceInfoHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/PriceInfoHandler.go @@ -148,7 +148,7 @@ func (priceInfoHandler *AlibabaPriceInfoHandler) ListProductFamily(regionName st func (priceInfoHandler *AlibabaPriceInfoHandler) GetPriceInfo(productFamily string, regionName string, filterList []irs.KeyValue) (string, error) { priceMap := make(map[string]irs.Price) - cblogger.Info(filterList) + cblogger.Debug(filterList) filter, _ := filterListToMap(filterList) cblogger.Infof("filter value : %+v", filterList) @@ -397,7 +397,7 @@ func (priceInfoHandler *AlibabaPriceInfoHandler) GetPriceInfo(productFamily stri continue } - fmt.Println("priceResponseStr::", priceResponseStr) + cblogger.Debug("priceResponseStr::", priceResponseStr) pricingPolicy, err := BindpricingPolicy(priceResp, product.SubscriptionType, pricingModulePriceType, regionName, attr.Value) if err != nil { @@ -607,8 +607,8 @@ func toCamelCase(val string) string { if val == "" { return "" } - - return fmt.Sprintf("%s%s", strings.ToLower(val[:1]), val[1:]) + returnString := fmt.Sprintf("%s%s", strings.ToLower(val[:1]), val[1:]) + return returnString } func pricePolicyInfoFilter(policy interface{}, filter map[string]*string) bool { diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/RegionZoneHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/RegionZoneHandler.go index 185a6b7a6..25c1dfe4e 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/RegionZoneHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/RegionZoneHandler.go @@ -57,10 +57,10 @@ func (regionZoneHandler AlibabaRegionZoneHandler) ListRegionZone() ([]*irs.Regio regionId := item.RegionId // ZoneList var zoneInfoList []irs.ZoneInfo - cblogger.Info("regionId ", regionId) + cblogger.Debug("regionId ", regionId) zonesResult, err := DescribeZonesByRegion(regionZoneHandler.Client, regionId) if err != nil { - cblogger.Debug("DescribeZone failed ", err) + cblogger.Error("DescribeZone failed ", err) } for _, zone := range zonesResult.Zones.Zone { zoneInfo := irs.ZoneInfo{} @@ -241,10 +241,10 @@ func (regionZoneHandler AlibabaRegionZoneHandler) GetRegionZone(reqRegionId stri // ZoneList var zoneInfoList []irs.ZoneInfo - cblogger.Info("regionId ", regionId) + cblogger.Debug("regionId ", regionId) zonesResult, err := DescribeZonesByRegion(regionZoneHandler.Client, regionId) if err != nil { - cblogger.Debug("DescribeZone failed ", err) + cblogger.Error("DescribeZone failed ", err) } for _, zone := range zonesResult.Zones.Zone { zoneInfo := irs.ZoneInfo{} diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/SecurityHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/SecurityHandler.go index 659425866..9801d6f18 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/SecurityHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/SecurityHandler.go @@ -11,9 +11,9 @@ package resources import ( + "encoding/json" "errors" "strings" - "encoding/json" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" @@ -30,7 +30,7 @@ type AlibabaSecurityHandler struct { type RuleAction string const ( - Add RuleAction = "Add" + Add RuleAction = "Add" Remove RuleAction = "Remove" ) @@ -48,7 +48,7 @@ func (securityHandler *AlibabaSecurityHandler) CreateSecurity(securityReqInfo ir request.SecurityGroupName = securityReqInfo.IId.NameId request.VpcId = securityReqInfo.VpcIID.SystemId request.SecurityGroupType = "enterprise" - cblogger.Debugf("보안 그룹 생성 요청 정보", request) + cblogger.Debugf("Security group creation request information", request) // logger for HisCall callogger := call.GetLogger("HISCALL") @@ -75,7 +75,7 @@ func (securityHandler *AlibabaSecurityHandler) CreateSecurity(securityReqInfo ir return irs.SecurityInfo{}, err } callogger.Info(call.String(callLogInfo)) - cblogger.Infof("[%s] 보안 그룹 생성완료: SecurityGroupId:[%s]", securityReqInfo.IId.NameId, createRes.SecurityGroupId) + cblogger.Infof("[%s] Security group creation complete: SecurityGroupId:[%s]", securityReqInfo.IId.NameId, createRes.SecurityGroupId) //spew.Dump(createRes) //======================================= @@ -98,8 +98,8 @@ func (securityHandler *AlibabaSecurityHandler) CreateSecurity(securityReqInfo ir return irs.SecurityInfo{}, err } cblogger.Infof("[%s] [%s] AuthorizeSecurityGroup Request success - RequestId:[%s]", defaultRuleRequest.IpProtocol, defaultRuleRequest.PortRange, response) - - cblogger.Infof("보안 그룹[%s]에 인바운드/아웃바운드 보안 정책 처리", defaultRuleRequest.SecurityGroupId) + + cblogger.Infof("Processing inbound/outbound security policies for security group [%s]", defaultRuleRequest.SecurityGroupId) return securityHandler.AddRules(irs.IID{SystemId: createRes.SecurityGroupId}, securityReqInfo.SecurityRules) //createRuleRes, errRule := securityHandler.AuthorizeSecurityRules(createRes.SecurityGroupId, securityReqInfo.VpcIID.SystemId, securityReqInfo.SecurityRules) @@ -124,15 +124,18 @@ func (securityHandler *AlibabaSecurityHandler) CreateSecurity(securityReqInfo ir // 공통 함수명은 AddRules 이나 실제 Alibaba는 AuthorizeSecurityRules // SecurityGroup 생성시에도 호출 // 저장 후 rule 목록 조회하여 return -// - vpcId deprecated -// - function name 변경 : AuthorizeSecurityRules to AddRules -//func (securityHandler *AlibabaSecurityHandler) AuthorizeSecurityRules(securityGroupId string, vpcId string, securityRuleInfos *[]irs.SecurityRuleInfo) (*[]irs.SecurityRuleInfo, error) { -//func (securityHandler *AlibabaSecurityHandler) AuthorizeSecurityRules(securityGroupId string, securityRuleInfos *[]irs.SecurityRuleInfo) (*[]irs.SecurityRuleInfo, error) { +// - vpcId deprecated +// - function name 변경 : AuthorizeSecurityRules to AddRules +// +// func (securityHandler *AlibabaSecurityHandler) AuthorizeSecurityRules(securityGroupId string, vpcId string, securityRuleInfos *[]irs.SecurityRuleInfo) (*[]irs.SecurityRuleInfo, error) { +// func (securityHandler *AlibabaSecurityHandler) AuthorizeSecurityRules(securityGroupId string, securityRuleInfos *[]irs.SecurityRuleInfo) (*[]irs.SecurityRuleInfo, error) { func (securityHandler *AlibabaSecurityHandler) AddRules(securityIID irs.IID, reqSecurityRules *[]irs.SecurityRuleInfo) (irs.SecurityInfo, error) { securityGroupId := securityIID.SystemId cblogger.Infof("securityGroupId : [%s] / securityRuleInfos : [%v]", securityGroupId, reqSecurityRules) //cblogger.Info("AuthorizeSecurityRules ", securityRuleInfos) - spew.Dump(reqSecurityRules) + if cblogger.Level.String() == "debug" { + spew.Dump(reqSecurityRules) + } if len(*reqSecurityRules) < 1 { return irs.SecurityInfo{}, errors.New("invalid value - The SecurityRules to add is empty") @@ -155,7 +158,7 @@ func (securityHandler *AlibabaSecurityHandler) AddRules(securityIID irs.IID, req } errorMsg += string(jsonRule) } - return irs.SecurityInfo{}, errors.New("invalid value - "+ errorMsg +" already exists!") + return irs.SecurityInfo{}, errors.New("invalid value - " + errorMsg + " already exists!") } for _, curRule := range *reqSecurityRules { @@ -185,7 +188,10 @@ func (securityHandler *AlibabaSecurityHandler) AddRules(securityIID irs.IID, req request.DestCidrIp = curRule.CIDR cblogger.Infof("[%s] [%s] outbound rule Request", request.IpProtocol, request.PortRange) - spew.Dump(request) + if cblogger.Level.String() == "debug" { + spew.Dump(request) + } + response, err := securityHandler.Client.AuthorizeSecurityGroupEgress(request) if err != nil { cblogger.Errorf("Unable to create security group[%s] outbound rule - [%s] [%s] AuthorizeSecurityGroup Request", securityGroupId, request.IpProtocol, request.PortRange) @@ -205,7 +211,7 @@ func (securityHandler *AlibabaSecurityHandler) AddRules(securityIID irs.IID, req // 공통 함수명은 RemoveRules 이나 실제 Alibaba는 RevokeSecurityRules // If the security group rule to be deleted does not exist, the RevokeSecurityGroup operation succeeds but no rule is deleted. -//func (securityHandler *AlibabaSecurityHandler) RevokeSecurityRules(securityGroupId string, securityRuleInfos *[]irs.SecurityRuleInfo) (*[]irs.SecurityRuleInfo, error) { +// func (securityHandler *AlibabaSecurityHandler) RevokeSecurityRules(securityGroupId string, securityRuleInfos *[]irs.SecurityRuleInfo) (*[]irs.SecurityRuleInfo, error) { func (securityHandler *AlibabaSecurityHandler) RemoveRules(securityIID irs.IID, reqSecurityRules *[]irs.SecurityRuleInfo) (bool, error) { securityGroupId := securityIID.SystemId cblogger.Infof("securityGroupId : [%s] / securityRuleInfos : [%v]", securityGroupId, reqSecurityRules) @@ -228,10 +234,9 @@ func (securityHandler *AlibabaSecurityHandler) RemoveRules(securityIID irs.IID, } errorMsg += string(jsonRule) } - return false, errors.New("invalid value - "+ errorMsg +" does not exist!") + return false, errors.New("invalid value - " + errorMsg + " does not exist!") } - // "cidr": "string", // "fromPort": "string", // "ipprotocol": "string", @@ -332,9 +337,9 @@ func (securityHandler *AlibabaSecurityHandler) ListSecurity() ([]*irs.SecurityIn cblogger.Error(err) return nil, err } - callogger.Info(call.String(callLogInfo)) + callogger.Debug(call.String(callLogInfo)) - cblogger.Info(result) + cblogger.Debug(result) //spew.Dump(result) //ecs.DescribeSecurityGroupsResponse @@ -509,14 +514,14 @@ func (securityHandler *AlibabaSecurityHandler) DeleteSecurity(securityIID irs.II } callogger.Info(call.String(callLogInfo)) - cblogger.Info(response) + cblogger.Debug(response) cblogger.Infof("Successfully delete security group %q.", securityIID.SystemId) return true, nil } // 동일한 rule이 있는지 체크 // RuleAction이 Add면 중복인 rule 리턴, Remove면 없는 rule 리턴 -func sameRulesCheck(presentSecurityRules *[]irs.SecurityRuleInfo, reqSecurityRules *[]irs.SecurityRuleInfo, action RuleAction) (*[]irs.SecurityRuleInfo) { +func sameRulesCheck(presentSecurityRules *[]irs.SecurityRuleInfo, reqSecurityRules *[]irs.SecurityRuleInfo, action RuleAction) *[]irs.SecurityRuleInfo { var checkResult []irs.SecurityRuleInfo cblogger.Infof("presentSecurityRules: [%v] / reqSecurityRules: [%v]", presentSecurityRules, reqSecurityRules) for _, reqRule := range *reqSecurityRules { @@ -575,4 +580,4 @@ func sameRulesCheck(presentSecurityRules *[]irs.SecurityRuleInfo, reqSecurityRul } return nil -} \ No newline at end of file +} diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMHandler.go index 81f44cd6a..153915650 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMHandler.go @@ -55,8 +55,8 @@ func (vmHandler *AlibabaVMHandler) GetImageSize(ImageSystemId string) (int64, er return imageSize, nil } else { - cblogger.Error("요청된 Image 정보[" + ImageSystemId + "]를 찾을 수 없습니다.") - return -1, errors.New("요청된 Image 정보[" + ImageSystemId + "]를 찾을 수 없습니다.") + cblogger.Error("The requested Image information [" + ImageSystemId + "] could not be found.") + return -1, errors.New("The requested Image information [" + ImageSystemId + "] could not be found.") } } @@ -121,7 +121,7 @@ func (vmHandler *AlibabaVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, vmImage, err := DescribeImageByImageId(vmHandler.Client, vmHandler.Region, vmReqInfo.ImageIID, false) if err != nil { cblogger.Error(err) - errMsg := "요청된 이미지의 정보를 조회할 수 없습니다." + err.Error() + errMsg := "We cannot retrieve information for the requested image." + err.Error() return irs.VMInfo{}, errors.New(errMsg) } @@ -155,18 +155,18 @@ func (vmHandler *AlibabaVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, //============================= // 보안그룹 처리 - SystemId 기반 //============================= - cblogger.Debug("SystemId 기반으로 처리하기 위해 IID 기반의 보안그룹 배열을 SystemId 기반 보안그룹 배열로 조회및 변환함.") + cblogger.Debug("To process based on SystemId, the security group array based on IID is retrieved and converted into a security group array based on SystemId.") var newSecurityGroupIds []string //var firstSecurityGroupId string for _, sgId := range vmReqInfo.SecurityGroupIIDs { - cblogger.Debugf("보안그룹 변환 : [%s]", sgId) + cblogger.Debugf("Security group transformation: [%s]", sgId) newSecurityGroupIds = append(newSecurityGroupIds, sgId.SystemId) //firstSecurityGroupId = sgId.SystemId //break } - cblogger.Debug("보안그룹 변환 완료") + cblogger.Debug("Security group transformation complete.") cblogger.Debug(newSecurityGroupIds) //request := ecs.CreateCreateInstanceRequest() // CreateInstance는 PublicIp가 자동으로 할당되지 않음. @@ -367,13 +367,13 @@ func (vmHandler *AlibabaVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, } if rootDiskSize < diskSizeValue.diskMinSize { - cblogger.Info("Disk Size Error!!: ", rootDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", rootDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) //return irs.VMInfo{}, errors.New("Requested disk size cannot be smaller than the minimum disk size, invalid") return irs.VMInfo{}, errors.New("Root Disk Size must be at least the default size (" + strconv.FormatInt(diskSizeValue.diskMinSize, 10) + " GB).") } if rootDiskSize > diskSizeValue.diskMaxSize { - cblogger.Info("Disk Size Error!!: ", rootDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", rootDiskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) //return irs.VMInfo{}, errors.New("Requested disk size cannot be larger than the maximum disk size, invalid") return irs.VMInfo{}, errors.New("Root Disk Size must be smaller than the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } @@ -382,10 +382,10 @@ func (vmHandler *AlibabaVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, //imageSize, err := vmHandler.GetImageSize(vmReqInfo.ImageIID.SystemId) imageSize := int64(vmImage.Size) if imageSize < 0 { - return irs.VMInfo{}, errors.New("요청된 이미지의 기본 사이즈 정보를 조회할 수 없습니다.") + return irs.VMInfo{}, errors.New("we cannot retrieve the basic size information for the requested image") } else { if rootDiskSize < imageSize { - cblogger.Info("Disk Size Error!!: ", rootDiskSize) + cblogger.Error("Disk Size Error!!: ", rootDiskSize) return irs.VMInfo{}, errors.New("Root Disk Size must be larger then the image size (" + strconv.FormatInt(imageSize, 10) + " GB).") } @@ -454,7 +454,7 @@ func (vmHandler *AlibabaVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, cblogger.Error(errStatus.Error()) return irs.VMInfo{}, nil } - cblogger.Info("==>생성된 VM[%s]의 현재 상태[%s]", newVmIID, curStatus) + cblogger.Debug("==> Current status [%s] of the created VM [%s]", newVmIID, curStatus) // dataDisk attach for _, dataDiskIID := range vmReqInfo.DataDiskIIDs { @@ -501,7 +501,7 @@ func (vmHandler *AlibabaVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, // VM 상태가 정보를 조회할 수 있는 상태가 될때까지 기다림(최대 30초간 대기) func (vmHandler *AlibabaVMHandler) WaitForExist(vmIID irs.IID) (irs.VMStatus, error) { - cblogger.Info("======> VM 생성 직후에는 VM 정보를 조회할 수 없기 때문에 NotExist 상태가 아닐 때까지만 대기함.") + cblogger.Debug("======> After creating a VM, it's not possible to retrieve VM information immediately, so it waits until the status is not \"NotExist\" before proceeding.") waitStatus := "NotExist" //VM정보 조회가 안됨. //waitStatus := "Running" @@ -521,17 +521,17 @@ func (vmHandler *AlibabaVMHandler) WaitForExist(vmIID irs.IID) (irs.VMStatus, er cblogger.Info("===>VM Status : ", curStatus) if curStatus != irs.VMStatus(waitStatus) { //|| curStatus == irs.VMStatus("Running") { - cblogger.Infof("===>VM 상태[%s]는 [%s]가 아니라서 대기를 중단합니다.", curStatus, waitStatus) + cblogger.Infof("===> Suspended waiting because the VM status [%s] is not [%s].", curStatus, waitStatus) break } //if curStatus != irs.VMStatus(waitStatus) { curRetryCnt++ - cblogger.Errorf("VM 상태가 [%s]라서 1초 대기후 조회합니다.", curStatus) + cblogger.Errorf("Waiting for 1 second and then querying because the VM status is [%s].", curStatus) time.Sleep(time.Second * 1) if curRetryCnt > maxRetryCnt { - cblogger.Errorf("장시간(%d 초) 대기해도 VM의 Status 값이 [%s]를 유지해서 강제로 중단합니다.", maxRetryCnt, waitStatus) - return irs.VMStatus("Failed"), errors.New("장시간 기다렸으나 생성된 VM의 상태가 [" + waitStatus + "]외의 상태로 바뀌지 않아서 중단 합니다.") + cblogger.Errorf("Forcing termination as the VM status remains [%s] even after a long wait (%d seconds).", maxRetryCnt, waitStatus) + return irs.VMStatus("Failed"), errors.New("After waiting for a long time, the status of the created VM did not change to [" + waitStatus + "], so the process is being terminated.") } //} else { //break @@ -543,7 +543,7 @@ func (vmHandler *AlibabaVMHandler) WaitForExist(vmIID irs.IID) (irs.VMStatus, er // VM 정보를 조회할 수 있을 때까지 최대 30초간 대기 func (vmHandler *AlibabaVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error) { - cblogger.Info("======> VM 생성 직후에는 정보 조회가 안되기 때문에 Running 될 때까지 대기함.") + cblogger.Debug("======> Waiting until information retrieval is not possible immediately after VM creation because it is not running yet.") //waitStatus := "NotExist" //VM정보 조회가 안됨. waitStatus := "Running" @@ -563,17 +563,17 @@ func (vmHandler *AlibabaVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, erro cblogger.Info("===>VM Status : ", curStatus) if curStatus == irs.VMStatus(waitStatus) { //|| curStatus == irs.VMStatus("Running") { - cblogger.Infof("===>VM 상태가 [%s]라서 대기를 중단합니다.", curStatus) + cblogger.Infof("===> Stopping the wait because the VM status is [%s].", curStatus) break } //if curStatus != irs.VMStatus(waitStatus) { curRetryCnt++ - cblogger.Errorf("VM 상태가 [%s]이 아니라서 1초 대기후 조회합니다.", waitStatus) + cblogger.Errorf("The VM status is not [%s], so waiting for 1 second before querying.", waitStatus) time.Sleep(time.Second * 1) if curRetryCnt > maxRetryCnt { - cblogger.Errorf("장시간(%d 초) 대기해도 VM의 Status 값이 [%s]으로 변경되지 않아서 강제로 중단합니다.", maxRetryCnt, waitStatus) - return irs.VMStatus("Failed"), errors.New("장시간 기다렸으나 생성된 VM의 상태가 [" + waitStatus + "]으로 바뀌지 않아서 중단 합니다.") + cblogger.Errorf("Forcing termination as the VM status remains unchanged as [%s] even after waiting for a long time (%d seconds).", maxRetryCnt, waitStatus) + return irs.VMStatus("Failed"), errors.New("After waiting for a long time, the status of the created VM did not change to [" + waitStatus + "], so the process is being terminated.") } //} else { //break @@ -610,7 +610,7 @@ func (vmHandler *AlibabaVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error) } if curStatus != "Suspended" { - return irs.VMStatus("Failed"), errors.New(string("vm 상태가 Suspended 가 아닙니다." + curStatus)) + return irs.VMStatus("Failed"), errors.New(string("The VM status is not Suspended." + curStatus)) } response, err := vmHandler.Client.StartInstance(request) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) @@ -621,9 +621,9 @@ func (vmHandler *AlibabaVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error) cblogger.Error(err.Error()) return irs.VMStatus("Failed"), err } - callogger.Info(call.String(callLogInfo)) + callogger.Debug(call.String(callLogInfo)) - cblogger.Info(response) + cblogger.Debug(response) return irs.VMStatus("Resuming"), nil } @@ -659,8 +659,8 @@ func (vmHandler *AlibabaVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error cblogger.Error(err.Error()) return irs.VMStatus("Failed"), err } - callogger.Info(call.String(callLogInfo)) - cblogger.Info(response) + callogger.Debug(call.String(callLogInfo)) + cblogger.Debug(response) return irs.VMStatus("Suspending"), nil } @@ -693,8 +693,8 @@ func (vmHandler *AlibabaVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error) cblogger.Error(err.Error()) return irs.VMStatus("Failed"), err } - callogger.Info(call.String(callLogInfo)) - cblogger.Info(response) + callogger.Debug(call.String(callLogInfo)) + cblogger.Debug(response) return irs.VMStatus("Rebooting"), nil } @@ -763,8 +763,8 @@ func (vmHandler *AlibabaVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, err if strings.Contains(err.Error(), "IncorrectInstanceStatus") { // Loop: IncorrectInstanceStatus error callLogInfo.ErrorMSG = err.Error() - callogger.Info(call.String(callLogInfo)) - cblogger.Info(err.Error()) + callogger.Error(call.String(callLogInfo)) + cblogger.Error(err.Error()) time.Sleep(time.Second * 3) } else { // general error callLogInfo.ErrorMSG = err.Error() @@ -773,8 +773,8 @@ func (vmHandler *AlibabaVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, err return irs.VMStatus("Failed"), err } } else { - callogger.Info(call.String(callLogInfo)) - cblogger.Info(response) + callogger.Debug(call.String(callLogInfo)) + cblogger.Debug(response) break } } @@ -822,14 +822,14 @@ func (vmHandler *AlibabaVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) { instanceInfo, err := DescribeInstanceById(vmHandler.Client, vmHandler.Region, vmIID) vmInfo, err := vmHandler.ExtractDescribeInstances(&instanceInfo) - cblogger.Info("vmInfo", vmInfo) + cblogger.Debug("vmInfo", vmInfo) return vmInfo, err } // @TODO : 2020-03-26 Ali클라우드 API 구조가 바뀐 것 같아서 임시로 변경해 놓음. // func (vmHandler *AlibabaVMHandler) ExtractDescribeInstances() irs.VMInfo { func (vmHandler *AlibabaVMHandler) ExtractDescribeInstances(instanceInfo *ecs.Instance) (irs.VMInfo, error) { - cblogger.Info(instanceInfo) + cblogger.Debug(instanceInfo) //diskInfo := vmHandler.getDiskInfo(instanceInfo.InstanceId) diskInfoList, err := DescribeDisksByInstanceId(vmHandler.Client, vmHandler.Region, irs.IID{SystemId: instanceInfo.InstanceId}) if err != nil { @@ -914,15 +914,15 @@ func (vmHandler *AlibabaVMHandler) ExtractDescribeInstances(instanceInfo *ecs.In } timeLen := len(instanceInfo.CreationTime) - cblogger.Infof("서버 구동 시간 포멧 변환 처리") - cblogger.Infof("======> 생성시간 길이 [%s]", timeLen) + cblogger.Infof("Server startup time format conversion processing") + cblogger.Infof("======> Length of creation time [%s]", timeLen) if timeLen > 7 { - cblogger.Infof("======> 생성시간 마지막 문자열 [%s]", instanceInfo.CreationTime[timeLen-1:]) + cblogger.Infof("======> Last character of creation time [%s]", instanceInfo.CreationTime[timeLen-1:]) var NewStartTime string if instanceInfo.CreationTime[timeLen-1:] == "Z" && timeLen == 17 { //cblogger.Infof("======> 문자열 변환 : [%s]", StartTime[:timeLen-1]) NewStartTime = instanceInfo.CreationTime[:timeLen-1] + ":00Z" - cblogger.Infof("======> 최종 문자열 변환 : [%s]", NewStartTime) + cblogger.Infof("======> Final string conversion: [%s]", NewStartTime) } else { NewStartTime = instanceInfo.CreationTime } @@ -935,7 +935,7 @@ func (vmHandler *AlibabaVMHandler) ExtractDescribeInstances(instanceInfo *ecs.In cblogger.Error(err) return irs.VMInfo{}, err } else { - cblogger.Infof("======> [%v]", t) + cblogger.Debug("======> [%v]", t) vmInfo.StartTime = t } } @@ -982,21 +982,25 @@ func (vmHandler *AlibabaVMHandler) ListVM() ([]*irs.VMInfo, error) { for _, curInstance := range resultInstanceList { //for _, curInstance := range response.Instances.Instance { - cblogger.Info("[%s] ECS 정보 조회", curInstance.InstanceId) + cblogger.Info("[%s] ECS information retrieval", curInstance.InstanceId) vmInfo, errVmInfo := vmHandler.GetVM(irs.IID{SystemId: curInstance.InstanceId}) if errVmInfo != nil { cblogger.Error(errVmInfo.Error()) return nil, errVmInfo } //cblogger.Info("=======>VM 조회 결과") - spew.Dump(vmInfo) + if cblogger.Level.String() == "debug" { + spew.Dump(vmInfo) + } vmInfoList = append(vmInfoList, &vmInfo) } + if cblogger.Level.String() == "debug" { + //cblogger.Info("=======>VM 최종 목록결과") + spew.Dump(vmInfoList) + //cblogger.Info("=======>VM 목록 완료") + } - //cblogger.Info("=======>VM 최종 목록결과") - spew.Dump(vmInfoList) - //cblogger.Info("=======>VM 목록 완료") return vmInfoList, nil } @@ -1033,9 +1037,9 @@ func (vmHandler *AlibabaVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, err cblogger.Error(err.Error()) return irs.VMStatus("Failed"), err } - callogger.Info(call.String(callLogInfo)) + callogger.Debug(call.String(callLogInfo)) - cblogger.Info("Success", response) + cblogger.Debug("Success", response) if response.TotalCount < 1 { //return irs.VMStatus("Failed"), errors.New("Notfound: '" + vmIID.SystemId + "' VM Not found") return irs.VMStatus("NotExist"), nil @@ -1097,8 +1101,8 @@ func (vmHandler *AlibabaVMHandler) ConvertVMStatusString(vmStatus string) (irs.V resultStatus = "Suspended" } else { //resultStatus = "Failed" - cblogger.Errorf("vmStatus [%s]와 일치하는 맵핑 정보를 찾지 못 함.", vmStatus) - return irs.VMStatus("Failed"), errors.New(vmStatus + "와 일치하는 CB VM 상태정보를 찾을 수 없습니다.") + cblogger.Errorf("Cannot find mapping information matching vmStatus [%s].", vmStatus) + return irs.VMStatus("Failed"), errors.New("Cannot find CB VM status information matching " + vmStatus) } cblogger.Infof("VM 상태 치환 : [%s] ==> [%s]", vmStatus, resultStatus) return irs.VMStatus(resultStatus), nil diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VPCHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VPCHandler.go index ae22f763a..b414a10b3 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VPCHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VPCHandler.go @@ -9,7 +9,7 @@ // by zephy@mz.co.kr, 2019.09. // by devunet@mz.co.kr, 2020.04. -//VPC & Subnet 처리 (AlibabaCloud's Subnet --> VSwitch 임) +// VPC & Subnet 처리 (AlibabaCloud's Subnet --> VSwitch 임) package resources import ( @@ -40,7 +40,7 @@ type AlibabaVPCHandler struct { } func (VPCHandler *AlibabaVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error) { - cblogger.Info(vpcReqInfo) + cblogger.Debug(vpcReqInfo) request := vpc.CreateCreateVpcRequest() request.Scheme = "https" @@ -81,7 +81,7 @@ func (VPCHandler *AlibabaVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.V //========================== // Subnet 생성 //========================== - cblogger.Info("Subnet 생성 시작") + cblogger.Info("Subnet creation started") //var resSubnetList []irs.SubnetInfo for _, curSubnet := range vpcReqInfo.SubnetInfoList { cblogger.Infof("[%s] Subnet 생성", curSubnet.IId.NameId) @@ -105,7 +105,7 @@ func (VPCHandler *AlibabaVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.V } func (VPCHandler *AlibabaVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.SubnetInfo) (irs.SubnetInfo, error) { - cblogger.Info(reqSubnetInfo) + cblogger.Debug(reqSubnetInfo) /* vpcInfo, errVpcInfo := VPCHandler.GetSubnet(reqSubnetInfo.IId.SystemId) @@ -117,7 +117,7 @@ func (VPCHandler *AlibabaVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo ir */ zoneId := VPCHandler.Region.Zone - if reqSubnetInfo.Zone != ""{ + if reqSubnetInfo.Zone != "" { zoneId = reqSubnetInfo.Zone } //서브넷 생성 @@ -147,7 +147,7 @@ func (VPCHandler *AlibabaVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo ir cblogger.Info(response) if err != nil { callLogInfo.ErrorMSG = err.Error() - callogger.Info(call.String(callLogInfo)) + callogger.Error(call.String(callLogInfo)) cblogger.Error(err.Error()) return irs.SubnetInfo{}, err } @@ -195,7 +195,7 @@ func (VPCHandler *AlibabaVPCHandler) ListVPC() ([]*irs.VPCInfo, error) { var vpcInfoList []*irs.VPCInfo for _, curVpc := range result.Vpcs.Vpc { - cblogger.Infof("[%s] VPC 정보 조회", curVpc.VpcId) + cblogger.Infof("[%s] VPC information retrieval", curVpc.VpcId) //vpcInfo := ExtractVpcDescribeInfo(&curVpc) vpcInfo, vpcErr := VPCHandler.GetVPC(irs.IID{SystemId: curVpc.VpcId}) if vpcErr != nil { @@ -209,7 +209,7 @@ func (VPCHandler *AlibabaVPCHandler) ListVPC() ([]*irs.VPCInfo, error) { return vpcInfoList, nil } -//VPC 정보를 추출함 +// VPC 정보를 추출함 func ExtractVpcDescribeInfo(vpcInfo *vpc.Vpc) irs.VPCInfo { aliVpcInfo := irs.VPCInfo{ IId: irs.IID{NameId: vpcInfo.VpcName, SystemId: vpcInfo.VpcId}, @@ -227,9 +227,9 @@ func ExtractVpcDescribeInfo(vpcInfo *vpc.Vpc) irs.VPCInfo { return aliVpcInfo } -//Pending , Available +// Pending , Available func (VPCHandler *AlibabaVPCHandler) WaitForRun(vpcId string) error { - cblogger.Info("======> VPC가 Running 될 때까지 대기함.") + cblogger.Debug("======> Waiting until VPC is running.") maxRetryCnt := 20 curRetryCnt := 0 @@ -252,10 +252,10 @@ func (VPCHandler *AlibabaVPCHandler) WaitForRun(vpcId string) error { cblogger.Info("===>VPC Status : ", status) if strings.EqualFold(status, "Pending") { curRetryCnt++ - cblogger.Error("VPC 상태가 Available이 아니라서 1초가 대기후 조회합니다.") + cblogger.Error("Waiting for 1 second and then querying because the VPC status is not Available.") time.Sleep(time.Second * 1) if curRetryCnt > maxRetryCnt { - cblogger.Error("장시간 VPC의 Status 값이 Available로 변경되지 않아서 강제로 중단합니다.") + cblogger.Error("Forcing termination as the VPC status remains unchanged as Available for a long time.") } } else { if strings.EqualFold(status, "Available") { @@ -299,7 +299,7 @@ func (VPCHandler *AlibabaVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error) } callogger.Info(call.String(callLogInfo)) - cblogger.Info("VPC 개수 : ", len(result.Vpcs.Vpc)) + cblogger.Info("VPC Count : ", len(result.Vpcs.Vpc)) //if result.TotalCount < 1 { if len(result.Vpcs.Vpc) < 1 { return irs.VPCInfo{}, errors.New("Notfound: '" + vpcIID.SystemId + "' VPC Not found") @@ -315,10 +315,10 @@ func (VPCHandler *AlibabaVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error) for _, curSubnet := range result.Vpcs.Vpc[0].VSwitchIds.VSwitchId { //cblogger.Infof("\n\n\n\n") //cblogger.Infof("---------------------------------------------------------------------") - cblogger.Infof("[%s] VSwitch 정보 조회", curSubnet) + cblogger.Infof("[%s] VSwitch Information retrieval", curSubnet) subnetInfo, errSubnet := VPCHandler.GetSubnet(curSubnet) if errSubnet != nil { - cblogger.Errorf("[%s] VSwitch 정보 조회 실패", curSubnet) + cblogger.Errorf("[%s] VSwitch Information retrieval failed", curSubnet) cblogger.Error(errSubnet) return irs.VPCInfo{}, errSubnet } @@ -356,7 +356,7 @@ func (VPCHandler *AlibabaVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error) { // Subnet삭제 //================= for _, curSubnet := range vpcInfo.SubnetInfoList { - cblogger.Infof("[%s] VSwitch 삭제 처리", curSubnet.IId.SystemId) + cblogger.Infof("[%s] VSwitch deletion processing", curSubnet.IId.SystemId) _, errSubnet := VPCHandler.DeleteSubnet(curSubnet.IId) if errSubnet != nil { return false, errSubnet @@ -369,7 +369,7 @@ func (VPCHandler *AlibabaVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error) { //특정 시간 이후 자동 삭제되니 라우트 삭제 대신 3초 대기후 시도해 봄. time.Sleep(time.Second * 3) - cblogger.Infof("[%s] VPC를 삭제 함.", vpcInfo.IId.SystemId) + cblogger.Infof("[%s] Deleting VPC.", vpcInfo.IId.SystemId) //cblogger.Info("VPC 제거를 위해 생성된 IGW / Route들 제거 시작") request := vpc.CreateDeleteVpcRequest() @@ -480,12 +480,12 @@ func (VPCHandler *AlibabaVPCHandler) GetSubnet(reqSubnetId string) (irs.SubnetIn } } -//Subnet(VSwitch) 정보를 추출함 +// Subnet(VSwitch) 정보를 추출함 func ExtractSubnetDescribeInfo(subnetInfo vpc.VSwitch) irs.SubnetInfo { vNetworkInfo := irs.SubnetInfo{ IId: irs.IID{NameId: subnetInfo.VSwitchName, SystemId: subnetInfo.VSwitchId}, IPv4_CIDR: subnetInfo.CidrBlock, - Zone: subnetInfo.ZoneId, + Zone: subnetInfo.ZoneId, } keyValueList := []irs.KeyValue{ @@ -532,13 +532,13 @@ func (VPCHandler *AlibabaVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.Su } findSubnet := false - cblogger.Debug("============== 체크할 값 =========") + cblogger.Debug("============== Checking Values =========") for posSubnet, curSubnetInfo := range vpcInfo.SubnetInfoList { - cblogger.Debugf("%d - [%s] Subnet 처리 시작", posSubnet, curSubnetInfo.IId.SystemId) + cblogger.Debugf("%d - [%s] Subnet processing started", posSubnet, curSubnetInfo.IId.SystemId) if resSubnet.IId.SystemId == curSubnetInfo.IId.SystemId { - cblogger.Infof("추가 요청 받은 [%s] Subnet을 발견 했습니다. - SystemID:[%s]", subnetInfo.IId.NameId, curSubnetInfo.IId.SystemId) + cblogger.Infof("Discovered additional requested [%s] Subnet. - SystemID:[%s]", subnetInfo.IId.NameId, curSubnetInfo.IId.SystemId) //for ~ range는 포인터가 아니라서 값 수정이 안됨. for loop으로 직접 서브넷을 체크하거나 vpcInfo의 배열의 값을 수정해야 함. - cblogger.Infof("인덱스 위치 : %d", posSubnet) + cblogger.Infof("Index position: %d", posSubnet) //vpcInfo.SubnetInfoList[posSubnet].IId.NameId = "테스트~" vpcInfo.SubnetInfoList[posSubnet].IId.NameId = subnetInfo.IId.NameId findSubnet = true @@ -547,7 +547,7 @@ func (VPCHandler *AlibabaVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.Su } if !findSubnet { - cblogger.Errorf("서브넷 생성은 성공했으나 VPC의 서브넷 목록에서 추가 요청한 [%s]서브넷의 정보[%s]를 찾지 못했습니다.", subnetInfo.IId.NameId, resSubnet.IId.SystemId) + cblogger.Errorf("Subnet creation was successful, but the information [%s] requested for the [%s] subnet could not be found in the VPC's subnet list.", subnetInfo.IId.NameId, resSubnet.IId.SystemId) return irs.VPCInfo{}, errors.New("MismatchSubnet.NotFound: No SysmteId[" + resSubnet.IId.SystemId + "] found for newly created Subnet[" + subnetInfo.IId.NameId + "].") } @@ -557,7 +557,7 @@ func (VPCHandler *AlibabaVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.Su } func (VPCHandler *AlibabaVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID) (bool, error) { - cblogger.Infof("[%s] VPC의 [%s] Subnet 삭제", vpcIID.SystemId, subnetIID.SystemId) + cblogger.Infof("[%s] VPC의 [%s] Subnet Delete", vpcIID.SystemId, subnetIID.SystemId) return VPCHandler.DeleteSubnet(subnetIID) } diff --git a/cloud-control-manager/cloud-driver/drivers/aws/AwsDriver.go b/cloud-control-manager/cloud-driver/drivers/aws/AwsDriver.go index 2cdd39dcb..8c2bdd22a 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/AwsDriver.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/AwsDriver.go @@ -15,13 +15,12 @@ import ( acon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/aws/connect" ars "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/aws/resources" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" + "github.com/sirupsen/logrus" icon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/connect" //icon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/connect/AwsNewIfCloudConnect" //icon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/connect/connect" - "fmt" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" @@ -31,8 +30,15 @@ import ( "github.com/aws/aws-sdk-go/service/elbv2" "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/pricing" + cblogger "github.com/cloud-barista/cb-log" ) +var cblog *logrus.Logger + +func init() { + cblog = cblogger.GetLogger("CLOUD-BARISTA") +} + type AwsDriver struct { } @@ -62,10 +68,9 @@ func (AwsDriver) GetDriverCapability() idrv.DriverCapabilityInfo { func getVMClient(connectionInfo idrv.ConnectionInfo) (*ec2.EC2, error) { // setup Region - // fmt.Println("AwsDriver : getVMClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") - // fmt.Println("AwsDriver : getVMClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") - //fmt.Println("전달 받은 커넥션 정보") - //spew.Dump(connectionInfo) + //cblog.Info("AwsDriver : getVMClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + //cblog.Info("AwsDriver : getVMClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") + //cblog.Info("전달 받은 커넥션 정보") sess, err := session.NewSession(&aws.Config{ CredentialsChainVerboseErrors: aws.Bool(true), @@ -74,14 +79,14 @@ func getVMClient(connectionInfo idrv.ConnectionInfo) (*ec2.EC2, error) { Credentials: credentials.NewStaticCredentials(connectionInfo.CredentialInfo.ClientId, connectionInfo.CredentialInfo.ClientSecret, "")}, ) if err != nil { - fmt.Println("Could not create aws New Session", err) + cblog.Error("Could not create aws New Session", err) return nil, err } // Create EC2 service client svc := ec2.New(sess) if err != nil { - fmt.Println("Could not create EC2 service client", err) + cblog.Error("Could not create EC2 service client", err) return nil, err } @@ -93,10 +98,9 @@ func getNLBClient(connectionInfo idrv.ConnectionInfo) (*elbv2.ELBV2, error) { //func getNLBClient(connectionInfo idrv.ConnectionInfo) (*elb.ELB, error) { // setup Region - // fmt.Println("AwsDriver : getVMClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") - // fmt.Println("AwsDriver : getVMClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") - //fmt.Println("전달 받은 커넥션 정보") - //spew.Dump(connectionInfo) + //cblog.Info("AwsDriver : getVMClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + //cblog.Info("AwsDriver : getVMClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") + //cblog.Info("전달 받은 커넥션 정보") sess, err := session.NewSession(&aws.Config{ Region: aws.String(connectionInfo.RegionInfo.Region), @@ -104,7 +108,7 @@ func getNLBClient(connectionInfo idrv.ConnectionInfo) (*elbv2.ELBV2, error) { Credentials: credentials.NewStaticCredentials(connectionInfo.CredentialInfo.ClientId, connectionInfo.CredentialInfo.ClientSecret, "")}, ) if err != nil { - fmt.Println("Could not create aws New Session", err) + cblog.Error("Could not create aws New Session", err) return nil, err } @@ -112,7 +116,7 @@ func getNLBClient(connectionInfo idrv.ConnectionInfo) (*elbv2.ELBV2, error) { // Create ELBv2 service client svc := elbv2.New(sess) if err != nil { - fmt.Println("Could not create ELBv2 service client", err) + cblog.Error("Could not create ELBv2 service client", err) return nil, err } @@ -123,10 +127,9 @@ func getNLBClient(connectionInfo idrv.ConnectionInfo) (*elbv2.ELBV2, error) { func getEKSClient(connectionInfo idrv.ConnectionInfo) (*eks.EKS, error) { // setup Region - // fmt.Println("AwsDriver : getEKSClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") - // fmt.Println("AwsDriver : getEKSClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") - //fmt.Println("전달 받은 커넥션 정보") - //spew.Dump(connectionInfo) + //cblog.Info("AwsDriver : getEKSClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + //cblog.Info("AwsDriver : getEKSClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") + //cblog.Info("전달 받은 커넥션 정보") sess, err := session.NewSession(&aws.Config{ Region: aws.String(connectionInfo.RegionInfo.Region), @@ -134,15 +137,15 @@ func getEKSClient(connectionInfo idrv.ConnectionInfo) (*eks.EKS, error) { Credentials: credentials.NewStaticCredentials(connectionInfo.CredentialInfo.ClientId, connectionInfo.CredentialInfo.ClientSecret, "")}, ) if err != nil { - fmt.Println("Could not create aws New Session", err) + cblog.Error("Could not create aws New Session", err) return nil, err } svc := eks.New(sess) - if err != nil { - fmt.Println("Could not create eks service client", err) - return nil, err - } + //if err != nil { + // cblog.Error("Could not create eks service client", err) + // return nil, err + //} return svc, nil } @@ -150,10 +153,9 @@ func getEKSClient(connectionInfo idrv.ConnectionInfo) (*eks.EKS, error) { // Iam 처리를 위한 iam 클라이언트 획득 func getIamClient(connectionInfo idrv.ConnectionInfo) (*iam.IAM, error) { // setup Region - // fmt.Println("AwsDriver : getIamClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") - // fmt.Println("AwsDriver : getIamClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") - //fmt.Println("전달 받은 커넥션 정보") - //spew.Dump(connectionInfo) + //cblog.Info("AwsDriver : getIamClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + //cblog.Info("AwsDriver : getIamClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") + //cblog.Info("전달 받은 커넥션 정보") sess, err := session.NewSession(&aws.Config{ Region: aws.String(connectionInfo.RegionInfo.Region), @@ -161,15 +163,15 @@ func getIamClient(connectionInfo idrv.ConnectionInfo) (*iam.IAM, error) { Credentials: credentials.NewStaticCredentials(connectionInfo.CredentialInfo.ClientId, connectionInfo.CredentialInfo.ClientSecret, "")}, ) if err != nil { - fmt.Println("Could not create aws New Session", err) + cblog.Error("Could not create aws New Session", err) return nil, err } svc := iam.New(sess) - if err != nil { - fmt.Println("Could not create iam service client", err) - return nil, err - } + //if err != nil { + // cblog.Error("Could not create iam service client", err) + // return nil, err + //} return svc, nil } @@ -178,27 +180,26 @@ func getIamClient(connectionInfo idrv.ConnectionInfo) (*iam.IAM, error) { func getAutoScalingClient(connectionInfo idrv.ConnectionInfo) (*autoscaling.AutoScaling, error) { // setup Region - // fmt.Println("AwsDriver : getAutoScalingClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") - // fmt.Println("AwsDriver : getAutoScalingClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") - //fmt.Println("전달 받은 커넥션 정보") - //spew.Dump(connectionInfo) + //cblog.Info("AwsDriver : getAutoScalingClient() - Region : [" + connectionInfo.RegionInfo.Region + "]") + //cblog.Info("AwsDriver : getAutoScalingClient() - Zone : [" + connectionInfo.RegionInfo.Zone + "]") + //cblog.Info("전달 받은 커넥션 정보") sess, err := session.NewSession(&aws.Config{ Region: aws.String(connectionInfo.RegionInfo.Region), Credentials: credentials.NewStaticCredentials(connectionInfo.CredentialInfo.ClientId, connectionInfo.CredentialInfo.ClientSecret, "")}, ) if err != nil { - fmt.Println("Could not create aws New Session", err) + cblog.Error("Could not create aws New Session", err) return nil, err } //svc := elb.New(sess) // Create ELBv2 service client svc := autoscaling.New(sess) - if err != nil { - fmt.Println("Could not create autoscaling service client", err) - return nil, err - } + //if err != nil { + // cblog.Error("Could not create autoscaling service client", err) + // return nil, err + //} return svc, nil } @@ -212,8 +213,7 @@ func (driver *AwsDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) (icon. // Initialize Logger ars.InitLog() - //fmt.Println("ConnectCloud의 전달 받은 idrv.ConnectionInfo 정보") - //spew.Dump(connectionInfo) + //cblog.Info("ConnectCloud의 전달 받은 idrv.ConnectionInfo 정보") // sample code, do not user like this^^ //var iConn icon.CloudConnection diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go index 3aea034a8..216a6e7e4 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go @@ -213,7 +213,7 @@ func (ClusterHandler *AwsClusterHandler) WaitUntilClusterActive(clusterName stri cblogger.Errorf("failed to wait until cluster Active: %v", err) return err } - cblogger.Debug("=========WaitUntilClusterActive() 종료") + cblogger.Debug("=========WaitUntilClusterActive() ended") return nil } @@ -414,7 +414,7 @@ func (ClusterHandler *AwsClusterHandler) GetCluster(clusterIID irs.IID) (irs.Clu //노드 그룹 타입 변환 for _, curNodeGroup := range resNodeGroupList { - cblogger.Debugf("노드 그룹 : [%s]", curNodeGroup.IId.NameId) + cblogger.Debugf("Nod Group : [%s]", curNodeGroup.IId.NameId) clusterInfo.NodeGroupList = append(clusterInfo.NodeGroupList, *curNodeGroup) } @@ -540,7 +540,7 @@ NodeGroup에 다른 Subnet 설정이 꼭 필요시 추후 재논의 func (ClusterHandler *AwsClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGroupReqInfo irs.NodeGroupInfo) (irs.NodeGroupInfo, error) { // validation check if nodeGroupReqInfo.MaxNodeSize < 1 { // nodeGroupReqInfo.MaxNodeSize 는 최소가 1이다. - return irs.NodeGroupInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "MaxNodeSize 값은 1이상이 되어야 합니다.", nil) + return irs.NodeGroupInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "The MaxNodeSize value must be greater than or equal to 1.", nil) } // get Role Arn @@ -566,6 +566,7 @@ func (ClusterHandler *AwsClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGr subnetList = append(subnetList, &subnetId) } + cblogger.Debug("Final Subnet List") // 이 부분에서 VPC subnet ID 를 바탕으로 리스트 순회하며 ModifySubnetAttribute 를 통해 Auto-assign public IPv4 address를 활성화 for _, subnetIdPtr := range subnetList { input := &ec2.ModifySubnetAttributeInput{ @@ -584,6 +585,7 @@ func (ClusterHandler *AwsClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGr } cblogger.Debug("최종 Subnet 목록") + if cblogger.Level.String() == "debug" { spew.Dump(subnetList) } @@ -728,7 +730,7 @@ func (ClusterHandler *AwsClusterHandler) GetNodeGroup(clusterIID irs.IID, nodeGr result, err := ClusterHandler.Client.DescribeNodegroup(input) if cblogger.Level.String() == "debug" { - cblogger.Debug("===> 노드 그룹 호출 결과") + cblogger.Debug("===> Node Group Invocation Result") spew.Dump(result) } if err != nil { @@ -785,7 +787,7 @@ func (ClusterHandler *AwsClusterHandler) GetAutoScalingGroups(autoScalingGroupNa } } - cblogger.Debug("**VM 인스턴스 목록**") + cblogger.Debug("**VM Instance List**") spew.Dump(nodeList) return nodeList, nil } @@ -1021,11 +1023,11 @@ func (NodeGroupHandler *AwsClusterHandler) convertNodeGroup(nodeGroupOutput *eks nodeGroupTag = *val break } - cblogger.Info(key, *val) + cblogger.Debug(key, *val) } //printToJson(nodeGroupTagList) - cblogger.Info("nodeGroupName=", *nodeGroupName) - cblogger.Info("tag=", nodeGroupTagList[NODEGROUP_TAG]) + cblogger.Debug("nodeGroupName=", *nodeGroupName) + cblogger.Debug("tag=", nodeGroupTagList[NODEGROUP_TAG]) nodeGroupInfo.IId = irs.IID{ NameId: nodeGroupTag, // TAG에 이름 SystemId: *nodeGroupName, diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonAwsFunc.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonAwsFunc.go index 38a870760..683dd7de9 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonAwsFunc.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonAwsFunc.go @@ -124,19 +124,15 @@ func (VPCHandler *AwsVPCHandler) GetAutoCBNetworkInfo() (AwsCBNetworkInfo, error //VPC & Subnet을 생성했으므로 예외처리 없이 조회만 처리함. awsVpcInfo, _ := VPCHandler.GetVpc(GetCBDefaultVNetName()) - spew.Dump(awsVpcInfo) awsCBNetworkInfo.VpcId = awsVpcInfo.Id awsCBNetworkInfo.VpcName = awsVpcInfo.Name awsSubnetInfo, _ := VPCHandler.GetVNetwork(irs.IID{}) - spew.Dump(awsSubnetInfo) //awsCBNetworkInfo.SubnetId = awsSubnetInfo.Id //awsCBNetworkInfo.SubnetName = awsSubnetInfo.Name awsCBNetworkInfo.SubnetId = awsSubnetInfo.IId.SystemId awsCBNetworkInfo.SubnetName = awsSubnetInfo.IId.NameId - spew.Dump(awsCBNetworkInfo) - return awsCBNetworkInfo, nil } */ @@ -248,7 +244,6 @@ func (VPCHandler *AwsVPCHandler) FindOrCreateMcloudBaristaDefaultVPC(vNetworkReq } cblogger.Infof("CB Default VPC[%s] 생성 완료 - CIDR : [%s]", GetCBDefaultVNetName(), result.CidrBlock) cblogger.Info(result) - spew.Dump(result) return result.Id, nil } @@ -264,7 +259,7 @@ func (VPCHandler *AwsVPCHandler) IsAvailableAutoCBNet() bool { // Name Tag 설정 func SetNameTag(Client *ec2.EC2, Id string, value string) bool { // Tag에 Name 설정 - cblogger.Infof("Name Tage 설정 - ResourceId : [%s] Value : [%s] ", Id, value) + cblogger.Infof("Name Tage Set - ResourceId : [%s] Value : [%s] ", Id, value) _, errtag := Client.CreateTags(&ec2.CreateTagsInput{ Resources: []*string{&Id}, Tags: []*ec2.Tag{ @@ -275,7 +270,7 @@ func SetNameTag(Client *ec2.EC2, Id string, value string) bool { }, }) if errtag != nil { - cblogger.Error("Name Tag 설정 실패 : ") + cblogger.Error("Failed to set Name Tag: ") cblogger.Error(errtag) return false } @@ -300,15 +295,11 @@ func ConvertJsonStringNoEscape(v interface{}) (string, error) { encoder.SetEscapeHTML(false) errJson := encoder.Encode(v) if errJson != nil { - cblogger.Error("JSON 변환 실패") + cblogger.Error("JSON conversion failed") cblogger.Error(errJson) return "", errJson } - //fmt.Println("After marshal", string(buffer.Bytes())) - //spew.Dump(string(buffer.Bytes())) - //spew.Dump("\"TEST") - jsonString := string(buffer.Bytes()) //jsonString = strings.Replace(jsonString, "\n", "", -1) jsonString = strings.Replace(jsonString, "\"", "", -1) @@ -321,7 +312,7 @@ func ConvertJsonString(v interface{}) (string, error) { jsonBytes, errJson := json.Marshal(v) if errJson != nil { - cblogger.Error("JSON 변환 실패") + cblogger.Error("JSON conversion failed") cblogger.Error(errJson) return "", errJson } @@ -365,13 +356,12 @@ func ConvertToString(value interface{}) (string, error) { // Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용 func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) { - //spew.Dump(v) var keyValueList []irs.KeyValue var i map[string]interface{} jsonBytes, errJson := json.Marshal(v) if errJson != nil { - cblogger.Error("KeyValue 변환 실패") + cblogger.Error("KeyValue conversion failed") cblogger.Error(errJson) return nil, errJson } @@ -427,9 +417,9 @@ func ContainString(s []string, str string) bool { func PrintToJson(class interface{}) { e, err := json.Marshal(class) if err != nil { - cblogger.Info(err) + cblogger.Error(err) } - cblogger.Info(string(e)) + cblogger.Debug(string(e)) } // ZoneStatus 일반화 diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonHandler.go index ae9978caa..6c32d8235 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/CommonHandler.go @@ -2,16 +2,13 @@ package resources import ( "errors" - "fmt" "reflect" "strings" - "github.com/aws/aws-sdk-go/aws/awserr" - call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" - "github.com/davecgh/go-spew/spew" - "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ec2" + call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" ) @@ -162,7 +159,7 @@ func WaitUntilVolumeAvailable(svc *ec2.EC2, volumeID string) error { cblogger.Errorf("failed to wait until volume available: %v", err) return err } - cblogger.Info("=========WaitUntilVolumeAvailable() 종료") + cblogger.Info("=========WaitUntilVolumeAvailable() ended") return nil } @@ -178,7 +175,7 @@ func WaitUntilVolumeDeleted(svc *ec2.EC2, volumeID string) error { cblogger.Errorf("failed to wait until volume deleted: %v", err) return err } - cblogger.Info("=========WaitUntilVolumeDeleted() 종료") + cblogger.Info("=========WaitUntilVolumeDeleted() ended") return nil } @@ -194,7 +191,7 @@ func WaitUntilVolumeInUse(svc *ec2.EC2, volumeID string) error { cblogger.Errorf("failed to wait until volume in use: %v", err) return err } - cblogger.Info("=========WaitUntilVolumeInUse() 종료") + cblogger.Info("=========WaitUntilVolumeInUse() ended") return nil } @@ -234,15 +231,15 @@ func DescribeVolumnes(svc *ec2.EC2, volumeIdList []*string) (*ec2.DescribeVolume if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } return nil, err } if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return result, nil @@ -264,15 +261,15 @@ func DescribeVolumneById(svc *ec2.EC2, volumeId string) (*ec2.Volume, error) { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } return nil, err } if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } for _, volume := range result.Volumes { @@ -315,7 +312,9 @@ func DescribeVolumnesBySnapshot(svc *ec2.EC2, snapShotIIDs []string) (*ec2.Descr result, err := svc.DescribeVolumes(input) callogger.Info("DescribeVolumnesBySnapshot IN PU T") - spew.Dump(input) + if cblogger.Level.String() == "debug" { + cblogger.Debug(input) + } callLogInfo.ElapsedTime = call.Elapsed(callLogStart) callogger.Info(call.String(callLogInfo)) @@ -323,16 +322,16 @@ func DescribeVolumnesBySnapshot(svc *ec2.EC2, snapShotIIDs []string) (*ec2.Descr if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } return nil, err } - //if cblogger.Level.String() == "debug" { - spew.Dump(result.Volumes) - //} + if cblogger.Level.String() == "debug" { + cblogger.Debug(result.Volumes) + } return result, nil } @@ -363,16 +362,16 @@ func AttachVolume(svc *ec2.EC2, deviceName string, instanceId string, volumeId s if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } return err } if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } err = WaitUntilVolumeInUse(svc, volumeId) @@ -395,18 +394,18 @@ func DeleteDisk(svc *ec2.EC2, disks []irs.IID) (bool, error) { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } return false, err } if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } err = WaitUntilVolumeDeleted(svc, diskIID.SystemId) @@ -484,12 +483,12 @@ func DescribeImages(svc *ec2.EC2, imageIIDs []*irs.IID, owners []*string) (*ec2. if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } } @@ -513,12 +512,12 @@ func DescribeImageById(svc *ec2.EC2, imageIID *irs.IID, owners []*string) (*ec2. if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } } @@ -642,7 +641,7 @@ func GetOsTypeFromEc2Image(ec2Image *ec2.Image) string { // } // input.SnapshotIds = snapshotIds // } -// //fmt.Println("sign name " + svc.Client.SigningName)// ec2 +// //cblogger.Info("sign name " + svc.Client.SigningName)// ec2 // // //input.OwnerIds = []*string{aws.String("050864702683")} // input.OwnerIds = []*string{aws.String("self")} @@ -652,15 +651,15 @@ func GetOsTypeFromEc2Image(ec2Image *ec2.Image) string { // if aerr, ok := err.(awserr.Error); ok { // switch aerr.Code() { // default: -// fmt.Println(aerr.Error()) +// cblogger.Error(aerr.Error()) // } // } else { // // Print the error, cast err to awserr.Error to get the Code and // // Message from an error. -// fmt.Println(err.Error()) +// cblogger.Error(err.Error()) // } // } -// spew.Dump(result) +// // return result, err //} //func DescribeSnapshotById(svc *ec2.EC2, snapshotIID *irs.IID) (*ec2.Snapshot, error) { @@ -678,12 +677,12 @@ func GetOsTypeFromEc2Image(ec2Image *ec2.Image) string { // if aerr, ok := err.(awserr.Error); ok { // switch aerr.Code() { // default: -// fmt.Println(aerr.Error()) +// cblogger.Error(aerr.Error()) // } // } else { // // Print the error, cast err to awserr.Error to get the Code and // // Message from an error. -// fmt.Println(err.Error()) +// cblogger.Error(err.Error()) // } // return nil, err // } diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/DiskHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/DiskHandler.go index eed96318b..6b9e3a870 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/DiskHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/DiskHandler.go @@ -4,7 +4,6 @@ package resources import ( "errors" - "fmt" "reflect" "strconv" "strings" @@ -16,7 +15,6 @@ import ( idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" cim "github.com/cloud-barista/cb-spider/cloud-info-manager" - "github.com/davecgh/go-spew/spew" ) type AwsDiskHandler struct { @@ -65,7 +63,6 @@ func (DiskHandler *AwsDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs.Dis if diskReqInfo.Zone != "" { zone = diskReqInfo.Zone } - //spew.Dump(DiskHandler.Region) err := validateCreateDisk(&diskReqInfo) if err != nil { return irs.DiskInfo{}, err @@ -108,17 +105,16 @@ func (DiskHandler *AwsDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs.Dis // case3 : 암호화된 disk 생성 //input.Encrypted = true //input.KmsKeyId = "" - //spew.Dump(input) result, err := DiskHandler.Client.CreateVolume(input) hiscallInfo.ElapsedTime = call.Elapsed(start) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } cblogger.Error(err) LoggingError(hiscallInfo, err) @@ -165,7 +161,7 @@ func (DiskHandler *AwsDiskHandler) ListDisk() ([]*irs.DiskInfo, error) { for _, volumeInfo := range result.Volumes { diskInfo, err := DiskHandler.convertVolumeInfoToDiskInfo(volumeInfo) if err != nil { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } returnDiskInfoList = append(returnDiskInfoList, &diskInfo) } @@ -236,12 +232,12 @@ func (DiskHandler *AwsDiskHandler) ChangeDiskSize(diskIID irs.IID, size string) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } cblogger.Error(err) LoggingError(hiscallInfo, err) @@ -272,12 +268,12 @@ func (DiskHandler *AwsDiskHandler) DeleteDisk(diskIID irs.IID) (bool, error) { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } cblogger.Error(err) LoggingError(hiscallInfo, err) @@ -286,7 +282,7 @@ func (DiskHandler *AwsDiskHandler) DeleteDisk(diskIID irs.IID) (bool, error) { calllogger.Info(call.String(hiscallInfo)) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } err = WaitUntilVolumeDeleted(DiskHandler.Client, diskIID.SystemId) @@ -335,7 +331,6 @@ func (DiskHandler *AwsDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) return irs.DiskInfo{}, err } - //spew.Dump(diskDeviceList) if diskDeviceList != nil { isAvailable := true for _, avn := range availableVolumeNames { @@ -398,10 +393,10 @@ func (DiskHandler *AwsDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } cblogger.Error(err) LoggingError(hiscallInfo, err) @@ -410,7 +405,7 @@ func (DiskHandler *AwsDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) calllogger.Info(call.String(hiscallInfo)) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } err = WaitUntilVolumeInUse(DiskHandler.Client, diskIID.SystemId) @@ -452,10 +447,10 @@ func (DiskHandler *AwsDiskHandler) DetachDisk(diskIID irs.IID, ownerVM irs.IID) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } cblogger.Error(err) LoggingError(hiscallInfo, err) @@ -464,7 +459,7 @@ func (DiskHandler *AwsDiskHandler) DetachDisk(diskIID irs.IID, ownerVM irs.IID) calllogger.Info(call.String(hiscallInfo)) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } err = WaitUntilVolumeInUse(DiskHandler.Client, diskIID.SystemId) @@ -515,7 +510,7 @@ func validateCreateDisk(diskReqInfo *irs.DiskInfo) error { arrRootDiskType := cloudOSMetaInfo.RootDiskType arrDiskSizeOfType := cloudOSMetaInfo.DiskSize - cblogger.Info(arrDiskType) + cblogger.Debug(arrDiskType) reqDiskType := diskReqInfo.DiskType reqDiskSize := diskReqInfo.DiskSize if reqDiskType == "" || reqDiskType == "default" { @@ -592,12 +587,12 @@ func validateCreateDisk(diskReqInfo *irs.DiskInfo) error { } if volumeSize < diskSizeValue.diskMinSize { - fmt.Println("Disk Size Error!!: ", volumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", volumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be at least the default size (" + strconv.FormatInt(diskSizeValue.diskMinSize, 10) + " GB).") } if volumeSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", volumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", volumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be smaller than the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } @@ -728,12 +723,12 @@ func validateModifyDisk(diskReqInfo irs.DiskInfo, diskSize string) error { } if targetVolumeSize < diskSizeValue.diskMinSize { - fmt.Println("Disk Size Error!!: ", targetVolumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", targetVolumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Root Disk Size must be at least the default size (" + strconv.FormatInt(diskSizeValue.diskMinSize, 10) + " GB).") } if targetVolumeSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", targetVolumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", targetVolumeSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Root Disk Size must be smaller than the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } @@ -874,13 +869,13 @@ func (DiskHandler *AwsDiskHandler) convertVolumeInfoToDiskInfo(volumeInfo *ec2.V } } } - cblogger.Info(vmId) + cblogger.Debug(vmId) diskStatus, errStatus := convertVolumeStatusToDiskStatus(*volumeInfo.State, attachments, vmId) if errStatus != nil { return irs.DiskInfo{}, errStatus } - cblogger.Info(diskStatus) + cblogger.Debug(diskStatus) diskInfo.Status = diskStatus if !strings.EqualFold(vmId, "") { @@ -891,11 +886,9 @@ func (DiskHandler *AwsDiskHandler) convertVolumeInfoToDiskInfo(volumeInfo *ec2.V // return irs.DiskInfo{}, errStatus //} //diskInfo.OwnerVM = vmInfo.IId - //spew.Dump(vmInfo) } diskInfo.CreatedTime = *volumeInfo.CreateTime - //spew.Dump(volumeInfo) //KeyValueList []KeyValue var inKeyValueList []irs.KeyValue //if !reflect.ValueOf(volumeInfo.Encrypted).IsNil() { @@ -910,9 +903,9 @@ func (DiskHandler *AwsDiskHandler) convertVolumeInfoToDiskInfo(volumeInfo *ec2.V //inKeyValueList = append(inKeyValueList, icbs.KeyValue{Key: "Tags", Value: strings.Join(volumeInfo.Tags, ",")}) //inKeyValueList = append(inKeyValueList, icbs.KeyValue{Key: "OutpostArn", Value: *volumeInfo.OutpostArn}) diskInfo.KeyValueList = inKeyValueList - cblogger.Info("keyvalue2") + cblogger.Debug("keyvalue2") if cblogger.Level.String() == "debug" { - spew.Dump(diskInfo) + cblogger.Debug(diskInfo) } return diskInfo, nil } diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/ImageHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/ImageHandler.go index a0d717e9a..937b8a6b1 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/ImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/ImageHandler.go @@ -95,7 +95,6 @@ func (imageHandler *AwsImageHandler) ListImage() ([]*irs.ImageInfo, error) { callLogStart := call.Start() result, err := imageHandler.Client.DescribeImages(input) - //spew.Dump(result) //출력 정보가 너무 많아서 생략 callLogInfo.ElapsedTime = call.Elapsed(callLogStart) @@ -119,18 +118,17 @@ func (imageHandler *AwsImageHandler) ListImage() ([]*irs.ImageInfo, error) { cnt := 0 for _, cur := range result.Images { - //spew.Dump(cur) if reflect.ValueOf(cur.State).IsNil() { - cblogger.Errorf("===>[%s] AMI는 State 정보가 없어서 Skip함.", *cur.ImageId) + cblogger.Errorf("===>[%s] AMI is skipped because it lacks State information.", *cur.ImageId) continue } if reflect.ValueOf(cur.Name).IsNil() { - cblogger.Infof("===>[%s] AMI는 Name 정보가 없어서 Skip함.", *cur.ImageId) + cblogger.Infof("===>[%s] AMI is skipped because it lacks Name information.", *cur.ImageId) continue } - cblogger.Debugf("[%s] - [%s] - [%s] AMI 정보 처리", *cur.ImageId, *cur.State, *cur.Name) + cblogger.Debugf("[%s] - [%s] - [%s] AMI State name", *cur.ImageId, *cur.State, *cur.Name) //cblogger.Infof("[%s] - [%s] - [%s] - [%s] AMI 정보 처리", *cur.ImageId, *cur.State, *cur.Name, *cur.UsageOperation) imageInfo := ExtractImageDescribeInfo(cur) @@ -143,8 +141,7 @@ func (imageHandler *AwsImageHandler) ListImage() ([]*irs.ImageInfo, error) { */ } - cblogger.Info("%d개의 이미지가 조회됨.", cnt) - //spew.Dump(imageInfoList) + cblogger.Info("%d images retrieved.", cnt) return imageInfoList, nil } @@ -152,7 +149,7 @@ func (imageHandler *AwsImageHandler) ListImage() ([]*irs.ImageInfo, error) { // Image 정보를 추출함 // @TODO : GuestOS 쳌크할 것 func ExtractImageDescribeInfo(image *ec2.Image) irs.ImageInfo { - //spew.Dump(image) + imageInfo := irs.ImageInfo{ //IId: irs.IID{*image.Name, *image.ImageId}, IId: irs.IID{*image.ImageId, *image.ImageId}, @@ -237,8 +234,8 @@ func (imageHandler *AwsImageHandler) GetAmiImage(imageIID irs.IID) (*ec2.Image, result, err := imageHandler.Client.DescribeImages(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - //spew.Dump(result) - cblogger.Info(result) + + cblogger.Debug(result) if err != nil { callLogInfo.ErrorMSG = err.Error() diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/KeyPairHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/KeyPairHandler.go index a62f6e062..551ee0a71 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/KeyPairHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/KeyPairHandler.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "log" "os" "github.com/aws/aws-sdk-go/aws" @@ -14,8 +13,7 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" - _ "github.com/davecgh/go-spew/spew" + //_ "github.com/davecgh/go-spew/spew" ) type AwsKeyPairHandler struct { @@ -36,7 +34,7 @@ type KeyPairInfo struct { func (keyPairHandler *AwsKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error) { cblogger.Debug("Start ListKey()") var keyPairList []*irs.KeyPairInfo - //spew.Dump(keyPairHandler) + //cblogger.Debug(keyPairHandler) cblogger.Debug(keyPairHandler) input := &ec2.DescribeKeyPairsInput{ @@ -81,7 +79,7 @@ func (keyPairHandler *AwsKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error) { keyPairInfo, errKeyPair := ExtractKeyPairDescribeInfo(pair) if errKeyPair != nil { //cblogger.Infof("[%s] KeyPair는 Local에서 관리하는 대상이 아니기 때문에 Skip합니다.", *pair.KeyName) - cblogger.Info(errKeyPair.Error()) + cblogger.Error(errKeyPair.Error()) //return nil, errKeyPair } else { keyPairList = append(keyPairList, &keyPairInfo) @@ -89,13 +87,13 @@ func (keyPairHandler *AwsKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error) { } cblogger.Debug(keyPairList) - //spew.Dump(keyPairList) + //cblogger.Debug(keyPairList) return keyPairList, nil } // 2021-10-26 이슈#480에 의해 Local Key 로직 제거 func (keyPairHandler *AwsKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error) { - cblogger.Info(keyPairReqInfo) + cblogger.Debug(keyPairReqInfo) /* 2021-10-26 이슈#480에 의해 Local Key 로직 제거 keyPairPath := os.Getenv("CBSPIDER_ROOT") + CBKeyPairPath cblogger.Infof("Getenv[CBSPIDER_ROOT] : [%s]", os.Getenv("CBSPIDER_ROOT")) @@ -152,7 +150,7 @@ func (keyPairHandler *AwsKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReq */ cblogger.Infof("Public Key") - //spew.Dump(publicKey) + //cblogger.Debug(publicKey) keyPairInfo := irs.KeyPairInfo{ //Name: *result.KeyName, IId: irs.IID{keyPairReqInfo.IId.NameId, *result.KeyName}, @@ -165,7 +163,7 @@ func (keyPairHandler *AwsKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReq }, } - //spew.Dump(keyPairInfo) + //cblogger.Debug(keyPairInfo) // resultStr = strings.ReplaceAll(resultStr, "//", "/") //@TODO : File에 저장할 키 파일 이름의 PK 특징 때문에 제약이 걸릴 수 있음. (인증정보로 해쉬를 하면 부모 하위의 IAM 계정에서 해당 키를 못 찾을 수 있으며 사용자 정보를 사용하지 않으면 Uniqueue하지 않아서 충돌 날 수 있음.) 현재는 핑거프린트와 리전을 키로 사용함. @@ -240,20 +238,19 @@ func (keyPairHandler *AwsKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo result, err := keyPairHandler.Client.DescribeKeyPairs(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - cblogger.Info("result : ", result) - cblogger.Info("err : ", err) + cblogger.Debug("result : ", result) + cblogger.Debug("err : ", err) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) if aerr, ok := err.(awserr.Error); ok { - cblogger.Info("aerr : ", aerr) - cblogger.Info("aerr.Code() : ", aerr.Code()) - cblogger.Info("ok : ", ok) + cblogger.Debug("aerr : ", aerr) + cblogger.Debug("aerr.Code() : ", aerr.Code()) + cblogger.Debug("ok : ", ok) switch aerr.Code() { - default: - //fmt.Println(aerr.Error()) + default: cblogger.Error(aerr.Error()) return irs.KeyPairInfo{}, aerr } @@ -273,7 +270,7 @@ func (keyPairHandler *AwsKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo return irs.KeyPairInfo{}, errKeyPair } - spew.Dump(keyPairInfo) + cblogger.Debug(keyPairInfo) return keyPairInfo, nil } else { return irs.KeyPairInfo{}, errors.New("No information found.") @@ -282,7 +279,7 @@ func (keyPairHandler *AwsKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo // KeyPair 정보를 추출함 func ExtractKeyPairDescribeInfo(keyPair *ec2.KeyPairInfo) (irs.KeyPairInfo, error) { - //spew.Dump(keyPair) + //cblogger.Debug(keyPair) keyPairInfo := irs.KeyPairInfo{ IId: irs.IID{*keyPair.KeyName, *keyPair.KeyName}, //Name: *keyPair.KeyName, @@ -356,7 +353,7 @@ func (keyPairHandler *AwsKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error) }) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - //spew.Dump(result) + //cblogger.Debug(result) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -405,14 +402,14 @@ func (keyPairHandler *AwsKeyPairHandler) CheckKeyPairFolder(keyPairPath string) //키페어 생성 시 폴더가 존재하지 않으면 생성 함. _, errChkDir := os.Stat(keyPairPath) if os.IsNotExist(errChkDir) { - cblogger.Errorf("[%s] Path가 존재하지 않아서 생성합니다.", keyPairPath) + cblogger.Errorf("[%s] Path does not exist, so it will be created.", keyPairPath) //errDir := os.MkdirAll(keyPairPath, 0755) errDir := os.MkdirAll(keyPairPath, 0700) //errDir := os.MkdirAll(keyPairPath, os.ModePerm) // os.ModePerm : 0777 //os.ModeDir if errDir != nil { //log.Fatal(err) - cblogger.Errorf("[%s] Path가 생성 실패", keyPairPath) + cblogger.Errorf("[%s] Failed to create path.", keyPairPath) cblogger.Error(errDir) return errDir } @@ -425,8 +422,8 @@ func (keyPairHandler *AwsKeyPairHandler) CheckKeyPairFolder(keyPairPath string) // // KeyPair 해시 생성 함수 (PK 이슈로 현재는 사용하지 않음) func CreateHashString(credentialInfo idrv.CredentialInfo, Region idrv.RegionInfo) (string, error) { - log.Println("credentialInfo.ClientId : " + credentialInfo.ClientId) - log.Println("Region.Region : " + Region.Region) + cblogger.Info("credentialInfo.ClientId : " + credentialInfo.ClientId) + cblogger.Info("Region.Region : " + Region.Region) keyString := credentialInfo.ClientId + credentialInfo.ClientSecret + Region.Region //keyString := credentialInfo hasher := md5.New() diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/MyImageHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/MyImageHandler.go index 3169eb687..a3a994c74 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/MyImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/MyImageHandler.go @@ -14,7 +14,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" ) // https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.CreateImage @@ -83,12 +82,12 @@ const ( // if aerr, ok := err.(awserr.Error); ok { // switch aerr.Code() { // default: -// fmt.Println(aerr.Error()) +// cblogger.Error(aerr.Error()) // } // } else { // // Print the error, cast err to awserr.Error to get the Code and // // Message from an error. -// fmt.Println(err.Error()) +// cblogger.Error(err.Error()) // } // return irs.MyImageInfo{}, err // } @@ -113,7 +112,6 @@ const ( // if err != nil { // return nil, err // } -// spew.Dump(result) // for _, snapShot := range result.Snapshots { // myImage, err := convertAWSSnapShopToMyImageInfo(snapShot) // if err != nil { @@ -152,12 +150,12 @@ const ( // if aerr, ok := err.(awserr.Error); ok { // switch aerr.Code() { // default: -// fmt.Println(aerr.Error()) +// cblogger.Error(aerr.Error()) // } // } else { // // Print the error, cast err to awserr.Error to get the Code and // // Message from an error. -// fmt.Println(err.Error()) +// cblogger.Error(err.Error()) // } // return false, err // } @@ -170,7 +168,6 @@ const ( // // return false, err // //} // // -// spew.Dump(result) // return true, nil //} // @@ -307,7 +304,7 @@ func (ImageHandler *AwsMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyImageInf } if cblogger.Level.String() == "debug" { - spew.Dump(input) + cblogger.Debug(input) } result, err := ImageHandler.Client.CreateImage(input) @@ -316,12 +313,12 @@ func (ImageHandler *AwsMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyImageInf if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } cblogger.Error(err) LoggingError(hiscallInfo, err) @@ -361,7 +358,7 @@ func (ImageHandler *AwsMyImageHandler) ListMyImage() ([]*irs.MyImageInfo, error) calllogger.Info(call.String(hiscallInfo)) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } for _, awsImage := range result.Images { myImage, err := convertAWSImageToMyImageInfo(awsImage) @@ -420,7 +417,7 @@ func (ImageHandler *AwsMyImageHandler) DeleteMyImage(myImageIID irs.IID) (bool, return false, err } if cblogger.Level.String() == "debug" { - spew.Dump(diskIIDs) + cblogger.Debug(diskIIDs) } input := &ec2.DeregisterImageInput{} @@ -436,7 +433,7 @@ func (ImageHandler *AwsMyImageHandler) DeleteMyImage(myImageIID irs.IID) (bool, calllogger.Info(call.String(hiscallInfo)) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } for _, snapshotId := range snapshotIds { @@ -551,7 +548,6 @@ func (MyImageHandler *AwsMyImageHandler) DeleteSnapshotById(snapshotId string) ( // if err != nil { // return false, err // } - // spew.Dump(result) input := &ec2.DeleteSnapshotInput{ SnapshotId: aws.String(snapshotId), @@ -562,16 +558,16 @@ func (MyImageHandler *AwsMyImageHandler) DeleteSnapshotById(snapshotId string) ( if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: - fmt.Println(aerr.Error()) + cblogger.Error(aerr.Error()) } } else { - fmt.Println(err.Error()) + cblogger.Error(err.Error()) } return false, err } if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return true, nil diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/NLBHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/NLBHandler.go index eda81b774..788969bab 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/NLBHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/NLBHandler.go @@ -10,8 +10,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/davecgh/go-spew/spew" - //"github.com/aws/aws-sdk-go/service/elb" "github.com/aws/aws-sdk-go/service/ec2" @@ -63,7 +61,7 @@ func (NLBHandler *AwsNLBHandler) CreateListener(nlbReqInfo irs.NLBInfo) (*elbv2. if n, err := strconv.ParseInt(nlbReqInfo.Listener.Port, 10, 64); err == nil { input.SetPort(n) } else { - cblogger.Error(nlbReqInfo.Listener.Port, "은 숫자가 아님!!") + cblogger.Error(nlbReqInfo.Listener.Port, "is not number!!") return nil, err } } else { @@ -123,9 +121,9 @@ func (NLBHandler *AwsNLBHandler) CreateListener(nlbReqInfo irs.NLBInfo) (*elbv2. return nil, err } - cblogger.Debug("Listener 생성 결과") + cblogger.Debug("Listener creation result") if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return result, nil @@ -152,7 +150,7 @@ func (NLBHandler *AwsNLBHandler) CreateTargetGroup(nlbReqInfo irs.NLBInfo) (*elb if n, err := strconv.ParseInt(nlbReqInfo.VMGroup.Port, 10, 64); err == nil { input.SetPort(n) } else { - cblogger.Error(nlbReqInfo.VMGroup.Port, "은 숫자가 아님!!") + cblogger.Error(nlbReqInfo.VMGroup.Port, "is not number!!") return nil, err } } else { @@ -208,9 +206,9 @@ func (NLBHandler *AwsNLBHandler) CreateTargetGroup(nlbReqInfo irs.NLBInfo) (*elb return nil, err } - cblogger.Debug("TargetGroup 생성 결과") + cblogger.Debug("TargetGroup creation result") if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return result, nil @@ -230,7 +228,7 @@ func (NLBHandler *AwsNLBHandler) ExtractNlbSubnets(vpcId string) ([]*string, err }, } - //spew.Dump(input) + //cblogger.Debug(input) result, err := NLBHandler.VMClient.DescribeSubnets(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { @@ -247,19 +245,19 @@ func (NLBHandler *AwsNLBHandler) ExtractNlbSubnets(vpcId string) ([]*string, err } if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } //서브넷 정보 추출 mapZone := map[string]string{} //AZ별 1개의 서브넷만 사용 가능하기 때문에 중복을 제거 함. (형식) mapZone["AZ"]="서브넷" - cblogger.Debug("사용 가능한 Subnet 목록 조회") + cblogger.Debug("Retrieve available Subnet list") for _, curSubnet := range result.Subnets { cblogger.Debugf("[%s] AZ [%s] Subnet", *curSubnet.AvailabilityZone, *curSubnet.SubnetId) mapZone[*curSubnet.AvailabilityZone] = *curSubnet.SubnetId } //최종 사용할 서브넷 목록만 추출함. - cblogger.Info("NLB에 사용하기 위해 최종 선택된 Subnet 목록") + cblogger.Info("Final selected Subnet list for NLB usage") subnetList := []*string{} for key, val := range mapZone { cblogger.Infof("AZ[%s] Subnet[%s]", key, val) @@ -298,14 +296,14 @@ func (NLBHandler *AwsNLBHandler) ExtractVmSubnets(VMs *[]irs.IID) ([]*string, er } cblogger.Debug(result) - cblogger.Infof("조회된 VM 정보 수 : [%d]", len(result.Reservations)) + cblogger.Infof("Number of retrieved VM information: [%d]", len(result.Reservations)) if len(result.Reservations) == 0 { - cblogger.Error("조회된 VM 정보가 없습니다.") + cblogger.Error("No VM information retrieved.") return nil, awserr.New(CUSTOM_ERR_CODE_NOTFOUND, "VM information was not found.", nil) } if len(*VMs) != len(result.Reservations) { - cblogger.Errorf("요청된 VM 수[%d]와 조회된 VM 수[%d]가 일치하지 않습니다.", len(*VMs), len(result.Reservations)) + cblogger.Errorf("The requested VM count [%d] does not match the retrieved VM count [%d].", len(*VMs), len(result.Reservations)) return nil, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, fmt.Sprintf("Requested number of VMs [%d] and queried number of VMs [%d] do not match.", len(*VMs), len(result.Reservations)), nil) } @@ -352,10 +350,10 @@ func (NLBHandler *AwsNLBHandler) CheckHealthCheckerValidation(reqHealthCheckerIn if strings.EqualFold(reqHealthCheckerInfo.Protocol, "TCP") || strings.EqualFold(reqHealthCheckerInfo.Protocol, "TLS") || strings.EqualFold(reqHealthCheckerInfo.Protocol, "UDP") || strings.EqualFold(reqHealthCheckerInfo.Protocol, "TCP_UDP") { //헬스 체크 인터벌 값 검증 if reqHealthCheckerInfo.Interval == 10 || reqHealthCheckerInfo.Interval == 30 { - cblogger.Debugf("===================> 헬스 체크 인터벌 값 검증 : 통과 : [%d]", reqHealthCheckerInfo.Interval) + cblogger.Debugf("===================> Health check interval value validation: Passed: [%d]", reqHealthCheckerInfo.Interval) } else { - cblogger.Errorf("===================> 헬스 체크 인터벌 값 검증 : 실패 - 입력 값 : [%d]", reqHealthCheckerInfo.Interval) - cblogger.Error("TCP 프로토콜의 헬스 체크 인터벌은 10 또는 30만 가능 함.") + cblogger.Errorf("===================> Health check interval value validation: Failed - Input value: [%d]", reqHealthCheckerInfo.Interval) + cblogger.Error("The health check interval for TCP protocol must be either 10 or 30.") return awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "The health check interval for TCP protocol can only be 10 or 30.", nil) } @@ -370,10 +368,10 @@ func (NLBHandler *AwsNLBHandler) CheckHealthCheckerValidation(reqHealthCheckerIn // If the target type is lambda, the default is 30 seconds. if reqHealthCheckerInfo.Timeout > 0 { if strings.EqualFold(reqHealthCheckerInfo.Protocol, "TCP") { - cblogger.Errorf("===================> TCP 프로토콜은 헬스 체크 타임아웃 값 설정을 지원하지 않음") + cblogger.Errorf("===================> TCP protocol does not support health check timeout value setting") return awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "Custom health check timeouts are not supported for health checks for target groups with the TCP protocol.", nil) } else { - cblogger.Debugf("===================> 헬스 체크 타임아웃 값 검증 : 통과 : [%d](TCP프로토콜 아님)", reqHealthCheckerInfo.Timeout) + cblogger.Debugf("===================> Health check timeout value validation: Passed: [%d] (Not TCP protocol)", reqHealthCheckerInfo.Timeout) } } @@ -528,10 +526,10 @@ func (NLBHandler *AwsNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, } callogger.Info(call.String(callLogInfo)) - cblogger.Infof("[%s] NLB 생성 완료 - LoadBalancerArn : [%s]", nlbReqInfo.IId.NameId, *result.LoadBalancers[0].LoadBalancerArn) + cblogger.Infof("[%s] NLB creation completed - LoadBalancerArn: [%s]", nlbReqInfo.IId.NameId, *result.LoadBalancers[0].LoadBalancerArn) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } nlbReqInfo.IId.SystemId = *result.LoadBalancers[0].LoadBalancerArn //리스너 생성및 장애시 삭제 처리를 위해 Req에 LoadBalancerArn 정보를 셋팅함. @@ -544,21 +542,21 @@ func (NLBHandler *AwsNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, cblogger.Error(errTargetGroup.Error()) //생성된 NLB 포함 리소스들 삭제 - cblogger.Infof("VM 그룹 생성 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 시작!!", nlbReqInfo.IId.NameId) + cblogger.Infof("Starting NLB [%s] and related resources deletion due to VM group creation failure!!", nlbReqInfo.IId.NameId) _, errNlbInfo := NLBHandler.DeleteNLB(nlbReqInfo.IId) if errNlbInfo != nil { - cblogger.Errorf("VM 그룹 생성 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 실패!!", nlbReqInfo.IId.NameId) + cblogger.Errorf("Failed to delete NLB [%s] and related resources due to VM group creation failure!!", nlbReqInfo.IId.NameId) cblogger.Error(errNlbInfo.Error()) //만약 NLB 포함 관련 리소스 정보 제거에 실패해도 생성 에러 메시지 유지를 위해 다른 작업은 진행하지 않음. } else { - cblogger.Infof("VM 그룹 생성 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 완료!!", nlbReqInfo.IId.NameId) + cblogger.Infof("NLB [%s] and related resources deletion completed due to VM group creation failure!!", nlbReqInfo.IId.NameId) } return irs.NLBInfo{}, errTargetGroup } if cblogger.Level.String() == "debug" { - spew.Dump(targetGroup) + cblogger.Debug(targetGroup) } //=================== @@ -569,14 +567,14 @@ func (NLBHandler *AwsNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, cblogger.Error(errAddVms.Error()) //생성된 NLB 포함 리소스들 삭제 - cblogger.Infof("생성된 VM 그룹에 인스턴스 추가 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 시작!!", nlbReqInfo.IId.NameId) + cblogger.Infof("Starting NLB [%s] and related resources deletion due to failed addition of instances to the created VM group!!", nlbReqInfo.IId.NameId) _, errNlbInfo := NLBHandler.DeleteNLB(nlbReqInfo.IId) if errNlbInfo != nil { - cblogger.Errorf("생성된 VM 그룹에 인스턴스 추가 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 실패!!", nlbReqInfo.IId.NameId) + cblogger.Errorf("Failed to delete NLB [%s] and related resources due to failed addition of instances to the created VM group!!", nlbReqInfo.IId.NameId) cblogger.Error(errNlbInfo.Error()) //만약 NLB 포함 관련 리소스 정보 제거에 실패해도 생성 에러 메시지 유지를 위해 다른 작업은 진행하지 않음. } else { - cblogger.Infof("생성된 VM 그룹에 인스턴스 추가 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 완료!!", nlbReqInfo.IId.NameId) + cblogger.Infof("NLB [%s] and related resources deletion completed due to failed addition of instances to the created VM group!!", nlbReqInfo.IId.NameId) } return irs.NLBInfo{}, errAddVms @@ -591,21 +589,21 @@ func (NLBHandler *AwsNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, cblogger.Error(errListener.Error()) //생성된 NLB 포함 리소스들 삭제 - cblogger.Infof("리스너 생성 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 시작!!", nlbReqInfo.IId.NameId) + cblogger.Infof("Starting NLB [%s] and related resources deletion due to listener creation failure!!", nlbReqInfo.IId.NameId) _, errNlbInfo := NLBHandler.DeleteNLB(nlbReqInfo.IId) if errNlbInfo != nil { - cblogger.Errorf("리스너 생성 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 실패!!", nlbReqInfo.IId.NameId) + cblogger.Errorf("Failed to delete NLB [%s] and related resources due to listener creation failure!!", nlbReqInfo.IId.NameId) cblogger.Error(errNlbInfo.Error()) //만약 NLB 포함 관련 리소스 정보 제거에 실패해도 생성 에러 메시지 유지를 위해 다른 작업은 진행하지 않음. } else { - cblogger.Infof("리스너 생성 실패에 따른 NLB[%s]및 관련 리소스 삭제 작업 완료!!", nlbReqInfo.IId.NameId) + cblogger.Infof("NLB [%s] and related resources deletion completed due to listener creation failure!!", nlbReqInfo.IId.NameId) } return irs.NLBInfo{}, errListener } if cblogger.Level.String() == "debug" { - spew.Dump(listener) + cblogger.Debug(listener) } //================================ @@ -648,7 +646,7 @@ func (NLBHandler *AwsNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } if err != nil { @@ -674,7 +672,7 @@ func (NLBHandler *AwsNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { var results []*irs.NLBInfo for _, curNLB := range result.LoadBalancers { if !strings.EqualFold(*curNLB.Type, "network") { - cblogger.Infof("%s load balancer는 관리 대상이 아니라서 Skip함!!! - [%s]", *curNLB.Type, *curNLB.LoadBalancerName) + cblogger.Infof("%s Load balancer is not under management, so it is skipped - [%s]", *curNLB.Type, *curNLB.LoadBalancerName) continue } nlbInfo, errNLBInfo := NLBHandler.GetNLB(irs.IID{SystemId: *curNLB.LoadBalancerArn}) @@ -718,7 +716,7 @@ func (NLBHandler *AwsNLBHandler) IsExistNLB(nlbName string) (bool, error) { func (NLBHandler *AwsNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) { cblogger.Info("NLB IID : ", nlbIID.SystemId) if nlbIID.SystemId == "" { - cblogger.Error("IID 값이 Null임.") + cblogger.Error("IID value is Null.") return irs.NLBInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "nlbIID.systemId value of the input parameter is empty.", nil) } @@ -745,7 +743,7 @@ func (NLBHandler *AwsNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) { callLogInfo.ElapsedTime = call.Elapsed(callLogStart) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } if err != nil { @@ -794,7 +792,7 @@ func (NLBHandler *AwsNLBHandler) ExtractListenerInfo(nlbIID irs.IID) (irs.Listen cblogger.Error(elbv2.ErrCodeListenerNotFoundException, aerr.Error()) //Test 결과 NLB에 리스너가 할당되지 않아도 지금은 ErrCodeListenerNotFoundException 예외는 발생하지 않고 정상 결과로 처리되지만 //만약을 위해서 TargetGroup처럼 NotFound의 경우 정상 처리 함. - cblogger.Info("조회 및 삭제 로직을 위해 리스너 Not Found는 에러로 처리하지 않음.") + cblogger.Info("Listener Not Found is not treated as an error for retrieval and deletion logic.") return irs.ListenerInfo{}, nil case elbv2.ErrCodeLoadBalancerNotFoundException: cblogger.Error(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error()) @@ -813,7 +811,7 @@ func (NLBHandler *AwsNLBHandler) ExtractListenerInfo(nlbIID irs.IID) (irs.Listen cblogger.Debug(resListener) if cblogger.Level.String() == "debug" { - spew.Dump(resListener) + cblogger.Debug(resListener) } if len(resListener.Listeners) > 0 { @@ -852,7 +850,7 @@ func (NLBHandler *AwsNLBHandler) ExtractVMGroupInfo(nlbIID irs.IID) (TargetGroup cblogger.Error(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error()) //TargetGroup 정보가 없는 경우 생성 도중 실패나 AWS 콘솔 등에서 삭제된 경우를 감안해서 List및 삭제 작업 시 발생할 에러를 방지하기 위해 아무런 처리도 하지 않음. - cblogger.Info("조회 및 삭제 로직을 위해 타겟그룹 Not Found는 에러로 처리하지 않음.") + cblogger.Info("For retrieval and deletion logic, Target Group Not Found is not treated as an error.") return TargetGroupInfo{}, nil default: cblogger.Error(aerr.Error()) @@ -866,7 +864,7 @@ func (NLBHandler *AwsNLBHandler) ExtractVMGroupInfo(nlbIID irs.IID) (TargetGroup } cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } if len(result.TargetGroups) > 0 { @@ -942,7 +940,7 @@ func (NLBHandler *AwsNLBHandler) ExtractHealthCheckerInfo(targetGroupArn string) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return result.TargetHealthDescriptions, nil @@ -977,7 +975,7 @@ func (NLBHandler *AwsNLBHandler) ExtractNLBInfo(nlbResInfo *elbv2.LoadBalancer) //================== // VM Group 처리 //================== - cblogger.Info("VM Group 정보 조회 시작") + cblogger.Info("VM Group information retrieval started") retTargetGroupInfo, errVMGroupInfo := NLBHandler.ExtractVMGroupInfo(retNLBInfo.IId) //NLB Name으로 검색함. //NLB에 연결되지 않았거나 아직 생성되지 않은 TargetGroup을 감안해서 404 Notfound는 에러처리 하지 않음 if errVMGroupInfo != nil { @@ -990,7 +988,7 @@ func (NLBHandler *AwsNLBHandler) ExtractNLBInfo(nlbResInfo *elbv2.LoadBalancer) //================== // 리스너 처리 //================== - cblogger.Info("Listener 정보 조회 시작") + cblogger.Info("Listener information retrieval started") retListenerInfo, errListener := NLBHandler.ExtractListenerInfo(retNLBInfo.IId) //NLB Arn으로 검색 함. if errListener != nil { cblogger.Error(errListener.Error()) @@ -1030,7 +1028,7 @@ func (NLBHandler *AwsNLBHandler) DeleteListener(listenerArn *string) (bool, erro result, err := NLBHandler.Client.DeleteListener(input) if err != nil { - cblogger.Errorf("Listener[%s] 삭제 실패", listenerArn) + cblogger.Errorf("Listener[%s] deleted failed", listenerArn) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case elbv2.ErrCodeListenerNotFoundException: @@ -1048,10 +1046,10 @@ func (NLBHandler *AwsNLBHandler) DeleteListener(listenerArn *string) (bool, erro return false, err } - cblogger.Infof("Listener[%s] 삭제 완료", listenerArn) + cblogger.Infof("Listener[%s] deleted complate", listenerArn) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return true, nil @@ -1064,7 +1062,7 @@ func (NLBHandler *AwsNLBHandler) DeleteTargetGroup(targetGroupArn *string) (bool result, err := NLBHandler.Client.DeleteTargetGroup(input) if err != nil { - cblogger.Errorf("TargetGroup[%s] 삭제 실패", targetGroupArn) + cblogger.Errorf("TargetGroup[%s] deleted failed", targetGroupArn) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case elbv2.ErrCodeResourceInUseException: @@ -1080,10 +1078,10 @@ func (NLBHandler *AwsNLBHandler) DeleteTargetGroup(targetGroupArn *string) (bool return false, err } - cblogger.Infof("TargetGroup[%s] 삭제 완료", targetGroupArn) + cblogger.Infof("TargetGroup[%s] deleted complate", targetGroupArn) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return true, nil @@ -1098,10 +1096,10 @@ func (NLBHandler *AwsNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { return false, errNlbInfo } - cblogger.Info("삭제할 NLB 정보") - cblogger.Info(nlbInfo) + cblogger.Debug("NLB information to be deleted") + cblogger.Debug(nlbInfo) if cblogger.Level.String() == "debug" { - spew.Dump(nlbInfo) + cblogger.Debug(nlbInfo) } //========================= @@ -1110,7 +1108,7 @@ func (NLBHandler *AwsNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { // Listener 정보가 있는 경우에만 진행 //nlbInfo.Listener = irs.ListenerInfo{} if nlbInfo.Listener.CspID != "" { - cblogger.Infof("[%s] Listener 삭제 시작", nlbInfo.Listener.CspID) + cblogger.Infof("[%s] Listener deletion started", nlbInfo.Listener.CspID) _, errDeleteListener := NLBHandler.DeleteListener(&nlbInfo.Listener.CspID) if errDeleteListener != nil { @@ -1128,7 +1126,7 @@ func (NLBHandler *AwsNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { //if !reflect.ValueOf(nlbInfo.VMGroup).IsNil() && nlbInfo.VMGroup.CspID != "" { //nlbInfo.VMGroup = irs.VMGroupInfo{} if nlbInfo.VMGroup.CspID != "" { - cblogger.Infof("[%s] TargetGroup 삭제 시작", nlbInfo.VMGroup.CspID) + cblogger.Infof("[%s] TargetGroup deletion started", nlbInfo.VMGroup.CspID) _, errDeleteTargetGroup := NLBHandler.DeleteTargetGroup(&nlbInfo.VMGroup.CspID) if errDeleteTargetGroup != nil { cblogger.Error(errDeleteTargetGroup.Error()) @@ -1162,7 +1160,7 @@ func (NLBHandler *AwsNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) - cblogger.Errorf("NLB[%s] 삭제 실패", nlbIID.SystemId) + cblogger.Errorf("Failed to delete NLB [%s]", nlbIID.SystemId) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case elbv2.ErrCodeLoadBalancerNotFoundException: @@ -1183,10 +1181,10 @@ func (NLBHandler *AwsNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { } callogger.Info(call.String(callLogInfo)) - cblogger.Infof("NLB[%s] 삭제 완료", nlbIID.SystemId) + cblogger.Infof("NLB [%s] deleted successfully", nlbIID.SystemId) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return true, nil @@ -1196,7 +1194,7 @@ func (NLBHandler *AwsNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { // Protocol 하고 Port 정보만 변경 가능 func (NLBHandler *AwsNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.ListenerInfo) (irs.ListenerInfo, error) { if nlbIID.SystemId == "" { - cblogger.Error("IID 값이 Null임.") + cblogger.Error("IID value is Null.") return irs.ListenerInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "nlbIID.systemId value of the input parameter is empty.", nil) } @@ -1208,7 +1206,7 @@ func (NLBHandler *AwsNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.Lis } if listenerInfo.CspID == "" { - cblogger.Error("NLB와 연결된 리스너의 ARN 값을 찾을 수 없음") + cblogger.Error("Cannot find the ARN value of the listener associated with the NLB") return irs.ListenerInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "Listener associated with NLB does not exist.", nil) } @@ -1235,12 +1233,12 @@ func (NLBHandler *AwsNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.Lis if n, err := strconv.ParseInt(listener.Port, 10, 64); err == nil { input.SetPort(n) } else { - cblogger.Error(listener.Port, "은 숫자가 아님!!") + cblogger.Error(listener.Port, "is not number!!") return irs.ListenerInfo{}, err } } - cblogger.Info("리스너 정보 변경 시작") + cblogger.Info("Listener information modification started") cblogger.Info(input) // logger for HisCall @@ -1310,10 +1308,10 @@ func (NLBHandler *AwsNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.Lis return irs.ListenerInfo{}, err } - cblogger.Infof("리스너 정보 변경 완료") + cblogger.Infof("Listener information modification completed") cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } //변경된 최종 리스너 정보를 리턴 함. @@ -1360,7 +1358,7 @@ func (NLBHandler *AwsNLBHandler) ChangeVMGroupInfo(nlbIID irs.IID, vmGroup irs.V // @TODO : 이미 등록된 AZ의 다른 서브넷을 사용하는 Instance 처리 필요 func (NLBHandler *AwsNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs.VMGroupInfo, error) { if nlbIID.NameId == "" || nlbIID.SystemId == "" { - cblogger.Error("IID 값이 Null임.") + cblogger.Error("IID value is null.") return irs.VMGroupInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "nlbIID value of the input parameter is empty.", nil) } @@ -1373,7 +1371,7 @@ func (NLBHandler *AwsNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs. //NLB과 관련된 Target 그룹이 존재하지 않을 경우 if retTargetGroupInfo.VMGroup.Port == "" { - cblogger.Errorf("[%s] NLB와 연결된 VM Group이 존재하지 않아서 요청된 Instance를 추가할 수 없음", nlbIID.NameId) + cblogger.Errorf("Cannot add the requested instances because there is no VM Group associated with the NLB [%s]", nlbIID.NameId) return irs.VMGroupInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "VM Group does not exist to add the instance.", nil) } @@ -1401,11 +1399,11 @@ func (NLBHandler *AwsNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs. input.Targets = append(input.Targets, &elbv2.TargetDescription{Id: aws.String(curVM.SystemId), Port: iTagetPort}) } - cblogger.Infof("VM 그룹(%s)에 추가 예정 인스턴스 정보들", retTargetGroupInfo.VMGroup.CspID) + cblogger.Infof("Information of instances scheduled to be added to VM group (%s)", retTargetGroupInfo.VMGroup.CspID) cblogger.Info(input) if cblogger.Level.String() == "debug" { - spew.Dump(input) + cblogger.Debug(input) } // logger for HisCall @@ -1449,10 +1447,10 @@ func (NLBHandler *AwsNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs. } callogger.Info(call.String(callLogInfo)) - cblogger.Infof("VM 그룹(%s)에 인스턴스 추가 완료", retTargetGroupInfo.VMGroup.CspID) + cblogger.Infof("Instances added to VM group (%s) successfully", retTargetGroupInfo.VMGroup.CspID) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } //최신 정보 전달을 위해 다시 호출함. @@ -1467,7 +1465,7 @@ func (NLBHandler *AwsNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs. func (NLBHandler *AwsNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (bool, error) { if nlbIID.NameId == "" || nlbIID.SystemId == "" { - cblogger.Error("IID 값이 Null임.") + cblogger.Error("IID value is Null.") return false, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "nlbIID value of the input parameter is empty.", nil) } @@ -1480,7 +1478,7 @@ func (NLBHandler *AwsNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (b //NLB과 관련된 Target 그룹이 존재하지 않을 경우 if retTargetGroupInfo.VMGroup.Port == "" { - cblogger.Errorf("[%s] NLB와 연결된 VM Group이 존재하지 않아서 요청된 Instance를 제거할 수 없음", nlbIID.NameId) + cblogger.Errorf("Cannot remove the requested instances because there is no VM Group associated with the NLB [%s]", nlbIID.NameId) return false, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "VM Group does not exist to remove the instance.", nil) } @@ -1500,10 +1498,10 @@ func (NLBHandler *AwsNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (b input.Targets = append(input.Targets, &elbv2.TargetDescription{Id: aws.String(curVM.SystemId)}) } - cblogger.Infof("VM 그룹(%s)에서 삭제 예정 인스턴스 정보들", retTargetGroupInfo.VMGroup.CspID) + cblogger.Infof("Information of instances scheduled to be removed from VM group (%s)", retTargetGroupInfo.VMGroup.CspID) cblogger.Info(input) if cblogger.Level.String() == "debug" { - spew.Dump(input) + cblogger.Debug(input) } // logger for HisCall @@ -1541,10 +1539,10 @@ func (NLBHandler *AwsNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (b } callogger.Info(call.String(callLogInfo)) - cblogger.Infof("VM 그룹(%s)에서 인스턴스 삭제 성공", retTargetGroupInfo.VMGroup.CspID) + cblogger.Infof("Instances successfully removed from VM group (%s)", retTargetGroupInfo.VMGroup.CspID) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } return true, nil @@ -1580,7 +1578,7 @@ func (NLBHandler *AwsNLBHandler) ExtractVMGroupHealthInfo(targetGroupArn string) cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } retHealthInfo := irs.HealthInfo{} @@ -1617,7 +1615,7 @@ func (NLBHandler *AwsNLBHandler) ExtractVMGroupHealthInfo(targetGroupArn string) // @TODO : 5가지의 상태(Healthy / Unhealthy / Unused / Initial / Draining)가 존재 하기 때문에 리턴 객체에 담을 Unhealthy의 범위 확정이 필요 함. func (NLBHandler *AwsNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.HealthInfo, error) { if nlbIID.SystemId == "" { - cblogger.Error("IID 값이 Null임.") + cblogger.Error("IID value is Null.") return irs.HealthInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "nlbIID.systemId value of the input parameter is empty.", nil) } @@ -1655,7 +1653,7 @@ func (NLBHandler *AwsNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.Healt func (NLBHandler *AwsNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthChecker irs.HealthCheckerInfo) (irs.HealthCheckerInfo, error) { if nlbIID.SystemId == "" { - cblogger.Error("IID 값이 Null임.") + cblogger.Error("IID value is Null.") return irs.HealthCheckerInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "nlbIID.systemId value of the input parameter is empty.", nil) } @@ -1668,7 +1666,7 @@ func (NLBHandler *AwsNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC //TCP의 경우 인터벌은 생성 후 변경 불가 if healthChecker.Interval > 0 { if strings.EqualFold(healthChecker.Protocol, "TCP") { - cblogger.Errorf("===================> TCP 프로토콜은 인터벌 값 변경을 지원하지 않음") + cblogger.Errorf("===================> TCP protocol does not support interval value change") return irs.HealthCheckerInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "You cannot change the health check interval for a target group with the TCP protocol.", nil) } } @@ -1755,10 +1753,10 @@ func (NLBHandler *AwsNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC } callogger.Info(call.String(callLogInfo)) - cblogger.Info("Health 정보 변경 완료") + cblogger.Info("Health information modification completed") cblogger.Debug(result) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } //최신 정보 조회 diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/RegionZoneHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/RegionZoneHandler.go index bc0853978..ab304d66e 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/RegionZoneHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/RegionZoneHandler.go @@ -5,8 +5,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" - "github.com/davecgh/go-spew/spew" - "github.com/aws/aws-sdk-go/service/ec2" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" @@ -101,7 +99,7 @@ func (regionZoneHandler *AwsRegionZoneHandler) GetRegionZone(Name string) (irs.R var regionZoneInfo irs.RegionZoneInfo for _, region := range responseRegions.Regions { - spew.Dump("####################", region.RegionName) + cblogger.Debug("####################", region.RegionName) sess, err := session.NewSession(&aws.Config{ Region: region.RegionName, //Region: aws.String("us-west-1"), diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/SecurityHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/SecurityHandler.go index 53b226121..7b04a7bad 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/SecurityHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/SecurityHandler.go @@ -31,12 +31,12 @@ type AwsSecurityHandler struct { Client *ec2.EC2 } -//2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. (보안 그룹은 그룹명으로 처리 가능하기 때문에 Name 태깅시 에러는 무시함) -//@TODO : 존재하는 보안 그룹에 정책 추가하는 기능 필요 -//VPC 생략 시 활성화된 세션의 기본 VPC를 이용 함. +// 2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. (보안 그룹은 그룹명으로 처리 가능하기 때문에 Name 태깅시 에러는 무시함) +// @TODO : 존재하는 보안 그룹에 정책 추가하는 기능 필요 +// VPC 생략 시 활성화된 세션의 기본 VPC를 이용 함. func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error) { cblogger.Debugf("securityReqInfo : ", securityReqInfo) - //spew.Dump(securityReqInfo) + //cblogger.Debug(securityReqInfo) /* //VPC & Subnet을 자동으로 찾아서 처리 @@ -62,7 +62,7 @@ func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.Se // VpcId: aws.String(securityReqInfo.VpcId),awsCBNetworkInfo VpcId: aws.String(vpcId), } - cblogger.Debugf("보안 그룹 생성 요청 정보", input) + cblogger.Debugf("Security group creation request information", input) // logger for HisCall callogger := call.GetLogger("HISCALL") callLogInfo := call.CLOUDLOGSCHEMA{ @@ -95,9 +95,9 @@ func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.Se return irs.SecurityInfo{}, err } callogger.Info(call.String(callLogInfo)) - cblogger.Infof("[%s] 보안 그룹 생성완료", aws.StringValue(createRes.GroupId)) + cblogger.Infof("[%s] Security group creation completed", aws.StringValue(createRes.GroupId)) cblogger.Debug(createRes) - //spew.Dump(createRes) + //cblogger.Debug(createRes) //보안 그룹에 룰을 추가 함. _, err = securityHandler.ProcessAddRules(createRes.GroupId, securityReqInfo.SecurityRules) @@ -120,7 +120,7 @@ func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.Se } // cblogger.Debug("===>변환중") - // spew.Dump(ip) + // cblogger.Debug(ip) ipPermission := new(ec2.IpPermission) ipPermission.SetIpProtocol(ip.IPProtocol) @@ -152,7 +152,7 @@ func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.Se //SetCidrIp("0.0.0.0/0"), }) // cblogger.Debug("===>변환완료") - // spew.Dump(ipPermission) + // cblogger.Debug(ipPermission) ipPermissions = append(ipPermissions, ipPermission) } @@ -161,7 +161,7 @@ func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.Se if len(ipPermissions) > 0 { cblogger.Debug("===>적용할 최종 인바운드 정책") cblogger.Debug(ipPermissions) - // spew.Dump(ipPermissions) + // cblogger.Debug(ipPermissions) // Add permissions to the security group _, err = securityHandler.Client.AuthorizeSecurityGroupIngress(&ec2.AuthorizeSecurityGroupIngressInput{ @@ -241,7 +241,7 @@ func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.Se } ***/ - cblogger.Debug("Name Tag 처리") + cblogger.Debug("Name Tag processing") //====================== // Name 태그 처리 //====================== @@ -257,7 +257,7 @@ func (securityHandler *AwsSecurityHandler) CreateSecurity(securityReqInfo irs.Se }, }, } - //spew.Dump(tagInput) + //cblogger.Debug(tagInput) _, errTag := securityHandler.Client.CreateTags(tagInput) //Tag 실패 시 별도의 처리 없이 에러 로그만 남겨 놓음. @@ -341,8 +341,8 @@ func (securityHandler *AwsSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, return results, nil } -//2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. -//func (securityHandler *AwsSecurityHandler) GetSecurity(securityNameId string) (irs.SecurityInfo, error) { +// 2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. +// func (securityHandler *AwsSecurityHandler) GetSecurity(securityNameId string) (irs.SecurityInfo, error) { func (securityHandler *AwsSecurityHandler) GetSecurity(securityIID irs.IID) (irs.SecurityInfo, error) { cblogger.Infof("securityNameId : [%s]", securityIID.SystemId) @@ -414,12 +414,12 @@ func ExtractSecurityInfo(securityGroupResult *ec2.SecurityGroup) irs.SecurityInf var ipPermissionsEgress []irs.SecurityRuleInfo var securityRules []irs.SecurityRuleInfo - cblogger.Debugf("===[그룹아이디:%s]===", *securityGroupResult.GroupId) + cblogger.Debugf("===[SecurityGroup ID:%s]===", *securityGroupResult.GroupId) ipPermissions = ExtractIpPermissions(securityGroupResult.IpPermissions, "inbound") cblogger.Debug("InBouds : ", ipPermissions) ipPermissionsEgress = ExtractIpPermissions(securityGroupResult.IpPermissionsEgress, "outbound") cblogger.Debug("OutBounds : ", ipPermissionsEgress) - //spew.Dump(ipPermissionsEgress) + //cblogger.Debug(ipPermissionsEgress) securityRules = append(ipPermissions, ipPermissionsEgress...) securityInfo := irs.SecurityInfo{ @@ -438,7 +438,7 @@ func ExtractSecurityInfo(securityGroupResult *ec2.SecurityGroup) irs.SecurityInf } //Name은 Tag의 "Name" 속성에만 저장됨 - cblogger.Debug("Name Tag 찾기") + cblogger.Debug("find Name Tag") for _, t := range securityGroupResult.Tags { if *t.Key == "Name" { //securityInfo.Name = *t.Value @@ -481,7 +481,7 @@ func ExtractIpPermissions(ipPermissions []*ec2.IpPermission, direction string) [ //ipv4 처리 for _, ipv4 := range ip.IpRanges { - cblogger.Debug("Inbound/Outbound 정보 조회 : ", *ip.IpProtocol) + cblogger.Debug("Inbound/Outbound information retrieval: ", *ip.IpProtocol) securityRuleInfo := irs.SecurityRuleInfo{ Direction: direction, // "inbound | outbound" CIDR: *ipv4.CidrIp, @@ -534,8 +534,8 @@ func ExtractIpPermissions(ipPermissions []*ec2.IpPermission, direction string) [ return results } -//2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. -//func (securityHandler *AwsSecurityHandler) DeleteSecurity(securityNameId string) (bool, error) { +// 2019-11-16부로 CB-Driver 전체 로직이 NameId 기반으로 변경됨. +// func (securityHandler *AwsSecurityHandler) DeleteSecurity(securityNameId string) (bool, error) { func (securityHandler *AwsSecurityHandler) DeleteSecurity(securityIID irs.IID) (bool, error) { cblogger.Infof("securityNameId : [%s]", securityIID.SystemId) @@ -641,18 +641,18 @@ func (securityHandler *AwsSecurityHandler) AddRules(sgIID irs.IID, securityRules func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, securityRules *[]irs.SecurityRuleInfo) (irs.SecurityInfo, error) { var err error - cblogger.Debug("인바운드 보안 정책 처리") + cblogger.Debug("Inbound security policy processing") //Ingress 처리 var ipPermissions []*ec2.IpPermission for _, ip := range *securityRules { //for _, ip := range securityReqInfo.IPPermissions { if ip.Direction != "inbound" { - cblogger.Debug("==> inbound가 아닌 보안 그룹 Skip : ", ip.Direction) + cblogger.Debug("==> Skipping security group that is not inbound: ", ip.Direction) continue } // cblogger.Debug("===>변환중") - // spew.Dump(ip) + // cblogger.Debug(ip) ipPermission := new(ec2.IpPermission) ipPermission.SetIpProtocol(ip.IPProtocol) @@ -660,7 +660,7 @@ func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, s if n, err := strconv.ParseInt(ip.FromPort, 10, 64); err == nil { ipPermission.SetFromPort(n) } else { - cblogger.Error(ip.FromPort, "은 숫자가 아님!!") + cblogger.Error(ip.FromPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -671,7 +671,7 @@ func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, s if n, err := strconv.ParseInt(ip.ToPort, 10, 64); err == nil { ipPermission.SetToPort(n) } else { - cblogger.Error(ip.ToPort, "은 숫자가 아님!!") + cblogger.Error(ip.ToPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -684,16 +684,16 @@ func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, s //SetCidrIp("0.0.0.0/0"), }) // cblogger.Debug("===>변환완료") - // spew.Dump(ipPermission) + // cblogger.Debug(ipPermission) ipPermissions = append(ipPermissions, ipPermission) } //인바운드 정책이 있는 경우에만 처리 if len(ipPermissions) > 0 { - cblogger.Debug("===>적용할 최종 인바운드 정책") + cblogger.Debug("===> Final inbound policy to apply") cblogger.Debug(ipPermissions) - // spew.Dump(ipPermissions) + // cblogger.Debug(ipPermissions) // Add permissions to the security group _, err = securityHandler.Client.AuthorizeSecurityGroupIngress(&ec2.AuthorizeSecurityGroupIngressInput{ @@ -709,13 +709,13 @@ func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, s cblogger.Info("Successfully set security group ingress") } - cblogger.Debug("아웃바운드 보안 정책 처리") + cblogger.Debug("Outbound security policy processing") //Egress 처리 var ipPermissionsEgress []*ec2.IpPermission //for _, ip := range securityReqInfo.IPPermissionsEgress { for _, ip := range *securityRules { if ip.Direction != "outbound" { - cblogger.Debug("==> outbound가 아닌 보안 그룹 Skip : ", ip.Direction) + cblogger.Debug("==> Skipping security group that is not outbound: ", ip.Direction) continue } @@ -727,7 +727,7 @@ func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, s if n, err := strconv.ParseInt(ip.FromPort, 10, 64); err == nil { ipPermission.SetFromPort(n) } else { - cblogger.Error(ip.FromPort, "은 숫자가 아님!!") + cblogger.Error(ip.FromPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -738,7 +738,7 @@ func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, s if n, err := strconv.ParseInt(ip.ToPort, 10, 64); err == nil { ipPermission.SetToPort(n) } else { - cblogger.Error(ip.ToPort, "은 숫자가 아님!!") + cblogger.Error(ip.ToPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -756,7 +756,7 @@ func (securityHandler *AwsSecurityHandler) ProcessAddRules(newGroupId *string, s //아웃바운드 정책이 있는 경우에만 처리 if len(ipPermissionsEgress) > 0 { - cblogger.Debug("===>적용할 최종 아웃바운드 정책") + cblogger.Debug("===> Final outbound policy to apply") cblogger.Debug(ipPermissionsEgress) // Add permissions to the security group @@ -800,18 +800,18 @@ func (securityHandler *AwsSecurityHandler) RemoveRules(sgIID irs.IID, securityRu func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string, securityRules *[]irs.SecurityRuleInfo) (irs.SecurityInfo, error) { var err error - cblogger.Debug("인바운드 보안 정책 처리") + cblogger.Debug("Inbound security policy processing") //Ingress 처리 var ipPermissions []*ec2.IpPermission for _, ip := range *securityRules { //for _, ip := range securityReqInfo.IPPermissions { if ip.Direction != "inbound" { - cblogger.Debug("==> inbound가 아닌 보안 그룹 Skip : ", ip.Direction) + cblogger.Debug("==> Skipping security group that is not inbound: ", ip.Direction) continue } // cblogger.Debug("===>변환중") - // spew.Dump(ip) + // cblogger.Debug(ip) ipPermission := new(ec2.IpPermission) ipPermission.SetIpProtocol(ip.IPProtocol) @@ -819,7 +819,7 @@ func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string if n, err := strconv.ParseInt(ip.FromPort, 10, 64); err == nil { ipPermission.SetFromPort(n) } else { - cblogger.Error(ip.FromPort, "은 숫자가 아님!!") + cblogger.Error(ip.FromPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -830,7 +830,7 @@ func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string if n, err := strconv.ParseInt(ip.ToPort, 10, 64); err == nil { ipPermission.SetToPort(n) } else { - cblogger.Error(ip.ToPort, "은 숫자가 아님!!") + cblogger.Error(ip.ToPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -843,16 +843,16 @@ func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string //SetCidrIp("0.0.0.0/0"), }) // cblogger.Debug("===>변환완료") - // spew.Dump(ipPermission) + // cblogger.Debug(ipPermission) ipPermissions = append(ipPermissions, ipPermission) } //인바운드 정책이 있는 경우에만 처리 if len(ipPermissions) > 0 { - cblogger.Debug("===>적용할 최종 인바운드 정책") + cblogger.Debug("===> Final inbound policy to apply") cblogger.Debug(ipPermissions) - // spew.Dump(ipPermissions) + // cblogger.Debug(ipPermissions) // Add permissions to the security group _, err = securityHandler.Client.RevokeSecurityGroupIngress(&ec2.RevokeSecurityGroupIngressInput{ @@ -868,13 +868,13 @@ func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string cblogger.Info("Successfully set security group ingress") } - cblogger.Debug("아웃바운드 보안 정책 처리") + cblogger.Debug("Outbound security policy processing") //Egress 처리 var ipPermissionsEgress []*ec2.IpPermission //for _, ip := range securityReqInfo.IPPermissionsEgress { for _, ip := range *securityRules { if ip.Direction != "outbound" { - cblogger.Debug("==> outbound가 아닌 보안 그룹 Skip : ", ip.Direction) + cblogger.Debug("==> Skipping security group that is not outbound: ", ip.Direction) continue } @@ -886,7 +886,7 @@ func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string if n, err := strconv.ParseInt(ip.FromPort, 10, 64); err == nil { ipPermission.SetFromPort(n) } else { - cblogger.Error(ip.FromPort, "은 숫자가 아님!!") + cblogger.Error(ip.FromPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -897,7 +897,7 @@ func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string if n, err := strconv.ParseInt(ip.ToPort, 10, 64); err == nil { ipPermission.SetToPort(n) } else { - cblogger.Error(ip.ToPort, "은 숫자가 아님!!") + cblogger.Error(ip.ToPort, "is not number!!") return irs.SecurityInfo{}, err } } else { @@ -915,7 +915,7 @@ func (securityHandler *AwsSecurityHandler) ProcessRemoveRules(newGroupId *string //아웃바운드 정책이 있는 경우에만 처리 if len(ipPermissionsEgress) > 0 { - cblogger.Debug("===>적용할 최종 아웃바운드 정책") + cblogger.Debug("===> Final outbound policy to apply") cblogger.Debug(ipPermissionsEgress) // Add permissions to the security group diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMHandler.go index 37d6a8b5b..f250f5682 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMHandler.go @@ -9,7 +9,6 @@ package resources import ( "encoding/base64" "errors" - "fmt" "io/ioutil" "os" "reflect" @@ -20,8 +19,6 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/davecgh/go-spew/spew" - call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" cdcom "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/common" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" @@ -40,7 +37,7 @@ func Connect(region string) *ec2.EC2 { ) if err != nil { - fmt.Println("Could not create instance", err) + cblogger.Error("Could not create instance", err) return nil } @@ -101,7 +98,7 @@ func (vmHandler *AwsVMHandler) GetAmiDiskInfo(ImageSystemId string) (int64, erro func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error) { cblogger.Debug(vmReqInfo) if cblogger.Level.String() == "debug" { - spew.Dump(vmReqInfo) + cblogger.Debug(vmReqInfo) } // amiImage, errImgInfo := DescribeImageById(imageHandler.Client, &vmReqInfo.ImageIID, nil) @@ -202,7 +199,7 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err // 요청된 사이즈는 볼륨 사이즈 보다는 크거나 같아야 함. if iChkDiskSize < imageVolumeSize { - cblogger.Errorf("루트볼륨은 %dGB보다 커야 합니다.", imageVolumeSize) + cblogger.Errorf("The root volume must be larger than %dGB.", imageVolumeSize) return irs.VMInfo{}, awserr.New(CUSTOM_ERR_CODE_BAD_REQUEST, "Root Disk Size must be at least the default size ("+strconv.FormatInt(imageVolumeSize, 10)+" GB).", nil) } } @@ -239,15 +236,15 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err //============================= // 보안그룹 처리 - SystemId 기반 //============================= - cblogger.Debug("SystemId 기반으로 처리하기 위해 IID 기반의 보안그룹 배열을 SystemId 기반 보안그룹 배열로 조회및 변환함.") + cblogger.Debug("To process based on SystemId, the security group array based on IID is retrieved and converted into a security group array based on SystemId.") var newSecurityGroupIds []string for _, sgName := range vmReqInfo.SecurityGroupIIDs { - cblogger.Debugf("보안그룹 변환 : [%s]", sgName) + cblogger.Debugf("Security group conversion: [%s]", sgName) newSecurityGroupIds = append(newSecurityGroupIds, sgName.SystemId) } - cblogger.Debug("보안그룹 변환 완료") + cblogger.Debug("Security group conversion completed") cblogger.Debug(newSecurityGroupIds) /* 2020-04-08 EIP 로직 제거 @@ -280,7 +277,7 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err userData = userData + keyPairInfo.PublicKey userDataBase64 := aws.String(base64.StdEncoding.EncodeToString([]byte(userData))) cblogger.Infof("===== userData ===") - spew.Dump(userDataBase64) + cblogger.Debug(userDataBase64) */ //============================= @@ -315,7 +312,7 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err //OS 종류에 따른 Cloud Init Data 처리 if isWindowsImage { userData = strings.Replace(string(fileDataCloudInit), "*PASSWORD*", vmReqInfo.VMUserPasswd, 1) - cblogger.Debugf("Windows용 Cloud-Init : [%s]", userData) + cblogger.Debugf("Windows Cloud-Init : [%s]", userData) } else { userData = string(fileDataCloudInit) } @@ -454,7 +451,7 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) - cblogger.Errorf("EC2 인스턴스 생성 실패 : ", err) + cblogger.Errorf("EC2 instance creation failed: ", err) return irs.VMInfo{}, err } callogger.Info(call.String(callLogInfo)) @@ -467,7 +464,7 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err // Name Tag 처리 - NameId 기반 //============================= newVmId := *runResult.Instances[0].InstanceId - cblogger.Infof("[%s] VM이 생성되었습니다.", newVmId) + cblogger.Infof("[%s] VM has been created.", newVmId) if baseName != "" { // Tag에 VM Name 설정 @@ -481,21 +478,21 @@ func (vmHandler *AwsVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err }, }) if errtag != nil { - cblogger.Errorf("[%s] VM에 Name Tag 설정 실패", newVmId) + cblogger.Errorf("Failed to set Name Tag for [%s] VM", newVmId) cblogger.Error(errtag) //return irs.VMInfo{}, errtag } } else { - cblogger.Error("vmReqInfo.IId.NameId가 전달되지 않아서 Name Tag를 설정하지않습니다.") + cblogger.Error("Name Tag will not be set because vmReqInfo.IId.NameId is not provided.") } //Public IP및 최신 정보 전달을 위해 부팅이 완료될 때까지 대기했다가 전달하는 것으로 변경 함. //cblogger.Info("Public IP 할당 및 VM의 최신 정보 획득을 위해 EC2가 Running 상태가 될때까지 대기") //2021-05-11 EIP 할당 로직이 제거되었으며 빠른 생성을 위해 Running 상태가 될때까지 대기하지 않음. //2021-05-11 WaitForRun을 호출하지 않아도 GetVM() 호출 시 에러가 발생하지 않는 것은 확인했음. (우선은 정책이 최종 확정이 아니라서 WaitForRun을 사용하도록 원복함.) - cblogger.Debug("VM의 최신 정보 획득을 위해 EC2가 Running 상태가 될때까지 대기") + cblogger.Debug("Waiting for EC2 to be in the Running state to obtain the latest information about the VM") WaitForRun(vmHandler.Client, newVmId) - cblogger.Debug("EC2 Running 상태 완료 : ", runResult.Instances[0].State.Name) + cblogger.Debug("EC2 Running state completed: ", runResult.Instances[0].State.Name) /* 2020-04-08 EIP 로직 제거 //EC2에 EIP 할당 (펜딩 상태에서는 EIP 할당 불가) @@ -590,7 +587,7 @@ func WaitForRun(svc *ec2.EC2, instanceID string) { if err != nil { cblogger.Errorf("failed to wait until instances exist: %v", err) } - cblogger.Info("=========WaitForRun() 종료") + cblogger.Info("=========WaitForRun() ended") } // func (vmHandler *AwsVMHandler) ResumeVM(vmNameId string) (irs.VMStatus, error) { @@ -630,26 +627,27 @@ func (vmHandler *AwsVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error) { result, err := vmHandler.Client.StartInstances(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - spew.Dump(result) + if cblogger.Level.String() == "debug" { + cblogger.Debug(result) + } awsErr, ok := err.(awserr.Error) if ok && awsErr.Code() == "DryRunOperation" { // Let's now set dry run to be false. This will allow us to start the instances input.DryRun = aws.Bool(false) result, err = vmHandler.Client.StartInstances(input) - spew.Dump(result) + if cblogger.Level.String() == "debug" { + cblogger.Debug(result) + } if err != nil { - //fmt.Println("Error", err) cblogger.Error(err) callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) return irs.VMStatus("Failed"), err } else { - //fmt.Println("Success", result.StartingInstances) cblogger.Info("Success", result.StartingInstances) } } else { // This could be due to a lack of permissions - //fmt.Println("Error", err) cblogger.Error(err) callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -695,12 +693,14 @@ func (vmHandler *AwsVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error) { callLogStart := call.Start() result, err := vmHandler.Client.StopInstances(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - spew.Dump(result) + cblogger.Debug(result) awsErr, ok := err.(awserr.Error) if ok && awsErr.Code() == "DryRunOperation" { input.DryRun = aws.Bool(false) result, err = vmHandler.Client.StopInstances(input) - spew.Dump(result) + if cblogger.Level.String() == "debug" { + cblogger.Debug(result) + } if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -755,22 +755,24 @@ func (vmHandler *AwsVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error) { callLogStart := call.Start() result, err := vmHandler.Client.RebootInstances(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - cblogger.Info("result 값 : ", result) - cblogger.Info("err 값 : ", err) + cblogger.Info("result value : ", result) + cblogger.Info("err value : ", err) awsErr, ok := err.(awserr.Error) - cblogger.Info("ok 값 : ", ok) - cblogger.Info("awsErr 값 : ", awsErr) + cblogger.Info("ok value : ", ok) + cblogger.Info("awsErr value : ", awsErr) if ok && awsErr.Code() == "DryRunOperation" { - cblogger.Info("Reboot 권한 있음 - awsErr.Code() : ", awsErr.Code()) + cblogger.Info("Reboot permission granted - awsErr.Code(): ", awsErr.Code()) //DryRun 권한 해제 후 리부팅을 요청 함. - cblogger.Info("DryRun 권한 해제 후 리부팅을 요청 함.") + cblogger.Info("Requested reboot after releasing DryRun permission.") input.DryRun = aws.Bool(false) result, err = vmHandler.Client.RebootInstances(input) - spew.Dump(result) - cblogger.Info("result 값 : ", result) - cblogger.Info("err 값 : ", err) + if cblogger.Level.String() == "debug" { + cblogger.Debug(result) + } + cblogger.Info("result value : ", result) + cblogger.Info("err value : ", err) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -780,7 +782,7 @@ func (vmHandler *AwsVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error) { cblogger.Info("Success", result) } } else { // This could be due to a lack of permissions - cblogger.Info("리부팅 권한이 없는 것같음.") + cblogger.Info("no permission to reboot.") cblogger.Error("Error", err) callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -819,7 +821,9 @@ func (vmHandler *AwsVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, error) result, err := vmHandler.Client.TerminateInstances(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - spew.Dump(result) + if cblogger.Level.String() == "debug" { + cblogger.Debug(result) + } if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -860,7 +864,7 @@ func (vmHandler *AwsVMHandler) GetPasswordData(vmIID irs.IID) (string, error) { callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if cblogger.Level.String() == "debug" { - spew.Dump(result) + cblogger.Debug(result) } if err != nil { @@ -983,12 +987,11 @@ func (vmHandler *AwsVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) { func (vmHandler *AwsVMHandler) ExtractDescribeInstanceToVmInfo(instance *ec2.Instance) irs.VMInfo { //cblogger.Info("ExtractDescribeInstances", reservation) cblogger.Info("Instance", instance) - //spew.Dump(reservation.Instances[0]) //"stopped" / "terminated" / "running" ... var state string state = *instance.State.Name - cblogger.Infof("EC2 상태 : [%s]", state) + cblogger.Infof("EC2 state : [%s]", state) //VM상태와 무관하게 항상 값이 존재하는 항목들만 초기화 vmInfo := irs.VMInfo{ @@ -1077,8 +1080,9 @@ func (vmHandler *AwsVMHandler) ExtractDescribeInstanceToVmInfo(instance *ec2.Ins //awsImageInfo.OwnerId // //awsImageInfo.ImageOwnerAlias } - spew.Dump(awsImageInfo) //ImageId: "ami-00f1068284b9eca92", - + if cblogger.Level.String() == "debug" { + cblogger.Debug(awsImageInfo) //ImageId: "ami-00f1068284b9eca92", + } // instance.ImageId // describeImage -> is-public @@ -1158,7 +1162,7 @@ func (vmHandler *AwsVMHandler) ExtractDescribeInstanceToVmInfo(instance *ec2.Ins for _, t := range instance.Tags { if *t.Key == "Name" { vmInfo.IId.NameId = *t.Value - cblogger.Debug("EC2 명칭 : ", vmInfo.IId.NameId) + cblogger.Debug("EC2 Name : ", vmInfo.IId.NameId) break } } @@ -1173,12 +1177,11 @@ func (vmHandler *AwsVMHandler) ExtractDescribeInstanceToVmInfo(instance *ec2.Ins func (vmHandler *AwsVMHandler) ExtractDescribeInstances(reservation *ec2.Reservation) irs.VMInfo { //cblogger.Info("ExtractDescribeInstances", reservation) cblogger.Info("Instances[0]", reservation.Instances[0]) - //spew.Dump(reservation.Instances[0]) //"stopped" / "terminated" / "running" ... var state string state = *reservation.Instances[0].State.Name - cblogger.Infof("EC2 상태 : [%s]", state) + cblogger.Infof("EC2 State : [%s]", state) //VM상태와 무관하게 항상 값이 존재하는 항목들만 초기화 vmInfo := irs.VMInfo{ @@ -1314,11 +1317,11 @@ func (vmHandler *AwsVMHandler) ExtractDescribeInstances(reservation *ec2.Reserva } //Name은 Tag의 "Name" 속성에만 저장됨 - cblogger.Debug("Name Tag 찾기") + cblogger.Debug("Name Tag Search") for _, t := range reservation.Instances[0].Tags { if *t.Key == "Name" { vmInfo.IId.NameId = *t.Value - cblogger.Debug("EC2 명칭 : ", vmInfo.IId.NameId) + cblogger.Debug("EC2 Name : ", vmInfo.IId.NameId) break } } @@ -1364,11 +1367,11 @@ func (vmHandler *AwsVMHandler) GetVolumInfo(volumeId string) (*ec2.Volume, error } //cblogger.Info(result) - cblogger.Infof("조회된 볼륨 수 : [%d]", len(result.Volumes)) + cblogger.Infof("Number of retrieved volumes: [%d]", len(result.Volumes)) if len(result.Volumes) > 1 { return nil, awserr.New("700", "One or more volumes exist.", nil) } else if len(result.Volumes) == 0 { - cblogger.Errorf("[%s]와 일치하는 볼륨 정보가 존재하지 않습니다.", volumeId) + cblogger.Errorf("No volume information matching [%s] exists.", volumeId) return nil, awserr.New("404", "["+volumeId+"] Volume Not Found", nil) } @@ -1379,7 +1382,7 @@ func (vmHandler *AwsVMHandler) GetVolumInfo(volumeId string) (*ec2.Volume, error func ExtractVmName(Tags []*ec2.Tag) string { for _, t := range Tags { if *t.Key == "Name" { - cblogger.Info(" --> EC2 명칭 : ", *t.Key) + cblogger.Info(" --> EC2 Name : ", *t.Key) return *t.Value } } @@ -1432,7 +1435,7 @@ func (vmHandler *AwsVMHandler) ListVM() ([]*irs.VMInfo, error) { //tmpVmName := "" for _, i := range result.Reservations { for _, vm := range i.Instances { - cblogger.Info("[%s] EC2 정보 조회", *vm.InstanceId) + cblogger.Info("[%s] EC2 information retrieve", *vm.InstanceId) /* tmpVmName = ExtractVmName(vm.Tags) if tmpVmName == "" { @@ -1472,7 +1475,7 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) { resultStatus = "Terminated" } else { //resultStatus = "Failed" - cblogger.Errorf("vmStatus [%s]와 일치하는 맵핑 정보를 찾지 못 함.", vmStatus) + cblogger.Errorf("No mapping information found matching vmStatus [%s", vmStatus) return irs.VMStatus("Failed"), errors.New("Cannot find status information that matches " + vmStatus) } cblogger.Infof("VM 상태 치환 : [%s] ==> [%s]", vmStatus, resultStatus) @@ -1625,7 +1628,7 @@ func (vmHandler *AwsVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error) { // AssociationId 대신 PublicIP로도 가능 함. func (vmHandler *AwsVMHandler) AssociatePublicIP(allocationId string, instanceId string) (bool, error) { - cblogger.Infof("EC2에 퍼블릭 IP할당 - AllocationId : [%s], InstanceId : [%s]", allocationId, instanceId) + cblogger.Infof("Assigning a public IP to EC2 - AllocationId: [%s], InstanceId: [%s]", allocationId, instanceId) // EC2에 할당. // Associate the new Elastic IP address with an existing EC2 instance. @@ -1634,7 +1637,7 @@ func (vmHandler *AwsVMHandler) AssociatePublicIP(allocationId string, instanceId InstanceId: aws.String(instanceId), }) - spew.Dump(assocRes) + cblogger.Debug(assocRes) //cblogger.Infof("[%s] EC2에 EIP(AllocationId : [%s]) 할당 완료 - AssociationId Id : [%s]", instanceId, allocationId, *assocRes.AssociationId) if err != nil { @@ -1658,7 +1661,7 @@ func (vmHandler *AwsVMHandler) AssociatePublicIP(allocationId string, instanceId // 전달 받은 vNic을 VM에 추가함. func (vmHandler *AwsVMHandler) AttachNetworkInterface(vNicId string, instanceId string) (bool, error) { - cblogger.Infof("EC2[%s] VM에 vNic[%s] 추가 시작", vNicId, instanceId) + cblogger.Infof("Adding vNic [%s] to EC2 [%s] VM started", vNicId, instanceId) input := &ec2.AttachNetworkInterfaceInput{ DeviceIndex: aws.Int64(1), @@ -1670,7 +1673,7 @@ func (vmHandler *AwsVMHandler) AttachNetworkInterface(vNicId string, instanceId cblogger.Info(result) if err != nil { - cblogger.Errorf("EC2[%s] VM에 vNic[%s] 추가 실패", vNicId, instanceId) + cblogger.Errorf("Failed to add vNic [%s] to EC2 [%s] VM", vNicId, instanceId) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go index 177bcd08b..836ea13d3 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go @@ -23,7 +23,7 @@ type AwsVmSpecHandler struct { func ExtractGpuInfo(gpuDeviceInfo *ec2.GpuDeviceInfo) irs.GpuInfo { cblogger.Debug(gpuDeviceInfo) //cblogger.Info("================") - //spew.Dump(gpuDeviceInfo) + //cblogger.Debug(gpuDeviceInfo) gpuInfo := irs.GpuInfo{ Count: strconv.FormatInt(*gpuDeviceInfo.Count, 10), @@ -38,7 +38,7 @@ func ExtractGpuInfo(gpuDeviceInfo *ec2.GpuDeviceInfo) irs.GpuInfo { // 인스턴스 스펙 정보를 추출함 func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) irs.VMSpecInfo { cblogger.Debugf("ExtractVMSpecInfo : Region:[%s] / SpecName:[%s]", Region, *instanceTypeInfo.InstanceType) - //spew.Dump(instanceTypeInfo) + //cblogger.Debug(instanceTypeInfo) vCpuInfo := irs.VCpuInfo{} gpuInfoList := []irs.GpuInfo{} @@ -66,7 +66,7 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) ir gpuInfo := ExtractGpuInfo(curGpu) gpuInfoList = append(gpuInfoList, gpuInfo) } - //spew.Dump(gpuInfoList) + //cblogger.Debug(gpuInfoList) } vmSpecInfo.Gpu = gpuInfoList @@ -157,7 +157,7 @@ func (vmSpecHandler *AwsVmSpecHandler) ListVMSpecAZ(ZoneName string) (map[string callogger.Info(call.String(callLogInfo)) cblogger.Infof("===> Total Check AZ Spec Count : [%d]", totCnt) - //spew.Dump(mapVmSpecIds) + //cblogger.Debug(mapVmSpecIds) return mapVmSpecIds, nil } @@ -258,7 +258,7 @@ func (vmSpecHandler *AwsVmSpecHandler) ListVMSpec() ([]*irs.VMSpecInfo, error) { return vMSpecInfoList, err } callogger.Info(call.String(callLogInfo)) - //spew.Dump(vMSpecInfoList) + //cblogger.Debug(vMSpecInfoList) //cblogger.Infof("===> Total Check Spec Count : [%d]", totCnt) cblogger.Infof("==>In the [%s] AZ, [%d] specs are available from the [%s] region, and [%d] of them can be utilized.", zoneId, vmSpecHandler.Region.Region, totCnt, len(vMSpecInfoList)) @@ -415,7 +415,7 @@ func (vmSpecHandler *AwsVmSpecHandler) ListOrgVMSpec() (string, error) { return "", err } callogger.Info(call.String(callLogInfo)) - //spew.Dump(vMSpecInfoList) + //cblogger.Debug(vMSpecInfoList) cblogger.Infof("==>In the [%s] AZ, [%d] specs are available from the [%s] region, and [%d] of them can be utilized.", zoneId, vmSpecHandler.Region.Region, totCnt, len(resp.InstanceTypes)) diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/VPCHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/VPCHandler.go index efef4e259..d302b0807 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/VPCHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/VPCHandler.go @@ -21,7 +21,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" ) type AwsVPCHandler struct { @@ -43,7 +42,7 @@ func (VPCHandler *AwsVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCIn CidrBlock: aws.String(vpcReqInfo.IPv4_CIDR), } - //spew.Dump(input) + //cblogger.Debug(input) // logger for HisCall callogger := call.GetLogger("HISCALL") callLogInfo := call.CLOUDLOGSCHEMA{ @@ -78,7 +77,7 @@ func (VPCHandler *AwsVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCIn callogger.Info(call.String(callLogInfo)) cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) retVpcInfo := ExtractVpcDescribeInfo(result.Vpc) retVpcInfo.IId.NameId = vpcReqInfo.IId.NameId // NameId는 요청 받은 값으로 리턴해야 함. @@ -173,7 +172,7 @@ func (VPCHandler *AwsVPCHandler) CreateRouteIGW(vpcId string, igwId string) erro return errRoute } - cblogger.Infof("RouteTable[%s]에 IGW[%s]에 대한 라우팅(0.0.0.0/0) 정보를 추가 합니다.", routeTableId, igwId) + cblogger.Infof("Adding routing information for IGW [%s] to RouteTable [%s] for destination (0.0.0.0/0).", routeTableId, igwId) input := &ec2.CreateRouteInput{ DestinationCidrBlock: aws.String("0.0.0.0/0"), GatewayId: aws.String(igwId), @@ -198,7 +197,7 @@ func (VPCHandler *AwsVPCHandler) CreateRouteIGW(vpcId string, igwId string) erro callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { - cblogger.Errorf("RouteTable[%s]에 IGW[%s]에 대한 라우팅(0.0.0.0/0) 정보 추가 실패", routeTableId, igwId) + cblogger.Errorf("Failed to add routing information for IGW [%s] to RouteTable [%s] for destination (0.0.0.0/0).", routeTableId, igwId) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { default: @@ -214,11 +213,11 @@ func (VPCHandler *AwsVPCHandler) CreateRouteIGW(vpcId string, igwId string) erro callogger.Info(call.String(callLogInfo)) return err } - cblogger.Infof("RouteTable[%s]에 IGW[%s]에 대한 라우팅(0.0.0.0/0) 정보를 추가 완료", routeTableId, igwId) + cblogger.Infof("Added routing information for IGW [%s] to RouteTable [%s] for destination (0.0.0.0/0) successfully.", routeTableId, igwId) callogger.Info(call.String(callLogInfo)) cblogger.Info(result) - spew.Dump(result) + cblogger.Debug(result) return nil } @@ -253,11 +252,11 @@ func (VPCHandler *AwsVPCHandler) GetDefaultRouteTable(vpcId string) (string, err } cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) if len(result.RouteTables) > 0 { routeTableId := *result.RouteTables[0].RouteTableId - cblogger.Infof("라우팅 테이블 ID 찾음 : [%s]", routeTableId) + cblogger.Infof("Found routing table ID: [%s]", routeTableId) return routeTableId, nil } else { return "", errors.New("The routing table ID assigned to the VPC could not be found.") @@ -270,7 +269,7 @@ func (VPCHandler *AwsVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.Su zoneId := VPCHandler.Region.Zone // subnet에 zone 정보가 있으면 해당 zone 사용. default는 connection의 zone - if reqSubnetInfo.Zone != ""{ + if reqSubnetInfo.Zone != "" { zoneId = reqSubnetInfo.Zone } cblogger.Infof("Zone : %s", zoneId) @@ -331,7 +330,7 @@ func (VPCHandler *AwsVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.Su } callogger.Info(call.String(callLogInfo)) cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) //vNetworkInfo := irs.VNetworkInfo{} vNetworkInfo := ExtractSubnetDescribeInfo(result.Subnet) @@ -402,7 +401,7 @@ func (VPCHandler *AwsVPCHandler) AssociateRouteTable(vpcId string, subnetId stri callogger.Info(call.String(callLogInfo)) cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) return nil } @@ -450,7 +449,7 @@ func (VPCHandler *AwsVPCHandler) ListVPC() ([]*irs.VPCInfo, error) { vNetworkInfoList = append(vNetworkInfoList, &vNetworkInfo) } - spew.Dump(vNetworkInfoList) + cblogger.Debug(vNetworkInfoList) return vNetworkInfoList, nil } @@ -497,7 +496,7 @@ func (VPCHandler *AwsVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error) { callogger.Info(call.String(callLogInfo)) cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) if reflect.ValueOf(result.Vpcs).IsNil() { return irs.VPCInfo{}, nil @@ -647,8 +646,8 @@ func (VPCHandler *AwsVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error) { // logger for HisCall callogger := call.GetLogger("HISCALL") callLogInfo := call.CLOUDLOGSCHEMA{ - CloudOS: call.AWS, - RegionZone: VPCHandler.Region.Zone, + CloudOS: call.AWS, + RegionZone: VPCHandler.Region.Zone, //RegionZone: curSubnet.Zone, ResourceType: call.VPCSUBNET, ResourceName: vpcInfo.IId.SystemId, @@ -679,7 +678,7 @@ func (VPCHandler *AwsVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error) { callogger.Info(call.String(callLogInfo)) cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) return true, nil } @@ -722,7 +721,7 @@ func (VPCHandler *AwsVPCHandler) DeleteRouteIGWOld(vpcId string) error { cblogger.Infof("RouteTable[%s]에 대한 라우팅(0.0.0.0/0) 정보 삭제 완료", routeTableId) cblogger.Info(result) - spew.Dump(result) + cblogger.Debug(result) cblogger.Info("라우팅 테이블에 추가한 0.0.0.0/0 IGW 라우터 삭제 완료") return nil } @@ -751,7 +750,7 @@ func (VPCHandler *AwsVPCHandler) DeleteRouteIGW(vpcId string) error { } cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) if len(result.RouteTables) < 1 { return errors.New("The routing table information assigned to the VPC could not be found.") @@ -809,7 +808,7 @@ func (VPCHandler *AwsVPCHandler) DeleteRouteIGW(vpcId string) error { cblogger.Infof("Completed deleting routing information (0.0.0.0/0) for RouteTable[%s]", routeTableId) cblogger.Info(resultDel) - //spew.Dump(resultDel) + //cblogger.Debug(resultDel) cblogger.Info("Completed deleting the 0.0.0.0/0 IGW router added to the routing table") return nil } @@ -843,7 +842,7 @@ func (VPCHandler *AwsVPCHandler) DeleteAllIGW(vpcId string) error { } cblogger.Info(result) - spew.Dump(result) + cblogger.Debug(result) // VPC 삭제를 위해 연결된 모든 IGW 제거 // 일단, 에러는 무시함. @@ -882,7 +881,7 @@ func (VPCHandler *AwsVPCHandler) DetachInternetGateway(vpcId string, igwId strin } cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) return nil } @@ -908,7 +907,7 @@ func (VPCHandler *AwsVPCHandler) DeleteIGW(igwId string) error { } cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) return nil } @@ -942,7 +941,7 @@ func (VPCHandler *AwsVPCHandler) ListSubnet(vpcId string) ([]irs.SubnetInfo, err } callLogStart := call.Start() - //spew.Dump(input) + //cblogger.Debug(input) result, err := VPCHandler.Client.DescribeSubnets(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) @@ -964,7 +963,7 @@ func (VPCHandler *AwsVPCHandler) ListSubnet(vpcId string) ([]irs.SubnetInfo, err } callogger.Info(call.String(callLogInfo)) - //spew.Dump(result) + //cblogger.Debug(result) for _, curSubnet := range result.Subnets { cblogger.Infof("Retrieve [%s] Subnet info", *curSubnet.SubnetId) arrSubnetInfo := ExtractSubnetDescribeInfo(curSubnet) @@ -978,7 +977,7 @@ func (VPCHandler *AwsVPCHandler) ListSubnet(vpcId string) ([]irs.SubnetInfo, err arrSubnetInfoList = append(arrSubnetInfoList, arrSubnetInfo) } - //spew.Dump(arrSubnetInfoList) + //cblogger.Debug(arrSubnetInfoList) return arrSubnetInfoList, nil } @@ -991,7 +990,7 @@ func (VPCHandler *AwsVPCHandler) GetSubnet(reqSubnetId string) (irs.SubnetInfo, }, } - //spew.Dump(input) + //cblogger.Debug(input) // logger for HisCall callogger := call.GetLogger("HISCALL") @@ -1008,7 +1007,7 @@ func (VPCHandler *AwsVPCHandler) GetSubnet(reqSubnetId string) (irs.SubnetInfo, result, err := VPCHandler.Client.DescribeSubnets(input) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) cblogger.Info(result) - //spew.Dump(result) + //cblogger.Debug(result) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { @@ -1107,7 +1106,7 @@ func (VPCHandler *AwsVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.Subnet cblogger.Errorf("The subnet creation was successful, but the information [%s] for the requested [%s] subnet was not found in the VPC's subnet list.", subnetInfo.IId.NameId, resSubnet.IId.SystemId) return irs.VPCInfo{}, errors.New("MismatchSubnet.NotFound: No SysmteId[" + resSubnet.IId.SystemId + "] found for newly created Subnet[" + subnetInfo.IId.NameId + "].") } - //spew.Dump(vpcInfo) + //cblogger.Debug(vpcInfo) return vpcInfo, nil } diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/GCPDriver.go b/cloud-control-manager/cloud-driver/drivers/gcp/GCPDriver.go index c631badd0..4e4a473e7 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/GCPDriver.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/GCPDriver.go @@ -13,7 +13,8 @@ package gcp import ( "context" "encoding/json" - "fmt" + cblogger "github.com/cloud-barista/cb-log" + "github.com/sirupsen/logrus" gcpcon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/gcp/connect" gcps "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/gcp/resources" @@ -31,6 +32,12 @@ import ( "google.golang.org/api/option" ) +var cblog *logrus.Logger + +func init() { + cblog = cblogger.GetLogger("CLOUD-BARISTA") +} + type GCPDriver struct { } @@ -69,33 +76,34 @@ func (driver *GCPDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) (icon. gcps.InitLog() Ctx, VMClient, err := getVMClient(connectionInfo.CredentialInfo) - fmt.Println("################## getVMClient ##################") - fmt.Println("getVMClient") - fmt.Println("################## getVMClient ##################") + + cblog.Debug("################## getVMClient ##################") + cblog.Debug("getVMClient") + cblog.Debug("################## getVMClient ##################") if err != nil { return nil, err } //Ctx2, containerClient, err := getContainerClient(connectionInfo.CredentialInfo) _, containerClient, err := getContainerClient(connectionInfo.CredentialInfo) - fmt.Println("################## getContainerClient ##################") - fmt.Println("getContainerClient") - fmt.Println("################## getContainerClient ##################") + cblog.Debug("################## getContainerClient ##################") + cblog.Debug("getContainerClient") + cblog.Debug("################## getContainerClient ##################") if err != nil { return nil, err } _, billingCatalogClient, err := getBillingCatalogClient(connectionInfo.CredentialInfo) - fmt.Println("################## getBillingCatalogClient ##################") - fmt.Println("getBillingCatalogClient") - fmt.Println("################## getBillingCatalogClient ##################") + cblog.Debug("################## getBillingCatalogClient ##################") + cblog.Debug("getBillingCatalogClient") + cblog.Debug("################## getBillingCatalogClient ##################") if err != nil { return nil, err } _, costEstimationClient, err := getCostEstimationClient(connectionInfo.CredentialInfo) - fmt.Println("################## getCostEstimationClient ##################") - fmt.Println("getCostEstimationClient") - fmt.Println("################## getCostEstimationClient ##################") + cblog.Debug("################## getCostEstimationClient ##################") + cblog.Debug("getCostEstimationClient") + cblog.Debug("################## getCostEstimationClient ##################") if err != nil { return nil, err } @@ -119,9 +127,9 @@ func (driver *GCPDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) (icon. CostEstimationClient: costEstimationClient, } - //fmt.Println("################## resource ConnectionInfo ##################") - //fmt.Println("iConn : ", iConn) - //fmt.Println("################## resource ConnectionInfo ##################") + //cblog.Info("################## resource ConnectionInfo ##################") + //cblog.Info("iConn : ", iConn) + //cblog.Info("################## resource ConnectionInfo ##################") return &iConn, nil } @@ -140,9 +148,9 @@ func getVMClient(credential idrv.CredentialInfo) (context.Context, *compute.Serv data["private_key"] = credential.PrivateKey data["client_email"] = credential.ClientEmail - fmt.Println("################## data ##################") - //fmt.Println("data to json : ", data) - fmt.Println("################## data ##################") + //cblog.Debug("################## data ##################") + //cblog.Debug("data to json : ", data) + //cblog.Debug("################## data ##################") res, _ := json.Marshal(data) // data, err := ioutil.ReadFile(credential.ClientSecret) @@ -175,9 +183,9 @@ func getContainerClient(credential idrv.CredentialInfo) (context.Context, *conta data["private_key"] = credential.PrivateKey data["client_email"] = credential.ClientEmail - fmt.Println("################## data ##################") - //fmt.Println("data to json : ", data) - fmt.Println("################## data ##################") + //cblog.Debug("################## data ##################") + //cblog.Debug("data to json : ", data) + //cblog.Debug("################## data ##################") res, _ := json.Marshal(data) authURL := "https://www.googleapis.com/auth/cloud-platform" @@ -208,9 +216,9 @@ func getBillingCatalogClient(credential idrv.CredentialInfo) (context.Context, * data["private_key"] = credential.PrivateKey data["client_email"] = credential.ClientEmail - fmt.Println("################## data ##################") - //fmt.Println("data to json : ", data) - fmt.Println("################## data ##################") + //cblog.Debug("################## data ##################") + //cblog.Debug("data to json : ", data) + //cblog.Debug("################## data ##################") // https://www.googleapis.com/auth/cloud-platform // https://www.googleapis.com/auth/cloud-billing @@ -221,7 +229,7 @@ func getBillingCatalogClient(credential idrv.CredentialInfo) (context.Context, * conf, err := goo.JWTConfigFromJSON(res, authURL) if err != nil { - fmt.Println("JWTConfig ", conf) + cblog.Error("JWTConfig ", conf) return nil, nil, err } @@ -229,7 +237,7 @@ func getBillingCatalogClient(credential idrv.CredentialInfo) (context.Context, * billingCatalogClient, err := cloudbilling.New(client) if err != nil { - fmt.Println("billingCatalogClient err ", err) + cblog.Error("billingCatalogClient err ", err) return nil, nil, err } @@ -248,9 +256,9 @@ func getCostEstimationClient(credential idrv.CredentialInfo) (context.Context, * data["private_key"] = credential.PrivateKey data["client_email"] = credential.ClientEmail - fmt.Println("################## data ##################") - //fmt.Println("data to json : ", data) - fmt.Println("################## data ##################") + //cblog.Debug("################## data ##################") + //cblog.Debug("data to json : ", data) + //cblog.Debug("################## data ##################") // https://www.googleapis.com/auth/cloud-platform // https://www.googleapis.com/auth/cloud-billing @@ -261,7 +269,7 @@ func getCostEstimationClient(credential idrv.CredentialInfo) (context.Context, * conf, err := goo.JWTConfigFromJSON(res, authURL) if err != nil { - fmt.Println("JWTConfig ", conf) + cblog.Error("JWTConfig ", conf) return nil, nil, err } @@ -272,7 +280,7 @@ func getCostEstimationClient(credential idrv.CredentialInfo) (context.Context, * costEstimationClient, err := cbb.NewService(ctx, option.WithHTTPClient(client)) if err != nil { - fmt.Println("costEstimation Service create err ", err) + cblog.Error("costEstimation Service create err ", err) return nil, nil, err } diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/ClusterHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/ClusterHandler.go index 562dbede4..fed3ee954 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/ClusterHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/ClusterHandler.go @@ -12,7 +12,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" compute "google.golang.org/api/compute/v1" container "google.golang.org/api/container/v1" ) @@ -148,7 +147,7 @@ func (ClusterHandler *GCPClusterHandler) CreateCluster(clusterReqInfo irs.Cluste reqCluster.InitialNodeCount = 3 // Cluster.initial_node_count must be greater than zero } - spew.Dump(rb) + cblogger.Debug(rb) // if 1 == 1 { // return irs.ClusterInfo{}, nil // } @@ -201,12 +200,12 @@ func (ClusterHandler *GCPClusterHandler) ListCluster() ([]*irs.ClusterInfo, erro cblogger.Error(err) return nil, err } - //spew.Dump(resp) + //cblogger.Debug(resp) clusterInfoList := []*irs.ClusterInfo{} respClusters := resp.Clusters - cblogger.Info(respClusters) + cblogger.Debug(respClusters) for _, cluster := range respClusters { // clusterInfo, err := mappingClusterInfo(cluster) // if err != nil { @@ -330,7 +329,7 @@ func (ClusterHandler *GCPClusterHandler) DeleteCluster(clusterIID irs.IID) (bool cblogger.Error(err) return false, err } - spew.Dump(op) + cblogger.Debug(op) operationErr := WaitContainerOperationFail(ClusterHandler.ContainerClient, projectID, region, zone, op.Name, GCP_CONTAINER_OPERATION_DELETE_CLUSTER) if operationErr != nil { @@ -362,7 +361,7 @@ func (ClusterHandler *GCPClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGr sgTags = append(sgTags, securityGroupIID.NameId) } } - //spew.Dump(nodeGroupReqInfo) + //cblogger.Debug(nodeGroupReqInfo) // param set reqNodePool := container.NodePool{} reqNodePool.Name = nodeGroupReqInfo.IId.NameId @@ -401,7 +400,7 @@ func (ClusterHandler *GCPClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGr parent := getParentClusterAtContainer(projectID, zone, clusterIID.NameId) cblogger.Info("parent : ", parent) - //spew.Dump(reqNodePool) + //cblogger.Debug(reqNodePool) rb := &container.CreateNodePoolRequest{ NodePool: &reqNodePool, @@ -415,7 +414,7 @@ func (ClusterHandler *GCPClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGr cblogger.Error(err) return nodeGroupInfo, err } - //spew.Dump(op) + //cblogger.Debug(op) operationErr := WaitContainerOperationFail(ClusterHandler.ContainerClient, projectID, region, zone, op.Name, GCP_CONTAINER_OPERATION_CREATE_NODE_POOL) if operationErr != nil { @@ -480,7 +479,7 @@ func (ClusterHandler *GCPClusterHandler) SetNodeGroupAutoScaling(clusterIID irs. rb := &container.SetNodePoolAutoscalingRequest{ Autoscaling: &container.NodePoolAutoscaling{Enabled: on}, } - spew.Dump(rb) + cblogger.Debug(rb) hiscallInfo := GetCallLogScheme(ClusterHandler.Region, call.CLUSTER, clusterIID.NameId, "SetNodeGroupAutoScaling()") start := call.Start() @@ -491,7 +490,7 @@ func (ClusterHandler *GCPClusterHandler) SetNodeGroupAutoScaling(clusterIID irs. cblogger.Error(err) return false, err } - spew.Dump(op) + cblogger.Debug(op) operationErr := WaitContainerOperationDone(ClusterHandler.ContainerClient, projectID, region, zone, op.Name, GCP_CONTAINER_OPERATION_SET_NODE_POOL_MANAGEMENT, 30) if operationErr != nil { @@ -575,7 +574,7 @@ func (ClusterHandler *GCPClusterHandler) ChangeNodeGroupScaling(clusterIID irs.I cblogger.Error(err) return irs.NodeGroupInfo{}, err } - spew.Dump(op) + cblogger.Debug(op) operationErr := WaitContainerOperationDone(ClusterHandler.ContainerClient, projectID, region, zone, op.Name, GCP_CONTAINER_OPERATION_SET_NODE_POOL_MANAGEMENT, 30) if operationErr != nil { @@ -633,7 +632,7 @@ func (ClusterHandler *GCPClusterHandler) ChangeNodeGroupScaling(clusterIID irs.I cblogger.Error(err2) return irs.NodeGroupInfo{}, err } - spew.Dump(op2) + cblogger.Debug(op2) operationErr2 := WaitContainerOperationDone(ClusterHandler.ContainerClient, projectID, region, zone, op2.Name, GCP_CONTAINER_OPERATION_SET_NODE_POOL_SIZE, 30) if operationErr2 != nil { @@ -671,7 +670,7 @@ func (ClusterHandler *GCPClusterHandler) RemoveNodeGroup(clusterIID irs.IID, nod cblogger.Error(err) return false, err } - spew.Dump(op) + cblogger.Debug(op) operationErr := WaitContainerOperationDone(ClusterHandler.ContainerClient, projectID, region, zone, op.Name, GCP_CONTAINER_OPERATION_DELETE_NODE_POOL, 600) if operationErr != nil { @@ -708,7 +707,7 @@ func (ClusterHandler *GCPClusterHandler) UpgradeCluster(clusterIID irs.IID, newV cblogger.Error(err) return clusterInfo, err } - spew.Dump(op) + cblogger.Debug(op) operationErr := WaitContainerOperationFail(ClusterHandler.ContainerClient, projectID, region, zone, op.Name, GCP_CONTAINER_OPERATION_UPDATE_CLUSTER) if operationErr != nil { @@ -901,7 +900,7 @@ func mappingClusterInfo(cluster *container.Cluster) (ClusterInfo irs.ClusterInfo clusterInfo.CreatedTime = createDatetime clusterInfo.Addons = addOnsInfo - // spew.Dump(clusterInfo) + // cblogger.Debug(clusterInfo) return clusterInfo, nil } @@ -995,7 +994,7 @@ func getNodeGroupStatus(nodePoolStatus string) irs.NodeGroupStatus { // autoScaling := container.NodePoolAutoscaling{} // parent := getParentNodePoolsAtContainer(projectID, zone, clusterIID.NameId, nodeGroupReqInfo.IId.NameId) -// spew.Dump(nodeGroupReqInfo) +// cblogger.Debug(nodeGroupReqInfo) // if strings.EqualFold(autoscalingType, GCP_SET_AUTOSCALING_ENABLE) { // if orgNodeGroupReqInfo.OnAutoScaling != nodeGroupReqInfo.OnAutoScaling { // autoScaling.Enabled = nodeGroupReqInfo.OnAutoScaling @@ -1045,7 +1044,7 @@ func getNodeGroupStatus(nodePoolStatus string) irs.NodeGroupStatus { // cblogger.Error(err) // return false, err // } -// spew.Dump(op) +// cblogger.Debug(op) // operationErr := WaitContainerOperationDone(containerClient, projectID, region, zone, op.Name, 3, 1200) // if operationErr != nil { @@ -1104,7 +1103,7 @@ func convertNodeGroup(client *compute.Service, credential idrv.CredentialInfo, r nodeGroupList := []irs.NodeGroupInfo{} for _, nodeGroupInfo := range orgNodeGroupList { cblogger.Info("convertNodeGroup ", nodeGroupInfo) - //spew.Dump(nodeGroupInfo) + //cblogger.Debug(nodeGroupInfo) keyValueList := nodeGroupInfo.KeyValueList for _, keyValue := range keyValueList { cblogger.Info("keyValue ", keyValue) @@ -1122,7 +1121,7 @@ func convertNodeGroup(client *compute.Service, credential idrv.CredentialInfo, r if err != nil { return nodeGroupList, err } - //spew.Dump(instanceInfo) + //cblogger.Debug(instanceInfo) // nodeGroup의 Instance ID nodeIID := irs.IID{NameId: instanceInfo.Name, SystemId: instanceInfo.Name} nodeList = append(nodeList, nodeIID) @@ -1140,7 +1139,7 @@ func convertNodeGroup(client *compute.Service, credential idrv.CredentialInfo, r cblogger.Info("nodeList ", nodeList) nodeGroupInfo.Nodes = nodeList //cblogger.Info("nodeGroupInfo ", nodeGroupInfo) - spew.Dump(nodeGroupInfo) + cblogger.Debug(nodeGroupInfo) } } nodeGroupList = append(nodeGroupList, nodeGroupInfo) diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/CommonHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/CommonHandler.go index 4c3d1c586..b80d07f2e 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/CommonHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/CommonHandler.go @@ -29,7 +29,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" "github.com/sirupsen/logrus" compute "google.golang.org/api/compute/v1" container "google.golang.org/api/container/v1" @@ -112,7 +111,7 @@ func GetKeyValueList(i map[string]interface{}) []irs.KeyValue { //cblogger.Infof("K:[%s]====>", k) _, ok := v.(string) if !ok { - cblogger.Errorf("Key[%s]의 값은 변환 불가", k) + cblogger.Errorf("The value for key [%s] cannot be converted.", k) continue } //if strings.EqualFold(k, "users") { @@ -128,13 +127,13 @@ func GetKeyValueList(i map[string]interface{}) []irs.KeyValue { // Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용 func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) { - //spew.Dump(v) + //cblogger.Debug(v) var keyValueList []irs.KeyValue var i map[string]interface{} jsonBytes, errJson := json.Marshal(v) if errJson != nil { - cblogger.Error("KeyValue 변환 실패") + cblogger.Error("KeyValue conversion failed") cblogger.Error(errJson) return nil, errJson } @@ -290,16 +289,16 @@ func WaitUntilComplete(client *compute.Service, project string, region string, r opSatus, err = client.RegionOperations.Get(project, region, resourceId).Do() } if err != nil { - cblogger.Infof("WaitUntilComplete / [%s]", err) + cblogger.Errorf("WaitUntilComplete / [%s]", err) return err } - cblogger.Infof("==> 상태 : 진행율 : [%d] / [%s]", opSatus.Progress, opSatus.Status) + cblogger.Infof("==> Status: Progress: [%d] / [%s]", opSatus.Progress, opSatus.Status) //PENDING, RUNNING, or DONE. if (opSatus.Status == "RUNNING" || opSatus.Status == "DONE") && opSatus.Progress >= 100 { //if opSatus.Status == "RUNNING" || opSatus.Status == "DONE" { //if opSatus.Status == "DONE" { - cblogger.Info("Wait을 종료합니다.", resourceId, ":", opSatus.Status) + cblogger.Info("Exiting Wait.", resourceId, ":", opSatus.Status) return nil } @@ -307,8 +306,8 @@ func WaitUntilComplete(client *compute.Service, project string, region string, r after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 리소스[%s]의 상태가 완료되지 않아서 Wait을 강제로 종료함.", max_time, resourceId) - return errors.New("장시간 요청 작업이 완료되지 않아서 Wait을 강제로 종료함.)") + cblogger.Errorf("Forcing termination of Wait because the status of resource [%s] has not completed within [%d] seconds.", max_time, resourceId) + return errors.New("Forcing termination of Wait due to the request operation not completing for a long time.") } } @@ -332,16 +331,16 @@ func WaitOperationComplete(client *compute.Service, project string, region strin opSatus, err = client.ZoneOperations.Get(project, zone, resourceId).Do() } if err != nil { - cblogger.Infof("WaitUntilOperationComplete / [%s]", err) + cblogger.Errorf("WaitUntilOperationComplete / [%s]", err) return err } - cblogger.Infof("==> 상태 : 진행율 : [%d] / [%s]", opSatus.Progress, opSatus.Status) + cblogger.Infof("==> Status: Progress: [%d] / [%s]", opSatus.Progress, opSatus.Status) //PENDING, RUNNING, or DONE. if (opSatus.Status == "RUNNING" || opSatus.Status == "DONE") && opSatus.Progress >= 100 { //if opSatus.Status == "RUNNING" || opSatus.Status == "DONE" { //if opSatus.Status == "DONE" { - cblogger.Info("Wait을 종료합니다.", resourceId, ":", opSatus.Status) + cblogger.Info("Exiting Wait.", resourceId, ":", opSatus.Status) return nil } @@ -349,8 +348,8 @@ func WaitOperationComplete(client *compute.Service, project string, region strin after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 리소스[%s]의 상태가 완료되지 않아서 Wait을 강제로 종료함.", max_time, resourceId) - return errors.New("장시간 요청 작업이 완료되지 않아서 Wait을 강제로 종료함.)") + cblogger.Errorf("Forcing termination of Wait because the status of resource [%s] has not completed within [%d] seconds.", max_time, resourceId) + return errors.New("Forcing termination of Wait due to the request operation not completing for a long time.") } } @@ -364,7 +363,7 @@ func GetDiskInfo(client *compute.Service, credential idrv.CredentialInfo, region targetZone := region.TargetZone // 대상 zone이 다른경우 targetZone을 사용 - if targetZone != ""{ + if targetZone != "" { zone = targetZone } diskResp, err := client.Disks.Get(projectID, zone, diskName).Do() @@ -387,7 +386,7 @@ func GetMachineImageInfo(client *compute.Service, projectId string, imageName st return nil, errors.New("Not Found : [" + imageName + "] Image information not found") } // cblogger.Infof("result ", imageResp) - // spew.Dump(imageResp) + // cblogger.Debug(imageResp) return imageResp, nil } @@ -456,7 +455,7 @@ func FindImageByID(client *compute.Service, imageIID irs.IID) (*compute.Image, e res, err = req.Do() if err != nil { - cblogger.Errorf("[%s] 프로젝트 소유의 이미지 목록 조회 실패!", projectId) + cblogger.Errorf("[%s] Failed to retrieve the list of project-owned images", projectId) cblogger.Error(err) return nil, err } @@ -465,14 +464,14 @@ func FindImageByID(client *compute.Service, imageIID irs.IID) (*compute.Image, e cblogger.Info("NestPageToken : ", nextPageToken) for { - cblogger.Info("Loop?") + cblogger.Debug("Loop?") for _, item := range res.Items { cnt++ if strings.EqualFold(reqImageName, item.SelfLink) { - cblogger.Info("found Image : ", item) + cblogger.Debug("found Image : ", item) return item, nil } - cblogger.Info("cnt : ", item) + cblogger.Debug("cnt : ", item) } } } @@ -492,10 +491,10 @@ func WaitContainerOperationComplete(client *container.Service, project string, r for { opSatus, err = client.Projects.Locations.Operations.Get(operationName).Do() if err != nil { - cblogger.Infof("WaitUntilOperationComplete / [%s]", err) + cblogger.Errorf("WaitUntilOperationComplete / [%s]", err) return err } - cblogger.Infof("==> 상태 : 진행율 : [%d] / [%s]", opSatus.Progress, opSatus.Status) + cblogger.Infof("==> Status: Progress: [%d] / [%s]", opSatus.Progress, opSatus.Status) //PENDING, RUNNING, or DONE. @@ -505,7 +504,7 @@ func WaitContainerOperationComplete(client *container.Service, project string, r // DONE The operation is done, either cancelled or completed. // ABORTING The operation is aborting. if opSatus.Status == "DONE" { - cblogger.Info("Wait을 종료합니다.", resourceId, ":", opSatus.Status) + cblogger.Info("Exiting Wait.", resourceId, ":", opSatus.Status) return nil } @@ -513,8 +512,8 @@ func WaitContainerOperationComplete(client *container.Service, project string, r after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 리소스[%s]의 상태가 완료되지 않아서 Wait을 강제로 종료함.", max_time, resourceId) - return errors.New("장시간 요청 작업이 완료되지 않아서 Wait을 강제로 종료함.)") + cblogger.Errorf("Forcing termination of Wait because the status of resource [%s] has not completed within [%d] seconds.", max_time, resourceId) + return errors.New("Forcing termination of Wait due to the request operation not completing for a long time.") } } @@ -536,8 +535,8 @@ func WaitContainerOperationFail(client *container.Service, project string, regio cblogger.Infof("WaitContainerOperationFail / [%s]", err) return err } - spew.Dump(opSatus) - cblogger.Infof("==> 상태 : 진행율 : [%d] / [%s]", opSatus.Progress, opSatus.Status) + cblogger.Debug(opSatus) + cblogger.Infof("==> Status: Progress: [%d] / [%s]", opSatus.Progress, opSatus.Status) //PENDING, RUNNING, or DONE. @@ -547,7 +546,7 @@ func WaitContainerOperationFail(client *container.Service, project string, regio // DONE The operation is done, either cancelled or completed. // ABORTING The operation is aborting. if opSatus.Status == "ABORTING" { - cblogger.Info("Wait을 종료합니다.", resourceId, ":", opSatus.Status) + cblogger.Info("Exiting Wait.", resourceId, ":", opSatus.Status) return nil } @@ -555,7 +554,7 @@ func WaitContainerOperationFail(client *container.Service, project string, regio after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 리소스[%s]의 상태가 완료되지 않아서 Wait을 강제로 종료함.", max_time, resourceId) + cblogger.Errorf("Forcing termination of Wait because the status of resource [%s] has not completed within [%d] seconds.", max_time, resourceId) return nil } } @@ -574,11 +573,11 @@ func WaitContainerOperationDone(client *container.Service, project string, regio for { opSatus, err = client.Projects.Locations.Operations.Get(operationName).Do() if err != nil { - cblogger.Infof("WaitContainerOperationDone / [%s]", err) + cblogger.Errorf("WaitContainerOperationDone / [%s]", err) return err } - spew.Dump(opSatus) - cblogger.Infof("==> 상태 : 진행율 : [%d] / [%s]", opSatus.Progress, opSatus.Status) + cblogger.Debug(opSatus) + cblogger.Infof("==> Status: Progress: [%d] / [%s]", opSatus.Progress, opSatus.Status) //PENDING, RUNNING, or DONE. @@ -588,7 +587,7 @@ func WaitContainerOperationDone(client *container.Service, project string, regio // DONE The operation is done, either cancelled or completed. // ABORTING The operation is aborting. if opSatus.Status == "DONE" { - cblogger.Info("Wait을 종료합니다.", resourceId, ":", opSatus.Status) + cblogger.Info("Exiting Wait.", resourceId, ":", opSatus.Status) return nil } @@ -596,7 +595,7 @@ func WaitContainerOperationDone(client *container.Service, project string, regio after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > maxTime { - cblogger.Errorf("[%d]초 동안 리소스[%s]의 상태가 완료되지 않아서 Wait을 강제로 종료함.", maxTime, resourceId) + cblogger.Errorf("Forcing termination of Wait because the status of resource [%s] has not completed within [%d] seconds.", maxTime, resourceId) return nil } } @@ -695,7 +694,7 @@ func GetZoneListByRegion(client *compute.Service, projectId string, regionUrl st cblogger.Error(err) return nil, err } - // spew.Dump(resp) + // cblogger.Debug(resp) return resp, nil } diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/DiskHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/DiskHandler.go index 0f7fb3330..1938c6372 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/DiskHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/DiskHandler.go @@ -3,7 +3,6 @@ package resources import ( "context" "errors" - "fmt" "strconv" "strings" "time" @@ -41,7 +40,7 @@ func (DiskHandler *GCPDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs.Dis zone := DiskHandler.Region.Zone diskName := diskReqInfo.IId.NameId - if diskReqInfo.Zone != "" {// #1067 disk의 zone이 있으면 해당 zone 사용. + if diskReqInfo.Zone != "" { // #1067 disk의 zone이 있으면 해당 zone 사용. cblogger.Info("SetDisk zone before ", DiskHandler.Region) zone = diskReqInfo.Zone DiskHandler.Region.Zone = zone // Region은 동일할 것이고 zone을 새로 설정. @@ -109,12 +108,12 @@ func (DiskHandler *GCPDiskHandler) ListDisk() ([]*irs.DiskInfo, error) { cblogger.Error("get ZoneInfo by region ") //GetRegionZone(regionName string) (irs.RegionZoneInfo, error) // #1067에 의해 connection의 zone -> region내 disk 조회로 변경 - regionZoneHandler := GCPRegionZoneHandler{ - Client: DiskHandler.Client, - Credential : DiskHandler.Credential, - Region:DiskHandler.Region, - Ctx : DiskHandler.Ctx, - } + regionZoneHandler := GCPRegionZoneHandler{ + Client: DiskHandler.Client, + Credential: DiskHandler.Credential, + Region: DiskHandler.Region, + Ctx: DiskHandler.Ctx, + } regionZoneInfo, err := regionZoneHandler.GetRegionZone(regionID) if err != nil { cblogger.Error("failed to get ZoneInfo by region ", err) @@ -127,7 +126,7 @@ func (DiskHandler *GCPDiskHandler) ListDisk() ([]*irs.DiskInfo, error) { cblogger.Error("zone Info ", zoneItem) // get Disks by Zone hiscallInfo.ElapsedTime = call.Elapsed(start) - diskList, err := DiskHandler.Client.Disks.List(projectID, zoneItem.Name).Do() + diskList, err := DiskHandler.Client.Disks.List(projectID, zoneItem.Name).Do() if err != nil { cblogger.Error(err) LoggingError(hiscallInfo, err) @@ -144,10 +143,8 @@ func (DiskHandler *GCPDiskHandler) ListDisk() ([]*irs.DiskInfo, error) { diskInfoList = append(diskInfoList, &diskInfo) } } - + } - - return diskInfoList, nil } @@ -206,7 +203,7 @@ func (DiskHandler *GCPDiskHandler) ChangeDiskSize(diskIID irs.IID, size string) op, err := DiskHandler.Client.Disks.Resize(projectID, zone, disk, diskSize).Do() hiscallInfo.ElapsedTime = call.Elapsed(start) if err != nil { - cblogger.Info(op) + cblogger.Error(op) cblogger.Error(err) LoggingError(hiscallInfo, err) return false, err @@ -229,14 +226,14 @@ func (DiskHandler *GCPDiskHandler) DeleteDisk(diskIID irs.IID) (bool, error) { disk := diskIID.SystemId // 대상 zone이 다른경우 targetZone을 사용 - if targetZone != ""{ + if targetZone != "" { zone = targetZone } op, err := DiskHandler.Client.Disks.Delete(projectID, zone, disk).Do() hiscallInfo.ElapsedTime = call.Elapsed(start) if err != nil { - cblogger.Info(op) + cblogger.Error(op) cblogger.Error(err) LoggingError(hiscallInfo, err) return false, err @@ -250,12 +247,12 @@ func (DiskHandler *GCPDiskHandler) DeleteDisk(diskIID irs.IID) (bool, error) { func (DiskHandler *GCPDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) (irs.DiskInfo, error) { // disk와 vm의 zone valid check - attachDiskInfo, err := DiskHandler.GetDisk(diskIID) + attachDiskInfo, err := DiskHandler.GetDisk(diskIID) if err != nil { - cblogger.Error(err) + cblogger.Error(err) return irs.DiskInfo{}, err } - + // check disk status : "available" state only if attachDiskInfo.Status != irs.DiskStatus("Available") { return irs.DiskInfo{}, errors.New(string("The disk must be in the Available state : " + attachDiskInfo.Status)) @@ -272,24 +269,22 @@ func (DiskHandler *GCPDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) cblogger.Error(err.Error()) return irs.DiskInfo{}, err } - - - if vmInfo.Region.Zone != attachDiskInfo.Zone{ - cblogger.Error("The disk and the VM must be in the same zone." + vmInfo.Region.Zone, attachDiskInfo.Zone) + + if vmInfo.Region.Zone != attachDiskInfo.Zone { + cblogger.Error("The disk and the VM must be in the same zone."+vmInfo.Region.Zone, attachDiskInfo.Zone) return irs.DiskInfo{}, errors.New(string("The disk and the VM must be in the same zone.")) } // vmStatus는 다시 조회해야 하기 때문에 attach할 수 있는 상태가 아니면 오류로 return // valid check end - hiscallInfo := GetCallLogScheme(DiskHandler.Region, call.DISK, diskIID.NameId, "AttachDisk()") start := call.Start() projectID := DiskHandler.Credential.ProjectID region := DiskHandler.Region.Region //zone := DiskHandler.Region.Zone - zone := vmInfo.Region.Zone// vm의 zone으로 설정 + zone := vmInfo.Region.Zone // vm의 zone으로 설정 instance := ownerVM.SystemId attachedDisk := &compute.AttachedDisk{ @@ -299,7 +294,7 @@ func (DiskHandler *GCPDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) op, err := DiskHandler.Client.Instances.AttachDisk(projectID, zone, instance, attachedDisk).Do() hiscallInfo.ElapsedTime = call.Elapsed(start) if err != nil { - cblogger.Info(op) + cblogger.Error(op) cblogger.Error(err) LoggingError(hiscallInfo, err) return irs.DiskInfo{}, err @@ -352,7 +347,7 @@ func (DiskHandler *GCPDiskHandler) DetachDisk(diskIID irs.IID, ownerVM irs.IID) op, err := DiskHandler.Client.Instances.DetachDisk(projectID, zone, instance, deviceName).Do() hiscallInfo.ElapsedTime = call.Elapsed(start) if err != nil { - cblogger.Info(op) + cblogger.Error(op) cblogger.Error(err) LoggingError(hiscallInfo, err) return false, err @@ -409,12 +404,12 @@ func validateDiskSize(diskInfo irs.DiskInfo) error { } if diskSize < diskSizeValue.diskMinSize { - fmt.Println("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be at least the minimum size (" + strconv.FormatInt(diskSizeValue.diskMinSize, 10) + " GB).") } if diskSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be smaller than or equal to the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } @@ -470,7 +465,7 @@ func validateChangeDiskSize(diskInfo irs.DiskInfo, newSize string) error { } if newDiskSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be smaller than or equal to the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } @@ -505,14 +500,13 @@ func convertDiskInfo(diskResp *compute.Disk) (irs.DiskInfo, error) { diskInfo.DiskSize = strconv.FormatInt(diskResp.SizeGb, 10) diskInfo.CreatedTime, _ = time.Parse(time.RFC3339, diskResp.CreationTimestamp) //diskInfo.Zone = diskResp.Zone // diskResp의 zone은 url 형태이므로 zone 만 추출 - index := strings.Index(diskResp.Zone, "zones/") // "zones/"의 인덱스를 찾음 + index := strings.Index(diskResp.Zone, "zones/") // "zones/"의 인덱스를 찾음 if index != -1 { - diskInfo.Zone = diskResp.Zone[index+len("zones/"):] // "zones/" 다음의 문자열을 추출 - }else{ + diskInfo.Zone = diskResp.Zone[index+len("zones/"):] // "zones/" 다음의 문자열을 추출 + } else { diskInfo.Zone = diskResp.Zone } - // Users : the users of the disk (attached instances) if diskResp.Users != nil { arrUsers := strings.Split(diskResp.Users[0], "/") diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/ImageHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/ImageHandler.go index 0f41d39c6..cb488959f 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/ImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/ImageHandler.go @@ -14,14 +14,12 @@ package resources import ( "context" "errors" - "fmt" "strconv" "strings" call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" compute "google.golang.org/api/compute/v1" ) @@ -72,14 +70,14 @@ func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error) { imageList = append(imageList, &info) } - //spew.Dump(imageList) + //cblogger.Debug(imageList) return imageList, nil } */ // 리스트의 경우 Name 기반으로 조회해서 처리하기에는 너무 느리기 때문에 직접 컨버팅함. func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error) { - cblogger.Debug("전체 이미지 조회") + cblogger.Debug("Retrieve All VM Images") //https://cloud.google.com/compute/docs/images?hl=ko arrImageProjectList := []string{ @@ -120,7 +118,7 @@ func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error) { callLogStart := call.Start() for _, projectId := range arrImageProjectList { - cblogger.Infof("[%s] 프로젝트 소유의 이미지 목록 처리", projectId) + cblogger.Infof("Processing image list owned by [%s] project", projectId) //첫번째 호출 req = imageHandler.Client.Images.List(projectId) @@ -129,7 +127,7 @@ func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error) { callLogInfo.ElapsedTime = call.Elapsed(callLogStart) callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) - cblogger.Errorf("[%s] 프로젝트 소유의 이미지 목록 조회 실패!", projectId) + cblogger.Errorf("Failed to retrieve image list owned by [%s] project!", projectId) cblogger.Error(err) return nil, err } @@ -141,7 +139,9 @@ func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error) { for { for _, item := range res.Items { cnt++ - spew.Dump(item) + if cblogger.Level.String() == "debug" { + cblogger.Debug(item) + } info := mappingImageInfo(item) imageList = append(imageList, &info) } // for : 페이지 데이터 추출 @@ -159,7 +159,6 @@ func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error) { callLogInfo.ElapsedTime = call.Elapsed(callLogStart) callogger.Info(call.String(callLogInfo)) - //spew.Dump(imageList) return imageList, nil } @@ -182,8 +181,10 @@ type GcpImageInfo struct { // GCP 호출을 줄이기 위해 조회된 정보를 CB형태로 직접 변환해서 전달 함. func (imageHandler *GCPImageHandler) ConvertGcpImageInfoToCbImageInfo(imageInfo GcpImageInfo) irs.ImageInfo { - cblogger.Info(imageInfo) - spew.Dump(imageInfo) + cblogger.Debug(imageInfo) + if cblogger.Level.String() == "debug" { + cblogger.Debug(imageInfo) + } cbImageInfo := irs.ImageInfo{ IId: irs.IID{ @@ -212,7 +213,7 @@ func (imageHandler *GCPImageHandler) ConvertGcpImageInfoToCbImageInfo(imageInfo // 이슈 #239에 의해 Name 기반에서 URL 기반으로 로직 변경 // 전달 받은 URL에서 projectId와 Name을 추출해서 조회함. func (imageHandler *GCPImageHandler) GetImage(imageIID irs.IID) (irs.ImageInfo, error) { - cblogger.Info(imageIID) + cblogger.Debug(imageIID) //"https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-minimal-1804-bionic-v20200415" //projectId := imageHandler.Credential.ProjectID @@ -262,7 +263,7 @@ func (imageHandler *GCPImageHandler) GetImage(imageIID irs.IID) (irs.ImageInfo, // 이슈 #239에 의해 Name 기반에서 URL 기반으로 로직 변경 // 전체 목록에서 이미지 정보를 조회 함. - 위의 GetImage()로 검색되지 않는 경우가 발생하면 이 함수를 이용할 것. func (imageHandler *GCPImageHandler) GetImageByUrl(imageIID irs.IID) (irs.ImageInfo, error) { - cblogger.Info(imageIID) + cblogger.Debug(imageIID) //이미지 명을 기반으로 이미지 정보를 조회함. gcpImageInfo, err := imageHandler.FindImageInfo(imageIID.SystemId) @@ -271,7 +272,7 @@ func (imageHandler *GCPImageHandler) GetImageByUrl(imageIID irs.IID) (irs.ImageI cblogger.Error(err) return irs.ImageInfo{}, err } - cblogger.Info(gcpImageInfo) + cblogger.Debug(gcpImageInfo) //return irs.ImageInfo{}, nil return imageHandler.ConvertGcpImageInfoToCbImageInfo(gcpImageInfo), nil @@ -326,7 +327,7 @@ func (imageHandler *GCPImageHandler) DeleteImage(imageIID irs.IID) (bool, error) return false, err } callogger.Info(call.String(callLogInfo)) - fmt.Println(res) + cblogger.Debug(res) return true, err } @@ -335,7 +336,7 @@ func (imageHandler *GCPImageHandler) DeleteImage(imageIID irs.IID) (bool, error) // https://cloud.google.com/compute/docs/images?hl=ko // @TODO : 효율을 위해서 최소한 ProjectId 정보를 입력 받아야 하지만 현재는 이미지 URL만 전달 받기 때문에 하나로 통합해 놓음. func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImageInfo, error) { - cblogger.Infof("[%s] 이미지 정보 찾기 ", reqImageName) + cblogger.Infof("Finding information for [%s] image", reqImageName) //https://cloud.google.com/compute/docs/images?hl=ko arrImageProjectList := []string{ @@ -365,7 +366,7 @@ func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImag var res *compute.ImageList var err error for _, projectId := range arrImageProjectList { - cblogger.Infof("[%s] 프로젝트 소유의 이미지 목록 조회 처리", projectId) + cblogger.Infof("Processing retrieval of image list owned by [%s] project", projectId) //첫번째 호출 req = imageHandler.Client.Images.List(projectId) @@ -374,7 +375,7 @@ func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImag res, err = req.Do() if err != nil { - cblogger.Errorf("[%s] 프로젝트 소유의 이미지 목록 조회 실패!", projectId) + cblogger.Errorf("Failed to retrieve image list owned by [%s] project!", projectId) cblogger.Error(err) return GcpImageInfo{}, err } @@ -418,10 +419,9 @@ func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImag //2020-07-24 Name 기반에서 URL기반으로 바뀌었기 때문에 직접 SelfLink만 체크 함. if strings.EqualFold(reqImageName, item.SelfLink) { //if strings.EqualFold(reqImageName, item.Name) || strings.EqualFold(reqImageName, curImageLink) { - //cblogger.Debug("=====************** 찾았다!!! *********======") - cblogger.Debugf("=====************** [%d]번째에 찾았다!!! *********======", cnt) + if item.SelfLink == "" { - cblogger.Errorf("요청 받은 [%s] 이미지의 정보를 찾았지만 Image URL[SelfLink]정보가 없습니다.", reqImageName) + cblogger.Errorf("Found information for the requested [%s] image, but Image URL [SelfLink] information is missing.", reqImageName) return GcpImageInfo{}, errors.New("Not Found : [" + reqImageName + "] Image information does not contain URL information.") } //imageInfo.Id = item.Id @@ -439,8 +439,10 @@ func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImag imageInfo.Family = item.Family imageInfo.ProjectId = projectId - cblogger.Info("최종 이미지 정보") - //spew.Dump(imageInfo) + //cblogger.Info("최종 이미지 정보") + //if cblogger.Level.String() == "debug" { + // cblogger.Debug(imageInfo) + //} return imageInfo, nil } } // for : 조회 결과에서 일치하는 데이터 찾기 @@ -456,14 +458,14 @@ func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImag } // for : 멀티 페이지 처리 } - cblogger.Errorf("요청 받은 [%s] 이미지에 대한 정보를 찾지 못 했습니다. - 총 이미지 체크 갯수 : [%d]", reqImageName, cnt) + cblogger.Errorf("Could not find information for the requested [%s] image. - Total image check count: [%d]", reqImageName, cnt) return GcpImageInfo{}, errors.New("Not Found : [" + reqImageName + "] Image information not found") } // 목록에서 이미지 Name으로 정보를 찾아서 리턴 함. - 2020-07-24 URL기반으로 변경되어서 이 메소드는 사용 안 함. // @TODO : 효율을 위해서 최소한 ProjectId 정보를 입력 받아야 하지만 현재는 이미지 명만 전달 받기 때문에 하나로 통합해 놓음. func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (GcpImageInfo, error) { - cblogger.Infof("[%s] 이미지 정보 찾기 ", reqImageName) + cblogger.Infof("Finding information for [%s] image", reqImageName) //https://cloud.google.com/compute/docs/images?hl=ko arrImageProjectList := []string{ @@ -493,7 +495,7 @@ func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (G var res *compute.ImageList var err error for _, projectId := range arrImageProjectList { - cblogger.Infof("[%s] 프로젝트 소유의 이미지 목록 조회 처리", projectId) + cblogger.Infof("[%s] Project Ownership Image List Retrieval Process", projectId) //첫번째 호출 req = imageHandler.Client.Images.List(projectId) @@ -501,7 +503,7 @@ func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (G res, err = req.Do() if err != nil { - cblogger.Errorf("[%s] 프로젝트 소유의 이미지 목록 조회 실패!", projectId) + cblogger.Errorf("[%s] Failed to Retrieve Image List Owned by the Project!", projectId) cblogger.Error(err) return GcpImageInfo{}, err } @@ -541,9 +543,9 @@ func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (G if strings.EqualFold(reqImageName, item.Name) || strings.EqualFold(reqImageName, curImageLink) { //cblogger.Debug("=====************** 찾았다!!! *********======") - cblogger.Infof("=====************** [%d]번째에 찾았다!!! *********======", cnt) + //cblogger.Infof("=====************** [%d]번째에 찾았다!!! *********======", cnt) if item.SelfLink == "" { - cblogger.Errorf("요청 받은 [%s] 이미지의 정보를 찾았지만 Image URL[SelfLink]정보가 없습니다.", reqImageName) + cblogger.Errorf("We found information for the requested [%s] image, but there is no Image URL [SelfLink] available.", reqImageName) return GcpImageInfo{}, errors.New("Not Found : [" + reqImageName + "] Image information does not contain URL information.") } //imageInfo.Id = item.Id @@ -560,8 +562,9 @@ func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (G imageInfo.Family = item.Family imageInfo.ProjectId = projectId - cblogger.Info("최종 이미지 정보") - spew.Dump(imageInfo) + if cblogger.Level.String() == "debug" { + cblogger.Debug(imageInfo) + } return imageInfo, nil } } // for : 조회 결과에서 일치하는 데이터 찾기 @@ -577,7 +580,7 @@ func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (G } // for : 멀티 페이지 처리 } - cblogger.Errorf("요청 받은 [%s] 이미지에 대한 정보를 찾지 못 했습니다. - 총 이미지 체크 갯수 : [%d]", reqImageName, cnt) + cblogger.Errorf("We couldn't find information for the requested [%s] image. - Total Image Check Count: [%d]", reqImageName, cnt) return GcpImageInfo{}, errors.New("Not Found : [" + reqImageName + "] Image information not found") } @@ -622,7 +625,6 @@ func mappingImageInfo(imageInfo *compute.Image) irs.ImageInfo { //os := lArr[len(lArr)-1] //cblogger.Info("===================================") - //spew.Dump(imageInfo) imageList := irs.ImageInfo{ IId: irs.IID{ diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/KeyPairHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/KeyPairHandler.go index 099e267b5..409b1a336 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/KeyPairHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/KeyPairHandler.go @@ -137,7 +137,7 @@ func (keyPairHandler *GCPKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error) { func (keyPairHandler *GCPKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo, error) { cblogger.Infof("keyPairName : [%s]", keyIID.SystemId) keyPairName := strings.ToLower(keyIID.SystemId) - cblogger.Infof("keyPairName 소문자로 치환 : [%s]", keyPairName) + cblogger.Infof("Replace keyPairName with lowercase: [%s]", keyPairName) hashString, err := CreateHashString(keyPairHandler.CredentialInfo) if err != nil { @@ -167,7 +167,7 @@ func (keyPairHandler *GCPKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo func (keyPairHandler *GCPKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error) { cblogger.Infof("keyPairName : [%s]", keyIID.SystemId) keyPairName := strings.ToLower(keyIID.SystemId) - cblogger.Infof("keyPairName 소문자로 치환 : [%s]", keyPairName) + cblogger.Infof("Replace keyPairName with lowercase: [%s]", keyPairName) hashString, err := CreateHashString(keyPairHandler.CredentialInfo) if err != nil { diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/MyImageHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/MyImageHandler.go index c29491443..c04e095be 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/MyImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/MyImageHandler.go @@ -195,7 +195,7 @@ func (MyImageHandler *GCPMyImageHandler) CheckWindowsImage(myImageIID irs.IID) ( } } - cblogger.Info(isWindows) + cblogger.Debug(isWindows) } } diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/NLBHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/NLBHandler.go index 247bee590..15c1b48d5 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/NLBHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/NLBHandler.go @@ -4,11 +4,9 @@ import ( "context" "encoding/json" "errors" - "fmt" call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" compute "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" "strconv" @@ -16,7 +14,8 @@ import ( "time" ) -/** +/* +* Adderess(LB) -> pool(backend) -> firewallrule(Listener) */ type GCPNLBHandler struct { @@ -269,12 +268,12 @@ const ( // url set이 가능한 parma은 cspID임. */ func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, error) { - cblogger.Info("CreateNLB") + cblogger.Debug("CreateNLB") projectID := nlbHandler.Credential.ProjectID regionID := nlbHandler.Region.Region nlbName := nlbReqInfo.IId.NameId - cblogger.Info("start ", projectID) + cblogger.Debug("start ", projectID) resultMap := make(map[string]string) // 에러 발생 시 자원 회수용 @@ -284,9 +283,9 @@ func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, // 404면 없는게 맞으므로 진행 is404, checkErr := checkErrorCode(ErrorCode_NotFound, err) // 404 : not found면 pass if is404 && checkErr { // 하나라도 false 면 error return - cblogger.Info("existsTargetPoolChecks : ", err) + cblogger.Error("existsTargetPoolChecks : ", err) } else { - cblogger.Info("validateCreateNLB ", err) + cblogger.Error("validateCreateNLB ", err) return irs.NLBInfo{}, err } } @@ -327,7 +326,7 @@ func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, // targetPool 안에 healthCheckID가 들어 감. newTargetPool, err := nlbHandler.convertNlbInfoToTargetPool(&nlbReqInfo) if err != nil { - cblogger.Info("targetPoolList convert err: ", err) + cblogger.Error("targetPoolList convert err: ", err) // 이전 step 자원 회수 후 return resultMsg := nlbHandler.rollbackCreatedNlbResources(regionID, resultMap) resultMsg += resultMsg + "(2) TargetPool " + err.Error() @@ -337,7 +336,7 @@ func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, targetPool, err := nlbHandler.insertTargetPool(regionID, newTargetPool) if err != nil { - cblogger.Info("targetPoolList err: ", err) + cblogger.Error("targetPoolList err: ", err) // 이전 step 자원 회수 후 return resultMsg := nlbHandler.rollbackCreatedNlbResources(regionID, resultMap) resultMsg += resultMsg + "(2) TargetPool " + err.Error() @@ -345,14 +344,14 @@ func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, } resultMap[NLB_Component_TARGETPOOL] = targetPool.SelfLink printToJson(targetPool) - cblogger.Info("backend TargetPool 생성 완료 ") + cblogger.Info("backend TargetPool created ") - cblogger.Info("frontend (forwarding rule) 생성 ") + cblogger.Info("frontend (forwarding rule) created ") // targetPool 생성 후 selfLink 를 forwardingRule의 target으로 set. newForwardingRule := convertNlbInfoToForwardingRule(nlbReqInfo.Listener, targetPool) err = nlbHandler.insertRegionForwardingRules(regionID, &newForwardingRule) if err != nil { - cblogger.Info("forwardingRule err : ", err) + cblogger.Error("forwardingRule err : ", err) // 이전 step 자원 회수 후 return resultMsg := nlbHandler.rollbackCreatedNlbResources(regionID, resultMap) resultMsg += resultMsg + "(3) Forwarding Rule " + err.Error() @@ -378,24 +377,24 @@ func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, } /* - At the API level, there is no Load Balancer, - only the components that make it up. - Your best bet to get a view similar to the UI is to list forwarding rules (global and regional). + At the API level, there is no Load Balancer, + only the components that make it up. + Your best bet to get a view similar to the UI is to list forwarding rules (global and regional). + You can use gcloud compute forwarding-rules list which will show you all the forwarding rules in use (similar to the UI view), along with the IPs of each and the target (which may be a backend service or a target pool). - load balancer => GCP forwardingrules - listener => GCP frontend - vmGroup => GCP backend. vm instances target pull or instance group list - healthchecker => GCP Healthchecker + load balancer => GCP forwardingrules + listener => GCP frontend + vmGroup => GCP backend. vm instances target pull or instance group list + healthchecker => GCP Healthchecker - backend service 없음. - region forwarding rule, targetpool, targetpool안의 instance에서 사용하는 healthchecker - NLBInfo의 IID 에서 NameId = targetPool name, SystemId = targetPool Url + NLBInfo의 IID 에서 NameId = targetPool name, SystemId = targetPool Url - VPC정보조회를 위해 INSTANCE 정보 조회 시 같은 region의 다른 zone은 가져오지 못함. getVPCInfoFromVM 으로 가져오도록 함. - */ func (nlbHandler *GCPNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { var nlbInfoList []*irs.NLBInfo @@ -439,7 +438,7 @@ func (nlbHandler *GCPNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { regionForwardingRuleList, err := nlbHandler.listRegionForwardingRules(regionID, String_Empty, String_Empty) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { - cblogger.Info("regionForwardingRule list: ", err) + cblogger.Error("regionForwardingRule list: ", err) callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) cblogger.Error(err) @@ -454,7 +453,7 @@ func (nlbHandler *GCPNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { nlbInfo, err := nlbHandler.GetNLB(irs.IID{NameId: "", SystemId: targetLbValue}) if err != nil { // 에러가 났어도 다음 nlb 조회 - cblogger.Info("getNLB error. targetPoolUrl = " + targetPoolUrl) + cblogger.Error("getNLB error. targetPoolUrl = " + targetPoolUrl) cblogger.Error(err) } else { nlbInfoList = append(nlbInfoList, &nlbInfo) @@ -555,8 +554,8 @@ func (nlbHandler *GCPNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) { projectID := nlbHandler.Credential.ProjectID regionID := nlbHandler.Region.Region - cblogger.Info("projectID: ", projectID) - cblogger.Info("regionID: ", regionID) + cblogger.Debug("projectID: ", projectID) + cblogger.Debug("regionID: ", regionID) printToJson(nlbInfo) // region forwarding rule 는 target pool 과 lb이름으로 엮임. // map에 nb이름으로 nbInfo를 넣고 해당 값들 추가해서 조합 @@ -634,9 +633,9 @@ func (nlbHandler *GCPNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) { //} //cblogger.Info("forwardingRules result size : ", len(regionForwardingRuleList.Items)) - cblogger.Info("regionForwardingRule end: ") + cblogger.Debug("regionForwardingRule end: ") - cblogger.Info("Targetpool start: ") + cblogger.Debug("Targetpool start: ") targetPool, err := nlbHandler.getTargetPool(regionID, nlbID) if err != nil { @@ -650,7 +649,7 @@ func (nlbHandler *GCPNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) { return irs.NLBInfo{}, err } - cblogger.Info("Targetpool end: ") + cblogger.Debug("Targetpool end: ") nlbInfo.VMGroup.Protocol = listenerInfo.Protocol nlbInfo.VMGroup.Port = listenerInfo.Port @@ -669,10 +668,10 @@ func (nlbHandler *GCPNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) { // ex) frontend는 삭제되고 targetPool이 어떤이유에서 삭제가 되지 않았을 때, // 다음 시도에서 삭제 - 삭제 시도 시 404 Error인 경우는 이미 지워진 것일 수 있음. + 삭제 시도 시 404 Error인 경우는 이미 지워진 것일 수 있음. - 3가지 resource가 모두 없으면 404 Error - 1가지라도 있어서 삭제하면 삭제처리. + 3가지 resource가 모두 없으면 404 Error + 1가지라도 있어서 삭제하면 삭제처리. */ func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { deleteResultMap := make(map[string]error) // 삭제가 정상이면 error == nil @@ -685,7 +684,7 @@ func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { forwardingRuleDeleteResult, err := nlbHandler.deleteRegionForwardingRules(regionID, nlbIID) if err != nil { - cblogger.Info("DeleteNLB forwardingRule ", forwardingRuleDeleteResult, err) + cblogger.Error("DeleteNLB forwardingRule ", forwardingRuleDeleteResult, err) deleteResultMap[NLB_Component_FORWARDINGRULE] = err } cblogger.Info("DeleteNLB forwardingRuleDeleteResult ", forwardingRuleDeleteResult) @@ -706,7 +705,7 @@ func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { err = nlbHandler.removeTargetPool(regionID, targetPoolName) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { - cblogger.Info("DeleteNLB removeTargetPool err: ", err) + cblogger.Error("DeleteNLB removeTargetPool err: ", err) callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) cblogger.Error(err) @@ -717,7 +716,7 @@ func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { // health checker err = nlbHandler.removeHttpHealthCheck(targetPoolName, String_Empty) if err != nil { - cblogger.Info("DeleteNLB removeHttpHealthCheck err: ", err) + cblogger.Error("DeleteNLB removeHttpHealthCheck err: ", err) deleteResultMap[NLB_Component_HEALTHCHECKER] = err //return false, err } @@ -731,7 +730,7 @@ func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { for errKey, errMsg := range deleteResultMap { if errMsg != nil { isValidCode, isValidErrorFormat := checkErrorCode(ErrorCode_NotFound, errMsg) - cblogger.Info("DeleteNLB checkErrorCode: ", errKey, errMsg, isValidCode, isValidErrorFormat) + cblogger.Error("DeleteNLB checkErrorCode: ", errKey, errMsg, isValidCode, isValidErrorFormat) if !isValidCode && isValidErrorFormat { returnMsg += "(" + strconv.Itoa(resourceIdx) + ") " + errKey + " " + errMsg.Error() resourceIdx++ @@ -759,40 +758,39 @@ func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error) { //------ Frontend Control /* - Listener 정보 변경 -> 수정기능이 없으므로 Error return +Listener 정보 변경 -> 수정기능이 없으므로 Error return - 수정 가능한 항목은 Protocol, IP, Port, DNSName(현재 버전에서는 사용x. 향후 사용가능) - : patch function이 있으나 현재는 NetworkTier만 수정가능하여 해당 function사용 못함 + 수정 가능한 항목은 Protocol, IP, Port, DNSName(현재 버전에서는 사용x. 향후 사용가능) + : patch function이 있으나 현재는 NetworkTier만 수정가능하여 해당 function사용 못함 - 부하 분산기를 전환하려면 다음 단계를 따르세요. + 부하 분산기를 전환하려면 다음 단계를 따르세요. - 프리미엄 등급 IP 주소를 사용하는 새로운 부하 분산기 전달 규칙을 만듭니다. - 현재 표준 등급 IP 주소에서 새로운 프리미엄 등급 IP 주소로 트래픽을 천천히 마이그레이션하려면 DNS를 사용합니다. - 마이그레이션이 완료되면 표준 등급 IP 주소 및 이와 연결된 리전 부하 분산기를 해제할 수 있습니다. - 여러 부하 분산기가 동일한 백엔드를 가리키도록 할 수 있으므로 백엔드를 변경할 필요는 없습니다. - - (참고) patch 사용하려던 로직 - if !strings.EqualFold(listener.Protocol, "") { - patchRegionForwardingRule.IPProtocol = listener.Protocol - } + 프리미엄 등급 IP 주소를 사용하는 새로운 부하 분산기 전달 규칙을 만듭니다. + 현재 표준 등급 IP 주소에서 새로운 프리미엄 등급 IP 주소로 트래픽을 천천히 마이그레이션하려면 DNS를 사용합니다. + 마이그레이션이 완료되면 표준 등급 IP 주소 및 이와 연결된 리전 부하 분산기를 해제할 수 있습니다. + 여러 부하 분산기가 동일한 백엔드를 가리키도록 할 수 있으므로 백엔드를 변경할 필요는 없습니다. - if !strings.EqualFold(listener.IP, "") { - patchRegionForwardingRule.IPAddress = listener.IP - } + (참고) patch 사용하려던 로직 + if !strings.EqualFold(listener.Protocol, "") { + patchRegionForwardingRule.IPProtocol = listener.Protocol + } - if !strings.EqualFold(listener.Port, "") { - patchRegionForwardingRule.PortRange = listener.Port - } + if !strings.EqualFold(listener.IP, "") { + patchRegionForwardingRule.IPAddress = listener.IP + } - patchRegionForwardingRule.NetworkTier = "STANDARD" - //networkTier : - // . If this field is not specified, it is assumed to be PREMIUM. - // . If IPAddress is specified, this value must be equal to the networkTier of the Address. - // - Region forwording rule : PREMIUM and STANDARD - // - Global forwording rule : PREMIUM only + if !strings.EqualFold(listener.Port, "") { + patchRegionForwardingRule.PortRange = listener.Port + } - nlbHandler.patchRegionForwardingRules(regionID, forwardingRuleName, &patchRegionForwardingRule) + patchRegionForwardingRule.NetworkTier = "STANDARD" + //networkTier : + // . If this field is not specified, it is assumed to be PREMIUM. + // . If IPAddress is specified, this value must be equal to the networkTier of the Address. + // - Region forwording rule : PREMIUM and STANDARD + // - Global forwording rule : PREMIUM only + nlbHandler.patchRegionForwardingRules(regionID, forwardingRuleName, &patchRegionForwardingRule) */ func (nlbHandler *GCPNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.ListenerInfo) (irs.ListenerInfo, error) { @@ -855,8 +853,8 @@ func (nlbHandler *GCPNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.Lis } /* - VM Group 변경에서는 VMs 는 제외임. - GCP의 경우 frontend와 backend를 protocol, ip로 연결하지 않으므로 해당 기능은 제외한다. +VM Group 변경에서는 VMs 는 제외임. +GCP의 경우 frontend와 backend를 protocol, ip로 연결하지 않으므로 해당 기능은 제외한다. */ func (nlbHandler *GCPNLBHandler) ChangeVMGroupInfo(nlbIID irs.IID, vmGroup irs.VMGroupInfo) (irs.VMGroupInfo, error) { @@ -864,9 +862,9 @@ func (nlbHandler *GCPNLBHandler) ChangeVMGroupInfo(nlbIID irs.IID, vmGroup irs.V } /* - targetPool에 vm 추가 - 필요한 parameter는 instanceUrl이며 vmIID.SystemID에서 vm을 조회하여 사용해야 함. - 수정 후 해당 vmGroupInfo(instance 들) return + targetPool에 vm 추가 + 필요한 parameter는 instanceUrl이며 vmIID.SystemID에서 vm을 조회하여 사용해야 함. + 수정 후 해당 vmGroupInfo(instance 들) return */ func (nlbHandler *GCPNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs.VMGroupInfo, error) { // @@ -888,14 +886,14 @@ func (nlbHandler *GCPNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs. callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { callLogInfo.ErrorMSG = err.Error() - callogger.Info(call.String(callLogInfo)) + callogger.Error(call.String(callLogInfo)) cblogger.Error(err) return irs.VMGroupInfo{}, err } targetPool, err := nlbHandler.getTargetPool(regionID, targetPoolName) if err != nil { - cblogger.Info("targetPoolList list: ", err) + cblogger.Error("targetPoolList list: ", err) return irs.VMGroupInfo{}, err } @@ -916,9 +914,9 @@ func (nlbHandler *GCPNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs. } /* - targetPool에 vm 삭제 - 필요한 parameter는 instanceUrl이며 vmIID.SystemID에 들어있음. - 수정 성공여부 return + targetPool에 vm 삭제 + 필요한 parameter는 instanceUrl이며 vmIID.SystemID에 들어있음. + 수정 성공여부 return */ func (nlbHandler *GCPNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (bool, error) { // @@ -973,7 +971,7 @@ func (nlbHandler *GCPNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.Healt callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) cblogger.Error(err) - cblogger.Info("targetPoolList list: ", err) + cblogger.Error("targetPoolList list: ", err) } //vmGroup := extractVmGroup(targetPool) @@ -988,7 +986,7 @@ func (nlbHandler *GCPNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.Healt instanceHealthStatusList, err := nlbHandler.getTargetPoolHealth(regionID, targetPoolName, instanceUrl) if err != nil { - cblogger.Info("targetPool HealthList list: ", err) + cblogger.Error("targetPool HealthList list: ", err) return irs.HealthInfo{}, err } @@ -1018,6 +1016,7 @@ func (nlbHandler *GCPNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.Healt /* // HealthCheckerInfo 변경 + cspId = selfLink healthCheckerName = nbl name @@ -1052,12 +1051,12 @@ func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC targetPool, err := nlbHandler.getTargetPool(regionID, targetPoolName) if err != nil { - cblogger.Info("targetPoolList list: ", err) + cblogger.Error("targetPoolList list: ", err) } returnHealthChecker, err := nlbHandler.extractHealthChecker(regionID, targetPool) if err != nil { - cblogger.Info("get targetpool err ", err) + cblogger.Error("get targetpool err ", err) } return returnHealthChecker, nil } @@ -1160,13 +1159,12 @@ func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC //func (nlbHandler *GCPNLBHandler) listInstanceTemplate(filter string) (*compute.InstanceTemplateList, error) { // projectID := nlbHandler.Credential.ProjectID // -// fmt.Printf(filter) // //if strings.EqualFold(filter, "") { // // req := nlbHandler.Client.InstanceTemplates.List(projectID) // // //req.Filter() // // if err := req.Pages(nlbHandler.Ctx, func(page *compute.InstanceTemplateList) error { // // for _, instanceTemplate := range page.Items { -// // fmt.Printf("%#v\n", instanceTemplate) +// // cblogger.Info("%#v\n", instanceTemplate) // // } // // return nil // // }); err != nil { @@ -1232,7 +1230,6 @@ func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC //func (nlbHandler *GCPNLBHandler) listRegionInstanceGroupManager(regionID string, filter string) (*compute.RegionInstanceGroupManagerList, error) { // projectID := nlbHandler.Credential.ProjectID // -// fmt.Printf(filter) // result, err := nlbHandler.Client.RegionInstanceGroupManagers.List(projectID, regionID).Do() // if err != nil { // return nil, err @@ -1266,7 +1263,7 @@ func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC //func (nlbHandler *GCPNLBHandler) listRegionInstanceGroups(regionID string, filter string) (*compute.RegionInstanceGroupList, error) { // projectID := nlbHandler.Credential.ProjectID // -// fmt.Printf(filter) +// cblogger.Info(filter) // result, err := nlbHandler.Client.RegionInstanceGroups.List(projectID, regionID).Do() // if err != nil { // return nil, err @@ -1284,7 +1281,7 @@ func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC //func (nlbHandler *GCPNLBHandler) listInstancesRegionInstanceGroups(regionID string, regionInstanceGroupName string, reqListInstance compute.RegionInstanceGroupsListInstancesRequest) (*compute.RegionInstanceGroupsListInstances, error) { // projectID := nlbHandler.Credential.ProjectID // -// fmt.Printf(regionInstanceGroupName) +// cblogger.Info(regionInstanceGroupName) // result, err := nlbHandler.Client.RegionInstanceGroups.ListInstances(projectID, regionID, regionInstanceGroupName, &reqListInstance).Do() // if err != nil { // return nil, err @@ -1344,7 +1341,7 @@ func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthC //func (nlbHandler *GCPNLBHandler) listGlobalInstanceGroup(zoneID string, filter string) (*compute.InstanceGroupList, error) { // projectID := nlbHandler.Credential.ProjectID // -// fmt.Printf(filter) +// cblogger.Info(filter) // result, err := nlbHandler.Client.InstanceGroups.List(projectID, zoneID).Do() // if err != nil { // return nil, err @@ -1412,7 +1409,7 @@ func (nlbHandler *GCPNLBHandler) aggregatedListRegionAddresses(filter string) (* return nil, err } for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) } return resp, nil } @@ -1442,7 +1439,7 @@ func (nlbHandler *GCPNLBHandler) listRegionAddresses(regionID string, filter str return nil, err } for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) } return resp, nil } @@ -1518,7 +1515,7 @@ func (nlbHandler *GCPNLBHandler) listGlobalAddresses(filter string) (*compute.Ad return nil, err } for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) } return resp, nil } @@ -1545,7 +1542,7 @@ func (nlbHandler *GCPNLBHandler) insertRegionForwardingRules(regionID string, re return nil } -//deleteRegionForwardingRule +// deleteRegionForwardingRule // 특정 forwarding rule만 삭제 func (nlbHandler *GCPNLBHandler) deleteRegionForwardingRule(regionID string, forwardingRuleName string) error { // path param @@ -1553,13 +1550,13 @@ func (nlbHandler *GCPNLBHandler) deleteRegionForwardingRule(regionID string, for req, err := nlbHandler.Client.ForwardingRules.Delete(projectID, regionID, forwardingRuleName).Do() if err != nil { - cblogger.Info("deleteRegionForwardingRule ", err) + cblogger.Error("deleteRegionForwardingRule ", err) return err } - cblogger.Info("req ", req) + cblogger.Debug("req ", req) err = WaitUntilComplete(nlbHandler.Client, projectID, regionID, req.Name, false) if err != nil { - cblogger.Info("WaitUntilComplete ", err) + cblogger.Error("WaitUntilComplete ", err) return err } return nil @@ -1574,7 +1571,7 @@ func (nlbHandler *GCPNLBHandler) deleteRegionForwardingRules(regionID string, nl forwardingRuleList, err := nlbHandler.listRegionForwardingRules(regionID, String_Empty, targetPoolId) if err != nil { - cblogger.Info("DeleteNLB forwardingRule err: ", err) + cblogger.Error("DeleteNLB forwardingRule err: ", err) return String_Empty, err } deleteCount := 0 @@ -1585,7 +1582,7 @@ func (nlbHandler *GCPNLBHandler) deleteRegionForwardingRules(regionID string, nl for _, forwardingRule := range forwardingRuleList.Items { err := nlbHandler.deleteRegionForwardingRule(regionID, forwardingRule.Name) if err != nil { - cblogger.Info("deleteRegionForwardingRule ", err) + cblogger.Error("deleteRegionForwardingRule ", err) return String_Empty, err } } @@ -1601,7 +1598,7 @@ func (nlbHandler *GCPNLBHandler) patchRegionForwardingRules(regionID string, for req, err := nlbHandler.Client.ForwardingRules.Patch(projectID, regionID, forwardingRuleName, patchRegionForwardingRule).Do() if err != nil { - cblogger.Info("patchRegionForwardingRules ", err) + cblogger.Error("patchRegionForwardingRules ", err) return &compute.ForwardingRule{}, err } @@ -1613,7 +1610,7 @@ func (nlbHandler *GCPNLBHandler) patchRegionForwardingRules(regionID string, for id := req.Id name := req.Name - cblogger.Info("id = ", id, " : name = ", name) + cblogger.Debug("id = ", id, " : name = ", name) forwardingRule, err := nlbHandler.getRegionForwardingRules(regionID, patchRegionForwardingRule.Name) if err != nil { return &compute.ForwardingRule{}, err @@ -1647,7 +1644,7 @@ func (nlbHandler *GCPNLBHandler) listRegionForwardingRules(regionID string, filt resp, err := nlbHandler.Client.ForwardingRules.List(projectID, regionID).Do() if err != nil { - cblogger.Info(err) + cblogger.Error(err) return nil, err } @@ -1663,7 +1660,7 @@ func (nlbHandler *GCPNLBHandler) listRegionForwardingRules(regionID string, filt if strings.EqualFold(itemForwardingRule, forwardingRuleName) { forwardingRuleList = append(forwardingRuleList, item) - cblogger.Info(item) + cblogger.Debug(item) } } responseForwardingRule.Items = forwardingRuleList @@ -1730,7 +1727,7 @@ func (nlbHandler *GCPNLBHandler) listGlobalForwardingRules(filter string) (*comp return nil, err } for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) } return resp, nil @@ -1778,7 +1775,7 @@ func (nlbHandler *GCPNLBHandler) getRegionBackendServices(region string, regionB // for _, item := range resp.Backends { - cblogger.Info(item) + cblogger.Debug(item) //if strings.EqualFold(item.Group, // instance group or network endpoint group(NEG) } //// item.group // instance group or network endpoint group @@ -1800,7 +1797,7 @@ func (nlbHandler *GCPNLBHandler) listRegionBackendServices(region string, filter //cblogger.Info(resp) printToJson(resp) for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) //if strings.EqualFold(item.Group, // instance group or network endpoint group(NEG) } //// item.group // instance group or network endpoint group @@ -1840,7 +1837,7 @@ func (nlbHandler *GCPNLBHandler) insertGlobalBackendServices(reqBackendService c } // Global BackendService 조회 -//func (nlbHandler *GCPNLBHandler) getBackendServices(resourceId string) (*compute.InstanceTemplate, error) { +// func (nlbHandler *GCPNLBHandler) getBackendServices(resourceId string) (*compute.InstanceTemplate, error) { func (nlbHandler *GCPNLBHandler) getGlobalBackendServices(backendServiceName string) (*compute.BackendService, error) { projectID := nlbHandler.Credential.ProjectID @@ -1853,7 +1850,7 @@ func (nlbHandler *GCPNLBHandler) getGlobalBackendServices(backendServiceName str // backServices := resp.Backends for _, item := range backServices { - cblogger.Info(item) + cblogger.Debug(item) //if strings.EqualFold(item.Group, // instance group or network endpoint group(NEG) } @@ -1871,7 +1868,7 @@ func (nlbHandler *GCPNLBHandler) listGlobalBackendServices(filter string) (*comp } for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) //if strings.EqualFold(item.Group, // instance group or network endpoint group(NEG) } //// item.group // instance group or network endpoint group @@ -2057,7 +2054,7 @@ func (nlbHandler *GCPNLBHandler) listHttpHealthChecks(filter string) (*compute.H } for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) } return resp, nil @@ -2123,7 +2120,7 @@ func (nlbHandler *GCPNLBHandler) listTargetPools(regionID string, filter string) } printToJson(resp) for _, item := range resp.Items { - cblogger.Info(item) + cblogger.Debug(item) } return resp, nil @@ -2133,12 +2130,12 @@ func (nlbHandler *GCPNLBHandler) listTargetPools(regionID string, filter string) /* getHealth : Instance의 가장 최근의 health check result + // instanceReference 는 instarce의 url을 인자로 갖는다. // targetPools.get(targetPoolName) 을 통해 instalces[]을 알 수 있음. 배열에서 하나씩 꺼내서 instanceReference에 넣고 사용. // Target pools are used for network TCP/UDP load balancing. A target pool references member instances, an associated legacy HttpHealthCheck resource, and, optionally, a backup target poo //https://www.googleapis.com/compute/v1/projects/myproject/zones/zoneName/instances/lbname - */ func (nlbHandler *GCPNLBHandler) getTargetPoolHealth(regionID string, targetPoolName string, instanceUrl string) (*compute.TargetPoolInstanceHealth, error) { @@ -2157,10 +2154,10 @@ func (nlbHandler *GCPNLBHandler) getTargetPoolHealth(regionID string, targetPool } /* - health checker 생성 - targetPoolName = health checker name - health checker는 독립적임. HttpHealthChecks의 insert - TimeoutSec should be less than checkIntervalSec +health checker 생성 +targetPoolName = health checker name +health checker는 독립적임. HttpHealthChecks의 insert +TimeoutSec should be less than checkIntervalSec */ func (nlbHandler *GCPNLBHandler) insertHealthCheck(regionID string, targetPoolName string, healthCheckerInfo *irs.HealthCheckerInfo) error { // path param @@ -2202,6 +2199,7 @@ func (nlbHandler *GCPNLBHandler) insertHealthCheck(regionID string, targetPoolNa 등록된 healthchecker 수정 health checker는 독립적임. HttpHealthChecks의 patch patch 가 맞는지, update 가 맞는지 확인 필요 + Updates a HttpHealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. @@ -2260,10 +2258,10 @@ func (nlbHandler *GCPNLBHandler) patchHealthCheck(regionID string, targetPoolNam } /* - 등록된 healthchecker 삭제 - health checker는 독립적임. +등록된 healthchecker 삭제 +health checker는 독립적임. - health checker Url 이 있으면 해당값이 제일 정확하므로 url에서 이름을 추충하여 사용 +health checker Url 이 있으면 해당값이 제일 정확하므로 url에서 이름을 추충하여 사용 */ func (nlbHandler *GCPNLBHandler) removeHttpHealthCheck(targetPoolName string, healthCheckUrl string) error { // path param @@ -2274,7 +2272,7 @@ func (nlbHandler *GCPNLBHandler) removeHttpHealthCheck(targetPoolName string, he // TargetPool이 없으면 targetPool이름으로 삭제 시도 targetPool, err := nlbHandler.getTargetPool(regionID, targetPoolName) if err != nil { - cblogger.Info("targetPoolList list for removeHttpHealthCheck: ", err) + cblogger.Error("targetPoolList list for removeHttpHealthCheck: ", err) } // queryParam @@ -2289,12 +2287,12 @@ func (nlbHandler *GCPNLBHandler) removeHttpHealthCheck(targetPoolName string, he cblogger.Info("removeHttpHealthCheck by targetPool ", healthCheckerName) req, err := nlbHandler.Client.HttpHealthChecks.Delete(projectID, healthCheckerName).Do() if err != nil { - cblogger.Info("HttpHealthChecks.Delete : ", err) + cblogger.Error("HttpHealthChecks.Delete : ", err) return err } err = WaitUntilComplete(nlbHandler.Client, projectID, String_Empty, req.Name, true) if err != nil { - cblogger.Info("HttpHealthChecks.Delete WaitUntilComplete : ", err) + cblogger.Error("HttpHealthChecks.Delete WaitUntilComplete : ", err) return err } } @@ -2302,12 +2300,12 @@ func (nlbHandler *GCPNLBHandler) removeHttpHealthCheck(targetPoolName string, he cblogger.Info("removeHttpHealthCheck by ", healthCheckerName) req, err := nlbHandler.Client.HttpHealthChecks.Delete(projectID, healthCheckerName).Do() if err != nil { - cblogger.Info("2HttpHealthChecks.Delete : ", err) + cblogger.Error("2HttpHealthChecks.Delete : ", err) return err } err = WaitUntilComplete(nlbHandler.Client, projectID, String_Empty, req.Name, true) if err != nil { - cblogger.Info("HttpHealthChecks.Delete WaitUntilComplete : ", err) + cblogger.Error("HttpHealthChecks.Delete WaitUntilComplete : ", err) return err } } @@ -2347,9 +2345,9 @@ func (nlbHandler *GCPNLBHandler) addTargetPoolHealthCheck(regionID string, targe } /* - TargetPool에 등록되어 있는 health checker 제거(링크만 제거) - TargetPool에 healthChecker는 없을 수도 있음. 없어도 오류가 아님. - 실제 healthCheck는 살아있음. httpHealthCheck 제거는 nlbHandler.removeHealthCheck + TargetPool에 등록되어 있는 health checker 제거(링크만 제거) + TargetPool에 healthChecker는 없을 수도 있음. 없어도 오류가 아님. + 실제 healthCheck는 살아있음. httpHealthCheck 제거는 nlbHandler.removeHealthCheck */ func (nlbHandler *GCPNLBHandler) removeTargetPoolHealthCheck(regionID string, targetPoolName string, healthCheckerName string) error { // path param @@ -2376,6 +2374,7 @@ func (nlbHandler *GCPNLBHandler) removeTargetPoolHealthCheck(regionID string, ta /* // TargetPool 에 Instance bind추가 + parameter instance = The URL for a specific instance // Target pools are used for network TCP/UDP load balancing. A target pool references member instances, an associated legacy HttpHealthCheck resource, and, optionally, a backup target poo @@ -2420,8 +2419,8 @@ func (nlbHandler *GCPNLBHandler) addTargetPoolInstance(regionID string, targetPo } /* - TargetPool에서 instance bind 삭제 - parameter instance = The URL for a specific instance +TargetPool에서 instance bind 삭제 +parameter instance = The URL for a specific instance */ func (nlbHandler *GCPNLBHandler) removeTargetPoolInstances(regionID string, targetPoolName string, deleteInstanceIIDs *[]irs.IID) error { // path param @@ -2519,36 +2518,36 @@ func (nlbHandler *GCPNLBHandler) removeTargetPool(regionID string, targetPoolNam func printToJson(class interface{}) { e, err := json.Marshal(class) if err != nil { - cblogger.Info(err) + cblogger.Error(err) } cblogger.Info(string(e)) } /* // lister 정보를 gcp의 forwardingRule에 맞게 변경 - ipProtocol // TCP, UDP, ESP, AH, SCTP, ICMP and L3_DEFAULT - allPorts : ports/portRange/allPorts 세가지 중 1가지만 사용가능 - - TCP, UDP and SCTP traffic, packets addressed to any ports will be forwarded to the target or backendService. - portRange - - load balancing scheme 가 EXTERNAL, INTERNAL_SELF_MANAGED or INTERNAL_MANAGED 일 때, - - IPProtocol 가 TCP, UDP or SCTP 일 떄 사용가능 - - targetPool이나 backendService로 전달 - ports[] : backendService로 직접전달 시 사용 - allowGlobalAccess : - - If the field is set to TRUE, clients can access ILB from all regions. - - Otherwise only allows access from clients in the same region as the internal load balancer. - - target - subnetwork : custom mode 또는 ipv6로 external forwarding rule 생성 시 필요 - network : external load balancing 에서 사용 안함. - networkTier : - . If this field is not specified, it is assumed to be PREMIUM. - . If IPAddress is specified, this value must be equal to the networkTier of the Address. - - Region forwording rule : PREMIUM and STANDARD - - Global forwording rule : PREMIUM only - backendService : Required for Internal TCP/UDP Load Balancing and Network Load Balancing; must be omitted for all other load balancer types. - ipVersion : IPV4 or IPV6. This can only be specified for an external global forwarding rule. + ipProtocol // TCP, UDP, ESP, AH, SCTP, ICMP and L3_DEFAULT + allPorts : ports/portRange/allPorts 세가지 중 1가지만 사용가능 + - TCP, UDP and SCTP traffic, packets addressed to any ports will be forwarded to the target or backendService. + portRange + - load balancing scheme 가 EXTERNAL, INTERNAL_SELF_MANAGED or INTERNAL_MANAGED 일 때, + - IPProtocol 가 TCP, UDP or SCTP 일 떄 사용가능 + - targetPool이나 backendService로 전달 + ports[] : backendService로 직접전달 시 사용 + allowGlobalAccess : + - If the field is set to TRUE, clients can access ILB from all regions. + - Otherwise only allows access from clients in the same region as the internal load balancer. + + target + subnetwork : custom mode 또는 ipv6로 external forwarding rule 생성 시 필요 + network : external load balancing 에서 사용 안함. + networkTier : + . If this field is not specified, it is assumed to be PREMIUM. + . If IPAddress is specified, this value must be equal to the networkTier of the Address. + - Region forwording rule : PREMIUM and STANDARD + - Global forwording rule : PREMIUM only + backendService : Required for Internal TCP/UDP Load Balancing and Network Load Balancing; must be omitted for all other load balancer types. + ipVersion : IPV4 or IPV6. This can only be specified for an external global forwarding rule. */ func convertNlbInfoToForwardingRule(nlbListener irs.ListenerInfo, targetPool *compute.TargetPool) compute.ForwardingRule { //ipProtocol // TCP, UDP, ESP, AH, SCTP, ICMP and L3_DEFAULT @@ -2591,22 +2590,23 @@ func convertNlbInfoToForwardingRule(nlbListener irs.ListenerInfo, targetPool *co /* // - NLB 생성을 위해 요청받은 nlbInfo 정보를 gcp의 TargetPool에 맞게 변경 - FailoverRatio : 설정 시 backupPool도 설정해야 함. - vmID 는 url형태가 아니므로 vm을 조회하여 selflink를 set - Instances[] : resource URLs - HealthChecks[] : resource URLs - - vmGroup = TargetPool - vmGroup.cspId = targetPoolName, lbName - - ex) - //"healthChecks":[ - // "https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/test-lb-seoul-healthchecker" - // ], - //"instances":[ - // "https://www.googleapis.com/compute/v1/projects/myproject/zones/asia-northeast3-a/instances/test-lb-seoul-01" - // ] + + NLB 생성을 위해 요청받은 nlbInfo 정보를 gcp의 TargetPool에 맞게 변경 + FailoverRatio : 설정 시 backupPool도 설정해야 함. + vmID 는 url형태가 아니므로 vm을 조회하여 selflink를 set + Instances[] : resource URLs + HealthChecks[] : resource URLs + + vmGroup = TargetPool + vmGroup.cspId = targetPoolName, lbName + + ex) + //"healthChecks":[ + // "https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/test-lb-seoul-healthchecker" + // ], + //"instances":[ + // "https://www.googleapis.com/compute/v1/projects/myproject/zones/asia-northeast3-a/instances/test-lb-seoul-01" + // ] */ func (nlbHandler *GCPNLBHandler) convertNlbInfoToTargetPool(nlbInfo *irs.NLBInfo) (compute.TargetPool, error) { vmList := nlbInfo.VMGroup.VMs @@ -2642,9 +2642,9 @@ func (nlbHandler *GCPNLBHandler) convertNlbInfoToTargetPool(nlbInfo *irs.NLBInfo } /* - 가져온 TargetPool정보를 Spider 의 NLBInfo로 변환 - extractVmGroup 은 추출만 하면 됨. - extractHealthChecker는 health checker 정보를 조회해야 하므로 nlbHandler 필요 +가져온 TargetPool정보를 Spider 의 NLBInfo로 변환 +extractVmGroup 은 추출만 하면 됨. +extractHealthChecker는 health checker 정보를 조회해야 하므로 nlbHandler 필요 */ func (nlbHandler *GCPNLBHandler) convertTargetPoolToNLBInfo(targetPool *compute.TargetPool, nlbInfo *irs.NLBInfo) error { regionID := nlbHandler.Region.Region @@ -2678,7 +2678,7 @@ func (nlbHandler *GCPNLBHandler) convertTargetPoolToNLBInfo(targetPool *compute. } /* - forwarding rule의 Port가 Range 이나 Spider에서는 1개만 사용하므로 첫번째 값만 사용 +forwarding rule의 Port가 Range 이나 Spider에서는 1개만 사용하므로 첫번째 값만 사용 */ func convertRegionForwardingRuleToNlbListener(forwardingRule *compute.ForwardingRule) irs.ListenerInfo { portRange := forwardingRule.PortRange @@ -2720,7 +2720,7 @@ func (nlbHandler *GCPNLBHandler) getListenerByNlbSystemID(nlbIID irs.IID) (irs.L regionForwardingRule, err := nlbHandler.getRegionForwardingRules(regionID, nlbID) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { - cblogger.Info("regionForwardingRule list: ", err) + cblogger.Error("regionForwardingRule list: ", err) callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) cblogger.Error(err) @@ -2747,6 +2747,7 @@ func (nlbHandler *GCPNLBHandler) getListenerByNlbSystemID(nlbIID irs.IID) (irs.L /* // TargetPool = backend = vmGroup 이며 + 가져온 targetPool을 spider에서 사용하는 vmGroup으로 변환하여 return ex) vmGroup @@ -2788,7 +2789,7 @@ func extractVmGroup(targetPool *compute.TargetPool, nlbInfo *irs.NLBInfo) irs.VM } /* - targetPool에서 healthcheker를 가져와서 spider의 HealthCheckerInfo 로 return +targetPool에서 healthcheker를 가져와서 spider의 HealthCheckerInfo 로 return */ func (nlbHandler *GCPNLBHandler) extractHealthChecker(regionID string, targetPool *compute.TargetPool) (irs.HealthCheckerInfo, error) { returnHealthChecker := irs.HealthCheckerInfo{} @@ -2812,7 +2813,7 @@ func (nlbHandler *GCPNLBHandler) extractHealthChecker(regionID string, targetPoo targetHealthCheckerInfo, err := nlbHandler.getHttpHealthChecks(targetHealthCheckerValue) //targetHealthCheckerInfo, err := nlbHandler.getHttpHealthChecks(targetPoolName) // healthchecker는 전역 if err != nil { - cblogger.Info("targetHealthCheckerInfo : ", err) + cblogger.Error("targetHealthCheckerInfo : ", err) return returnHealthChecker, err } if targetHealthCheckerInfo != nil { @@ -2834,8 +2835,8 @@ func (nlbHandler *GCPNLBHandler) extractHealthChecker(regionID string, targetPoo } /* - vpc를 가져오기 위해 vm 정보를 조회. - zone은 다를 수 있으므로 VMHandler의 GetVM을 사용하지 않고 zone을 parameter로 받는 function을 따로 만듬 +vpc를 가져오기 위해 vm 정보를 조회. +zone은 다를 수 있으므로 VMHandler의 GetVM을 사용하지 않고 zone을 parameter로 받는 function을 따로 만듬 */ func (nlbHandler *GCPNLBHandler) getVPCInfoFromVM(zoneID string, vmID irs.IID) (irs.IID, error) { projectID := nlbHandler.Credential.ProjectID @@ -2861,7 +2862,6 @@ func (nlbHandler *GCPNLBHandler) getVPCInfoFromVM(zoneID string, vmID irs.IID) ( return irs.IID{}, err } //callogger.Info(call.String(callLogInfo)) - //spew.Dump(vm) ////Network: (string) (len=87) "https://www.googleapis.com/compute/v1/projects/[projectID]/global/networks/[vpcName]", ////NetworkIP: (string) (len=8) "10.0.0.6", @@ -2886,8 +2886,8 @@ func (nlbHandler *GCPNLBHandler) getVPCInfoFromVM(zoneID string, vmID irs.IID) ( } /* - vm의 url 조회 - zone은 다를 수 있으므로 VMHandler의 GetVM을 사용하지 않고 zone을 parameter로 받는 function을 따로 만듬 +vm의 url 조회 +zone은 다를 수 있으므로 VMHandler의 GetVM을 사용하지 않고 zone을 parameter로 받는 function을 따로 만듬 */ func (nlbHandler *GCPNLBHandler) getVmUrl(zoneID string, vmID irs.IID) (string, error) { projectID := nlbHandler.Credential.ProjectID @@ -2913,18 +2913,21 @@ func (nlbHandler *GCPNLBHandler) getVmUrl(zoneID string, vmID irs.IID) (string, return "", err } callogger.Info(call.String(callLogInfo)) - spew.Dump(vm) + if cblogger.Level.String() == "debug" { + cblogger.Debug(vm) + } return vm.SelfLink, nil } /* // CreateNLB validation check + nlb이름이 같은 resource가 있는지 check */ func (nlbHandler *GCPNLBHandler) validateCreateNLB(nlbReqInfo irs.NLBInfo) error { //// validation check area - cblogger.Info("validateCreateNLB") + cblogger.Debug("validateCreateNLB") regionID := nlbHandler.Region.Region nlbName := nlbReqInfo.IId.NameId @@ -2934,7 +2937,7 @@ func (nlbHandler *GCPNLBHandler) validateCreateNLB(nlbReqInfo irs.NLBInfo) error if err != nil { is404, checkErr := checkErrorCode(ErrorCode_NotFound, err) // 404 : not found면 pass if !is404 || !checkErr { // 하나라도 false 면 error return - cblogger.Info("existsTargetPoolChecks : ", err) + cblogger.Error("existsTargetPoolChecks : ", err) return err } @@ -2948,7 +2951,7 @@ func (nlbHandler *GCPNLBHandler) validateCreateNLB(nlbReqInfo irs.NLBInfo) error if err != nil { is404, checkErr := checkErrorCode(ErrorCode_NotFound, err) // 404 : not found면 pass if !is404 || !checkErr { // 하나라도 false 면 error return - cblogger.Info("existsHealthChecks : ", err) + cblogger.Error("existsHealthChecks : ", err) return err } } else { @@ -2961,7 +2964,7 @@ func (nlbHandler *GCPNLBHandler) validateCreateNLB(nlbReqInfo irs.NLBInfo) error if err != nil { is404, checkErr := checkErrorCode(ErrorCode_NotFound, err) // 404 : not found면 pass if !is404 || !checkErr { // 하나라도 false 면 error return - cblogger.Info("existsListener : ", err) + cblogger.Error("existsListener : ", err) return err } } else { @@ -2987,6 +2990,7 @@ func (nlbHandler *GCPNLBHandler) validateCreateNLB(nlbReqInfo irs.NLBInfo) error /* // DeleteNLB validation check + 체크하면서 validation이 실패하면 errors.New("message ")로 map에 추가 삭제 전 대상 resource가 없는지 checkeck. 셋 다 있으면 OK. @@ -2998,7 +3002,7 @@ func (nlbHandler *GCPNLBHandler) validateDeleteNLB(nlbIID irs.IID) (map[string]e validationMap := make(map[string]error) - cblogger.Info("validateDeleteNLB") + cblogger.Debug("validateDeleteNLB") regionID := nlbHandler.Region.Region nlbName := nlbIID.NameId @@ -3042,7 +3046,7 @@ func (nlbHandler *GCPNLBHandler) validateDeleteNLB(nlbIID irs.IID) (map[string]e //} //for key, errResult := range validationMap { - // fmt.Println(key, errResult) + // cblogger.Info(key, errResult) // if errResult != nil { // if strings.EqualFold(NLB_Component_TARGETPOOL, key){ // @@ -3060,41 +3064,41 @@ func (nlbHandler *GCPNLBHandler) validateDeleteNLB(nlbIID irs.IID) (map[string]e countMap := 0 count404 := 0 for validKey, validErr := range validationMap { - cblogger.Info("validMap "+validKey, validErr) + cblogger.Debug("validMap "+validKey, validErr) isValidCode, isValidErrorFormat := checkErrorCode(ErrorCode_NotFound, validErr) - cblogger.Info("validMap isValidCode ", isValidCode, isValidErrorFormat) + cblogger.Debug("validMap isValidCode ", isValidCode, isValidErrorFormat) if isValidCode && isValidErrorFormat { count404++ } countMap++ } - cblogger.Info(countMap, count404) + cblogger.Debug(countMap, count404) if countMap == count404 { - cblogger.Info("all not found : ") + cblogger.Error("all not found : ") return nil, nil } return validationMap, nil } /* - GCP의 Error는 String이기 때문에 안에 있는 Code, Message를 겍체로 변환한 후 비교하는 function - 예상하는 ErrorCode면 true, 아니면 false - return param1 : 같은지 비교 - return param2 : Error 변환 에러 여부 +GCP의 Error는 String이기 때문에 안에 있는 Code, Message를 겍체로 변환한 후 비교하는 function +예상하는 ErrorCode면 true, 아니면 false +return param1 : 같은지 비교 +return param2 : Error 변환 에러 여부 - if err != nil { - if ee, ok := err.(*googleapi.Error); ok { - fmt.Printf("Error Code %v", ee.Code) - fmt.Printf("Error Message %v", ee.Message) - fmt.Printf("Error Details %v", ee.Details) - fmt.Printf("Error Body %v", ee.Body) - } - } + if err != nil { + if ee, ok := err.(*googleapi.Error); ok { + cblogger.Debug("Error Code %v", ee.Code) + cblogger.Debug("Error Message %v", ee.Message) + cblogger.Debug("Error Details %v", ee.Details) + cblogger.Debug("Error Body %v", ee.Body) + } + } - return 결과 : 비교결과, 비교성공 여부. 비교성공여부가 false면 error자체가 GCP의 에러가 아님. - 같으면 true, true - 다르면 false, true - 예외면 false, false +return 결과 : 비교결과, 비교성공 여부. 비교성공여부가 false면 error자체가 GCP의 에러가 아님. +같으면 true, true +다르면 false, true +예외면 false, false */ func checkErrorCode(expectErrorCode int, err error) (bool, bool) { var errorCode int @@ -3102,11 +3106,11 @@ func checkErrorCode(expectErrorCode int, err error) (bool, bool) { //var errorMessage string errorDetail, ok := err.(*googleapi.Error) // casting이 정상이면 ok=true, 비정상이면 ok=false - fmt.Printf("errorDetail", errorDetail) - fmt.Printf("ok", ok) + cblogger.Error("errorDetail", errorDetail) + cblogger.Error("ok", ok) if ok { - fmt.Printf("Error Code %v", errorDetail.Code) - fmt.Printf("Error Message %v", errorDetail.Message) + cblogger.Error("Error Code %v", errorDetail.Code) + cblogger.Error("Error Message %v", errorDetail.Message) errorCode = errorDetail.Code //errorMessage = errorDetail.Message } @@ -3115,15 +3119,15 @@ func checkErrorCode(expectErrorCode int, err error) (bool, bool) { } /* - 에러 발생 시 자원 회수(삭제)용 - map에 해당 자원의 경로가 들어 있음. - healthChecker = url - targetPool = url - - 오류 메시지 예시 - (1) XXX deleted - (2) YYY deleted - (3) ~~~~~ error.... (= CSP 반환 메시지) +에러 발생 시 자원 회수(삭제)용 +map에 해당 자원의 경로가 들어 있음. +healthChecker = url +targetPool = url + +오류 메시지 예시 +(1) XXX deleted +(2) YYY deleted +(3) ~~~~~ error.... (= CSP 반환 메시지) */ func (nlbHandler *GCPNLBHandler) rollbackCreatedNlbResources(regionID string, resourceMap map[string]string) string { rollbackResult := String_Empty @@ -3136,7 +3140,7 @@ func (nlbHandler *GCPNLBHandler) rollbackCreatedNlbResources(regionID string, re err := nlbHandler.removeHttpHealthCheck(healthCheckerName, healthCheckerUrl) if err != nil { - cblogger.Info("rollbackCreatedNlbResources removeHealthCheck err: ", err) + cblogger.Error("rollbackCreatedNlbResources removeHealthCheck err: ", err) rollbackResult = "(1) HealthChecker delete error : " + err.Error() //return false, err } else { @@ -3151,7 +3155,7 @@ func (nlbHandler *GCPNLBHandler) rollbackCreatedNlbResources(regionID string, re targetPoolName := targetPoolUrl[(targetPoolIndex + 1):] err := nlbHandler.removeTargetPool(regionID, targetPoolName) if err != nil { - cblogger.Info("rollbackCreatedNlbResources removeTargetPool err: ", err) + cblogger.Error("rollbackCreatedNlbResources removeTargetPool err: ", err) cblogger.Error(err) rollbackResult = "(2) Targetpool delete error : " + err.Error() //return false, err diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/SecurityHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/SecurityHandler.go index 3820f7600..aafee85c3 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/SecurityHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/SecurityHandler.go @@ -14,7 +14,6 @@ package resources import ( "context" "errors" - "fmt" "strconv" "strings" "time" @@ -22,7 +21,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" compute "google.golang.org/api/compute/v1" ) @@ -88,7 +86,6 @@ const ( // } // // vNetInfo, errVnet := vNetworkHandler.GetVPC(securityReqInfo.VpcIID) -// spew.Dump(vNetInfo) // if errVnet != nil { // cblogger.Error(errVnet) // return irs.SecurityInfo{}, errVnet @@ -203,7 +200,6 @@ const ( // // cblogger.Info("생성할 방화벽 정책") // cblogger.Debug(fireWall) -// //spew.Dump(fireWall) // // // logger for HisCall // callogger := call.GetLogger("HISCALL") @@ -227,7 +223,7 @@ const ( // return irs.SecurityInfo{}, err // } // callogger.Info(call.String(callLogInfo)) -// fmt.Println("create result : ", res) +// cblogger.Debug("create result : ", res) // time.Sleep(time.Second * 3) // //secInfo, _ := securityHandler.GetSecurity(securityReqInfo.IId) // secInfo, _ := securityHandler.GetSecurity(irs.IID{SystemId: securityReqInfo.IId.NameId}) @@ -236,14 +232,15 @@ const ( // securityGroup = GCP 의 Tag /* - SecurityGroup 생성. GCP는 firewall 추가 시 tag = securityGroupName - .GCP 기본 정책이 outbound에 대해 all allow이므로 - - 우선순위가 가장 낮은(65535) all deny outbound rule 추가 - - 우선순위 = 100 인 all allow outbound rule 추가 - .사용자의 요청에서 outbound all open 이 있는 경우. default로 생성하므로 skip +SecurityGroup 생성. GCP는 firewall 추가 시 tag = securityGroupName +.GCP 기본 정책이 outbound에 대해 all allow이므로 + - 우선순위가 가장 낮은(65535) all deny outbound rule 추가 + - 우선순위 = 100 인 all allow outbound rule 추가 + +.사용자의 요청에서 outbound all open 이 있는 경우. default로 생성하므로 skip */ func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error) { - cblogger.Info(securityReqInfo) + cblogger.Debug(securityReqInfo) var addFilewallList []compute.Firewall // 추가할 firewall 목록 var errorFirewallList []string // 에러발생시 error 항목을 담을 목록 @@ -256,7 +253,9 @@ func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.Se } vNetInfo, errVnet := vNetworkHandler.GetVPC(securityReqInfo.VpcIID) - spew.Dump(vNetInfo) + if cblogger.Level.String() == "debug" { + cblogger.Debug(vNetInfo) + } if errVnet != nil { cblogger.Error(errVnet) return irs.SecurityInfo{}, errVnet @@ -274,7 +273,7 @@ func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.Se reqEgressCount := 1 reqIngressCount := 1 - cblogger.Info("기본outbound deny 추가") + cblogger.Debug("Add default outbound deny.") _, err := securityHandler.insertDefaultOutboundPolicy(projectID, securityReqInfo.VpcIID.SystemId, securityReqInfo.IId.NameId, reqEgressCount) if err != nil { @@ -294,7 +293,7 @@ func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.Se //} //cblogger.Debug(defaultOutboundDenyFireWall) - cblogger.Info("기본outbound allow 추가") + cblogger.Debug("Add default outbound allow.") reqEgressCount++ // count 증가 defaultOutboundAllowSecurityRuleInfo := irs.SecurityRuleInfo{ @@ -332,11 +331,11 @@ func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.Se //IPProtocol: "all", //Direction: "outbound", //CIDR: "0.0.0.0/0", - //fmt.Println("default firewallFromPort : ", firewallFromPort) - //fmt.Println("default firewallToPort : ", firewallToPort) - //fmt.Println("default firewallIPProtocol : ", firewallIPProtocol) - //fmt.Println("default firewallDirection : ", firewallDirection) - //fmt.Println("default firewallCIDR : ", firewallCIDR) + //cblogger.Debug("default firewallFromPort : ", firewallFromPort) + //cblogger.Debug("default firewallToPort : ", firewallToPort) + //cblogger.Debug("default firewallIPProtocol : ", firewallIPProtocol) + //cblogger.Debug("default firewallDirection : ", firewallDirection) + //cblogger.Debug("default firewallCIDR : ", firewallCIDR) // outbound all open는 생성시 자동으로 추가하므로 사용자 요청이 있으면 skip한다. if strings.EqualFold(firewallFromPort, "-1") && strings.EqualFold(firewallToPort, "-1") && strings.EqualFold(firewallIPProtocol, "all") && strings.EqualFold(firewallDirection, Const_GCP_Direction_EGRESS) && strings.EqualFold(firewallCIDR, "0.0.0.0/0") { @@ -364,10 +363,11 @@ func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.Se continue } - cblogger.Info("생성할 방화벽 정책 ", itemIndex, firewallDirection, reqEgressCount, reqIngressCount) + cblogger.Info("Firewall policy to be created.", itemIndex, firewallDirection, reqEgressCount, reqIngressCount) cblogger.Debug(fireWall) - //spew.Dump(fireWall) - + if cblogger.Level.String() == "debug" { + cblogger.Debug(fireWall) + } addFilewallList = append(addFilewallList, fireWall) } @@ -395,7 +395,7 @@ func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.Se //return irs.SecurityInfo{}, nil } -//func getOperationsStatus(securityHandler GCPSecurityHandler, projectID string, operationName string, operationType string) { +// func getOperationsStatus(securityHandler GCPSecurityHandler, projectID string, operationName string, operationType string) { func (securityHandler GCPSecurityHandler) getOperationsStatus(ch chan string, projectID string, operationName string, operationType string) { // global : firewall // region : vpc @@ -403,10 +403,11 @@ func (securityHandler GCPSecurityHandler) getOperationsStatus(ch chan string, pr errWait := securityHandler.WaitUntilComplete(operationName) if errWait != nil { - cblogger.Errorf("SecurityGroup create 완료 대기 실패") + cblogger.Errorf("Waiting for SecurityGroup creation completion failed.") cblogger.Error(errWait) } - fmt.Println("getOperationsStatus ", operationName) + + cblogger.Info("getOperationsStatus ", operationName) ch <- operationName //waitGroup.Done() } @@ -473,7 +474,7 @@ func setNewFirewall(ruleInfo irs.SecurityRuleInfo, projectID string, vpcSystemId // firewallDirection = "INGRESS" // //} else if strings.EqualFold(firewallType, "-o-") { - // fmt.Println("create sequence : ", sequence, strconv.Itoa(sequence)) + // cblogger.Info("create sequence : ", sequence, strconv.Itoa(sequence)) // sequenceStr := lpad(strconv.Itoa(sequence), "0", 3) // firewallName = securityGroupName + "-o-" + sequenceStr // firewallDirection = "EGRESS" @@ -500,7 +501,7 @@ func setNewFirewall(ruleInfo irs.SecurityRuleInfo, projectID string, vpcSystemId fireWall.DestinationRanges = []string{cidr} } - fmt.Println("firewallset : ", fireWall) + cblogger.Info("firewallset : ", fireWall) return fireWall, nil } @@ -609,7 +610,7 @@ func (securityHandler *GCPSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, } securityInfoList = append(securityInfoList, &securityInfo) } - fmt.Println("securityInfoList = ", securityInfoList) + cblogger.Info("securityInfoList = ", securityInfoList) return securityInfoList, nil } @@ -656,7 +657,7 @@ func (securityHandler *GCPSecurityHandler) GetSecurity(securityIID irs.IID) (irs } } - fmt.Println("securityInfo : ", securityInfo) + cblogger.Info("securityInfo : ", securityInfo) return securityInfo, nil } @@ -751,7 +752,7 @@ func (securityHandler *GCPSecurityHandler) DeleteSecurity(securityIID irs.IID) ( securityGroupTag := securityIID.SystemId //var vpcIID irs.IID - fmt.Println("Delete Security ", securityGroupTag) + cblogger.Info("Delete Security ", securityGroupTag) // 해당 Tag를 가진 목록 조회 firewallList, err := securityHandler.firewallList(securityGroupTag) if err != nil { @@ -759,7 +760,7 @@ func (securityHandler *GCPSecurityHandler) DeleteSecurity(securityIID irs.IID) ( return false, err } - fmt.Println("Delete Security 삭제 대상 ", len(firewallList)) + cblogger.Info("Deleting target SecurityGroup.", len(firewallList)) for index, firewallInfo := range firewallList { //if index == 0 { // tempSecurityInfo, err := convertFromFirewallToSecurityInfo(firewallInfo) // securityInfo로 변환. securityInfo에 이름이 있어서 해당 이름 사용 @@ -769,7 +770,7 @@ func (securityHandler *GCPSecurityHandler) DeleteSecurity(securityIID irs.IID) ( // } // vpcIID = tempSecurityInfo.VpcIID //} - fmt.Println("Delete Security 삭제 대상item ", len(firewallInfo.Items), " index = ", index) + cblogger.Info("Deleting target SecurityGroup item.", len(firewallInfo.Items), " index = ", index) securityHandler.firewallDelete(securityGroupTag, "", firewallInfo) if err != nil { //500 convert Error @@ -788,7 +789,7 @@ func (securityHandler *GCPSecurityHandler) DeleteSecurity(securityIID irs.IID) ( // GCP의 outbound는 ALL Allow 이기 때문에 ALL Deny rule 추가. 우선순위=65535로 낮게. func (securityHandler *GCPSecurityHandler) insertDefaultOutboundPolicy(projectID string, vpcID string, securityID string, egressCount int) (bool, error) { - cblogger.Info("기본outbound ") + cblogger.Info("Default outbound ") defaultOutboundDenySecurityRuleInfo := irs.SecurityRuleInfo{ FromPort: "", // 지정하지 않으면 전체임. IPProtocol: "ALL", @@ -833,12 +834,12 @@ func (securityHandler *GCPSecurityHandler) insertDefaultOutboundPolicy(projectID // return false, err // } // callogger.Info(call.String(callLogInfo)) -// fmt.Println(res) +// // return true, nil //} func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules *[]irs.SecurityRuleInfo) (irs.SecurityInfo, error) { - cblogger.Info(*securityRules) + cblogger.Debug(*securityRules) projectID := securityHandler.Credential.ProjectID securityGroupTag := sgIID.SystemId @@ -924,7 +925,7 @@ func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules reqEgressCount++ } else { // direction 이 없는데.... continue - fmt.Println("no direction : ", firewallDirection) + cblogger.Info("no direction : ", firewallDirection) errorFirewallList = append(errorFirewallList, "there is no direction ") continue } @@ -945,7 +946,7 @@ func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules } // All Deny Outboun가 없으면 추가한다. - fmt.Println("existsAllDenyOutbound ----------------- ", existsAllDenyOutbound) + cblogger.Info("existsAllDenyOutbound ----------------- ", existsAllDenyOutbound) if !existsAllDenyOutbound { cblogger.Info("default outbound all deny does not exist, create one") maxEgessCount := maxFirewallSequence(firewallList, Const_GCP_Direction_EGRESS) @@ -1081,7 +1082,6 @@ func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules // // cblogger.Info("생성할 방화벽 정책") // cblogger.Debug(fireWall) -// //spew.Dump(fireWall) // // // logger for HisCall // callogger := call.GetLogger("HISCALL") @@ -1105,7 +1105,6 @@ func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules // return irs.SecurityInfo{}, err // } // callogger.Info(call.String(callLogInfo)) -// fmt.Println("create result : ", res) // time.Sleep(time.Second * 3) // //secInfo, _ := securityHandler.GetSecurity(securityReqInfo.IId) // secInfo, _ := securityHandler.GetSecurity(irs.IID{SystemId: sgIID.SystemId}) @@ -1116,7 +1115,7 @@ func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules // 요청받은 Security 그룹안의 SecurityRule이 동일한 firewall 삭제 // 추가가 allow만 가능 하므로 삭제도 allow만 가능 func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRules *[]irs.SecurityRuleInfo) (bool, error) { - cblogger.Info(*securityRules) + cblogger.Debug(*securityRules) projectID := securityHandler.Credential.ProjectID securityGroupTag := sgIID.SystemId @@ -1190,7 +1189,7 @@ func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRu } for _, firewallRule := range item.Allowed { - fmt.Println("firewallRule : ", firewallRule) + cblogger.Info("firewallRule : ", firewallRule) if ports := firewallRule.Ports; ports != nil { portArr = strings.Split(firewallRule.Ports[0], "-") @@ -1234,7 +1233,7 @@ func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRu if strings.EqualFold(resourceId, "") { //return false, errors.New("Cannot get a resourceID") - fmt.Println("cannot get a resourceID : ") + cblogger.Info("cannot get a resourceID : ") continue } @@ -1247,7 +1246,7 @@ func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRu } // All Deny Outboun가 없으면 추가한다. - fmt.Println("existsAllDenyOutbound ----------------- ", existsAllDenyOutbound) + cblogger.Info("existsAllDenyOutbound ----------------- ", existsAllDenyOutbound) if !existsAllDenyOutbound { cblogger.Info("default outbound all deny does not exist, create one") maxEgessCount := maxFirewallSequence(firewallList, Const_GCP_Direction_EGRESS) @@ -1406,7 +1405,6 @@ func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRu // // cblogger.Info("생성할 방화벽 정책") // cblogger.Debug(fireWall) -// //spew.Dump(fireWall) // // // logger for HisCall // callogger := call.GetLogger("HISCALL") @@ -1431,7 +1429,6 @@ func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRu // return false, err // } // callogger.Info(call.String(callLogInfo)) -// //fmt.Println("create result : ", res) // time.Sleep(time.Second * 3) // //secInfo, _ := securityHandler.GetSecurity(securityReqInfo.IId) // secInfo, _ := securityHandler.GetSecurity(irs.IID{SystemId: sgIID.SystemId}) @@ -1464,7 +1461,7 @@ func getTagFromTags(itemName string, tags []string) string { // 해당 tag에 param이 있는가 for _, tag := range tags { // naming rule에 의해 itemName 은 tag + surfix 로 구성되므로 tag가 itemName에 있어야 함. - fmt.Println("itemName : ", itemName, tag, strings.Index(itemName, tag)) + cblogger.Info("itemName : ", itemName, tag, strings.Index(itemName, tag)) if tag != "" && strings.Index(itemName, tag) == 0 { if strings.Index(itemName, tag+"-basic") == 0 { return tag @@ -1482,7 +1479,6 @@ func getTagFromTags(itemName string, tags []string) string { // tag는 여러개일 수 있으므로 tag에 해당 이름이 있는지 찾기 func existsNameInTags(name string, tags []string) bool { - //fmt.Println("existsNameInTags : ", name, tags) for _, tag := range tags { if strings.EqualFold(tag, name) { return true @@ -1523,33 +1519,26 @@ func extractFirewallList(firewallList compute.FirewallList, reqTag string) []com } } - fmt.Println("********* ", securityGroupNameMap) + cblogger.Debug("********* ", securityGroupNameMap) var returnFirewallList []compute.FirewallList for _, sgKey := range securityGroupNameMap { var returnFirewall compute.FirewallList var returnFirewallItemList []*compute.Firewall - //fmt.Println("returnFirewallItemList before length : ", len(returnFirewallItemList)) for _, item := range firewallList.Items { - //fmt.Println("get security list result : ", sgKey, item) if existsNameInTags(sgKey, item.SourceTags) { - //fmt.Println("SourceTags : ", sgKey, item.SourceTags) returnFirewallItemList = append(returnFirewallItemList, item) continue } if existsNameInTags(sgKey, item.TargetTags) { - //fmt.Println("TargetTags : ", sgKey, item.TargetTags) returnFirewallItemList = append(returnFirewallItemList, item) continue } if strings.EqualFold(sgKey, item.Name) { - //fmt.Println("Name : ", sgKey, item.Name) returnFirewallItemList = append(returnFirewallItemList, item) } //firewallItemList = append(firewallItemList, item) } - //fmt.Println("returnFirewallItemList length : ", len(returnFirewallItemList)) - //fmt.Println("returnFirewallItemList : ", returnFirewallItemList) returnFirewall.Items = returnFirewallItemList returnFirewallList = append(returnFirewallList, returnFirewall) } @@ -1585,7 +1574,7 @@ func convertFromFirewallToSecurityInfo(firewallList compute.FirewallList) (irs.S hasSecurityGroupNameFound = true } } - fmt.Println("get security list result : ", item) + cblogger.Info("get security list result : ", item) //Allowed []*FirewallAllowed `json:"allowed,omitempty"` //CreationTimestamp string `json:"creationTimestamp,omitempty"` @@ -1604,10 +1593,10 @@ func convertFromFirewallToSecurityInfo(firewallList compute.FirewallList) (irs.S //SourceRanges []string `json:"sourceRanges,omitempty"` //SourceServiceAccounts []string `json:"sourceServiceAccounts,omitempty"` //SourceTags []string `json:"sourceTags,omitempty"` - fmt.Println("SourceTags : ", item.SourceTags) + cblogger.Info("SourceTags : ", item.SourceTags) //TargetServiceAccounts []string `json:"targetServiceAccounts,omitempty"` //TargetTags []string `json:"targetTags,omitempty"` - fmt.Println("TargetTags : ", item.TargetTags) + cblogger.Info("TargetTags : ", item.TargetTags) //googleapi.ServerResponse `json:"-"` //ForceSendFields []string `json:"-"` // @@ -1621,7 +1610,7 @@ func convertFromFirewallToSecurityInfo(firewallList compute.FirewallList) (irs.S } else { cidr = strings.Join(item.DestinationRanges, ", ") } - fmt.Println("cidr : ", cidr) + cblogger.Info("cidr : ", cidr) var portArr []string var fromPort string @@ -1630,7 +1619,7 @@ func convertFromFirewallToSecurityInfo(firewallList compute.FirewallList) (irs.S for _, firewallRule := range item.Allowed { ipProtocol = firewallRule.IPProtocol - fmt.Println("ipProtocol : ", ipProtocol) + cblogger.Info("ipProtocol : ", ipProtocol) if strings.EqualFold(ipProtocol, "all") || strings.EqualFold(ipProtocol, "icmp") { fromPort = "-1" toPort = "-1" @@ -1700,16 +1689,15 @@ func convertFromFirewallToSecurityInfo(firewallList compute.FirewallList) (irs.S }, SecurityRules: &securityRules, } - fmt.Println("securityRules : ", securityRules) - fmt.Println("securityRules length: ", len(securityRules)) + cblogger.Info("securityRules : ", securityRules) + cblogger.Info("securityRules length: ", len(securityRules)) } // end of result.items - fmt.Println("securityInfo : ", securityInfo) + cblogger.Info("securityInfo : ", securityInfo) return securityInfo, nil } // Spider에서 온 값은 GCP로 변경 ( "INGRESS", GCP ) => inbound 로 return // GCP에서 온 값은 Spider로 변경 ( "inbound", SPIDER) => INGRESS 로 return -// func switchDirectionSpiderAndGCP(direction string, targetType string) string { returnDirection := direction // gcp로 변경을 하는 경우 return = INGRESS, EGESS @@ -1806,11 +1794,11 @@ func sameRuleCheck(searchedSecurityRules *[]irs.SecurityRuleInfo, requestedSecur if !strings.EqualFold(reqRule.CIDR, searchedRule.CIDR) { continue } - fmt.Println("aaa : ", reqRulePort, ":"+fromPort+" : "+toPort) - fmt.Println("bbb : ", searchedRulePort, ":"+searchedRule.FromPort+" : "+searchedRule.ToPort) - fmt.Println("Direction : ", reqRule.Direction, ":"+searchedRule.Direction) - fmt.Println("IPProtocol : ", reqRule.IPProtocol, ":"+searchedRule.IPProtocol) - fmt.Println("CIDR : ", reqRule.CIDR, ":"+searchedRule.CIDR) + cblogger.Debug("aaa : ", reqRulePort, ":"+fromPort+" : "+toPort) + cblogger.Debug("bbb : ", searchedRulePort, ":"+searchedRule.FromPort+" : "+searchedRule.ToPort) + cblogger.Debug("Direction : ", reqRule.Direction, ":"+searchedRule.Direction) + cblogger.Debug("IPProtocol : ", reqRule.IPProtocol, ":"+searchedRule.IPProtocol) + cblogger.Debug("CIDR : ", reqRule.CIDR, ":"+searchedRule.CIDR) // add일 때는 존재하는게 있으면 안됨. if action == Const_SecurityRule_Add { @@ -1852,8 +1840,8 @@ func maxFirewallSequence(firewallList []compute.FirewallList, gcpDirection strin if curSequence > maxSequence { maxSequence = curSequence } - fmt.Println("str : ", str) - fmt.Println("curSequence : ", curSequence) + cblogger.Debug("str : ", str) + cblogger.Debug("curSequence : ", curSequence) } } } @@ -1889,11 +1877,11 @@ func (securityHandler *GCPSecurityHandler) firewallInsert(firewallInfo compute.F return compute.Firewall{}, err } callogger.Info(call.String(callLogInfo)) - fmt.Println("create default firewall rule result : ", res) + cblogger.Debug("create default firewall rule result : ", res) errWait := securityHandler.WaitUntilComplete(res.Name) if errWait != nil { - cblogger.Errorf("SecurityGroup create 완료 대기 실패") + cblogger.Errorf("Waiting for SecurityGroup creation completion failed.") cblogger.Error(errWait) return compute.Firewall{}, errWait } @@ -1915,7 +1903,7 @@ func (securityHandler *GCPSecurityHandler) firewallDelete(securityGroupTag strin resourceID = firewallName } resourceID = item.Name - fmt.Println("firewallDelete ", securityGroupTag, " : ", resourceID) + cblogger.Info("firewallDelete ", securityGroupTag, " : ", resourceID) callogger := call.GetLogger("HISCALL") callLogInfo := call.CLOUDLOGSCHEMA{ CloudOS: call.GCP, @@ -1940,11 +1928,11 @@ func (securityHandler *GCPSecurityHandler) firewallDelete(securityGroupTag strin return false, err } callogger.Info(call.String(callLogInfo)) - fmt.Println("remove result : ", resourceID, res) + cblogger.Info("remove result : ", resourceID, res) errWait := securityHandler.WaitUntilComplete(res.Name) if errWait != nil { - cblogger.Errorf("SecurityGroup Delete 완료 대기 실패") + cblogger.Errorf("Waiting for SecurityGroup deletion completion failed.") cblogger.Error(errWait) return false, errWait } @@ -2002,12 +1990,12 @@ func (securityHandler *GCPSecurityHandler) WaitUntilComplete(resourceId string) if err != nil { return err } - cblogger.Infof("==> 상태 : 진행율 : [%d] / [%s]", opSatus.Progress, opSatus.Status) + cblogger.Infof("==> Status : Progress : [%d] / [%s]", opSatus.Progress, opSatus.Status) //PENDING, RUNNING, or DONE. //if (opSatus.Status == "RUNNING" || opSatus.Status == "DONE") && opSatus.Progress >= 100 { if opSatus.Status == "DONE" { - cblogger.Info("요청 작업이 정상적으로 처리되어서 Wait을 종료합니다.") + cblogger.Info("The request has been processed successfully, so we are ending the wait.") return nil } @@ -2015,8 +2003,8 @@ func (securityHandler *GCPSecurityHandler) WaitUntilComplete(resourceId string) after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 리소스[%s]의 상태가 완료되지 않아서 Wait을 강제로 종료함.", max_time, resourceId) - return errors.New("장시간 요청 작업이 완료되지 않아서 Wait을 강제로 종료함.)") + cblogger.Errorf("Forcefully ending the wait because the status of resource [%s] has not been completed for [%d] seconds.", max_time, resourceId) + return errors.New("Forcefully ending the wait due to prolonged request completion.") } } diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMHandler.go index 7698a18f9..0e6db88d6 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMHandler.go @@ -15,7 +15,6 @@ import ( "context" "errors" _ "errors" - "fmt" "net/http" "regexp" "strconv" @@ -33,7 +32,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" ) type GCPVMHandler struct { @@ -48,7 +46,7 @@ type GCPVMHandler struct { func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error) { // Set VM Create Information // GCP 는 reqinfo에 ProjectID를 받아야 함. - cblogger.Info(vmReqInfo) + cblogger.Debug(vmReqInfo) //ctx := vmHandler.Ctx vmName := vmReqInfo.IId.NameId @@ -109,7 +107,7 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err if disk.Boot { // Boot Device //diskSize := disk.DiskSizeGb imageSize = disk.DiskSizeGb // image size가 맞나?? - cblogger.Info(imageSize) + cblogger.Debug(imageSize) osFeatures := disk.GuestOsFeatures for _, feature := range osFeatures { if feature.Type == "WINDOWS" { @@ -117,7 +115,7 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err break } } - cblogger.Info(isWindows) + cblogger.Debug(isWindows) } } @@ -127,7 +125,7 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err computeImage, err := GetPublicImageInfo(vmHandler.Client, vmReqInfo.ImageIID) if err != nil { - cblogger.Info("GetPublicImageInfo err : ", err) + cblogger.Error("GetPublicImageInfo err : ", err) return irs.VMInfo{}, err } @@ -136,7 +134,6 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err // if err != nil { // log.Fatal(err) // } - // spew.Dump(imageResp) //osFeatures := imageResp.GuestOsFeatures osFeatures := computeImage.GuestOsFeatures @@ -217,7 +214,7 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err return irs.VMInfo{}, errKeypair } - cblogger.Debug("공개키 생성") + cblogger.Debug("Creation Public key") publicKey, errPub := cdcom.MakePublicKeyFromPrivateKey(keypairInfo.PrivateKey) if errPub != nil { cblogger.Error(errPub) @@ -226,8 +223,10 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err //pubKey := "cb-user:" + keypairInfo.PublicKey pubKey = "cb-user:" + strings.TrimSpace(publicKey) + " " + "cb-user" - cblogger.Debug("keypairInfo 정보") - spew.Dump(keypairInfo) + cblogger.Debug("keypairInfo Information") + if cblogger.Level.String() == "debug" { + cblogger.Debug(keypairInfo) + } } // Security Group Tags @@ -236,7 +235,7 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err //securityTags = append(securityTags, item.NameId) securityTags = append(securityTags, item.SystemId) } - cblogger.Info("Security Tags 정보 : ", securityTags) + cblogger.Info("Security Tags Information : ", securityTags) //networkURL := prefix + "/global/networks/" + vmReqInfo.VpcIID.NameId networkURL := prefix + "/global/networks/" + vmReqInfo.VpcIID.SystemId //subnetWorkURL := prefix + "/regions/" + region + "/subnetworks/" + vmReqInfo.SubnetIID.NameId @@ -365,11 +364,11 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err // RootDiskType을 조회하여 diskSize의 min, max, default값 추출 한 뒤 입력된 diskSize가 있으면 비교시 사용 diskSizeResp, err := vmHandler.Client.DiskTypes.Get(projectID, zone, diskType).Do() if err != nil { - fmt.Println("Invalid Disk Type Error!!") + cblogger.Error("Invalid Disk Type Error!!") return irs.VMInfo{}, err } - fmt.Printf("valid disk size: %#v\n", diskSizeResp.ValidDiskSize) + cblogger.Info("valid disk size: %#v\n", diskSizeResp.ValidDiskSize) //valid disk size 정의 re := regexp.MustCompile("GB-?") //ex) 10GB-65536GB @@ -389,13 +388,13 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err // diskUnit := "GB" // 기본 단위는 GB if iDiskSize < diskMinSize { - fmt.Println("Disk Size Error!!: ", iDiskSize) + cblogger.Error("Disk Size Error!!: ", iDiskSize) //return irs.VMInfo{}, errors.New("Requested disk size cannot be smaller than the minimum disk size, invalid") return irs.VMInfo{}, errors.New("Root Disk Size must be at least the default size (" + strconv.FormatInt(diskMinSize, 10) + " GB).") } if iDiskSize > diskMaxSize { - fmt.Println("Disk Size Error!!: ", iDiskSize) + cblogger.Error("Disk Size Error!!: ", iDiskSize) //return irs.VMInfo{}, errors.New("Requested disk size cannot be larger than the maximum disk size, invalid") return irs.VMInfo{}, errors.New("Root Disk Size must be smaller than the maximum size (" + strconv.FormatInt(diskMaxSize, 10) + " GB).") } @@ -404,7 +403,7 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err //imageSize = imageResp.DiskSizeGb if iDiskSize < imageSize { - fmt.Println("Disk Size Error!!: ", iDiskSize) + cblogger.Error("Disk Size Error!!: ", iDiskSize) return irs.VMInfo{}, errors.New("Root Disk Size must be larger then the image size (" + strconv.FormatInt(imageSize, 10) + " GB).") } @@ -420,9 +419,11 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err instance.Disks = append(instance.Disks, &disk) } - cblogger.Info("VM 생성 시작") + cblogger.Info("VM Creation Started") cblogger.Debug(instance) - spew.Dump(instance) + if cblogger.Level.String() == "debug" { + cblogger.Debug(instance) + } // logger for HisCall callogger := call.GetLogger("HISCALL") callLogInfo := call.CLOUDLOGSCHEMA{ @@ -467,9 +468,11 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err } callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - cblogger.Info("VM 생성 요청 호출 완료") - cblogger.Info(op) - spew.Dump(op) + cblogger.Info("VM creation request call completed.") + cblogger.Debug(op) + if cblogger.Level.String() == "debug" { + cblogger.Debug(op) + } callogger.Info(call.String(callLogInfo)) /* @@ -490,13 +493,13 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err //2021-05-11 WaitForRun을 호출하지 않아도 GetVM() 호출 시 에러가 발생하지 않는 것은 확인했음. (우선은 정책이 최종 확정이 아니라서 WaitForRun을 사용하도록 원복함.) vmStatus, _ := vmHandler.WaitForRun(irs.IID{NameId: vmName, SystemId: vmName}) - cblogger.Info("VM 상태 : ", vmStatus) + cblogger.Info("VM Status : ", vmStatus) - cblogger.Info("VM 정보 조회 호출 - GetVM()") + cblogger.Debug("VM information retrieval call - GetVM()") //만약 30초 이내에 VM이 Running 상태가 되지 않더라도 GetVM으로 VM의 정보 조회를 요청해 봄. vmInfo, errVmInfo := vmHandler.GetVM(irs.IID{NameId: vmName, SystemId: vmName}) if errVmInfo != nil { - cblogger.Errorf("[%s] VM을 생성했지만 정보 조회는 실패 함.", vmName) + cblogger.Errorf("[%s] VM was created but the information retrieval failed.", vmName) cblogger.Error(errVmInfo) return irs.VMInfo{}, errVmInfo @@ -577,7 +580,9 @@ func (vmHandler *GCPVMHandler) SuspendVM(vmID irs.IID) (irs.VMStatus, error) { //inst, err := vmHandler.Client.Instances.Stop(projectID, zone, vmID.SystemId).Context(ctx).Do() inst, err := vmHandler.GCPInstanceStop(projectID, zone, vmID.SystemId) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - spew.Dump(inst) + if cblogger.Level.String() == "debug" { + cblogger.Debug(inst) + } if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -586,7 +591,7 @@ func (vmHandler *GCPVMHandler) SuspendVM(vmID irs.IID) (irs.VMStatus, error) { } callogger.Info(call.String(callLogInfo)) - fmt.Println("instance stop status :", inst.Status) + cblogger.Info("instance stop status :", inst.Status) return irs.VMStatus("Suspending"), nil } @@ -620,7 +625,9 @@ func (vmHandler *GCPVMHandler) ResumeVM(vmID irs.IID) (irs.VMStatus, error) { callLogStart := call.Start() inst, err := vmHandler.Client.Instances.Start(projectID, zone, vmID.SystemId).Context(ctx).Do() callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - spew.Dump(inst) + if cblogger.Level.String() == "debug" { + cblogger.Debug(inst) + } if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -629,7 +636,7 @@ func (vmHandler *GCPVMHandler) ResumeVM(vmID irs.IID) (irs.VMStatus, error) { } callogger.Info(call.String(callLogInfo)) - fmt.Println("instance resume status :", inst.Status) + cblogger.Info("instance resume status :", inst.Status) return irs.VMStatus("Resuming"), nil } @@ -661,7 +668,7 @@ func (vmHandler *GCPVMHandler) RebootVM(vmID irs.IID) (irs.VMStatus, error) { } // running 상태일 때는 reset if status == "Running" { - callogger.Info("vm의 상태가 running이므로 reset 호춯") + callogger.Info("Since the VM is in a running state, reset is called.") operation, err := vmHandler.Client.Instances.Reset(projectID, zone, vmID.SystemId).Context(ctx).Do() if err != nil { @@ -672,14 +679,14 @@ func (vmHandler *GCPVMHandler) RebootVM(vmID irs.IID) (irs.VMStatus, error) { return irs.VMStatus("Failed"), err } } else if status == "Suspended" { - callogger.Info("vm의 상태가 Suspended이므로 ResumeVM 호춯") + callogger.Info("Since the VM is in a Suspended state, ResumeVM is called.") _, err := vmHandler.ResumeVM(vmID) if err != nil { return irs.VMStatus("Failed"), err } } else { // running/suspended 이외에는 비정상 - return irs.VMStatus("Failed"), errors.New(string("VM의 상태가 [" + status + "] 입니다.")) + return irs.VMStatus("Failed"), errors.New(string("The status of the VM is [" + status + "].")) } //callogger.Info(vmID) //callogger.Info(status) @@ -764,7 +771,9 @@ func (vmHandler *GCPVMHandler) TerminateVM(vmID irs.IID) (irs.VMStatus, error) { callLogStart := call.Start() inst, err := vmHandler.Client.Instances.Delete(projectID, zone, vmID.SystemId).Context(ctx).Do() callLogInfo.ElapsedTime = call.Elapsed(callLogStart) - spew.Dump(inst) + if cblogger.Level.String() == "debug" { + cblogger.Debug(inst) + } if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) @@ -773,7 +782,7 @@ func (vmHandler *GCPVMHandler) TerminateVM(vmID irs.IID) (irs.VMStatus, error) { } callogger.Info(call.String(callLogInfo)) - fmt.Println("instance status :", inst.Status) + cblogger.Info("instance status :", inst.Status) return irs.VMStatus("Terminating"), nil } @@ -843,8 +852,8 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) { resultStatus = "Resuming" } else { //resultStatus = "Failed" - cblogger.Errorf("vmStatus [%s]와 일치하는 맵핑 정보를 찾지 못 함.", vmStatus) - return irs.VMStatus("Failed"), errors.New(vmStatus + "와 일치하는 CB VM 상태정보를 찾을 수 없습니다.") + cblogger.Errorf("Couldn't find mapping information matching vmStatus [%s].", vmStatus) + return irs.VMStatus("Failed"), errors.New("Couldn't find CB VM status information matching vmStatus " + vmStatus) } cblogger.Infof("VM 상태 치환 : [%s] ==> [%s]", vmStatus, resultStatus) return irs.VMStatus(resultStatus), nil @@ -907,7 +916,7 @@ func (vmHandler *GCPVMHandler) ListVM() ([]*irs.VMInfo, error) { callLogInfo.ErrorMSG = err.Error() callogger.Info(call.String(callLogInfo)) cblogger.Error(err) - cblogger.Infof("해당존에 만들어진 Vm List 가 없음") + cblogger.Infof("There are no VM lists created in that zone.") return nil, err } callogger.Info(call.String(callLogInfo)) @@ -946,7 +955,9 @@ func (vmHandler *GCPVMHandler) GetVM(vmID irs.IID) (irs.VMInfo, error) { return irs.VMInfo{}, err } callogger.Info(call.String(callLogInfo)) - spew.Dump(vm) + if cblogger.Level.String() == "debug" { + cblogger.Debug(vm) + } vmInfo := vmHandler.mappingServerInfo(vm) return vmInfo, nil @@ -992,7 +1003,9 @@ func (vmHandler *GCPVMHandler) GetVmById(vmID irs.IID) (irs.VMInfo, error) { if item.Instances != nil { for _, instance := range item.Instances { if strings.EqualFold(vmID.SystemId, instance.Name) { - spew.Dump(instance) + if cblogger.Level.String() == "debug" { + cblogger.Debug(instance) + } vmInfo = vmHandler.mappingServerInfo(instance) foundVm = true break @@ -1032,9 +1045,11 @@ func (vmHandler *GCPVMHandler) GetVmById(vmID irs.IID) (irs.VMInfo, error) { // } func (vmHandler *GCPVMHandler) mappingServerInfo(server *compute.Instance) irs.VMInfo { - cblogger.Info("================맵핑=====================================") - spew.Dump(server) - fmt.Println("server: ", server) + cblogger.Debug("================Mapping=====================================") + if cblogger.Level.String() == "debug" { + cblogger.Debug(server) + } + cblogger.Info("server: ", server) //var gcpHanler *GCPVMHandler vpcArr := strings.Split(server.NetworkInterfaces[0].Network, "/") @@ -1126,9 +1141,9 @@ func (vmHandler *GCPVMHandler) mappingServerInfo(server *compute.Instance) irs.V vmInfo.ImageType = vmHandler.getImageType(server.SourceMachineImage) arrVmSpec := strings.Split(server.MachineType, "/") - cblogger.Info(arrVmSpec) + cblogger.Debug(arrVmSpec) if len(arrVmSpec) > 1 { - cblogger.Info(arrVmSpec[len(arrVmSpec)-1]) + cblogger.Debug(arrVmSpec[len(arrVmSpec)-1]) vmInfo.VMSpecName = arrVmSpec[len(arrVmSpec)-1] } @@ -1145,7 +1160,7 @@ func (vmHandler *GCPVMHandler) mappingServerInfo(server *compute.Instance) irs.V //2020-05-13T00:15:37.183-07:00 if len(server.CreationTimestamp) > 5 { - cblogger.Infof("서버 구동 시간 처리 : [%s]", server.CreationTimestamp) + cblogger.Infof("Server uptime processing: [%s]", server.CreationTimestamp) t, err := time.Parse(time.RFC3339, server.CreationTimestamp) if err != nil { cblogger.Error(err) @@ -1188,8 +1203,10 @@ func (vmHandler *GCPVMHandler) getImageIID(server *compute.Instance) irs.IID { } else { info, err := vmHandler.getDiskInfo(server.Disks[0].Source) - cblogger.Infof("********************************** Disk 정보 ****************") - spew.Dump(info) + cblogger.Infof("********************************** Disk Information ****************") + if cblogger.Level.String() == "debug" { + cblogger.Debug(info) + } if err != nil { cblogger.Error(err) return irs.IID{} @@ -1225,8 +1242,10 @@ func (vmHandler *GCPVMHandler) getDiskInfo(diskname string) (*compute.Disk, erro info, err := GetDiskInfo(vmHandler.Client, vmHandler.Credential, vmHandler.Region, result) - cblogger.Infof("********************************** Disk 정보 ****************") - spew.Dump(info) + cblogger.Infof("********************************** Disk Information ****************") + if cblogger.Level.String() == "debug" { + cblogger.Debug(info) + } if err != nil { cblogger.Error(err) return &compute.Disk{}, err @@ -1244,8 +1263,6 @@ func (vmHandler *GCPVMHandler) getDiskInfo(diskname string) (*compute.Disk, erro // SystemId: "cb-user", // } // result, err := gcpKeyPairHandler.GetKey(iId) - -// spew.Dump(result) // if err != nil { // cblogger.Error(err) // return result @@ -1256,7 +1273,7 @@ func (vmHandler *GCPVMHandler) getDiskInfo(diskname string) (*compute.Disk, erro // VM 정보를 조회할 수 있을 때까지 최대 30초간 대기 func (vmHandler *GCPVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error) { - cblogger.Info("======> 생성된 VM의 최종 정보 확인을 위해 Running 될 때까지 대기함.") + cblogger.Info("======> Waiting for the VM to be running to verify the final information of the created VM.") waitStatus := "Running" @@ -1273,17 +1290,17 @@ func (vmHandler *GCPVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error) { cblogger.Info("===>VM Status : ", curStatus) if curStatus == irs.VMStatus(waitStatus) { //|| curStatus == irs.VMStatus("Running") { - cblogger.Infof("===>VM 상태가 [%s]라서 대기를 중단합니다.", curStatus) + cblogger.Infof("===> Stopping the wait because the VM status is [%s].", curStatus) break } //if curStatus != irs.VMStatus(waitStatus) { curRetryCnt++ - cblogger.Errorf("VM 상태가 [%s]이 아니라서 1초 대기후 조회합니다.", waitStatus) + cblogger.Errorf("The VM status is not [%s], so waiting for 1 second before querying.", waitStatus) time.Sleep(time.Second * 1) if curRetryCnt > maxRetryCnt { - cblogger.Errorf("장시간(%d 초) 대기해도 VM의 Status 값이 [%s]으로 변경되지 않아서 강제로 중단합니다.", maxRetryCnt, waitStatus) - return irs.VMStatus("Failed"), errors.New("장시간 기다렸으나 생성된 VM의 상태가 [" + waitStatus + "]으로 바뀌지 않아서 중단 합니다.") + cblogger.Errorf("Forcibly stopping after waiting for a long time (%d seconds) as the VM's Status value hasn't changed to [%s].", maxRetryCnt, waitStatus) + return irs.VMStatus("Failed"), errors.New("Stopped waiting after waiting for a long time, but the status of the created VM did not change to [" + waitStatus + "].") } } diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VPCHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VPCHandler.go index 78b28d04e..a6e708161 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VPCHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VPCHandler.go @@ -24,7 +24,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" ) type GCPVPCHandler struct { @@ -34,25 +33,25 @@ type GCPVPCHandler struct { Credential idrv.CredentialInfo } -//@TODO : VPC 생성 로직 변경 필요 / 서브넷이 백그라운드로 생성되기 때문에 조회 시 모두 생성될 때까지 대기하는 로직 필요(그렇지 않으면 일부 정보가 누락됨) +// @TODO : VPC 생성 로직 변경 필요 / 서브넷이 백그라운드로 생성되기 때문에 조회 시 모두 생성될 때까지 대기하는 로직 필요(그렇지 않으면 일부 정보가 누락됨) // #1067 : gcp는 subnet 생성시 zone을 사용하지 않음. func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error) { - cblogger.Info(vpcReqInfo) + cblogger.Debug(vpcReqInfo) if vpcReqInfo.IId.NameId == "" { - cblogger.Infof("생성할 VPC 이름[%s]이 없습니다.", vpcReqInfo.IId.NameId) + cblogger.Infof("The VPC name [%s] to be created does not exist.", vpcReqInfo.IId.NameId) return irs.VPCInfo{}, errors.New("Invalid Request - VPC NameId is required.") } if vpcReqInfo.SubnetInfoList == nil { - cblogger.Info("생성할 VPC의 Subnet 정보가 없습니다.") + cblogger.Info("There is no subnet information for the VPC to be created.") return irs.VPCInfo{}, errors.New("Invalid Request - Subnet information is required.") } - cblogger.Infof("생성된 [%s] VPC가 있는지 체크", vpcReqInfo.IId.NameId) + cblogger.Infof("Checking if the [%s] VPC has been created.", vpcReqInfo.IId.NameId) _, errChkVpc := vVPCHandler.GetVPC(irs.IID{SystemId: vpcReqInfo.IId.NameId}) if errChkVpc == nil { - cblogger.Infof("이미 [%s] VPCs가 존재함.", vpcReqInfo.IId.NameId) + cblogger.Infof("The [%s] VPCs already exist.", vpcReqInfo.IId.NameId) return irs.VPCInfo{}, errors.New("Already Exist - " + vpcReqInfo.IId.NameId) } @@ -69,8 +68,8 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI ForceSendFields: []string{"AutoCreateSubnetworks"}, } - cblogger.Infof("[%s] VPC 생성 시작", name) - cblogger.Info(network) + cblogger.Infof("[%s] VPC creation initiated.", name) + cblogger.Debug(network) // logger for HisCall callogger := call.GetLogger("HISCALL") @@ -89,7 +88,7 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err != nil { - cblogger.Errorf("[%s] VPC 생성 실패", name) + cblogger.Errorf("[%s] VPC creation failed.", name) cblogger.Error(err) callLogInfo.ErrorMSG = err.Error() @@ -98,10 +97,10 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI } callogger.Info(call.String(callLogInfo)) - cblogger.Infof("[%s] VPC가 정상적으로 생성되고 있습니다 - 리소스 ID : [%d]", name, req.Id) + cblogger.Infof("[%s] VPC is being created successfully - Resource ID: [%d]", name, req.Id) errWait := vVPCHandler.WaitUntilComplete(strconv.FormatUint(req.Id, 10), true) if errWait != nil { - cblogger.Errorf("[%s] VPC 생성 완료 대기 실패", name) + cblogger.Errorf("Failed to wait for [%s] VPC creation completion.", name) cblogger.Error(errWait) return irs.VPCInfo{}, errWait } @@ -119,10 +118,10 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI vpcNetworkUrl := "https://www.googleapis.com/compute/v1/projects/" + projectID + "/global/networks/" + vpcReqInfo.IId.NameId for _, item := range vpcReqInfo.SubnetInfoList { subnetName := item.IId.NameId - cblogger.Infof("생성할 [%s] Subnet이 존재하는지 체크", subnetName) + cblogger.Infof("Checking if the [%s] subnet to be created already exists.", subnetName) checkInfo, err := vVPCHandler.Client.Subnetworks.Get(projectID, region, subnetName).Do() if err == nil { - cblogger.Errorf("이미 [%s] Subnet이 존재함", subnetName) + cblogger.Errorf("The [%s] subnet already exists.", subnetName) return irs.VPCInfo{}, errors.New("Already Exist - " + subnetName + " Subnet is exist") } cblogger.Info(" Subnet info : ", checkInfo) @@ -133,8 +132,8 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI IpCidrRange: item.IPv4_CIDR, Network: vpcNetworkUrl, } - cblogger.Infof("[%s] Subnet 생성시작", subnetName) - cblogger.Info(subnetWork) + cblogger.Infof("[%s] Subnet creation started.", subnetName) + cblogger.Debug(subnetWork) infoSubnet, errSubnet := vVPCHandler.Client.Subnetworks.Insert(projectID, region, subnetWork).Do() if errSubnet != nil { @@ -142,7 +141,7 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI return irs.VPCInfo{}, errors.New("Making Subnet Error - " + subnetName) } - //spew.Dump(infoSubnet) + //cblogger.Debug(infoSubnet) //생성된 서브넷이 조회되는데 시간이 필요하기 때문에 홀딩 함. /* errChkSubnetStatus := vVPCHandler.WaitForRunSubnet(subnetName, true) @@ -151,22 +150,22 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI return irs.VPCInfo{}, errChkSubnetStatus } */ - cblogger.Infof("[%s] Subnet 생성 성공 - 리소스 ID : [%d]", subnetName, infoSubnet.Id) + cblogger.Infof("[%s] Subnet creation successful - Resource ID: [%d]", subnetName, infoSubnet.Id) errWait := vVPCHandler.WaitUntilComplete(strconv.FormatUint(infoSubnet.Id, 10), false) if errWait != nil { - cblogger.Errorf("[%s] Subnet 생성 완료 대기 실패", subnetName) + cblogger.Errorf("Failed to wait for [%s] Subnet creation completion.", subnetName) cblogger.Error(errWait) return irs.VPCInfo{}, errWait } - cblogger.Infof("[%s] Subnet 생성완료", subnetName) - cblogger.Info(infoSubnet) + cblogger.Infof("[%s] Subnet creation completed.", subnetName) + cblogger.Debug(infoSubnet) } //최신 정보로 리턴 함. vpcInfo, errVPC := vVPCHandler.GetVPC(irs.IID{SystemId: vpcReqInfo.IId.NameId}) if errVPC != nil { - cblogger.Errorf("최종 생성된 [%s] VPC 정보 조회 실패", vpcReqInfo.IId.NameId) + cblogger.Errorf("Failed to retrieve the final information of the [%s] VPC created.", vpcReqInfo.IId.NameId) cblogger.Error(errVPC) return vpcInfo, errVPC } @@ -175,38 +174,38 @@ func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCI return vpcInfo, nil } -//VPC 정보가 조회될때까지 대기 -//waitFound : true - 정보가 조회될때까지 대기(생성 시) / false - 정보가 조회되지 않을때까지 대기(삭제 시) +// VPC 정보가 조회될때까지 대기 +// waitFound : true - 정보가 조회될때까지 대기(생성 시) / false - 정보가 조회되지 않을때까지 대기(삭제 시) func (vVPCHandler *GCPVPCHandler) WaitForRunVpc(name string, waitFound bool) error { - cblogger.Info("======> VPC 정보가 조회될때까지 대기함.") + cblogger.Info("======> Waiting for the VPC information to be retrieved.") before_time := time.Now() max_time := 300 //최대 300초간 체크 - cblogger.Infof("VPC 정보 조회가 %v될 때까지 1초 텀으로 체크 시작", waitFound) + cblogger.Infof("Checking every 1 second until VPC information retrieval is %v.", waitFound) for { - cblogger.Infof("==> [%s] VPC 정보 조회", name) + cblogger.Infof("==> Retrieving [%s] VPC information", name) vpcInfo, errVnet := vVPCHandler.Client.Networks.Get(vVPCHandler.Credential.ProjectID, name).Do() - //spew.Dump(vpcInfo) + //cblogger.Debug(vpcInfo) //============================ //정보가 조회될때까지 대기 //============================ if waitFound { if errVnet != nil { - cblogger.Errorf("==> [%s] VPC 정보 조회 실패", name) + cblogger.Errorf("==> Failed to retrieve [%s] VPC information", name) cblogger.Error(errVnet) time.Sleep(time.Second * 1) after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 [%s] VPC 정보가 조회되지 않아서 강제로 종료함.", max_time, name) + cblogger.Errorf("Forcibly ending after [%d] seconds as [%s] VPC information has not been retrieved.", max_time, name) return errVnet } } else { - cblogger.Infof("==> [%s] VPC 정보 조회 완료", name) - spew.Dump(vpcInfo) + cblogger.Infof("==> [%s] VPC information retrieval complete", name) + cblogger.Debug(vpcInfo) //cblogger.Info(vpcInfo) return nil } @@ -215,19 +214,19 @@ func (vVPCHandler *GCPVPCHandler) WaitForRunVpc(name string, waitFound bool) err //정보가 조회되지 않을때까지 대기 //============================ if errVnet == nil { - cblogger.Errorf("==> [%s] VPC 정보 조회 성공", name) + cblogger.Errorf("==> [%s] VPC information retrieval successful", name) //cblogger.Info(vpcInfo) - spew.Dump(vpcInfo) + cblogger.Debug(vpcInfo) time.Sleep(time.Second * 1) after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초를 기다려도 [%s] VPC 정보가 조회되고 있어서 Wait을 강제로 종료함.", max_time, name) - return errors.New("300초를 기다려도 생성된 " + name + " VPC 정보가 조회되고 있어서 Wait을 강제로 종료함.") + cblogger.Errorf("[%d] seconds waited, but [%s] VPC information is still being retrieved, so the wait was forcibly terminated.", max_time, name) + return errors.New("Wait was forcibly terminated after waiting 300 seconds because the information for the created VPC named " + name + " is still being retrieved.") } } else { - cblogger.Infof("==> [%s] VPC 정보가 사라졌음", name) + cblogger.Infof("==> [%s] VPC information has disappeared", name) return nil } } //end of if waitFound : 조회 옵션 @@ -236,38 +235,38 @@ func (vVPCHandler *GCPVPCHandler) WaitForRunVpc(name string, waitFound bool) err return nil } -//Subnet 정보가 조회될때까지 대기 -//waitFound : true - 정보가 조회될때까지 대기(생성 시) / false - 정보가 조회되지 않을때까지 대기(삭제 시) +// Subnet 정보가 조회될때까지 대기 +// waitFound : true - 정보가 조회될때까지 대기(생성 시) / false - 정보가 조회되지 않을때까지 대기(삭제 시) func (vVPCHandler *GCPVPCHandler) WaitForRunSubnet(subnetName string, waitFound bool) error { - cblogger.Info("======> Subnet 정보가 조회될때까지 대기함.") + cblogger.Info("======> Waiting for Subnet information to be retrieved.") before_time := time.Now() max_time := 300 //최대 300초간 체크 - cblogger.Infof("Subnet 정보 조회가 %v될 때까지 1초 텀으로 체크 시작", waitFound) + cblogger.Infof("Checking every 1 second until Subnet information retrieval is %v.", waitFound) for { - cblogger.Infof("--> 생성된 [%s] Subnet이 존재하는지 체크", subnetName) + cblogger.Infof("--> Checking if the created [%s] Subnet exists.", subnetName) chkInfo, err := vVPCHandler.Client.Subnetworks.Get(vVPCHandler.Credential.ProjectID, vVPCHandler.Region.Region, subnetName).Do() - //spew.Dump(chkInfo) + //cblogger.Debug(chkInfo) //============================ //정보가 조회될때까지 대기 //============================ if waitFound { if err != nil { - cblogger.Errorf("==> [%s] Subnet 정보 조회 실패", subnetName) - spew.Dump(err) + cblogger.Errorf("==> [%s] Failed to retrieve Subnet information.", subnetName) + cblogger.Debug(err) time.Sleep(time.Second * 1) after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 [%s] Subnet 정보가 조회되지 않아서 강제로 종료함.", max_time, subnetName) - return errors.New("생성된 Subnet 정보가 장시간 조회되지 않아서 강제로 종료함.)") + cblogger.Errorf("After waiting for [%d] seconds, the [%s] Subnet information was not retrieved, so the process was forcibly terminated.", max_time, subnetName) + return errors.New("the retrieval of the created Subnet information took too long, so it was forcibly terminated") } } else { - cblogger.Infof("==> [%s] Subnet 정보 조회 완료", subnetName) + cblogger.Infof("==> [%s] Subnet information retrieval complete", subnetName) //cblogger.Info(chkInfo) - spew.Dump(chkInfo) + cblogger.Debug(chkInfo) return nil } } else { @@ -275,20 +274,20 @@ func (vVPCHandler *GCPVPCHandler) WaitForRunSubnet(subnetName string, waitFound //정보가 조회되지 않을때까지 대기 //============================ if err == nil { - cblogger.Errorf("==> [%s] Subnet 정보 조회 성공", subnetName) + cblogger.Errorf("==> [%s] Subnet information retrieval complete", subnetName) //cblogger.Info(chkInfo) - spew.Dump(chkInfo) + cblogger.Debug(chkInfo) time.Sleep(time.Second * 1) after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초를 기다려도 [%s] Subnet 정보가 조회되고 있어서 Wait을 강제로 종료함.", max_time, subnetName) - return errors.New("300초를 기다려도 생성된 " + subnetName + " Subnet 정보가 조회되고 있어서 Wait을 강제로 종료함.") + cblogger.Errorf("After waiting for [%d] seconds, the [%s] Subnet information is still being retrieved, so the wait was forcibly terminated.", max_time, subnetName) + return errors.New("After waiting for 300 seconds, the created " + subnetName + " Subnet information is still being retrieved, so the wait was forcibly terminated.") } } else { - spew.Dump(err) - cblogger.Infof("==> [%s] Subnet 정보가 사라졌음", subnetName) + cblogger.Debug(err) + cblogger.Infof("==> [%s] Subnet information has disappeared", subnetName) return nil } } // end of if : 정보 조회 옵션 @@ -302,13 +301,13 @@ func (vVPCHandler *GCPVPCHandler) WaitForRunSubnet(subnetName string, waitFound //https://godoc.org/google.golang.org/api/compute/v1#GlobalOperationsGetCall.Do //https://cloud.google.com/compute/docs/reference/rest/v1/globalOperations/list -//https://cloud.google.com/compute/docs/reference/rest/v1/globalOperations/get +// https://cloud.google.com/compute/docs/reference/rest/v1/globalOperations/get // // resourceId : API 호출후 받은 리소스 값 -//VPC : 글로벌 -//https://www.googleapis.com/compute/v1/projects/mcloud-barista2020/global/networks/cb-vpc-load-test -//Subnet : Regions -//https://www.googleapis.com/compute/v1/projects/mcloud-barista2020/regions/asia-northeast3/operations/operation-1590139586815-5a6393937274c-71aebdca-1574e4d7 +// VPC : 글로벌 +// https://www.googleapis.com/compute/v1/projects/mcloud-barista2020/global/networks/cb-vpc-load-test +// Subnet : Regions +// https://www.googleapis.com/compute/v1/projects/mcloud-barista2020/regions/asia-northeast3/operations/operation-1590139586815-5a6393937274c-71aebdca-1574e4d7 // 404 에러 체크해서 global과 region 자동으로 처리 가능하니 필요하면 나중에 공통 유틸로 변경할 것 func (vVPCHandler *GCPVPCHandler) WaitUntilComplete(resourceId string, isGlobalAction bool) error { //compute.ZoneOperationsGetCall @@ -335,12 +334,12 @@ func (vVPCHandler *GCPVPCHandler) WaitUntilComplete(resourceId string, isGlobalA if err != nil { return err } - cblogger.Infof("==> 상태 : 진행율 : [%d] / [%s]", opSatus.Progress, opSatus.Status) + cblogger.Infof("==> Status : Progress : [%d] / [%s]", opSatus.Progress, opSatus.Status) //PENDING, RUNNING, or DONE. //if (opSatus.Status == "RUNNING" || opSatus.Status == "DONE") && opSatus.Progress >= 100 { if opSatus.Status == "DONE" { - cblogger.Info("요청 작업이 정상적으로 처리되어서 Wait을 종료합니다.") + cblogger.Info("The request has been processed successfully, so the wait is terminated.") return nil } @@ -348,8 +347,8 @@ func (vVPCHandler *GCPVPCHandler) WaitUntilComplete(resourceId string, isGlobalA after_time := time.Now() diff := after_time.Sub(before_time) if int(diff.Seconds()) > max_time { - cblogger.Errorf("[%d]초 동안 리소스[%s]의 상태가 완료되지 않아서 Wait을 강제로 종료함.", max_time, resourceId) - return errors.New("장시간 요청 작업이 완료되지 않아서 Wait을 강제로 종료함.)") + cblogger.Errorf("After waiting for [%d] seconds, the status of resource [%s] has not been completed, so the wait was forcibly terminated.", max_time, resourceId) + return errors.New("The wait was forcibly terminated as the request operation took too long to complete.") } } @@ -441,7 +440,7 @@ func (vVPCHandler *GCPVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error) { return irs.VPCInfo{}, err } callogger.Info(call.String(callLogInfo)) - spew.Dump(infoVPC) + cblogger.Debug(infoVPC) if infoVPC.Subnetworks != nil { for _, item := range infoVPC.Subnetworks { str := strings.Split(item, "/") @@ -530,10 +529,10 @@ func (vVPCHandler *GCPVPCHandler) DeleteVPC(vpcID irs.IID) (bool, error) { } */ - cblogger.Infof("[%s] Subnet 삭제 성공 - 리소스 ID : [%d]", item.IId.NameId, infoSubnet.Id) + cblogger.Infof("[%s] Subnet deletion successful - Resource ID: [%d]", item.IId.NameId, infoSubnet.Id) errWait := vVPCHandler.WaitUntilComplete(strconv.FormatUint(infoSubnet.Id, 10), false) if errWait != nil { - cblogger.Errorf("[%s] Subnet 삭제 완료 대기 실패", item.IId.NameId) + cblogger.Errorf("[%s] Subnet deletion completion wait failed", item.IId.NameId) cblogger.Error(errWait) return false, errWait } @@ -562,7 +561,7 @@ func (vVPCHandler *GCPVPCHandler) DeleteVPC(vpcID irs.IID) (bool, error) { callLogInfo.ElapsedTime = call.Elapsed(callLogStart) //time.Sleep(time.Second * 15) - cblogger.Info(info) + cblogger.Debug(info) if err != nil { cblogger.Error(err) callLogInfo.ErrorMSG = err.Error() @@ -578,13 +577,13 @@ func (vVPCHandler *GCPVPCHandler) DeleteVPC(vpcID irs.IID) (bool, error) { } */ - cblogger.Infof("[%s] VPC가 최종 삭제될까지 대기 - 리소스 ID : [%d]", name) + cblogger.Infof("Waiting for [%s] VPC to be finally deleted - Resource ID: [%d]", name) errChkVpcStatus := vVPCHandler.WaitUntilComplete(strconv.FormatUint(info.Id, 10), true) callogger.Info(call.String(callLogInfo)) if errChkVpcStatus != nil { callLogInfo.ErrorMSG = errChkVpcStatus.Error() callogger.Info(call.String(callLogInfo)) - cblogger.Errorf("[%s] Subnet 삭제 완료 대기 실패", name) + cblogger.Errorf("[%s] Subnet deletion completion wait failed", name) cblogger.Error(errChkVpcStatus) return false, errChkVpcStatus } @@ -594,7 +593,7 @@ func (vVPCHandler *GCPVPCHandler) DeleteVPC(vpcID irs.IID) (bool, error) { } func (VPCHandler *GCPVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.SubnetInfo) (irs.VPCInfo, error) { - cblogger.Infof("[%s] Subnet 추가 - CIDR : %s", subnetInfo.IId.NameId, subnetInfo.IPv4_CIDR) + cblogger.Infof("[%s] Subnet added - CIDR: %s", subnetInfo.IId.NameId, subnetInfo.IPv4_CIDR) //resSubnet, errSubnet := VPCHandler.CreateSubnet(vpcIID.SystemId, subnetInfo) _, errSubnet := VPCHandler.CreateSubnet(vpcIID.SystemId, subnetInfo) if errSubnet != nil { @@ -607,9 +606,9 @@ func (VPCHandler *GCPVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.Subnet //return irs.VPCInfo{}, nil } -//리턴 값은 구현하지 않고 nil을 리턴함. - 현재 사용되는 곳이 없어서 시간상 누락 시킴. +// 리턴 값은 구현하지 않고 nil을 리턴함. - 현재 사용되는 곳이 없어서 시간상 누락 시킴. func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.SubnetInfo) (irs.SubnetInfo, error) { - cblogger.Info(reqSubnetInfo) + cblogger.Debug(reqSubnetInfo) projectID := vVPCHandler.Credential.ProjectID region := vVPCHandler.Region.Region @@ -617,7 +616,7 @@ func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.S //서브넷 생성 vpcNetworkUrl := "https://www.googleapis.com/compute/v1/projects/" + projectID + "/global/networks/" + vpcId subnetName := reqSubnetInfo.IId.NameId - cblogger.Infof("생성할 [%s] Subnet이 존재하는지 체크", subnetName) + cblogger.Infof("Checking if the [%s] Subnet to be created exists.", subnetName) // logger for HisCall callogger := call.GetLogger("HISCALL") @@ -635,7 +634,7 @@ func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.S callLogInfo.ElapsedTime = call.Elapsed(callLogStart) if err == nil { callLogInfo.ErrorMSG = err.Error() - cblogger.Errorf("이미 [%s] Subnet이 존재함", subnetName) + cblogger.Errorf("[%s] Subnet already exists ", subnetName) callogger.Info(call.String(callLogInfo)) return irs.SubnetInfo{}, errors.New("Already Exist - " + subnetName + " Subnet is exist") } @@ -648,8 +647,8 @@ func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.S IpCidrRange: reqSubnetInfo.IPv4_CIDR, Network: vpcNetworkUrl, } - cblogger.Infof("[%s] Subnet 생성시작", subnetName) - cblogger.Info(subnetWork) + cblogger.Infof("[%s] Starting Subnet Creation ", subnetName) + cblogger.Debug(subnetWork) infoSubnet, errSubnet := vVPCHandler.Client.Subnetworks.Insert(projectID, region, subnetWork).Do() if errSubnet != nil { @@ -657,18 +656,18 @@ func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.S return irs.SubnetInfo{}, errors.New("Making Subnet Error - " + subnetName) } - spew.Dump(infoSubnet) + cblogger.Debug(infoSubnet) //생성된 서브넷이 조회되는데 시간이 필요하기 때문에 홀딩 함. - cblogger.Infof("[%s] Subnet 생성 성공 - 리소스 ID : [%d]", subnetName, infoSubnet.Id) + cblogger.Infof("[%s] Subnet creation successful - Resource ID: [%d]", subnetName, infoSubnet.Id) errWait := vVPCHandler.WaitUntilComplete(strconv.FormatUint(infoSubnet.Id, 10), false) if errWait != nil { - cblogger.Errorf("[%s] Subnet 생성 완료 대기 실패", subnetName) + cblogger.Errorf("[%s] Subnet creation completion wait failed", subnetName) cblogger.Error(errWait) return irs.SubnetInfo{}, errWait } - cblogger.Infof("[%s] Subnet 생성완료", subnetName) - cblogger.Info(infoSubnet) + cblogger.Infof("[%s] Subnet creation complete", subnetName) + cblogger.Debug(infoSubnet) //생성된 정보 조회 //mappingSubnet() 이용하면 되지만 수정해야 함. @@ -677,7 +676,7 @@ func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.S } func (vVPCHandler *GCPVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID) (bool, error) { - cblogger.Infof("[%s] VPC의 [%s] Subnet 삭제", vpcIID.SystemId, subnetIID.SystemId) + cblogger.Infof("Deleting [%s] Subnet of [%s] VPC", vpcIID.SystemId, subnetIID.SystemId) projectID := vVPCHandler.Credential.ProjectID region := vVPCHandler.Region.Region @@ -708,10 +707,10 @@ func (vVPCHandler *GCPVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID cblogger.Info("Delete subnet result :", infoSubnet) //서브넷이 완전히 삭제될때까지 대기 - cblogger.Infof("[%s] Subnet 삭제 성공 - 리소스 ID : [%d]", subnetIID.SystemId, infoSubnet.Id) + cblogger.Infof("[%s] Subnet deletion successful - Resource ID: [%d]", subnetIID.SystemId, infoSubnet.Id) errWait := vVPCHandler.WaitUntilComplete(strconv.FormatUint(infoSubnet.Id, 10), false) if errWait != nil { - cblogger.Errorf("[%s] Subnet 삭제 완료 대기 실패", subnetIID.SystemId) + cblogger.Errorf("[%s] Subnet deletion completion wait failed", subnetIID.SystemId) cblogger.Error(errWait) return false, errWait } diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/TencentDriver.go b/cloud-control-manager/cloud-driver/drivers/tencent/TencentDriver.go index 66f352ab7..330821aa5 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/TencentDriver.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/TencentDriver.go @@ -193,9 +193,6 @@ func (driver *TencentDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) (i // Initialize Logger trs.InitLog() - //fmt.Println("ConnectCloud의 전달 받은 idrv.ConnectionInfo 정보") - //spew.Dump(connectionInfo) - // sample code, do not user like this^^ //var iConn icon.CloudConnection vmClient, err := getVmClient(connectionInfo) diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/ClusterHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/ClusterHandler.go index 264e09885..b59a36f65 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/ClusterHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/ClusterHandler.go @@ -287,7 +287,7 @@ func (clusterHandler *TencentClusterHandler) SetNodeGroupAutoScaling(clusterIID calllogger.Error(call.String(callLogInfo)) return false, err } - cblogger.Info(temp.ToJsonString()) + cblogger.Debug(temp.ToJsonString()) calllogger.Info(call.String(callLogInfo)) return true, nil @@ -326,7 +326,7 @@ func (clusterHandler *TencentClusterHandler) ChangeNodeGroupScaling(clusterIID i calllogger.Error(call.String(callLogInfo)) return irs.NodeGroupInfo{}, err } - cblogger.Info(temp.ToJsonString()) + cblogger.Debug(temp.ToJsonString()) calllogger.Info(call.String(callLogInfo)) node_group_info, err := getNodeGroupInfo(clusterHandler.CredentialInfo.ClientId, clusterHandler.CredentialInfo.ClientSecret, clusterHandler.RegionInfo.Region, clusterIID.SystemId, nodeGroupIID.SystemId) @@ -353,7 +353,7 @@ func (clusterHandler *TencentClusterHandler) RemoveNodeGroup(clusterIID irs.IID, calllogger.Error(call.String(callLogInfo)) return false, err } - cblogger.Info(res.ToJsonString()) + cblogger.Debug(res.ToJsonString()) calllogger.Info(call.String(callLogInfo)) return true, nil @@ -373,7 +373,7 @@ func (clusterHandler *TencentClusterHandler) UpgradeCluster(clusterIID irs.IID, calllogger.Error(call.String(callLogInfo)) return irs.ClusterInfo{}, err } - cblogger.Info(res.ToJsonString()) + cblogger.Debug(res.ToJsonString()) calllogger.Info(call.String(callLogInfo)) clusterInfo, err := getClusterInfo(clusterHandler.CredentialInfo.ClientId, clusterHandler.CredentialInfo.ClientSecret, clusterHandler.RegionInfo.Region, clusterIID.SystemId) @@ -539,7 +539,7 @@ func getClusterAccessInfo(access_key string, access_secret string, region_id str res, err := tencent.GetClusterEndpoint(access_key, access_secret, region_id, cluster_id) if err != nil { if strings.Contains(err.Error(), "CLUSTER_IN_ABNORMAL_STAT") || strings.Contains(err.Error(), "CLUSTER_STATE_ERROR") { - cblogger.Info(cluster_id + err.Error()) + cblogger.Error(cluster_id + err.Error()) accessInfo.Endpoint = "Cluster is not ready yet!" } else { err := fmt.Errorf("Failed to Get Cluster Endpoint: %v", err) @@ -556,10 +556,10 @@ func getClusterAccessInfo(access_key string, access_secret string, region_id str _, err := tencent.CreateClusterEndpoint(access_key, access_secret, region_id, cluster_id, security_group_id) if err != nil { if strings.Contains(err.Error(), "CLUSTER_IN_ABNORMAL_STAT") || strings.Contains(err.Error(), "CLUSTER_STATE_ERROR") { - cblogger.Info(cluster_id + err.Error()) + cblogger.Error(cluster_id + err.Error()) accessInfo.Endpoint = "First, add a nodegroup." } else if strings.Contains(err.Error(), "same type task in execution") { - cblogger.Info(cluster_id + err.Error()) + cblogger.Error(cluster_id + err.Error()) accessInfo.Endpoint = "Preparing...." } else { err := fmt.Errorf("Failed to Create Cluster Endpoint: %v", err) @@ -575,7 +575,7 @@ func getClusterAccessInfo(access_key string, access_secret string, region_id str resKubeconfig, err := tencent.GetClusterKubeconfig(access_key, access_secret, region_id, cluster_id) if err != nil { if strings.Contains(err.Error(), "CLUSTER_IN_ABNORMAL_STAT") || strings.Contains(err.Error(), "CLUSTER_STATE_ERROR") { - cblogger.Info(cluster_id + err.Error()) + cblogger.Error(cluster_id + err.Error()) accessInfo.Kubeconfig = "Cluster is not ready yet!" } else { err := fmt.Errorf("Failed to Get Cluster Kubeconfig: %v", err) diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/CommonTencentFunc.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/CommonTencentFunc.go index 362fd491d..285c962b0 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/CommonTencentFunc.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/CommonTencentFunc.go @@ -120,10 +120,6 @@ func ConvertJsonStringNoEscape(v interface{}) (string, error) { return "", errJson } - //fmt.Println("After marshal", string(buffer.Bytes())) - //spew.Dump(string(buffer.Bytes())) - //spew.Dump("\"TEST") - jsonString := string(buffer.Bytes()) //jsonString = strings.Replace(jsonString, "\n", "", -1) jsonString = strings.Replace(jsonString, "\"", "", -1) @@ -174,7 +170,6 @@ func ConvertToString(value interface{}) (string, error) { // Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용 func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) { - //spew.Dump(v) var keyValueList []irs.KeyValue var i map[string]interface{} @@ -224,8 +219,8 @@ func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) { // array에 주어진 string이 있는지 체크 func ContainString(s []string, str string) bool { for _, v := range s { - cblogger.Info(v + " : " + str) - cblogger.Info(v == str) + cblogger.Debug(v + " : " + str) + cblogger.Debug(v == str) if v == str { return true } diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/DiskHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/DiskHandler.go index e326ed0ad..4e0c20b8f 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/DiskHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/DiskHandler.go @@ -2,7 +2,6 @@ package resources import ( "errors" - "fmt" "strconv" "strings" "time" @@ -45,7 +44,7 @@ func (DiskHandler *TencentDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs // region base이므로 특정 zone을 지정시 해당 zone에 생성. zone := DiskHandler.Region.Zone - if diskReqInfo.Zone != ""{ + if diskReqInfo.Zone != "" { zone = diskReqInfo.Zone } @@ -340,12 +339,12 @@ func validateDisk(diskReqInfo *irs.DiskInfo) error { } if diskSize < diskSizeValue.diskMinSize { - fmt.Println("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be at least the minimum size (" + strconv.FormatInt(diskSizeValue.diskMinSize, 10) + " GB).") } if diskSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be smaller than or equal to the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } @@ -401,7 +400,7 @@ func validateChangeDiskSize(diskInfo irs.DiskInfo, newSize string) error { } if newDiskSize > diskSizeValue.diskMaxSize { - fmt.Println("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) + cblogger.Error("Disk Size Error!!: ", diskSize, diskSizeValue.diskMinSize, diskSizeValue.diskMaxSize) return errors.New("Disk Size must be smaller than or equal to the maximum size (" + strconv.FormatInt(diskSizeValue.diskMaxSize, 10) + " GB).") } diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/ImageHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/ImageHandler.go index c372552ea..b31ddf8bd 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/ImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/ImageHandler.go @@ -30,7 +30,7 @@ type TencentImageHandler struct { // @TODO - 이미지 생성에 따른 구조체 정의 필요 - 현재는 IID뿐이 없어서 이미지 이름으로만 생성하도록 했음.(인스턴스Id가 없어서 에러 발생함.) func (imageHandler *TencentImageHandler) CreateImage(imageReqInfo irs.ImageReqInfo) (irs.ImageInfo, error) { - cblogger.Info(imageReqInfo) + cblogger.Debug(imageReqInfo) callogger := call.GetLogger("HISCALL") callLogInfo := call.CLOUDLOGSCHEMA{ @@ -65,7 +65,7 @@ func (imageHandler *TencentImageHandler) CreateImage(imageReqInfo irs.ImageReqIn cblogger.Error(err) return irs.ImageInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -112,23 +112,23 @@ func (imageHandler *TencentImageHandler) ListImage() ([]*irs.ImageInfo, error) { cblogger.Error(err) return nil, err } - //spew.Dump(response) + //cblogger.Debug(response) //cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) //cnt := 0 for _, curImage := range response.Response.ImageSet { - cblogger.Debugf("[%s] AMI 정보 처리", *curImage.ImageId) + cblogger.Debugf("[%s] AMI information processing", *curImage.ImageId) imageInfo := ExtractImageDescribeInfo(curImage) imageInfoList = append(imageInfoList, &imageInfo) } - //spew.Dump(imageInfoList) + //cblogger.Debug(imageInfoList) return imageInfoList, nil } func ExtractImageDescribeInfo(image *cvm.Image) irs.ImageInfo { - //spew.Dump(image) + //cblogger.Debug(image) imageInfo := irs.ImageInfo{ //IId: irs.IID{*image.Name, *image.ImageId}, IId: irs.IID{NameId: *image.ImageId, SystemId: *image.ImageId}, @@ -181,7 +181,7 @@ func (imageHandler *TencentImageHandler) GetImage(imageIID irs.IID) (irs.ImageIn return irs.ImageInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -189,7 +189,7 @@ func (imageHandler *TencentImageHandler) GetImage(imageIID irs.IID) (irs.ImageIn imageInfo := ExtractImageDescribeInfo(response.Response.ImageSet[0]) return imageInfo, nil } else { - return irs.ImageInfo{}, errors.New("정보를 찾을 수 없습니다") + return irs.ImageInfo{}, errors.New("I couldn't find the information.") } } @@ -222,7 +222,7 @@ func (imageHandler *TencentImageHandler) DeleteImage(imageIID irs.IID) (bool, er cblogger.Error(err) return false, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/KeyPairHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/KeyPairHandler.go index e9fe56d01..e9a14c29c 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/KeyPairHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/KeyPairHandler.go @@ -6,7 +6,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" _ "github.com/davecgh/go-spew/spew" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312" @@ -46,7 +45,7 @@ func (keyPairHandler *TencentKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, erro cblogger.Error(err) return nil, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -55,7 +54,7 @@ func (keyPairHandler *TencentKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, erro if errKeyPair != nil { // 2021-10-27 이슈#480에 의해 Local Key 로직 제거 //cblogger.Infof("[%s] KeyPair는 Local에서 관리하는 대상이 아니기 때문에 Skip합니다.", *pair.KeyName) - cblogger.Info(errKeyPair.Error()) + cblogger.Error(errKeyPair.Error()) //return nil, errKeyPair } else { keyPairList = append(keyPairList, &keyPairInfo) @@ -66,9 +65,9 @@ func (keyPairHandler *TencentKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, erro } // 2021-10-27 이슈#480에 의해 Local Key 로직 제거 -//KeyPair 정보를 추출함 +// KeyPair 정보를 추출함 func ExtractKeyPairDescribeInfo(keyPair *cvm.KeyPair) (irs.KeyPairInfo, error) { - spew.Dump(keyPair) + cblogger.Debug(keyPair) keyPairInfo := irs.KeyPairInfo{ IId: irs.IID{NameId: *keyPair.KeyName, SystemId: *keyPair.KeyId}, //PublicKey: *keyPair.PublicKey, @@ -120,7 +119,7 @@ func ExtractKeyPairDescribeInfo(keyPair *cvm.KeyPair) (irs.KeyPairInfo, error) { } // 2021-10-27 이슈#480에 의해 Local Key 로직 제거 -//KeyPair 생성시 이름은 알파벳, 숫자 또는 밑줄 "_"만 지원 +// KeyPair 생성시 이름은 알파벳, 숫자 또는 밑줄 "_"만 지원 func (keyPairHandler *TencentKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error) { cblogger.Info(keyPairReqInfo) @@ -175,12 +174,12 @@ func (keyPairHandler *TencentKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPai cblogger.Error(err) return irs.KeyPairInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) cblogger.Infof("Created [%s]key pair", *response.Response.KeyPair.KeyName) - //spew.Dump(result) + //cblogger.Debug(result) keyPairInfo := irs.KeyPairInfo{ //Name: *result.KeyName, IId: irs.IID{NameId: keyPairReqInfo.IId.NameId, SystemId: *response.Response.KeyPair.KeyId}, @@ -191,7 +190,7 @@ func (keyPairHandler *TencentKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPai }, } - //spew.Dump(keyPairInfo) + //cblogger.Debug(keyPairInfo) /* 2021-10-27 이슈#480에 의해 Local Key 로직 제거 //============================= @@ -241,7 +240,7 @@ func (keyPairHandler *TencentKeyPairHandler) isExist(chkName string) (bool, erro return false, nil } - cblogger.Infof("SSH Key 정보 찾음 - KeyId:[%s] / KeyName:[%s]", *response.Response.KeyPairSet[0].KeyId, *response.Response.KeyPairSet[0].KeyName) + cblogger.Infof("SSH Key - KeyId:[%s] / KeyName:[%s]", *response.Response.KeyPairSet[0].KeyId, *response.Response.KeyPairSet[0].KeyName) return true, nil } @@ -288,7 +287,7 @@ func (keyPairHandler *TencentKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPair cblogger.Error(err) return irs.KeyPairInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -299,10 +298,10 @@ func (keyPairHandler *TencentKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPair return irs.KeyPairInfo{}, errKeyPair } - //spew.Dump(keyPairInfo) + //cblogger.Debug(keyPairInfo) return keyPairInfo, nil } else { - return irs.KeyPairInfo{}, errors.New("정보를 찾을 수 없습니다.") + return irs.KeyPairInfo{}, errors.New("I couldn't find the information.") } } @@ -328,7 +327,7 @@ func (keyPairHandler *TencentKeyPairHandler) GetLocalKeyId(keyIID irs.IID) (stri // 2021-10-27 이슈#480에 의해 Local Key 로직 제거 func (keyPairHandler *TencentKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error) { - cblogger.Infof("삭제 요청된 키페어 : [%s]", keyIID.SystemId) + cblogger.Infof("Key pair requested for deletion: [%s]", keyIID.SystemId) /* 2021-10-27 이슈#480에 의해 Local Key 로직 제거 keyPairId, errGet := keyPairHandler.GetLocalKeyId(keyIID) @@ -363,7 +362,7 @@ func (keyPairHandler *TencentKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, er cblogger.Error(err) return false, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/MyImageHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/MyImageHandler.go index a3411196a..a68710473 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/MyImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/MyImageHandler.go @@ -7,7 +7,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" //cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312" @@ -113,7 +112,7 @@ func (myImageHandler *TencentMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyIm } calllogger.Info(call.String(hiscallInfo)) - spew.Dump(response) + cblogger.Debug(response) myImageInfo, myImageErr := myImageHandler.GetMyImage(irs.IID{SystemId: *response.Response.ImageId}) if myImageErr != nil { diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/NLBHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/NLBHandler.go index e6ebf2d2c..4f1e89c44 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/NLBHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/NLBHandler.go @@ -2,7 +2,6 @@ package resources import ( "errors" - "fmt" "strconv" "strings" @@ -175,7 +174,7 @@ func (NLBHandler *TencentNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI return irs.NLBInfo{}, listenerErr } - fmt.Printf("%s", listenerResponse.ToJsonString()) + cblogger.Info("%s", listenerResponse.ToJsonString()) newListenerId := *listenerResponse.Response.ListenerIds[0] backendPort, backendErr := strconv.ParseInt(nlbReqInfo.VMGroup.Port, 10, 64) @@ -216,7 +215,7 @@ func (NLBHandler *TencentNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI } return irs.NLBInfo{}, targetErr } - fmt.Printf("%s", targetResponse.ToJsonString()) + cblogger.Info("%s", targetResponse.ToJsonString()) // VM 연결되길 기다림 targetStatus, targetStatErr := NLBHandler.WaitForDone(*targetResponse.Response.RequestId) @@ -238,7 +237,7 @@ func (NLBHandler *TencentNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI callogger.Info(call.String(callLogInfo)) - fmt.Printf("%s", nlbResponse.ToJsonString()) + cblogger.Info("%s", nlbResponse.ToJsonString()) return nlbResult, nil } @@ -281,7 +280,7 @@ func (NLBHandler *TencentNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { var nlbInfoList []*irs.NLBInfo if *response.Response.TotalCount > 0 { for _, curNLB := range response.Response.LoadBalancerSet { - cblogger.Debugf("[%s] NLB 정보 조회 - [%s]", *curNLB.LoadBalancerId, *curNLB.LoadBalancerName) + cblogger.Debugf("[%s] NLB information retrieval - [%s]", *curNLB.LoadBalancerId, *curNLB.LoadBalancerName) nlbInfo, nlbErr := NLBHandler.GetNLB(irs.IID{SystemId: *curNLB.LoadBalancerId}) if nlbErr != nil { @@ -292,7 +291,7 @@ func (NLBHandler *TencentNLBHandler) ListNLB() ([]*irs.NLBInfo, error) { } } - cblogger.Debugf("리턴 결과 목록 수 : [%d]", len(nlbInfoList)) + cblogger.Debugf("Number of returned result items: [%d]", len(nlbInfoList)) return nlbInfoList, nil } @@ -329,7 +328,7 @@ func (NLBHandler *TencentNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) } callogger.Info(call.String(callLogInfo)) - cblogger.Debug("NLB 개수 : ", *response.Response.TotalCount) + cblogger.Debug("NLB Count : ", *response.Response.TotalCount) if *response.Response.TotalCount < 1 { return irs.NLBInfo{}, errors.New("Notfound: '" + nlbIID.SystemId + "' NLB Not found") } @@ -532,7 +531,7 @@ func (NLBHandler *TencentNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) ( if targetErr != nil { return irs.VMGroupInfo{}, targetErr } - fmt.Printf("%s", targetResponse.ToJsonString()) + cblogger.Info("%s", targetResponse.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -608,7 +607,7 @@ func (NLBHandler *TencentNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID if targetErr != nil { return false, targetErr } - fmt.Printf("%s", targetResponse.ToJsonString()) + cblogger.Info("%s", targetResponse.ToJsonString()) callogger.Info(call.String(callLogInfo)) diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/PriceInfoHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/PriceInfoHandler.go index fb812d493..3c850b98b 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/PriceInfoHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/PriceInfoHandler.go @@ -9,7 +9,6 @@ import ( idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312" ) @@ -406,7 +405,7 @@ func mappingProductInfo(regionName string, i interface{}) irs.ProductInfo { // storage 관련 정보 삭제 return productInfo default: - spew.Dump(v) + cblogger.Debug(v) } return irs.ProductInfo{} @@ -476,7 +475,7 @@ func mappingPricingPolicy(instanceChargeType *string, price any) irs.PricingPoli policyInfo.OfferingClass = strPtrNilCheck(nil) default: - //spew.Dump(objType) + //cblogger.Debug(objType) cblogger.Info("Type doesn't match", reflect.TypeOf(price)) } diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/SecurityHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/SecurityHandler.go index 2e5d190f2..526ced2e9 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/SecurityHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/SecurityHandler.go @@ -19,7 +19,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312" ) @@ -99,11 +98,11 @@ func (securityHandler *TencentSecurityHandler) CreateSecurity(securityReqInfo ir callogger.Error(call.String(callLogInfo)) cblogger.Error(err) - spew.Dump(defaultEgressRequest) + cblogger.Debug(defaultEgressRequest) return irs.SecurityInfo{}, err } - //spew.Dump(defaultEgressResponse) + //cblogger.Debug(defaultEgressResponse) cblogger.Debug(defaultEgressResponse.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -148,10 +147,10 @@ func (securityHandler *TencentSecurityHandler) CreateSecurity(securityReqInfo ir callogger.Error(call.String(callLogInfo)) cblogger.Error(err) - spew.Dump(request) + cblogger.Debug(request) return irs.SecurityInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -192,7 +191,7 @@ func (securityHandler *TencentSecurityHandler) ListSecurity() ([]*irs.SecurityIn cblogger.Error(err) return nil, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -263,7 +262,7 @@ func (securityHandler *TencentSecurityHandler) GetSecurity(securityIID irs.IID) cblogger.Error(err) return irs.SecurityInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -295,7 +294,7 @@ func (securityHandler *TencentSecurityHandler) GetSecurityRuleInfo(securityIID i cblogger.Error(err) return nil, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) var securityRuleInfos []irs.SecurityRuleInfo @@ -400,7 +399,7 @@ func (securityHandler *TencentSecurityHandler) DeleteSecurity(securityIID irs.II cblogger.Error(err) return false, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -497,7 +496,7 @@ func (securityHandler *TencentSecurityHandler) AddRules(securityIID irs.IID, req cblogger.Error(err) return irs.SecurityInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(ingressResponse.ToJsonString()) callogger.Info(call.String(callLogInfo)) } @@ -519,7 +518,7 @@ func (securityHandler *TencentSecurityHandler) AddRules(securityIID irs.IID, req cblogger.Error(err) return irs.SecurityInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(egressResponse.ToJsonString()) callogger.Info(call.String(callLogInfo)) } @@ -608,7 +607,7 @@ func (securityHandler *TencentSecurityHandler) RemoveRules(securityIID irs.IID, cblogger.Error(err) return false, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(ingressResponse.ToJsonString()) callogger.Info(call.String(callLogInfo)) } @@ -629,7 +628,7 @@ func (securityHandler *TencentSecurityHandler) RemoveRules(securityIID irs.IID, cblogger.Error(err) return false, err } - //spew.Dump(response) + //cblogger.Debug(response) cblogger.Debug(egressResponse.ToJsonString()) callogger.Info(call.String(callLogInfo)) } @@ -686,7 +685,7 @@ func sameRulesCheck(presentSecurityRules *[]irs.SecurityRuleInfo, reqSecurityRul } if action == Add { - cblogger.Info("add") + cblogger.Debug("add") checkResult = append(checkResult, reqRule) } hasFound = true diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMHandler.go index 9f259157d..705f7e829 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMHandler.go @@ -7,7 +7,6 @@ package resources import ( "encoding/base64" "errors" - "fmt" "io/ioutil" "os" "reflect" @@ -33,8 +32,9 @@ type TencentVMHandler struct { Region idrv.RegionInfo Client *cvm.Client DiskClient *tencentcbs.Client - VPCClient *tencentvpc.Client + VPCClient *tencentvpc.Client } + //Client *vpc.Client //type TencentCbsHandler struct { @@ -70,7 +70,7 @@ type TencentVMHandler struct { // VM생성 시 Zone이 필수라서 Credential의 Zone에만 생성함. func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error) { - cblogger.Info(vmReqInfo) + cblogger.Debug(vmReqInfo) zoneId := vmHandler.Region.Zone vpcHandler := TencentVPCHandler{ @@ -194,14 +194,14 @@ func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, //============================= // 보안그룹 처리 - SystemId 기반 //============================= - cblogger.Debug("SystemId 기반으로 처리하기 위해 IID 기반의 보안그룹 배열을 SystemId 기반 보안그룹 배열로 조회및 변환함.") + cblogger.Debug("Retrieving and converting IID-based security group arrays to SystemId-based security group arrays for processing based on SystemId.") var newSecurityGroupIds []string for _, curSecurityGroup := range vmReqInfo.SecurityGroupIIDs { - cblogger.Debugf("보안그룹 변환 : [%s]", curSecurityGroup) + cblogger.Debugf("Security group conversion: [%s]", curSecurityGroup) newSecurityGroupIds = append(newSecurityGroupIds, curSecurityGroup.SystemId) } - cblogger.Debug("보안그룹 변환 완료") + cblogger.Debug("Security group conversion complete") cblogger.Debug(newSecurityGroupIds) request.SecurityGroupIds = common.StringPtrs(newSecurityGroupIds) @@ -239,7 +239,7 @@ func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, //cloudOSMetaInfo, err := cim.GetCloudOSMetaInfo("TENCENT") // cloudos_meta 에 DiskType, min, max 값 정의 되어있음. //arrDiskSizeOfType := cloudOSMetaInfo.RootDiskSize // - //fmt.Println("arrDiskSizeOfType: ", arrDiskSizeOfType) + //cblogger.Info("arrDiskSizeOfType: ", arrDiskSizeOfType) // //if vmReqInfo.RootDiskType == "" || strings.EqualFold(vmReqInfo.RootDiskType, "default") { @@ -267,7 +267,7 @@ func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, // isExists := false // for idx, _ := range arrDiskSizeOfType { // diskSizeArr := strings.Split(arrDiskSizeOfType[idx], "|") - // fmt.Println("diskSizeArr: ", diskSizeArr) + // cblogger.Info(mt.Println("diskSizeArr: ", diskSizeArr) // // if strings.EqualFold(vmReqInfo.RootDiskType, diskSizeArr[0]) { // diskSizeValue.diskType = diskSizeArr[0] @@ -311,15 +311,15 @@ func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, } imageSize := *imageInfo.ImageSize - fmt.Println("image : ", imageSize) + cblogger.Info("image : ", imageSize) if rootDiskSize < imageSize { - fmt.Println("Disk Size Error!!: ", rootDiskSize, imageSize) + cblogger.Error("Disk Size Error!!: ", rootDiskSize, imageSize) return irs.VMInfo{}, errors.New("Root Disk Size must be larger then the image size (" + strconv.FormatInt(imageSize, 10) + " GB).") } - fmt.Println("rootDiskSize : ", rootDiskSize) - fmt.Println("rootDiskSize : ", common.Int64Ptr(rootDiskSize)) + cblogger.Info("rootDiskSize : ", rootDiskSize) + cblogger.Info("rootDiskSize : ", common.Int64Ptr(rootDiskSize)) request.SystemDisk.DiskSize = common.Int64Ptr(rootDiskSize) cblogger.Debug("request.SystemDisk.DiskSize ", request.SystemDisk.DiskSize) @@ -336,7 +336,7 @@ func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, dataDisk.SnapshotId = snapshot.SnapshotId dataDisk.DiskSize = snapshot.DiskSize dataDiskList = append(dataDiskList, &dataDisk) - cblogger.Info("Image에 DataDisk 포함 되어 있음. ") + cblogger.Info("The Image includes a DataDisk.") } } request.DataDisks = dataDiskList @@ -359,7 +359,9 @@ func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, request.UserData = common.StringPtr(userDataBase64) cblogger.Debug("===== Request object====") - spew.Config.Dump(request) + if cblogger.Level.String() == "debug" { + spew.Config.Dump(request) + } callLogStart := call.Start() response, err := vmHandler.Client.RunInstances(request) callLogInfo.ElapsedTime = call.Elapsed(callLogStart) @@ -371,7 +373,9 @@ func (vmHandler *TencentVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, cblogger.Error(err) return irs.VMInfo{}, err } - spew.Dump(response) + if cblogger.Level.String() == "debug" { + cblogger.Debug(response) + } callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -469,7 +473,6 @@ func (vmHandler *TencentVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error cblogger.Error(err) return irs.VMStatus("Failed"), err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -513,7 +516,6 @@ func (vmHandler *TencentVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error) cblogger.Error(err) return irs.VMStatus("Failed"), err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -554,7 +556,6 @@ func (vmHandler *TencentVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error) cblogger.Error(err) return irs.VMStatus("Failed"), err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) } else if curStatus == "Suspended" { @@ -601,7 +602,6 @@ func (vmHandler *TencentVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, err cblogger.Error(err) return irs.VMStatus("Failed"), err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -637,7 +637,6 @@ func (vmHandler *TencentVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) { return irs.VMInfo{}, err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -652,7 +651,6 @@ func (vmHandler *TencentVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) { func (vmHandler *TencentVMHandler) ExtractDescribeInstances(curVm *cvm.Instance) (irs.VMInfo, error) { //cblogger.Info("ExtractDescribeInstances", curVm) - //spew.Dump(curVm) //VM상태와 무관하게 항상 값이 존재하는 항목들만 초기화 vmInfo := irs.VMInfo{ @@ -837,7 +835,6 @@ func (vmHandler *TencentVMHandler) ListVM() ([]*irs.VMInfo, error) { return nil, err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -878,7 +875,6 @@ func (vmHandler *TencentVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, err cblogger.Error(err) return irs.VMStatus("Failed"), err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -919,7 +915,6 @@ func (vmHandler *TencentVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error) { cblogger.Error(err) return nil, err } - //spew.Dump(response) callogger.Info(call.String(callLogInfo)) cblogger.Debug(response.ToJsonString()) @@ -970,7 +965,7 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) { } else { //resultStatus = "Failed" cblogger.Debugf("Mapping information matching vmStatus [%s] not found.", vmStatus) - return irs.VMStatus("Failed"), errors.New(vmStatus + "와 일치하는 CB VM 상태정보를 찾을 수 없습니다.") + return irs.VMStatus("Failed"), errors.New("Cannot find CB VM status information matching " + vmStatus) } cblogger.Infof("VM 상태 치환 : [%s] ==> [%s]", vmStatus, resultStatus) return irs.VMStatus(resultStatus), nil @@ -978,7 +973,7 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) { // VM 정보를 조회할 수 있을 때까지 최대 30초간 대기 func (vmHandler *TencentVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error) { - cblogger.Info("======> VM 생성 직후에는 Public IP등 일부 정보 조회가 안되기 때문에 Running 될 때까지 대기함.") + cblogger.Info("======> Waiting until Running status is reached as some information, such as Public IP, cannot be retrieved immediately after VM creation.") //waitStatus := "NotExist" //VM정보 조회가 안됨. waitStatus := "Running" @@ -1102,7 +1097,6 @@ Lighthouse API가 있으나 ClientInterface 부분 처리 방법 필요 // cblogger.Error(err) // return nil, err // } -// //spew.Dump(response) // callogger.Info(call.String(callLogInfo)) // cblogger.Debug(response.ToJsonString()) // @@ -1153,7 +1147,6 @@ Lighthouse API가 있으나 ClientInterface 부분 처리 방법 필요 // cblogger.Error(err) // return nil, err // } -// //spew.Dump(response) // callogger.Info(call.String(callLogInfo)) // cblogger.Debug(response.ToJsonString()) // // diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMSpecHandler.go index f2728e8b8..496c689b5 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/VMSpecHandler.go @@ -59,7 +59,7 @@ func (vmSpecHandler *TencentVmSpecHandler) ListVMSpec() ([]*irs.VMSpecInfo, erro return nil, err } - //spew.Dump(response) + //cblogger.Debug(response) //cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -72,7 +72,7 @@ func (vmSpecHandler *TencentVmSpecHandler) ListVMSpec() ([]*irs.VMSpecInfo, erro } cblogger.Debug(vmSpecInfoList) - //spew.Dump(vmSpecInfoList) + //cblogger.Debug(vmSpecInfoList) return vmSpecInfoList, nil } @@ -122,7 +122,7 @@ func (vmSpecHandler *TencentVmSpecHandler) GetVMSpec(Name string) (irs.VMSpecInf return irs.VMSpecInfo{}, err } - //spew.Dump(response) + //cblogger.Debug(response) //cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -176,7 +176,7 @@ func (vmSpecHandler *TencentVmSpecHandler) ListOrgVMSpec() (string, error) { return "", err } - //spew.Dump(response) + //cblogger.Debug(response) // cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -235,7 +235,7 @@ func (vmSpecHandler *TencentVmSpecHandler) GetOrgVMSpec(Name string) (string, er return "", err } - //spew.Dump(response) + //cblogger.Debug(response) //cblogger.Debug(response.ToJsonString()) callogger.Info(call.String(callLogInfo)) @@ -257,7 +257,7 @@ func (vmSpecHandler *TencentVmSpecHandler) GetOrgVMSpec(Name string) (string, er // 인스턴스 스펙 정보를 추출함 func ExtractVMSpecInfo(instanceTypeInfo *cvm.InstanceTypeConfig) irs.VMSpecInfo { cblogger.Debugf("ExtractVMSpecInfo : SpecName:[%s]", *instanceTypeInfo.InstanceType) - //spew.Dump(instanceTypeInfo) + //cblogger.Debug(instanceTypeInfo) vCpuInfo := irs.VCpuInfo{} // gpuInfoList := []irs.GpuInfo{} diff --git a/cloud-control-manager/cloud-driver/drivers/tencent/resources/VPCHandler.go b/cloud-control-manager/cloud-driver/drivers/tencent/resources/VPCHandler.go index 0e1259bcb..c28147159 100644 --- a/cloud-control-manager/cloud-driver/drivers/tencent/resources/VPCHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/tencent/resources/VPCHandler.go @@ -17,8 +17,6 @@ import ( call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces" irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "github.com/davecgh/go-spew/spew" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312" ) @@ -29,7 +27,7 @@ type TencentVPCHandler struct { } func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error) { - cblogger.Info(vpcReqInfo) + cblogger.Debug(vpcReqInfo) //================================================= // 동일 이름 생성 방지 추가(cb-spider 요청 필수 기능) @@ -43,7 +41,7 @@ func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.V return irs.VPCInfo{}, errors.New("A VPC with the name " + vpcReqInfo.IId.NameId + " already exists.") } - zoneId := VPCHandler.Region.Zone// default + zoneId := VPCHandler.Region.Zone // default cblogger.Infof("Zone : %s", zoneId) // if zoneId == "" { // vpc 자체는 region dependency임. // cblogger.Error("Connection information does not contain Zone information.") @@ -74,7 +72,7 @@ func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.V callLogInfo.ElapsedTime = call.Elapsed(callLogStart) cblogger.Debug(response.ToJsonString()) - //spew.Dump(result) + //cblogger.Debug(result) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Error(call.String(callLogInfo)) @@ -94,12 +92,12 @@ func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.V requestSubnet.Subnets = []*vpc.SubnetInput{} for _, curSubnet := range vpcReqInfo.SubnetInfoList { - cblogger.Infof("[%s] Subnet 처리", curSubnet.IId.NameId) + cblogger.Infof("[%s] Subnet processing", curSubnet.IId.NameId) subnetZoneId := zoneId if curSubnet.Zone != "" { subnetZoneId = curSubnet.Zone } - + reqSubnet := &vpc.SubnetInput{ CidrBlock: common.StringPtr(curSubnet.IPv4_CIDR), SubnetName: common.StringPtr(curSubnet.IId.NameId), @@ -111,7 +109,7 @@ func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.V responseSubnet, errSubnet := VPCHandler.Client.CreateSubnets(requestSubnet) cblogger.Debug(responseSubnet.ToJsonString()) - //spew.Dump(responseSubnet) + //cblogger.Debug(responseSubnet) if errSubnet != nil { cblogger.Error(errSubnet) return irs.VPCInfo{}, errSubnet @@ -132,7 +130,7 @@ func (VPCHandler *TencentVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.V // VPC 정보를 추출함 func ExtractVpcDescribeInfo(vpcInfo *vpc.Vpc) irs.VPCInfo { // cblogger.Debug("전달 받은 내용") - // spew.Dump(vpcInfo) + // cblogger.Debug(vpcInfo) resVpcInfo := irs.VPCInfo{ //NameId는 사용되지 않기 때문에 전달할 필요가 없지만 Tencent는 Name도 필수로 들어가니 전달함. IId: irs.IID{SystemId: *vpcInfo.VpcId, NameId: *vpcInfo.VpcName}, @@ -163,7 +161,7 @@ func (VPCHandler *TencentVPCHandler) ListVPC() ([]*irs.VPCInfo, error) { callLogInfo.ElapsedTime = call.Elapsed(callLogStart) cblogger.Debug(response.ToJsonString()) - //spew.Dump(result) + //cblogger.Debug(result) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Error(call.String(callLogInfo)) @@ -172,15 +170,15 @@ func (VPCHandler *TencentVPCHandler) ListVPC() ([]*irs.VPCInfo, error) { } callogger.Info(call.String(callLogInfo)) - cblogger.Info("VPC 개수 : ", *response.Response.TotalCount) + cblogger.Info("VPC Count : ", *response.Response.TotalCount) var vpcInfoList []*irs.VPCInfo if *response.Response.TotalCount > 0 { for _, curVpc := range response.Response.VpcSet { - cblogger.Debugf("[%s] VPC 정보 조회 - [%s]", *curVpc.VpcId, *curVpc.VpcName) + cblogger.Debugf("[%s] VPC Infomation reteive - [%s]", *curVpc.VpcId, *curVpc.VpcName) vpcInfo, vpcErr := VPCHandler.GetVPC(irs.IID{SystemId: *curVpc.VpcId}) // cblogger.Info("==>조회 결과") - // spew.Dump(vpcInfo) + // cblogger.Debug(vpcInfo) if vpcErr != nil { cblogger.Error(vpcErr) return nil, vpcErr @@ -190,7 +188,7 @@ func (VPCHandler *TencentVPCHandler) ListVPC() ([]*irs.VPCInfo, error) { } cblogger.Debugf("Number of Return Results List : [%d]", len(vpcInfoList)) - // spew.Dump(vpcInfoList) + // cblogger.Debug(vpcInfoList) return vpcInfoList, nil } @@ -335,7 +333,7 @@ func (VPCHandler *TencentVPCHandler) ListSubnet(reqVpcId string) ([]irs.SubnetIn // callLogInfo.ElapsedTime = call.Elapsed(callLogStart) //cblogger.Debug(response.ToJsonString()) - spew.Dump(response) + cblogger.Debug(response) if err != nil { // callLogInfo.ErrorMSG = err.Error() // callogger.Error(call.String(callLogInfo)) @@ -377,10 +375,10 @@ func (VPCHandler *TencentVPCHandler) isExistSubnet(reqSubnetNameId string) (bool }, } - //spew.Dump(request) + //cblogger.Debug(request) response, err := VPCHandler.Client.DescribeSubnets(request) //cblogger.Debug("서브넷 실행 결과") - //spew.Dump(response) + //cblogger.Debug(response) if err != nil { cblogger.Error(err) return false, err @@ -448,7 +446,7 @@ func (VPCHandler *TencentVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.Su callLogInfo.ElapsedTime = call.Elapsed(callLogStart) cblogger.Debug(response.ToJsonString()) - spew.Dump(response) + cblogger.Debug(response) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Error(call.String(callLogInfo)) @@ -491,7 +489,7 @@ func (VPCHandler *TencentVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs. callLogInfo.ElapsedTime = call.Elapsed(callLogStart) cblogger.Debug(response.ToJsonString()) - //spew.Dump(response) + //cblogger.Debug(response) if err != nil { callLogInfo.ErrorMSG = err.Error() callogger.Error(call.String(callLogInfo))