Skip to content

Commit 6d77bf5

Browse files
author
Dingane Hlaluku
committed
* Fix few comment typos
* Refactor debug messages to use String.format() when debug log level is enabled.
1 parent 3f41afa commit 6d77bf5

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

api/src/main/java/com/cloud/hypervisor/HypervisorGuru.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import com.cloud.vm.VirtualMachineProfile;
3434

3535
public interface HypervisorGuru extends Adapter {
36-
static final ConfigKey<Boolean> VmwareFullClone = new ConfigKey<Boolean>("Advanced", Boolean.class, "vmware.create.full.clone", "true",
36+
ConfigKey<Boolean> VmwareFullClone = new ConfigKey<Boolean>("Advanced", Boolean.class, "vmware.create.full.clone", "true",
3737
"If set to true, creates guest VMs as full clones on ESX", false);
3838
HypervisorType getHypervisorType();
3939

@@ -87,7 +87,7 @@ public interface HypervisorGuru extends Adapter {
8787
Map<String, String> getClusterSettings(long vmId);
8888

8989
/**
90-
* will generate commands to migrate a vm to a pool. For now this will ony work for stopped VMs on Vmware.
90+
* Will generate commands to migrate a vm to a pool. For now this will only work for stopped VMs on Vmware.
9191
*
9292
* @param vm the stopped vm to migrate
9393
* @param destination the primary storage pool to migrate to

core/src/main/java/com/cloud/agent/api/UnregisterVMCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class UnregisterVMCommand extends Command {
2323
String vmName;
2424
boolean cleanupVmFiles = false;
25-
boolean executeInSequence = false;
25+
boolean executeInSequence;
2626

2727
public UnregisterVMCommand(String vmName) {
2828
this(vmName, false);

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
import com.cloud.host.Host;
2727

2828
/**
29-
* interface to query how to move data around and to commision the moving
29+
* Interface to query how to move data around and to commision the moving
3030
*/
3131
public interface DataMotionStrategy {
3232
/**
33-
* reports whether this instance can do a move from source to destination
33+
* Reports whether this instance can do a move from source to destination
3434
* @param srcData object to move
3535
* @param destData location to move it to
3636
* @return the expertise level with which this instance knows how to handle the move
@@ -40,7 +40,7 @@ public interface DataMotionStrategy {
4040
StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
4141

4242
/**
43-
* copy the source volume to its destination (on a host if not null)
43+
* Copy the source volume to its destination (on a host if not null)
4444
*
4545
* @param srcData volume to move
4646
* @param destData volume description as intended after the move

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,8 +1981,7 @@ private void orchestrateStorageMigration(final String vmUuid, final StoragePool
19811981

19821982
try {
19831983
if(s_logger.isDebugEnabled()) {
1984-
s_logger.debug(
1985-
String.format("Offline migration of %s vm %s with volumes",
1984+
s_logger.debug(String.format("Offline migration of %s vm %s with volumes",
19861985
vm.getHypervisorType().toString(),
19871986
vm.getInstanceName()));
19881987
}
@@ -1992,20 +1991,21 @@ private void orchestrateStorageMigration(final String vmUuid, final StoragePool
19921991
} catch (ConcurrentOperationException
19931992
| InsufficientCapacityException // possibly InsufficientVirtualNetworkCapacityException or InsufficientAddressCapacityException
19941993
| StorageUnavailableException e) {
1995-
s_logger.debug("Failed to migration: " + e.toString());
1996-
throw new CloudRuntimeException("Failed to migration: " + e.toString());
1994+
String msg = String.format("Failed to migrate VM: %s", vmUuid);
1995+
s_logger.debug(msg);
1996+
throw new CloudRuntimeException(msg, e);
19971997
} finally {
19981998
try {
19991999
stateTransitTo(vm, Event.AgentReportStopped, null);
20002000
} catch (final NoTransitionException e) {
2001-
s_logger.debug("Failed to change vm state: " + e.toString());
2002-
throw new CloudRuntimeException("Failed to change vm state: " + e.toString());
2001+
String anotherMEssage = String.format("failed to change vm state of VM: %s", vmUuid);
2002+
s_logger.debug(anotherMEssage);
2003+
throw new CloudRuntimeException(anotherMEssage, e);
20032004
}
20042005
}
20052006
}
20062007

20072008
private Answer[] attemptHypervisorMigration(StoragePool destPool, VMInstanceVO vm) {
2008-
boolean migrationResult = false;
20092009
final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
20102010
// OfflineVmwareMigration: in case of vmware call vcenter to do it for us.
20112011
// OfflineVmwareMigration: should we check the proximity of source and destination
@@ -2014,7 +2014,7 @@ private Answer[] attemptHypervisorMigration(StoragePool destPool, VMInstanceVO v
20142014
List<Command> commandsToSend = hvGuru.finalizeMigrate(vm, destPool);
20152015

20162016
Long hostId = vm.getHostId();
2017-
// OfflineVmwareMigration: probaby this is null when vm is stopped
2017+
// OfflineVmwareMigration: probably this is null when vm is stopped
20182018
if(hostId == null) {
20192019
hostId = vm.getLastHostId();
20202020
if (s_logger.isDebugEnabled()) {
@@ -2027,17 +2027,17 @@ private Answer[] attemptHypervisorMigration(StoragePool destPool, VMInstanceVO v
20272027
try {
20282028
// OfflineVmwareMigration: change to the call back variety?
20292029
// OfflineVmwareMigration: getting a Long seq to be filled with _agentMgr.send(hostId, commandsContainer, this)
2030-
Answer[] answers = _agentMgr.send(hostId, commandsContainer);
2031-
return answers;
2030+
return _agentMgr.send(hostId, commandsContainer);
20322031
} catch (AgentUnavailableException | OperationTimedoutException e) {
2033-
throw new CloudRuntimeException("Failed to migration: " + e.toString());
2032+
throw new CloudRuntimeException(String.format("Failed to migrate VM: %s", vm.getUuid()),e);
20342033
}
20352034
}
20362035
return null;
20372036
}
20382037

20392038
private void afterHypervisorMigrationCleanup(StoragePool destPool, VMInstanceVO vm, HostVO srcHost, Long srcClusterId, Answer[] hypervisorMigrationResults) throws InsufficientCapacityException {
2040-
if(s_logger.isDebugEnabled()) {
2039+
boolean isDebugEnabled = s_logger.isDebugEnabled();
2040+
if(isDebugEnabled) {
20412041
String msg = String.format("cleaning up after hypervisor pool migration volumes for VM %s(%s) to pool %s(%s)", vm.getInstanceName(), vm.getUuid(), destPool.getName(), destPool.getUuid());
20422042
s_logger.debug(msg);
20432043
}
@@ -2046,7 +2046,7 @@ private void afterHypervisorMigrationCleanup(StoragePool destPool, VMInstanceVO
20462046
Long destPodId = destPool.getPodId();
20472047
Long vmPodId = vm.getPodIdToDeployIn();
20482048
if (destPodId == null || ! destPodId.equals(vmPodId)) {
2049-
if(s_logger.isDebugEnabled()) {
2049+
if(isDebugEnabled) {
20502050
String msg = String.format("resetting lasHost for VM %s(%s) as pod (%s) is no good.", vm.getInstanceName(), vm.getUuid(), destPodId);
20512051
s_logger.debug(msg);
20522052
}
@@ -2064,7 +2064,7 @@ private void markVolumesInPool(VMInstanceVO vm, StoragePool destPool, Answer[] h
20642064
MigrateVmToPoolAnswer relevantAnswer = null;
20652065
for (Answer answer : hypervisorMigrationResults) {
20662066
if (s_logger.isTraceEnabled()) {
2067-
s_logger.trace(String.format("recieved an %s: %s", answer.getClass().getSimpleName(), answer));
2067+
s_logger.trace(String.format("received an %s: %s", answer.getClass().getSimpleName(), answer));
20682068
}
20692069
if (answer instanceof MigrateVmToPoolAnswer) {
20702070
relevantAnswer = (MigrateVmToPoolAnswer) answer;
@@ -2118,14 +2118,15 @@ private void preStorageMigrationStateCheck(StoragePool destPool, VMInstanceVO vm
21182118
try {
21192119
stateTransitTo(vm, Event.StorageMigrationRequested, null);
21202120
} catch (final NoTransitionException e) {
2121-
s_logger.debug("Unable to migrate vm: " + e.toString());
2122-
throw new CloudRuntimeException("Unable to migrate vm: " + e.toString());
2121+
String msg = String.format("Unable to migrate vm: %s", vm.getUuid());
2122+
s_logger.debug(msg);
2123+
throw new CloudRuntimeException(msg, e);
21232124
}
21242125
}
21252126

21262127
private void checkDestinationForTags(StoragePool destPool, VMInstanceVO vm) {
21272128
List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId());
2128-
// OfflineVmwareMigration: itterate over volumes
2129+
// OfflineVmwareMigration: iterate over volumes
21292130
// OfflineVmwareMigration: get disk offering
21302131
List<String> storageTags = storageMgr.getStoragePoolTagList(destPool.getId());
21312132
for(Volume vol : vols) {

test/integration/smoke/test_vm_life_cycle.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_deploy_vm_multiple(self):
238238
list_vms = VirtualMachine.list(self.apiclient, ids=[virtual_machine1.id, virtual_machine2.id], listAll=True)
239239
self.debug(
240240
"Verify listVirtualMachines response for virtual machines: %s, %s" % (
241-
virtual_machine1.id, virtual_machine2.id)
241+
virtual_machine1.id, virtual_machine2.id)
242242
)
243243
self.assertEqual(
244244
isinstance(list_vms, list),
@@ -606,7 +606,7 @@ def test_08_migrate_vm(self):
606606
migrate_host = suitable_hosts[1]
607607

608608
# deploy VM on target host
609-
self.vm_to_migrate = VirtualMachine.create(
609+
vm_to_migrate = VirtualMachine.create(
610610
self.apiclient,
611611
self.services["small"],
612612
accountid=self.account.name,
@@ -616,23 +616,23 @@ def test_08_migrate_vm(self):
616616
hostid=target_host.id
617617
)
618618
self.debug("Migrating VM-ID: %s to Host: %s" % (
619-
self.vm_to_migrate.id,
619+
vm_to_migrate.id,
620620
migrate_host.id
621621
))
622622

623-
self.vm_to_migrate.migrate(self.apiclient, migrate_host.id)
623+
vm_to_migrate.migrate(self.apiclient, migrate_host.id)
624624

625625
retries_cnt = 3
626626
while retries_cnt >= 0:
627627
list_vm_response = VirtualMachine.list(self.apiclient,
628-
id=self.vm_to_migrate.id)
628+
id=vm_to_migrate.id)
629629
self.assertNotEqual(
630630
list_vm_response,
631631
None,
632632
"Check virtual machine is listed"
633633
)
634634
vm_response = list_vm_response[0]
635-
self.assertEqual(vm_response.id, self.vm_to_migrate.id, "Check virtual machine ID of migrated VM")
635+
self.assertEqual(vm_response.id, vm_to_migrate.id, "Check virtual machine ID of migrated VM")
636636
self.assertEqual(vm_response.hostid, migrate_host.id, "Check destination hostID of migrated VM")
637637
retries_cnt = retries_cnt - 1
638638
return

0 commit comments

Comments
 (0)