Skip to content

Commit e010c9b

Browse files
authored
Fixup main build error (apache#9314)
1 parent 90fe1d5 commit e010c9b

File tree

4 files changed

+26
-28
lines changed

4 files changed

+26
-28
lines changed

plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,12 @@ protected void checkIfRestoreSessionFinished(String type, String path) throws IO
378378

379379
if (session.getResult().equalsIgnoreCase("Failed")) {
380380
String sessionUid = session.getUid();
381-
LOG.error(String.format("Failed to restore backup [%s] of VM [%s] due to [%s].",
381+
logger.error(String.format("Failed to restore backup [%s] of VM [%s] due to [%s].",
382382
sessionUid, session.getVmDisplayName(),
383383
getRestoreVmErrorDescription(StringUtils.substringAfterLast(sessionUid, ":"))));
384384
throw new CloudRuntimeException(String.format("Restore job [%s] failed.", sessionUid));
385385
}
386-
LOG.debug(String.format("Waiting %s seconds, out of a total of %s seconds, for the restore backup process to finish.", j, restoreTimeout));
386+
logger.debug(String.format("Waiting %s seconds, out of a total of %s seconds, for the restore backup process to finish.", j, restoreTimeout));
387387

388388
try {
389389
Thread.sleep(1000);
@@ -949,7 +949,7 @@ public Pair<Boolean, String> restoreVMToDifferentLocation(String restorePointId,
949949
* @return the description found in Veeam about the cause of error in the restore process.
950950
*/
951951
protected String getRestoreVmErrorDescription(String uid) {
952-
LOG.debug(String.format("Trying to find the cause of error in the restore process [%s].", uid));
952+
logger.debug(String.format("Trying to find the cause of error in the restore process [%s].", uid));
953953
List<String> cmds = Arrays.asList(
954954
String.format("$restoreUid = '%s'", uid),
955955
"$restore = Get-VBRRestoreSession -Id $restoreUid",

plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java

+13-15
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import org.apache.cloudstack.backup.BackupOffering;
3939
import org.apache.cloudstack.backup.veeam.api.RestoreSession;
4040
import org.apache.http.HttpResponse;
41-
import org.apache.logging.log4j.core.Logger;
41+
import org.apache.logging.log4j.Logger;
4242
import org.junit.Assert;
4343
import org.junit.Before;
4444
import org.junit.Rule;
@@ -59,8 +59,6 @@ public class VeeamClientTest {
5959
private VeeamClient mockClient;
6060
private static final SimpleDateFormat newDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
6161

62-
private VeeamClient mock = Mockito.mock(VeeamClient.class);
63-
6462
@Rule
6563
public WireMockRule wireMockRule = new WireMockRule(9399);
6664

@@ -177,35 +175,35 @@ public void checkIfRestoreSessionFinishedTestTimeoutException() throws IOExcepti
177175
@Test
178176
public void getRestoreVmErrorDescriptionTestFindErrorDescription() {
179177
Pair<Boolean, String> response = new Pair<>(true, "Example of error description found in Veeam.");
180-
Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
181-
Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(response);
182-
String result = mock.getRestoreVmErrorDescription("uuid");
178+
Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
179+
Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(response);
180+
String result = mockClient.getRestoreVmErrorDescription("uuid");
183181
Assert.assertEquals("Example of error description found in Veeam.", result);
184182
}
185183

186184
@Test
187185
public void getRestoreVmErrorDescriptionTestNotFindErrorDescription() {
188186
Pair<Boolean, String> response = new Pair<>(true, "Cannot find restore session with provided uid uuid");
189-
Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
190-
Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(response);
191-
String result = mock.getRestoreVmErrorDescription("uuid");
187+
Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
188+
Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(response);
189+
String result = mockClient.getRestoreVmErrorDescription("uuid");
192190
Assert.assertEquals("Cannot find restore session with provided uid uuid", result);
193191
}
194192

195193
@Test
196194
public void getRestoreVmErrorDescriptionTestWhenPowerShellOutputIsNull() {
197-
Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
198-
Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(null);
199-
String result = mock.getRestoreVmErrorDescription("uuid");
195+
Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
196+
Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(null);
197+
String result = mockClient.getRestoreVmErrorDescription("uuid");
200198
Assert.assertEquals("Failed to get the description of the failed restore session [uuid]. Please contact an administrator.", result);
201199
}
202200

203201
@Test
204202
public void getRestoreVmErrorDescriptionTestWhenPowerShellOutputIsFalse() {
205203
Pair<Boolean, String> response = new Pair<>(false, null);
206-
Mockito.when(mock.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
207-
Mockito.when(mock.executePowerShellCommands(Mockito.any())).thenReturn(response);
208-
String result = mock.getRestoreVmErrorDescription("uuid");
204+
Mockito.when(mockClient.getRestoreVmErrorDescription("uuid")).thenCallRealMethod();
205+
Mockito.when(mockClient.executePowerShellCommands(Mockito.any())).thenReturn(response);
206+
String result = mockClient.getRestoreVmErrorDescription("uuid");
209207
Assert.assertEquals("Failed to get the description of the failed restore session [uuid]. Please contact an administrator.", result);
210208
}
211209

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -548,18 +548,18 @@ private Long getPoolIdFromDatastoreUuid(long zoneId, String datastoreUuid) {
548548
StoragePoolVO pool = null;
549549
try {
550550
String poolUuid = UuidUtils.normalize(datastoreUuid);
551-
s_logger.info("Trying to find pool by UUID: " + poolUuid);
551+
logger.info("Trying to find pool by UUID: " + poolUuid);
552552
pool = _storagePoolDao.findByUuid(poolUuid);
553553
} catch (CloudRuntimeException ex) {
554-
s_logger.warn("Unable to get pool by datastore UUID: " + ex.getMessage());
554+
logger.warn("Unable to get pool by datastore UUID: " + ex.getMessage());
555555
}
556556
if (pool == null) {
557-
s_logger.info("Trying to find pool by path: " + datastoreUuid);
557+
logger.info("Trying to find pool by path: " + datastoreUuid);
558558
pool = _storagePoolDao.findPoolByZoneAndPath(zoneId, datastoreUuid);
559559
}
560560
if (pool == null && datastoreUuid.startsWith("-iqn") && datastoreUuid.endsWith("-0")) {
561561
String iScsiName = "/iqn" + datastoreUuid.substring(4, datastoreUuid.length() - 2) + "/0";
562-
s_logger.info("Trying to find volume by iScsi name: " + iScsiName);
562+
logger.info("Trying to find volume by iScsi name: " + iScsiName);
563563
VolumeVO volumeVO = _volumeDao.findOneByIScsiName(iScsiName);
564564
if (volumeVO != null) {
565565
pool = _storagePoolDao.findById(volumeVO.getPoolId());
@@ -1009,11 +1009,11 @@ private String getVlanFromDvsPort(VmwareContext context, String dvSwitchUuid, St
10091009
}
10101010
VMwareDVSPortSetting settings = (VMwareDVSPortSetting) dvPort.getConfig().getSetting();
10111011
VmwareDistributedVirtualSwitchVlanIdSpec vlanId = (VmwareDistributedVirtualSwitchVlanIdSpec) settings.getVlan();
1012-
s_logger.debug("Found port " + dvPort.getKey() + " with vlan " + vlanId.getVlanId());
1012+
logger.debug("Found port " + dvPort.getKey() + " with vlan " + vlanId.getVlanId());
10131013
return String.valueOf(vlanId.getVlanId());
10141014
}
10151015
} catch (Exception ex) {
1016-
s_logger.error("Got exception while get vlan from DVS port: " + ex.getMessage());
1016+
logger.error("Got exception while get vlan from DVS port: " + ex.getMessage());
10171017
}
10181018
return null;
10191019
}
@@ -1026,12 +1026,12 @@ private void syncVMNics(VirtualDevice[] nicDevices, DatacenterMO dcMo, Map<Strin
10261026
String macAddress = pair.first();
10271027
String vlanId = pair.second();
10281028
if (vlanId == null) {
1029-
s_logger.warn(String.format("vlanId for MAC address [%s] is null", macAddress));
1029+
logger.warn(String.format("vlanId for MAC address [%s] is null", macAddress));
10301030
continue;
10311031
}
10321032
NetworkVO networkVO = networksMapping.get(vlanId);
10331033
if (networkVO == null) {
1034-
s_logger.warn(String.format("Cannot find network for MAC address [%s] and vlanId [%s]", macAddress, vlanId));
1034+
logger.warn(String.format("Cannot find network for MAC address [%s] and vlanId [%s]", macAddress, vlanId));
10351035
continue;
10361036
}
10371037
NicVO nicVO = nicDao.findByNetworkIdAndMacAddressIncludingRemoved(networkVO.getId(), macAddress);
@@ -1349,7 +1349,7 @@ private VirtualMachineMO createCloneFromSourceVM(String vmName, VirtualMachineMO
13491349
List<DatastoreMO> vmDatastores = vmMo.getAllDatastores();
13501350
if (CollectionUtils.isEmpty(vmDatastores)) {
13511351
String err = String.format("Unable to fetch datastores, could not clone VM %s for migration from VMware", vmName);
1352-
s_logger.error(err);
1352+
logger.error(err);
13531353
throw new CloudRuntimeException(err);
13541354
}
13551355
DatastoreMO datastoreMO = vmDatastores.get(0); //pick the first datastore

vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ public static UnmanagedInstanceTO getUnmanagedInstance(VmwareHypervisorHost hype
812812
ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), hyperHost.getHyperHostCluster());
813813
instance.setClusterName(clusterMo.getName());
814814
} catch (Exception e) {
815-
s_logger.warn("Unable to get unmanaged instance cluster info, due to: " + e.getMessage());
815+
LOGGER.warn("Unable to get unmanaged instance cluster info, due to: " + e.getMessage());
816816
}
817817

818818
instance.setHostName(hyperHost.getHyperHostName());

0 commit comments

Comments
 (0)