Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3907a4a
Improve logs
Apr 13, 2021
d32a185
Remove unnecessary comments
Apr 13, 2021
54bb077
Use diamond inference
Apr 13, 2021
a17df55
Fix some logs
Apr 13, 2021
7a70e88
Remove unnecessary unboxing
Apr 13, 2021
5af8f72
Create method to handle job result
Apr 13, 2021
ad7347e
Remove unused vars and fix some logics
Apr 14, 2021
89ca034
Extract code to method and few adjusts
Apr 14, 2021
3e0be4d
Use CollectionUtils
Apr 14, 2021
da5406e
Extract pending work job validation to method
Apr 14, 2021
abc4b47
Create new constructors
Apr 14, 2021
aecf5f3
Extract work job and info creation to a method
Apr 14, 2021
6fd2cbb
Extract submit async job to a method
Apr 14, 2021
c6fc991
Extract find vm by id to a method
Apr 14, 2021
8e7f475
Change log level from trace to debug
Apr 14, 2021
2f7c385
Remove unnused methods and add logs
Apr 14, 2021
47ddbc4
Undo code remotion
Apr 29, 2021
a1acf58
Remove asserts and fix conditionals
May 4, 2021
0a08ad2
Address @GabrielBrascher reviews
Jul 23, 2021
94e4807
Remove double quotes from keys in manual json
GutoVeronezi Jul 27, 2021
f29e630
Undo code remotion
Aug 12, 2021
9871e75
Merge commit '8a16729fcf' into HEAD
Aug 23, 2021
1f9565d
Add object to log
Aug 23, 2021
eecbaec
Remove statement from try/catch
Aug 26, 2021
2c2efff
Merge remote-tracking branch 'apache-github/main' into HEAD
Sep 1, 2021
984bbbf
Merge commit '1ed828b2a1' into HEAD
Sep 3, 2021
c606926
Merge remote-tracking branch 'apache-github/main' into HEAD
Sep 14, 2021
c8cb75a
Implement toString with ReflectionToStringBuilderUtils
Sep 14, 2021
4524128
Merge branch 'main' into improve-logs-on-virtualmachinemanagerimpl
GutoVeronezi Sep 27, 2021
7ef522b
Merge branch 'main' into improve-logs-on-virtualmachinemanagerimpl
GutoVeronezi Oct 5, 2021
24b30cb
Merge branch 'main' into improve-logs-on-virtualmachinemanagerimpl
GutoVeronezi Oct 9, 2021
57ce0ed
Merge branch 'main' into improve-logs-on-virtualmachinemanagerimpl
GutoVeronezi Nov 8, 2021
9fcf33d
Merge branch 'main' into improve-logs-on-virtualmachinemanagerimpl
GutoVeronezi Nov 18, 2021
732bbcd
Fix errors related to merge main
Nov 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions api/src/main/java/com/cloud/vm/NicProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.net.URI;

import org.apache.cloudstack.api.InternalIdentity;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

import com.cloud.network.Network;
import com.cloud.network.Networks.AddressFormat;
Expand Down Expand Up @@ -430,16 +431,6 @@ public void deallocate() {

@Override
public String toString() {
return new StringBuilder("NicProfile[").append(id)
.append("-")
.append(vmId)
.append("-")
.append(reservationId)
.append("-")
.append(iPv4Address)
.append("-")
.append(broadcastUri)
.append("]")
.toString();
return String.format("NicProfile %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "id", "vmId", "reservationId", "iPv4Address", "broadcastUri"));
}
}
7 changes: 7 additions & 0 deletions engine/components-api/src/main/java/com/cloud/vm/VmWork.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public VmWork(long userId, long accountId, long vmId, String handlerName) {
this.handlerName = handlerName;
}

public VmWork(VmWork vmWork) {
this.userId = vmWork.getUserId();
this.accountId = vmWork.getAccountId();
this.vmId = vmWork.getVmId();
this.handlerName = vmWork.getHandlerName();
}

public long getUserId() {
return userId;
}
Expand Down
1,810 changes: 639 additions & 1,171 deletions engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public VmWorkAddVmToNetwork(long userId, long accountId, long vmId, String handl
requstedNicProfile = requested;
}

public VmWorkAddVmToNetwork(VmWork vmWork, long networkId, NicProfile requested) {
super(vmWork);
this.networkId = networkId;
this.requstedNicProfile = requested;
}

public Long getNetworkId() {
return networkId;
}
Expand Down
27 changes: 18 additions & 9 deletions engine/orchestration/src/main/java/com/cloud/vm/VmWorkMigrate.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,27 @@ public class VmWorkMigrate extends VmWork {
public VmWorkMigrate(long userId, long accountId, long vmId, String handlerName,
long srcHostId, DeployDestination dst) {
super(userId, accountId, vmId, handlerName);
setConstructorParams(srcHostId, dst);
}

public VmWorkMigrate(VmWork vmWork, long srcHostId, DeployDestination dest) {
super(vmWork);
setConstructorParams(srcHostId, dest);
}

private void setConstructorParams(long srcHostId, DeployDestination dest) {
this.srcHostId = srcHostId;
zoneId = dst.getDataCenter() != null ? dst.getDataCenter().getId() : null;
podId = dst.getPod() != null ? dst.getPod().getId() : null;
clusterId = dst.getCluster() != null ? dst.getCluster().getId() : null;
hostId = dst.getHost() != null ? dst.getHost().getId() : null;
if (dst.getStorageForDisks() != null) {
storage = new HashMap<String, String>(dst.getStorageForDisks().size());
for (Map.Entry<Volume, StoragePool> entry : dst.getStorageForDisks().entrySet()) {
storage.put(entry.getKey().getUuid(), entry.getValue().getUuid());
this.zoneId = dest.getDataCenter() != null ? dest.getDataCenter().getId() : null;
this.podId = dest.getPod() != null ? dest.getPod().getId() : null;
this.clusterId = dest.getCluster() != null ? dest.getCluster().getId() : null;
this.hostId = dest.getHost() != null ? dest.getHost().getId() : null;
if (dest.getStorageForDisks() != null) {
this.storage = new HashMap<>(dest.getStorageForDisks().size());
for (Map.Entry<Volume, StoragePool> entry : dest.getStorageForDisks().entrySet()) {
this.storage.put(entry.getKey().getUuid(), entry.getValue().getUuid());
}
} else {
storage = null;
this.storage = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public VmWorkMigrateAway(long userId, long accountId, long vmId, String handlerN
this.srcHostId = srcHostId;
}

public VmWorkMigrateAway(VmWork vmWork, long srcHostId) {
super(vmWork);
this.srcHostId = srcHostId;
}

public long getSrcHostId() {
return srcHostId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public VmWorkMigrateForScale(long userId, long accountId, long vmId, String hand
this.newSvcOfferingId = newSvcOfferingId;
}

public VmWorkMigrateForScale(VmWork vmWork, long srcHostId, DeployDestination dest, Long newSvcOfferingId) {
super(vmWork, srcHostId, dest);
this.newSvcOfferingId = newSvcOfferingId;
}

public Long getNewServiceOfferringId() {
return newSvcOfferingId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public VmWorkMigrateWithStorage(long userId, long accountId, long vmId, String h
this.volumeToPool = volumeToPool;
}

public VmWorkMigrateWithStorage(VmWork vmWork, long srcHostId, long destHostId, Map<Long, Long> volumeToPool) {
super(vmWork);
this.srcHostId = srcHostId;
this.destHostId = destHostId;
this.volumeToPool = volumeToPool;
}

public long getSrcHostId() {
return srcHostId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public VmWorkReboot(long userId, long accountId, long vmId, String handlerName,
setParams(params);
}

public VmWorkReboot(VmWork vmWork, Map<VirtualMachineProfile.Param, Object> params) {
super(vmWork);
setParams(params);
}

public Map<VirtualMachineProfile.Param, Object> getParams() {
Map<VirtualMachineProfile.Param, Object> map = new HashMap<VirtualMachineProfile.Param, Object>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public VmWorkReconfigure(long userId, long accountId, long vmId, String handlerN
this.sameHost = sameHost;
}

public VmWorkReconfigure(VmWork vmWork, long oldServiceOfferingId, long newServiceOfferingId, Map<String, String> customParameters, boolean sameHost) {
super(vmWork);
this.oldServiceOfferingId = oldServiceOfferingId;
this.newServiceOfferingId = newServiceOfferingId;
this.customParameters = customParameters;
this.sameHost = sameHost;
}

public Long getOldServiceOfferingId() {
return oldServiceOfferingId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public VmWorkRemoveNicFromVm(long userId, long accountId, long vmId, String hand
this.nicId = nicId;
}

public VmWorkRemoveNicFromVm(VmWork vmWork, long nicId) {
super(vmWork);
this.nicId = nicId;
}

public Long getNicId() {
return nicId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public VmWorkRemoveVmFromNetwork(long userId, long accountId, long vmId, String
this.broadcastUri = broadcastUri;
}

public VmWorkRemoveVmFromNetwork(VmWork vmWork, Network network, URI broadcastUri) {
super(vmWork);
this.network = network;
this.broadcastUri = broadcastUri;
}

public Network getNetwork() {
return network;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public VmWorkRestore(long userId, long accountId, long vmId, String handlerName,
this.templateId = templateId;
}

public VmWorkRestore(VmWork vmWork, Long templateId) {
super(vmWork);
this.templateId = templateId;
}

public Long getTemplateId() {
return templateId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public VmWorkStart(long userId, long accountId, long vmId, String handlerName) {
super(userId, accountId, vmId, handlerName);
}

public VmWorkStart(VmWork vmWork){
super(vmWork);
}

public DeploymentPlan getPlan() {

if (podId != null || clusterId != null || hostId != null || poolId != null || physicalNetworkId != null || avoids !=null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public VmWorkStop(long userId, long accountId, long vmId, String handlerName, bo
this.cleanup = cleanup;
}

public VmWorkStop(VmWork vmWork, boolean cleanup) {
super(vmWork);
this.cleanup = cleanup;
}

public boolean isCleanup() {
return cleanup;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class VmWorkStorageMigration extends VmWork {

Map<Long, Long> volumeToPool;

public VmWorkStorageMigration(long userId, long accountId, long vmId, String handlerName, Map <Long, Long> volumeToPool) {
public VmWorkStorageMigration(long userId, long accountId, long vmId, String handlerName, Map<Long, Long> volumeToPool) {
super(userId, accountId, vmId, handlerName);

this.volumeToPool = volumeToPool;
Expand All @@ -32,4 +32,9 @@ public VmWorkStorageMigration(long userId, long accountId, long vmId, String han
public Map<Long, Long> getVolumeToPool() {
return volumeToPool;
}

public VmWorkStorageMigration(VmWork vmWork, Map<Long, Long> volumeToPool) {
super(vmWork);
this.volumeToPool = volumeToPool;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public VmWorkUpdateDefaultNic(long userId, long accountId, long vmId, String han
this.defaultNicId = defaultNicId;
}

public VmWorkUpdateDefaultNic(VmWork vmWork, long nicId, long defaultNicId) {
super(vmWork);
this.nicId = nicId;
this.defaultNicId = defaultNicId;
}

public Long getNicId() {
return nicId;
}
Expand Down
10 changes: 3 additions & 7 deletions engine/schema/src/main/java/com/cloud/storage/VMTemplateVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
Expand Down Expand Up @@ -551,15 +553,9 @@ public int hashCode() {
return uniqueName.hashCode();
}

@Transient
String toString;

@Override
public String toString() {
if (toString == null) {
toString = new StringBuilder("Tmpl[").append(id).append("-").append(format).append("-").append(uniqueName).toString();
}
return toString;
return String.format("Template %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "id", "uniqueName", "format"));
}

public void setRemoved(Date removed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.cloud.agent.api.Command;
import com.cloud.agent.api.Command.OnError;
import com.cloud.utils.exception.CloudRuntimeException;
import java.util.stream.Collectors;

public class Commands implements Iterable<Command> {
OnError _handler;
Expand Down Expand Up @@ -150,4 +151,10 @@ public boolean isSuccessful() {
public Iterator<Command> iterator() {
return _cmds.iterator();
}

@Override
public String toString() {
return _cmds.stream().map(cmd -> cmd.toString()).collect(Collectors.joining(", "));
}

}