This is an automated email from the ASF dual-hosted git repository. sureshanaparti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push: new e010c9be936 Fixup main build error (#9314) e010c9be936 is described below commit e010c9be93638bdcfcab8078284432073f1cc21d Author: Vishesh <vishes...@gmail.com> AuthorDate: Sat Jun 29 14:25:53 2024 +0530 Fixup main build error (#9314) --- .../cloudstack/backup/veeam/VeeamClient.java | 6 ++--- .../cloudstack/backup/veeam/VeeamClientTest.java | 28 ++++++++++------------ .../java/com/cloud/hypervisor/guru/VMwareGuru.java | 18 +++++++------- .../cloud/hypervisor/vmware/util/VmwareHelper.java | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java b/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java index a92029808d8..d911736090c 100644 --- a/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java +++ b/plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java @@ -378,12 +378,12 @@ public class VeeamClient { if (session.getResult().equalsIgnoreCase("Failed")) { String sessionUid = session.getUid(); - LOG.error(String.format("Failed to restore backup [%s] of VM [%s] due to [%s].", + logger.error(String.format("Failed to restore backup [%s] of VM [%s] due to [%s].", sessionUid, session.getVmDisplayName(), getRestoreVmErrorDescription(StringUtils.substringAfterLast(sessionUid, ":")))); throw new CloudRuntimeException(String.format("Restore job [%s] failed.", sessionUid)); } - LOG.debug(String.format("Waiting %s seconds, out of a total of %s seconds, for the restore backup process to finish.", j, restoreTimeout)); + logger.debug(String.format("Waiting %s seconds, out of a total of %s seconds, for the restore backup process to finish.", j, restoreTimeout)); try { Thread.sleep(1000); @@ -949,7 +949,7 @@ public class VeeamClient { * @return the description found in Veeam about the cause of error in the restore process. */ protected String getRestoreVmErrorDescription(String uid) { - LOG.debug(String.format("Trying to find the cause of error in the restore process [%s].", uid)); + logger.debug(String.format("Trying to find the cause of error in the restore process [%s].", uid)); List<String> cmds = Arrays.asList( String.format("$restoreUid = '%s'", uid), "$restore = Get-VBRRestoreSession -Id $restoreUid", diff --git a/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java b/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java index b863955ba45..63d6896bb85 100644 --- a/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java +++ b/plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java @@ -38,7 +38,7 @@ import org.apache.cloudstack.backup.Backup; import org.apache.cloudstack.backup.BackupOffering; import org.apache.cloudstack.backup.veeam.api.RestoreSession; import org.apache.http.HttpResponse; -import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -59,8 +59,6 @@ public class VeeamClientTest { private VeeamClient mockClient; private static final SimpleDateFormat newDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - private VeeamClient mock = Mockito.mock(VeeamClient.class); - @Rule public WireMockRule wireMockRule = new WireMockRule(9399); @@ -177,35 +175,35 @@ public class VeeamClientTest { @Test public void getRestoreVmErrorDescriptionTestFindErrorDescription() { Pair<Boolean, String> response = new Pair<>(true, "Example of error description found in Veeam."); - Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); - Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(response); - String result = mock.getRestoreVmErrorDescription("uuid"); + Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); + Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(response); + String result = mockClient.getRestoreVmErrorDescription("uuid"); Assert.assertEquals("Example of error description found in Veeam.", result); } @Test public void getRestoreVmErrorDescriptionTestNotFindErrorDescription() { Pair<Boolean, String> response = new Pair<>(true, "Cannot find restore session with provided uid uuid"); - Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); - Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(response); - String result = mock.getRestoreVmErrorDescription("uuid"); + Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); + Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(response); + String result = mockClient.getRestoreVmErrorDescription("uuid"); Assert.assertEquals("Cannot find restore session with provided uid uuid", result); } @Test public void getRestoreVmErrorDescriptionTestWhenPowerShellOutputIsNull() { - Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); - Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(null); - String result = mock.getRestoreVmErrorDescription("uuid"); + Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); + Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(null); + String result = mockClient.getRestoreVmErrorDescription("uuid"); Assert.assertEquals("Failed to get the description of the failed restore session [uuid]. Please contact an administrator.", result); } @Test public void getRestoreVmErrorDescriptionTestWhenPowerShellOutputIsFalse() { Pair<Boolean, String> response = new Pair<>(false, null); - Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); - Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(response); - String result = mock.getRestoreVmErrorDescription("uuid"); + Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod(); + Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(response); + String result = mockClient.getRestoreVmErrorDescription("uuid"); Assert.assertEquals("Failed to get the description of the failed restore session [uuid]. Please contact an administrator.", result); } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java index 012ebc1b8b5..3ccf3bf8c62 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java @@ -548,18 +548,18 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co StoragePoolVO pool = null; try { String poolUuid = UuidUtils.normalize(datastoreUuid); - s_logger.info("Trying to find pool by UUID: " + poolUuid); + logger.info("Trying to find pool by UUID: " + poolUuid); pool = _storagePoolDao.findByUuid(poolUuid); } catch (CloudRuntimeException ex) { - s_logger.warn("Unable to get pool by datastore UUID: " + ex.getMessage()); + logger.warn("Unable to get pool by datastore UUID: " + ex.getMessage()); } if (pool == null) { - s_logger.info("Trying to find pool by path: " + datastoreUuid); + logger.info("Trying to find pool by path: " + datastoreUuid); pool = _storagePoolDao.findPoolByZoneAndPath(zoneId, datastoreUuid); } if (pool == null && datastoreUuid.startsWith("-iqn") && datastoreUuid.endsWith("-0")) { String iScsiName = "/iqn" + datastoreUuid.substring(4, datastoreUuid.length() - 2) + "/0"; - s_logger.info("Trying to find volume by iScsi name: " + iScsiName); + logger.info("Trying to find volume by iScsi name: " + iScsiName); VolumeVO volumeVO = _volumeDao.findOneByIScsiName(iScsiName); if (volumeVO != null) { pool = _storagePoolDao.findById(volumeVO.getPoolId()); @@ -1009,11 +1009,11 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co } VMwareDVSPortSetting settings = (VMwareDVSPortSetting) dvPort.getConfig().getSetting(); VmwareDistributedVirtualSwitchVlanIdSpec vlanId = (VmwareDistributedVirtualSwitchVlanIdSpec) settings.getVlan(); - s_logger.debug("Found port " + dvPort.getKey() + " with vlan " + vlanId.getVlanId()); + logger.debug("Found port " + dvPort.getKey() + " with vlan " + vlanId.getVlanId()); return String.valueOf(vlanId.getVlanId()); } } catch (Exception ex) { - s_logger.error("Got exception while get vlan from DVS port: " + ex.getMessage()); + logger.error("Got exception while get vlan from DVS port: " + ex.getMessage()); } return null; } @@ -1026,12 +1026,12 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co String macAddress = pair.first(); String vlanId = pair.second(); if (vlanId == null) { - s_logger.warn(String.format("vlanId for MAC address [%s] is null", macAddress)); + logger.warn(String.format("vlanId for MAC address [%s] is null", macAddress)); continue; } NetworkVO networkVO = networksMapping.get(vlanId); if (networkVO == null) { - s_logger.warn(String.format("Cannot find network for MAC address [%s] and vlanId [%s]", macAddress, vlanId)); + logger.warn(String.format("Cannot find network for MAC address [%s] and vlanId [%s]", macAddress, vlanId)); continue; } NicVO nicVO = nicDao.findByNetworkIdAndMacAddressIncludingRemoved(networkVO.getId(), macAddress); @@ -1349,7 +1349,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co List<DatastoreMO> vmDatastores = vmMo.getAllDatastores(); if (CollectionUtils.isEmpty(vmDatastores)) { String err = String.format("Unable to fetch datastores, could not clone VM %s for migration from VMware", vmName); - s_logger.error(err); + logger.error(err); throw new CloudRuntimeException(err); } DatastoreMO datastoreMO = vmDatastores.get(0); //pick the first datastore diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java index 37b0d4d2444..962469c9535 100644 --- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java +++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java @@ -812,7 +812,7 @@ public class VmwareHelper { ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), hyperHost.getHyperHostCluster()); instance.setClusterName(clusterMo.getName()); } catch (Exception e) { - s_logger.warn("Unable to get unmanaged instance cluster info, due to: " + e.getMessage()); + LOGGER.warn("Unable to get unmanaged instance cluster info, due to: " + e.getMessage()); } instance.setHostName(hyperHost.getHyperHostName());