Skip to content

Commit

Permalink
Merge pull request #1380 from innodreamer/master
Browse files Browse the repository at this point in the history
VM Subnet Zone info. is managed as a global variable. and Modify the first letter of some functions' name as a lowercase.
  • Loading branch information
powerkimhub authored Nov 1, 2024
2 parents 7f9f34b + 14ab3d6 commit 22b9083
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (diskHandler *NcpDiskHandler) ListDisk() ([]*irs.DiskInfo, error) {
RegionInfo: diskHandler.RegionInfo,
VMClient: diskHandler.VMClient,
}
zoneNo, err := vmHandler.GetZoneNo(diskHandler.RegionInfo.Region, diskHandler.RegionInfo.Zone) // Region/Zone info of diskHandler
zoneNo, err := vmHandler.getZoneNo(diskHandler.RegionInfo.Region, diskHandler.RegionInfo.Zone) // Region/Zone info of diskHandler
if err != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get NCP Zone No of the Zone Code : ", err)
return nil, rtnErr
Expand Down Expand Up @@ -465,7 +465,7 @@ func (diskHandler *NcpDiskHandler) GetNcpDiskInfo(diskIID irs.IID) (*server.Bloc
RegionInfo: diskHandler.RegionInfo,
VMClient: diskHandler.VMClient,
}
zoneNo, err := vmHandler.GetZoneNo(diskHandler.RegionInfo.Region, diskHandler.RegionInfo.Zone) // Region/Zone info of diskHandler
zoneNo, err := vmHandler.getZoneNo(diskHandler.RegionInfo.Region, diskHandler.RegionInfo.Zone) // Region/Zone info of diskHandler
if err != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get NCP Zone No of the Zone Code : ", err)
return nil, rtnErr
Expand Down Expand Up @@ -660,14 +660,14 @@ func (diskHandler *NcpDiskHandler) MappingDiskInfo(storage server.BlockStorageIn
var ncpVMInfo *server.ServerInstance
vmErr := errors.New("")
if strings.EqualFold(vmHandler.RegionInfo.Zone, subnetZone){ // Not diskHandler.RegionInfo.Zone
ncpVMInfo, vmErr = vmHandler.GetNcpVMInfo(ncloud.StringValue(storage.ServerInstanceNo))
ncpVMInfo, vmErr = vmHandler.getNcpVMInfo(ncloud.StringValue(storage.ServerInstanceNo))
if vmErr != nil {
newErr := fmt.Errorf("Failed to Get the VM Info of the Zone : [%s], [%v]", subnetZone, vmErr)
cblogger.Error(newErr.Error())
return irs.DiskInfo{}, newErr
}
} else {
ncpVMInfo, vmErr = vmHandler.GetNcpTargetZoneVMInfo(storage.ServerInstanceNo)
ncpVMInfo, vmErr = vmHandler.getNcpTargetZoneVMInfo(storage.ServerInstanceNo)
if vmErr != nil {
newErr := fmt.Errorf("Failed to Get the VM Info of the Zone : [%s], [%v]", subnetZone, vmErr)
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -726,12 +726,12 @@ func (diskHandler *NcpDiskHandler) GetNcpVMList() ([]*server.ServerInstance, err
RegionInfo: diskHandler.RegionInfo,
VMClient: diskHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(diskHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(diskHandler.RegionInfo.Region)
if err != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get NCP Region No of the Region Code : ", err)
return nil, rtnErr
}
zoneNo, err := vmHandler.GetZoneNo(diskHandler.RegionInfo.Region, diskHandler.RegionInfo.Zone) // Region/Zone info of diskHandler
zoneNo, err := vmHandler.getZoneNo(diskHandler.RegionInfo.Region, diskHandler.RegionInfo.Zone) // Region/Zone info of diskHandler
if err != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get NCP Zone No of the Zone Code : ", err)
return nil, rtnErr
Expand Down Expand Up @@ -765,12 +765,12 @@ func (diskHandler *NcpDiskHandler) GetNcpVMListWithZone(reqZoneId string) ([]*se
RegionInfo: diskHandler.RegionInfo,
VMClient: diskHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(diskHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(diskHandler.RegionInfo.Region)
if err != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get NCP Region No of the Region Code : ", err)
return nil, rtnErr
}
reqZoneNo, err := vmHandler.GetZoneNo(diskHandler.RegionInfo.Region, reqZoneId) // Not diskHandler.RegionInfo.Zone
reqZoneNo, err := vmHandler.getZoneNo(diskHandler.RegionInfo.Region, reqZoneId) // Not diskHandler.RegionInfo.Zone
if err != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get NCP Zone No of the Zone Code : ", err)
return nil, rtnErr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (imageHandler *NcpImageHandler) ListImage() ([]*irs.ImageInfo, error) {
RegionInfo: imageHandler.RegionInfo,
VMClient: imageHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(imageHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(imageHandler.RegionInfo.Region)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Region No of the Region Code: [%v]", err)
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -201,7 +201,7 @@ func (imageHandler *NcpImageHandler) GetNcpImageInfo(imageIID irs.IID) (*server.
RegionInfo: imageHandler.RegionInfo,
VMClient: imageHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(imageHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(imageHandler.RegionInfo.Region)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Region No of the Region Code : [%v]", err)
cblogger.Error(newErr.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (myImageHandler *NcpMyImageHandler) ListMyImage() ([]*irs.MyImageInfo, erro
RegionInfo: myImageHandler.RegionInfo,
VMClient: myImageHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(myImageHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(myImageHandler.RegionInfo.Region)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Region No of the Region Code: [%v]", err)
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -364,7 +364,7 @@ func (myImageHandler *NcpMyImageHandler) GetNcpMemberServerImageInfo(myImageIID
RegionInfo: myImageHandler.RegionInfo,
VMClient: myImageHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(myImageHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(myImageHandler.RegionInfo.Region)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Region No of the Region Code: [%v]", err)
cblogger.Error(newErr.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ func (nlbHandler *NcpNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (createNLB ir
RegionInfo: nlbHandler.RegionInfo,
VMClient: nlbHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(nlbHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(nlbHandler.RegionInfo.Region)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Region No of the Region Code: [%v]", err)
cblogger.Error(newErr.Error())
LoggingError(callLogInfo, newErr)
return irs.NLBInfo{}, newErr
}
zoneNo, err := vmHandler.GetZoneNo(nlbHandler.RegionInfo.Region, nlbHandler.RegionInfo.Zone)
zoneNo, err := vmHandler.getZoneNo(nlbHandler.RegionInfo.Region, nlbHandler.RegionInfo.Zone)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Zone No of the Zone Code : [%v]", err)
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -172,7 +172,7 @@ func (nlbHandler *NcpNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (createNLB ir
if len(*nlbReqInfo.VMGroup.VMs) > 0 {
var vmIds []*string
for _, IId := range *nlbReqInfo.VMGroup.VMs {
vmId, err := vmHandler.GetVmIdByName(IId.NameId)
vmId, err := vmHandler.getVmIdByName(IId.NameId)
if err != nil {
newErr := fmt.Errorf("Failed to Get the NCP VM ID with VM Name. [%v]", err.Error())
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -245,14 +245,14 @@ func (nlbHandler *NcpNLBHandler) ListNLB() ([]*irs.NLBInfo, error) {
RegionInfo: nlbHandler.RegionInfo,
VMClient: nlbHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(nlbHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(nlbHandler.RegionInfo.Region)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Region No of the Region Code: [%v]", err)
cblogger.Error(newErr.Error())
LoggingError(callLogInfo, newErr)
return nil, newErr
}
zoneNo, err := vmHandler.GetZoneNo(nlbHandler.RegionInfo.Region, nlbHandler.RegionInfo.Zone)
zoneNo, err := vmHandler.getZoneNo(nlbHandler.RegionInfo.Region, nlbHandler.RegionInfo.Zone)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Zone No of the Zone Code : [%v]", err)
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -388,7 +388,7 @@ func (nlbHandler *NcpNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs.
var newVmIdList []*string
if len(*vmIIDs) > 0 {
for _, vmIID := range *vmIIDs {
vmId, err := vmHandler.GetVmIdByName(vmIID.NameId)
vmId, err := vmHandler.getVmIdByName(vmIID.NameId)
if err != nil {
newErr := fmt.Errorf("Failed to Get the VM ID with the VM Name : [%v]", err)
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -465,7 +465,7 @@ func (nlbHandler *NcpNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (b
var vmIdList []*string
if len(*vmIIDs) > 0 {
for _, vmIID := range *vmIIDs {
vmId, err := vmHandler.GetVmIdByName(vmIID.NameId)
vmId, err := vmHandler.getVmIdByName(vmIID.NameId)
if err != nil {
newErr := fmt.Errorf("Failed to Get the VM ID with the VM Name : [%v]", err)
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -627,7 +627,7 @@ func (nlbHandler *NcpNLBHandler) GetVMGroupInfo(nlb lb.LoadBalancerInstance) (ir
}
var vmIIds []irs.IID
for _, member := range nlb.LoadBalancedServerInstanceList {
vm, err := vmHandler.GetNcpVMInfo(*member.ServerInstance.ServerInstanceNo)
vm, err := vmHandler.getNcpVMInfo(*member.ServerInstance.ServerInstanceNo)
if err != nil {
newErr := fmt.Errorf("Failed to Get the NCP VM Info with ServerInstance No. [%v]", err.Error())
cblogger.Error(newErr.Error())
Expand Down Expand Up @@ -781,14 +781,14 @@ func (nlbHandler *NcpNLBHandler) GetNcpNlbInfo(nlbIID irs.IID) (*lb.LoadBalancer
RegionInfo: nlbHandler.RegionInfo,
VMClient: nlbHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(nlbHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(nlbHandler.RegionInfo.Region)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Region No of the Region Code: [%v]", err)
cblogger.Error(newErr.Error())
LoggingError(callLogInfo, newErr)
return nil, newErr
}
zoneNo, err := vmHandler.GetZoneNo(nlbHandler.RegionInfo.Region, nlbHandler.RegionInfo.Zone)
zoneNo, err := vmHandler.getZoneNo(nlbHandler.RegionInfo.Region, nlbHandler.RegionInfo.Zone)
if err != nil {
newErr := fmt.Errorf("Failed to Get NCP Zone No of the Zone Code : [%v]", err)
cblogger.Error(newErr.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (regionZoneHandler *NcpRegionZoneHandler) ListOrgZone() (string, error) {
RegionInfo: regionZoneHandler.RegionInfo,
VMClient: regionZoneHandler.VMClient,
}
regionNo, err := vmHandler.GetRegionNo(regionZoneHandler.RegionInfo.Region)
regionNo, err := vmHandler.getRegionNo(regionZoneHandler.RegionInfo.Region)
if err != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get NCP Region No of the Region Code : ", err)
return "", rtnErr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (tagHandler *NcpTagHandler) getVMTagListWithVMId(vmID *string) ([]*server.I
}
if len(tagListResult.InstanceTagList) < 1 {
newErr := fmt.Errorf("Failed to Find Any Tag with the VM SystemID!!")
cblogger.Error(newErr.Error())
cblogger.Debug(newErr.Error())
return nil, newErr
} else {
cblogger.Infof("Tag Listing Result : [%s]", *tagListResult.ReturnMessage)
Expand Down
Loading

0 comments on commit 22b9083

Please sign in to comment.