diff --git a/cloud-control-manager/cloud-driver/drivers/ncp/resources/VMHandler.go b/cloud-control-manager/cloud-driver/drivers/ncp/resources/VMHandler.go index 24d716035..6fe71dade 100644 --- a/cloud-control-manager/cloud-driver/drivers/ncp/resources/VMHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/ncp/resources/VMHandler.go @@ -62,7 +62,6 @@ func init() { func (vmHandler *NcpVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error) { cblogger.Info("NCP Classic Cloud driver: called StartVM()!!") - InitLog() callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Zone, call.VM, vmReqInfo.IId.NameId, "StartVM()") @@ -481,7 +480,6 @@ func (vmHandler *NcpVMHandler) MappingServerInfo(NcpInstance *server.ServerInsta } else { // To get the VPC info. vpcHandler := NcpVPCHandler { - CredentialInfo: vmHandler.CredentialInfo, RegionInfo: vmHandler.RegionInfo, VMClient: vmHandler.VMClient, } @@ -502,7 +500,7 @@ func (vmHandler *NcpVMHandler) MappingServerInfo(NcpInstance *server.ServerInsta } } } - cblogger.Infof("NCP Instance Uptime : [%s]", *NcpInstance.Uptime) + // cblogger.Infof("NCP Instance Uptime : [%s]", *NcpInstance.Uptime) // Note : NCP VPC PlatformType : LNX32, LNX64, WND32, WND64, UBD64, UBS64 if strings.Contains(*NcpInstance.PlatformType.Code, "LNX") || strings.Contains(*NcpInstance.PlatformType.Code, "UB") { @@ -543,8 +541,6 @@ func (vmHandler *NcpVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) { func (vmHandler *NcpVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error) { cblogger.Info("NCP Classic Cloud driver: called SuspendVM()!!") - cblogger.Infof("vmID : [%s]", vmIID.SystemId) - InitLog() callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Zone, call.VM, vmIID.NameId, "SuspendVM()") @@ -605,8 +601,6 @@ func (vmHandler *NcpVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error) { func (vmHandler *NcpVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error) { cblogger.Info("NCP Classic Cloud driver: called ResumeVM()!") - cblogger.Infof("vmID : " + vmIID.SystemId) - InitLog() callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Zone, call.VM, vmIID.NameId, "ResumeVM()") @@ -673,8 +667,6 @@ func (vmHandler *NcpVMHandler) ResumeVM(vmIID irs.IID) (irs.VMStatus, error) { func (vmHandler *NcpVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error) { cblogger.Info("NCP Classic Cloud driver: called RebootVM()!") - cblogger.Infof("vmID : [%s]", vmIID.SystemId) - InitLog() callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Zone, call.VM, vmIID.NameId, "RebootVM()") @@ -742,8 +734,6 @@ func (vmHandler *NcpVMHandler) RebootVM(vmIID irs.IID) (irs.VMStatus, error) { func (vmHandler *NcpVMHandler) TerminateVM(vmIID irs.IID) (irs.VMStatus, error) { cblogger.Info("NCP Classic Cloud driver: called TerminateVM()!") - cblogger.Infof("vmID : [%s]", vmIID.SystemId) - InitLog() callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Zone, call.VM, vmIID.NameId, "TerminateVM()") @@ -961,7 +951,6 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) { func (vmHandler *NcpVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, error) { cblogger.Info("NCP Classic Cloud driver: called GetVMStatus()!") - InitLog() callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Zone, call.VM, vmIID.NameId, "GetVMStatus()") @@ -1000,13 +989,12 @@ func (vmHandler *NcpVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, error) // cblogger.Info("Succeeded in Getting ServerInstanceList!!") vmStatus, errStatus := ConvertVMStatusString(*result.ServerInstanceList[0].ServerInstanceStatusName) - cblogger.Info("# Converted VM Status : " + vmStatus) + // cblogger.Info("# Converted VM Status : " + vmStatus) return vmStatus, errStatus } func (vmHandler *NcpVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error) { cblogger.Info("NCP Classic Cloud driver: called ListVMStatus()!") - InitLog() callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Zone, call.VM, "ListVMStatus()", "ListVMStatus()") diff --git a/cloud-control-manager/cloud-driver/drivers/ncpvpc/resources/VMHandler.go b/cloud-control-manager/cloud-driver/drivers/ncpvpc/resources/VMHandler.go index e5d0d6e8c..20c64a9ba 100644 --- a/cloud-control-manager/cloud-driver/drivers/ncpvpc/resources/VMHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/ncpvpc/resources/VMHandler.go @@ -323,63 +323,19 @@ func (vmHandler *NcpVpcVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) { return irs.VMInfo{}, newErr } - curStatus, statusErr := vmHandler.GetVMStatus(vmIID) - if statusErr != nil { - newErr := fmt.Errorf("Failed to Get the VM Status with the VM ID : [%s], [%v]", vmIID.SystemId, statusErr) - cblogger.Error(newErr.Error()) - LoggingError(callLogInfo, newErr) - return irs.VMInfo{}, newErr - } - cblogger.Infof("===> VM Status : [%s]", curStatus) - - // Since it's impossible to get VM info. during Creation, ... - switch string(curStatus) { - case "Creating": - cblogger.Infof("The VM status is '%s', so wait for the VM creation before inquiring the info.", string(curStatus)) - return irs.VMInfo{}, errors.New("The VM status is 'Creating', so wait for the VM creation before inquiring the info. : " + vmIID.SystemId) - default: - cblogger.Infof("===> The VM status is not 'Creating', you can get the VM info.") - } - - /* - newVMIID := irs.IID{SystemId: systemId} - - curStatus, statusErr := vmHandler.WaitToGetInfo(newVMIID) - if statusErr != nil { - cblogger.Error(statusErr.Error()) - return irs.VMInfo{}, nil - } - */ - instanceNumList := []*string{ncloud.String(vmIID.SystemId),} - instanceReq := vserver.GetServerInstanceListRequest{ - RegionCode: ncloud.String(vmHandler.RegionInfo.Region), // $$$ Caution!! - ServerInstanceNoList: instanceNumList, - } - start := call.Start() - result, err := vmHandler.VMClient.V2Api.GetServerInstanceList(&instanceReq) + ncpVMInfo, err := vmHandler.GetNcpVMInfo(vmIID.SystemId) if err != nil { - newErr := fmt.Errorf("Failed to Find VM Instance List from NCP VPC!! : [%v]", err) + newErr := fmt.Errorf("Failed to Get the VM Info : [%v]", err) cblogger.Error(newErr.Error()) - LoggingError(callLogInfo, newErr) return irs.VMInfo{}, newErr } - LoggingInfo(callLogInfo, start) - if len(result.ServerInstanceList) < 1 { - newErr := fmt.Errorf("Failed to Find the VM Info. The VM does Not Exist!!") - cblogger.Error(newErr.Error()) - LoggingError(callLogInfo, newErr) - return irs.VMInfo{}, newErr - } - - vmInfo, err := vmHandler.MappingServerInfo(result.ServerInstanceList[0]) + vmInfo, err := vmHandler.MappingServerInfo(ncpVMInfo) if err != nil { - newErr := fmt.Errorf("Failed to Map the VM Info!! : [%v]", err) - cblogger.Error(newErr.Error()) - LoggingError(callLogInfo, newErr) - return irs.VMInfo{}, newErr + LoggingError(callLogInfo, err) + return irs.VMInfo{}, err } - return vmInfo, nil + return vmInfo, nil } func (vmHandler *NcpVpcVMHandler) SuspendVM(vmIID irs.IID) (irs.VMStatus, error) { @@ -774,9 +730,9 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) { resultStatus = "Creating" } else if strings.EqualFold(vmStatus, "booting") { //Caution!! - resultStatus = "Booting" + resultStatus = "Creating" } else if strings.EqualFold(vmStatus, "setting up") { - resultStatus = "Setting_up" + resultStatus = "Creating" } else if strings.EqualFold(vmStatus, "running") { resultStatus = "Running" } else if strings.EqualFold(vmStatus, "shutting down") { @@ -838,7 +794,7 @@ func (vmHandler *NcpVpcVMHandler) GetVMStatus(vmIID irs.IID) (irs.VMStatus, erro } vmStatus, statusErr := ConvertVMStatusString(*result.ServerInstanceList[0].ServerInstanceStatusName) - cblogger.Infof("VM Status of [%s] : [%s]", vmIID.SystemId, vmStatus) + // cblogger.Infof("VM Status of [%s] : [%s]", vmIID.SystemId, vmStatus) return vmStatus, statusErr } @@ -1338,14 +1294,13 @@ func (vmHandler *NcpVpcVMHandler) WaitToGetInfo(vmIID irs.IID) (irs.VMStatus, er cblogger.Errorf("Failed to Get the VM Status of [%s]", vmIID.SystemId) cblogger.Error(statusErr.Error()) } else { - cblogger.Infof("Succeeded in Getting the Status of VM [%s] : [%s]", vmIID.SystemId, curStatus) + cblogger.Infof("===> VM Status : [%s]", curStatus) } - cblogger.Infof("===> VM Status : [%s]", curStatus) switch string(curStatus) { - case "Creating", "Booting", "Setting_up": + case "Creating": curRetryCnt++ - cblogger.Infof("The VM is 'Creating' and 'Booting', so wait for a second more before inquiring the VM info.") + cblogger.Infof("The VM is 'Creating', so wait for a second more before inquiring the VM info.") time.Sleep(time.Second * 5) if curRetryCnt > maxRetryCnt { cblogger.Errorf("Despite waiting for a long time(%d sec), the VM status is '%s', so it is forcibly finishied.", maxRetryCnt, curStatus) @@ -1375,7 +1330,7 @@ func (vmHandler *NcpVpcVMHandler) WaitToDelPublicIp(vmIID irs.IID) (irs.VMStatus } else { cblogger.Infof("Succeeded in Getting the VM Status of [%s]", vmIID.SystemId) } - cblogger.Infof("===> VM Status [%s] : ", curStatus) + cblogger.Infof("===> VM Status : [%s]", curStatus) switch string(curStatus) { case "Suspended", "Terminating":