Skip to content

Commit

Permalink
Merge pull request #1222 from MZC-CSC/master
Browse files Browse the repository at this point in the history
[AWS] Resolve Issue : Remove Print Statements and Check Log Level #1207
  • Loading branch information
powerkimhub authored Jul 3, 2024
2 parents 1e67965 + ab9597f commit 3742942
Show file tree
Hide file tree
Showing 22 changed files with 218 additions and 402 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/davecgh/go-spew/spew"
"reflect"
"strconv"
"sync"
Expand Down Expand Up @@ -203,9 +202,7 @@ func ConvertToString(value interface{}) (string, error) {

// Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용
func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error) {
if cblogger.Level.String() == "debug" {
spew.Dump(v)
}
cblogger.Debug(v)

var keyValueList []irs.KeyValue
var i map[string]interface{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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"
)

//// Alibaba API 1:1로 대응
Expand Down Expand Up @@ -70,7 +69,7 @@ func DescribeDisks(client *ecs.Client, regionInfo idrv.RegionInfo, instanceIID i
for {
result, err := client.DescribeDisks(request)
callLogInfo.ElapsedTime = call.Elapsed(callLogStart)
//spew.Dump(result) //출력 정보가 너무 많아서 생략
//cblogger.Debug(result) //출력 정보가 너무 많아서 생략
if err != nil {
callLogInfo.ErrorMSG = err.Error()
callogger.Error(call.String(callLogInfo))
Expand All @@ -94,9 +93,8 @@ func DescribeDisks(client *ecs.Client, regionInfo idrv.RegionInfo, instanceIID i
}
}

if cblogger.Level.String() == "debug" {
spew.Dump(resultDiskList)
}
cblogger.Debug(resultDiskList)

return resultDiskList, nil
}

Expand Down Expand Up @@ -188,13 +186,13 @@ func DescribeAvailableResource(client *ecs.Client, regionId string, zoneId strin
request.DedicatedHostId = categoryValue
}
//request.DataDiskCategory = "cloud"
//spew.Dump(request)
//cblogger.Debug(request)
result, err := client.DescribeAvailableResource(request)
cblogger.Debug(result)
if err != nil {
cblogger.Errorf("DescribeAvailableResource %v.", err)
}
//spew.Dump(result)
//cblogger.Debug(result)

metaValue := reflect.ValueOf(result).Elem()
fieldAvailableZones := metaValue.FieldByName("AvailableZones")
Expand Down Expand Up @@ -367,13 +365,13 @@ func DescribeImages(client *ecs.Client, regionInfo idrv.RegionInfo, imageIIDs []
if isMyImage {
request.ImageOwnerAlias = "self"
}
//spew.Dump(request)
//cblogger.Debug(request)
result, err := client.DescribeImages(request)
if err != nil {
return nil, err
}

//spew.Dump(result)
//cblogger.Debug(result)
return result.Images.Image, nil
}

Expand Down Expand Up @@ -437,7 +435,7 @@ func DescribeImageStatus(client *ecs.Client, regionInfo idrv.RegionInfo, myImage
if len(result.Images.Image) == 0 { // return을 empty string 으로 할까?
return ALIBABA_IMAGE_STATE_ERROR, errors.New("no result")
}
//spew.Dump(result)
//cblogger.Debug(result)
return result.Images.Image[0].Status, nil
}

Expand Down Expand Up @@ -494,11 +492,11 @@ func WaitForImageStatus(client *ecs.Client, regionInfo idrv.RegionInfo, imageIID
}

curRetryCnt++
cblogger.Errorf("MyImage의 상태가 [%s]이 아니라서 1초 대기후 조회합니다. 현재 [%s]", targetStatus, aliImageState)
cblogger.Debugf("Since the state of MyImage is not [%s], we will wait for 1 second and then check again. The current state is [%s].", targetStatus, aliImageState)
time.Sleep(time.Second * 1)
if curRetryCnt > maxRetryCnt {
cblogger.Errorf("장시간(%d 초) 대기해도 MyImage의 Status 값이 [%s]으로 변경되지 않아서 강제로 중단합니다.", maxRetryCnt, targetStatus)
return irs.MyImageStatus(failStatus), errors.New("장시간 기다렸으나 생성된 MyImage의 상태가 [" + string(targetStatus) + "]으로 바뀌지 않아서 중단 합니다.")
cblogger.Errorf("Even after waiting for a long time (%d seconds), the status of MyImage did not change to [%s], so we are forcibly terminating it.", maxRetryCnt, targetStatus)
return irs.MyImageStatus(failStatus), errors.New("After waiting for a long time, the status of the created MyImage did not change to [" + string(targetStatus) + "], so we are terminating it.")
}
}
return irs.MyImageStatus(resultImageState), nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (diskHandler *AlibabaDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs
},
}

//spew.Dump(request)
//cblogger.Debug(request)
// Creates a new custom Image with the given name
result, err := diskHandler.Client.CreateDisk(request)
hiscallInfo.ElapsedTime = call.Elapsed(start)
Expand All @@ -92,7 +92,7 @@ func (diskHandler *AlibabaDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs
calllogger.Info(call.String(hiscallInfo))

cblogger.Infof("Created Disk %q %s\n %s\n", result.DiskId, diskReqInfo.IId.NameId, result.RequestId)
//spew.Dump(result)
//cblogger.Debug(result)

// 생성된 Disk 정보 획득 후, Image 정보 리턴
diskInfo, err := diskHandler.GetDisk(irs.IID{SystemId: result.DiskId})
Expand Down Expand Up @@ -151,10 +151,10 @@ func (diskHandler *AlibabaDiskHandler) ListDisk() ([]*irs.DiskInfo, error) {
//var totalCount = 0
//curPage := CBPageNumber
//for {
// spew.Dump(request)
// cblogger.Debug(request)
// result, err := diskHandler.Client.DescribeDisks(request)
// callLogInfo.ElapsedTime = call.Elapsed(callLogStart)
// //spew.Dump(result) //출력 정보가 너무 많아서 생략
// //cblogger.Debug(result) //출력 정보가 너무 많아서 생략
// if err != nil {
// callLogInfo.ErrorMSG = err.Error()
// callogger.Error(call.String(callLogInfo))
Expand Down Expand Up @@ -186,7 +186,7 @@ func (diskHandler *AlibabaDiskHandler) ListDisk() ([]*irs.DiskInfo, error) {
// break
// }
//}
//spew.Dump(imageInfoList)
//cblogger.Debug(imageInfoList)

for _, aliDisk := range aliDiskInfoList {
diskInfo, err := ExtractDiskDescribeInfo(&aliDisk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 AlibabaImageHandler struct {
Expand Down Expand Up @@ -104,7 +103,7 @@ func (imageHandler *AlibabaImageHandler) CreateImage(imageReqInfo irs.ImageReqIn
callogger.Info(call.String(callLogInfo))

cblogger.Infof("Created Image %q %s\n %s\n", result.ImageId, imageReqInfo.IId.NameId, result.RequestId)
spew.Dump(result)
cblogger.Debug(result)

/*
ImageInfo := irs.ImageInfo{
Expand Down Expand Up @@ -155,7 +154,7 @@ func (imageHandler *AlibabaImageHandler) ListImage() ([]*irs.ImageInfo, error) {
for {
result, err := imageHandler.Client.DescribeImages(request)
callLogInfo.ElapsedTime = call.Elapsed(callLogStart)
//spew.Dump(result) //출력 정보가 너무 많아서 생략
//cblogger.Debug(result) //출력 정보가 너무 많아서 생략
if err != nil {
callLogInfo.ErrorMSG = err.Error()
callogger.Error(call.String(callLogInfo))
Expand Down Expand Up @@ -184,7 +183,7 @@ func (imageHandler *AlibabaImageHandler) ListImage() ([]*irs.ImageInfo, error) {
break
}
}
//spew.Dump(imageInfoList)
//cblogger.Debug(imageInfoList)
return imageInfoList, nil
}

Expand All @@ -197,10 +196,8 @@ func ExtractImageDescribeInfo(image *ecs.Image) irs.ImageInfo {
//@TODO : 2020-04-20 ecs.ImageInDescribeImages를 인식 못해서 다시 ecs.Image로 변경해 놓음.
//func ExtractImageDescribeInfo(image *ecs.Image) irs.ImageInfo {
//*ecs.DescribeImagesResponse
if cblogger.Level.String() == "debug" {
cblogger.Debug("=====> ")
spew.Dump(image)
}
cblogger.Debug(image)

imageInfo := irs.ImageInfo{
IId: irs.IID{NameId: image.ImageId, SystemId: image.ImageId},
//Name: image.ImageName,
Expand Down Expand Up @@ -262,7 +259,7 @@ func (imageHandler *AlibabaImageHandler) GetImage(imageIID irs.IID) (irs.ImageIn
// callLogInfo.ElapsedTime = call.Elapsed(callLogStart)

// //ecs.DescribeImagesResponse.Images.Image
// //spew.Dump(result)
// //cblogger.Debug(result)
// cblogger.Info(result)
// if err != nil {
// callLogInfo.ErrorMSG = err.Error()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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 AlibabaKeyPairHandler struct {
Expand All @@ -31,7 +30,7 @@ type AlibabaKeyPairHandler struct {
func (keyPairHandler *AlibabaKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error) {
cblogger.Debug("Start ListKey()")
var keyPairList []*irs.KeyPairInfo
//spew.Dump(keyPairHandler)
//cblogger.Debug(keyPairHandler)
cblogger.Debug(keyPairHandler)

request := ecs.CreateDescribeKeyPairsRequest()
Expand Down Expand Up @@ -92,7 +91,7 @@ func (keyPairHandler *AlibabaKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, erro
request.PageNumber = requests.NewInteger(curPage)
}
cblogger.Debug(keyPairList)
//spew.Dump(keyPairList)
//cblogger.Debug(keyPairList)
return keyPairList, nil
}

Expand Down Expand Up @@ -143,9 +142,7 @@ 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)
if cblogger.Level.String() == "debug" {
spew.Dump(result)
}
cblogger.Debug(result)

/* 2021-10-27 이슈#480에 의해 Local Key 로직 제거
cblogger.Info("공개키 생성")
Expand All @@ -156,7 +153,7 @@ func (keyPairHandler *AlibabaKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPai
}
cblogger.Infof("Public Key")
spew.Dump(publicKey)
cblogger.Debug(publicKey)
*/
keyPairInfo := irs.KeyPairInfo{
IId: irs.IID{NameId: result.KeyPairName, SystemId: result.KeyPairName},
Expand Down Expand Up @@ -256,7 +253,6 @@ func (keyPairHandler *AlibabaKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPair
// 2021-10-27 이슈#480에 의해 Local Key 로직 제거
// KeyPair 정보를 추출함
func ExtractKeyPairDescribeInfo(keyPair *ecs.KeyPair) (irs.KeyPairInfo, error) {
spew.Dump(keyPair)

keyPairInfo := irs.KeyPairInfo{
IId: irs.IID{NameId: keyPair.KeyPairName, SystemId: keyPair.KeyPairName},
Expand Down Expand Up @@ -317,7 +313,7 @@ func (keyPairHandler *AlibabaKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, er
request.Scheme = "https"
request.KeyPairNames = "[" + "\"" + keyIID.SystemId + "\"]"

spew.Dump(request)
cblogger.Debug(request)

// logger for HisCall
callogger := call.GetLogger("HISCALL")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (myImageHandler AlibabaMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyIma
},
}

//spew.Dump(request)
//cblogger.Debug(request)
result, err := myImageHandler.Client.CreateImage(request)
hiscallInfo.ElapsedTime = call.Elapsed(start)
if err != nil {
Expand Down Expand Up @@ -120,7 +120,7 @@ func (myImageHandler AlibabaMyImageHandler) ListMyImage() ([]*irs.MyImageInfo, e
myImageInfoList = append(myImageInfoList, &myImageInfo)
}
}
//spew.Dump(myImageInfoList)
//cblogger.Debug(myImageInfoList)
return myImageInfoList, err
}

Expand Down Expand Up @@ -182,7 +182,7 @@ func (myImageHandler AlibabaMyImageHandler) DeleteMyImage(myImageIID irs.IID) (b
request.RegionId = myImageHandler.Region.Region
request.ImageId = myImageIID.SystemId

//spew.Dump(request)
//cblogger.Debug(request)
response, err := myImageHandler.Client.DeleteImage(request)
hiscallInfo.ElapsedTime = call.Elapsed(start)
if err != nil {
Expand Down Expand Up @@ -230,7 +230,7 @@ func (myImageHandler AlibabaMyImageHandler) DeleteMyImage(myImageIID irs.IID) (b
cblogger.Info("SnapShot deleted ", result, snapShotId)
}

//spew.Dump(response)
//cblogger.Debug(response)
return true, err
}

Expand Down Expand Up @@ -363,7 +363,7 @@ func (myImageHandler *AlibabaMyImageHandler) DeleteSnapshotBySnapshotID(snapshot

// snapshot disk도 삭제

//spew.Dump(response)
//cblogger.Debug(response)

return true, err
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (NLBHandler *AlibabaNLBHandler) ListNLB() ([]*irs.NLBInfo, error) {

result, err := NLBHandler.Client.DescribeLoadBalancers(request)
callLogInfo.ElapsedTime = call.Elapsed(callLogStart)
//spew.Dump(result)
//cblogger.Debug(result)
if err != nil {
callLogInfo.ErrorMSG = err.Error()
callogger.Info(call.String(callLogInfo))
Expand All @@ -224,7 +224,7 @@ func (NLBHandler *AlibabaNLBHandler) ListNLB() ([]*irs.NLBInfo, error) {
}

cblogger.Debug(result)
//spew.Dump(vpcInfoList)
//cblogger.Debug(vpcInfoList)
return nlbInfoList, nil
}
func (NLBHandler *AlibabaNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error) {
Expand Down
Loading

0 comments on commit 3742942

Please sign in to comment.