Skip to content
1 change: 1 addition & 0 deletions .github/linters/codespell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ environmnet
equivalant
erro
erronous
errorprone
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codespell exclusion entry "errorprone" should be capitalized as "ErrorProne" to match the actual tool name, or removed entirely as it's a valid technical term that doesn't need to be in the codespell ignore list.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we try this? it makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codespell matches words case insensitively, so this shouldn't matter

everthing
everytime
excetion
Expand Down
2 changes: 1 addition & 1 deletion agent/src/main/java/com/cloud/agent/mockvm/MockVmMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void freeVncPort(int port) {
public MockVm createVmFromSpec(VirtualMachineTO vmSpec) {
String vmName = vmSpec.getName();
long ramSize = vmSpec.getMinRam();
int utilizationPercent = randSeed.nextInt() % 100;
int utilizationPercent = randSeed.nextInt(100);
MockVm vm = null;

synchronized (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Boolean getAllowUserDrivenBackups() {
public void execute() {
try {
if (StringUtils.isAllEmpty(getName(), getDescription()) && getAllowUserDrivenBackups() == null) {
throw new InvalidParameterValueException(String.format("Can't update Backup Offering [id: %s] because there are no parameters to be updated, at least one of the",
throw new InvalidParameterValueException(String.format("Can't update Backup Offering [id: %s] because there are no parameters to be updated, at least one of the " +
"following should be informed: name, description or allowUserDrivenBackups.", id));
Comment on lines +86 to 87
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new InvalidParameterValueException(String.format("Can't update Backup Offering [id: %s] because there are no parameters to be updated, at least one of the " +
"following should be informed: name, description or allowUserDrivenBackups.", id));
throw new InvalidParameterValueException(String.format(
"Can't update Backup Offering [id: %s] because there are no parameters to be updated,” +
" at least one of the following should be informed: name, description or allowUserDrivenBackups.",
id));

(just readability??)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class IsolationMethodTest {
@After
public void cleanTheRegistry() {
PhysicalNetwork.IsolationMethod.registeredIsolationMethods.removeAll(PhysicalNetwork.IsolationMethod.registeredIsolationMethods);
PhysicalNetwork.IsolationMethod.registeredIsolationMethods.clear();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public abstract class AbstractConfigItemFacade {

public static AbstractConfigItemFacade getInstance(final Class<? extends NetworkElementCommand> key) {
if (!flyweight.containsKey(key)) {
throw new CloudRuntimeException("Unable to process the configuration for " + key.getClass().getName());
throw new CloudRuntimeException("Unable to process the configuration for " + key.getName());
}

final AbstractConfigItemFacade instance = flyweight.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ private List<String> getRulesForPool(final LoadBalancerTO lbTO, final boolean ke
}
dstSubRule.add(sb.toString());
if (stickinessSubRule != null) {
sb.append(" cookie ").append(dest.getDestIp().replace(".", "_")).append('-').append(dest.getDestPort()).toString();
sb.append(" cookie ").append(dest.getDestIp().replace(".", "_")).append('-').append(dest.getDestPort());
dstWithCookieSubRule.add(sb.toString());
}
destsAvailable = true;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/cloud/resource/RequestWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected CommandWrapper<Command, Answer, ServerResource> retrieveCommands(final

keepCommandClass = commandClass2;
} catch (final ClassCastException e) {
throw new CommandNotSupported("No key found for '" + keepCommandClass.getClass() + "' in the Map!");
throw new CommandNotSupported("No key found for '" + keepCommandClass + "' in the Map!");
} catch (final NullPointerException e) {
// Will now traverse all the resource hierarchy. Returning null
// is not a problem.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protected DirectDownloadCommand (final String url, final Long templateId, final
final Integer soTimeout, final Integer connectionRequestTimeout, final boolean followRedirects) {
this.url = url;
this.templateId = templateId;
this.destData = destData;
this.destPool = destPool;
this.checksum = checksum;
this.headers = headers;
Expand Down
23 changes: 11 additions & 12 deletions core/src/test/java/com/cloud/resource/ServerResourceBaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,36 +182,36 @@ public void tryToAutoDiscoverResourcePrivateNetworkInterfaceTestReturnNic() thro
@Test
public void defineResourceNetworkInterfacesTestUseXenbr0WhenPrivateNetworkInterfaceNotConfigured() {
Map<String, Object> params = createParamsMap(null, "cloudbr1", "cloudbr2", "cloudbr3");
try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) {
Mockito.when(NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4);
try (MockedStatic<NetUtils> mockedNetUtils = Mockito.mockStatic(NetUtils.class)) {
mockedNetUtils.when(() -> NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4);

serverResourceBaseSpy.defineResourceNetworkInterfaces(params);

verifyAndAssertNetworkInterfaces("xenbr0", "cloudbr1", "cloudbr2", "cloudbr3");
verifyAndAssertNetworkInterfaces(mockedNetUtils, "xenbr0", "cloudbr1", "cloudbr2", "cloudbr3");
}
}

@Test
public void defineResourceNetworkInterfacesTestUseXenbr1WhenPublicNetworkInterfaceNotConfigured() {
Map<String, Object> params = createParamsMap("cloudbr0", null, "cloudbr2", "cloudbr3");
try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) {
Mockito.when(NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4);
try (MockedStatic<NetUtils> mockedNetUtils = Mockito.mockStatic(NetUtils.class)) {
mockedNetUtils.when(() -> NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4);

serverResourceBaseSpy.defineResourceNetworkInterfaces(params);

verifyAndAssertNetworkInterfaces("cloudbr0", "xenbr1", "cloudbr2", "cloudbr3");
verifyAndAssertNetworkInterfaces(mockedNetUtils, "cloudbr0", "xenbr1", "cloudbr2", "cloudbr3");
}
}

@Test
public void defineResourceNetworkInterfacesTestUseConfiguredNetworkInterfaces() {
Map<String, Object> params = createParamsMap("cloudbr0", "cloudbr1", "cloudbr2", "cloudbr3");
try (MockedStatic<NetUtils> ignored = Mockito.mockStatic(NetUtils.class)) {
Mockito.when(NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4);
try (MockedStatic<NetUtils> mockedNetUtils = Mockito.mockStatic(NetUtils.class)) {
mockedNetUtils.when(() -> NetUtils.getNetworkInterface(Mockito.anyString())).thenReturn(networkInterfaceMock1, networkInterfaceMock2, networkInterfaceMock3, networkInterfaceMock4);

serverResourceBaseSpy.defineResourceNetworkInterfaces(params);

verifyAndAssertNetworkInterfaces("cloudbr0", "cloudbr1", "cloudbr2", "cloudbr3");
verifyAndAssertNetworkInterfaces(mockedNetUtils, "cloudbr0", "cloudbr1", "cloudbr2", "cloudbr3");
}
}

Expand All @@ -224,9 +224,8 @@ private Map<String, Object> createParamsMap(String... params) {
return result;
}

private void verifyAndAssertNetworkInterfaces(String... expectedResults) {
Mockito.verify(NetUtils.class, Mockito.times(4));
NetUtils.getNetworkInterface(keyCaptor.capture());
private void verifyAndAssertNetworkInterfaces(MockedStatic<NetUtils> mockedNetUtils, String... expectedResults) {
mockedNetUtils.verify(() -> NetUtils.getNetworkInterface(keyCaptor.capture()), Mockito.times(4));
List<String> keys = keyCaptor.getAllValues();

for (int i = 0; i < expectedResults.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -497,6 +498,11 @@ public void process(final Answer[] answers) {
*/
protected abstract boolean isClosed();

@Override
public int hashCode() {
return Objects.hash(_id, _uuid, _name);
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hashCode implementation uses _id, _uuid, and _name, but the equals method in AgentAttache only uses _id for comparison. The hashCode implementation should be consistent with equals and only use _id to maintain the equals-hashCode contract.

Suggested change
return Objects.hash(_id, _uuid, _name);
return Objects.hash(_id);

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or add _uuid and _name comparison to equals()? actually only _uuid and _name makes more sense.

}

protected class Alarm extends ManagedContextRunnable {
long _seq;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ private synchronized void scheduleFromQueue() {
}
}

@Override
public int hashCode() {
return super.hashCode();
}

protected class PingTask extends ManagedContextRunnable {
@Override
protected synchronized void runInContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ public void stop(final String vmUuid) throws ResourceUnavailableException {
} catch (final OperationTimedoutException e) {
throw new AgentUnavailableException(String.format("Unable to stop vm [%s] because the operation to stop timed out", vmUuid), e.getAgentId(), e);
} catch (final ConcurrentOperationException e) {
throw new CloudRuntimeException(String.format("Unable to stop vm because of a concurrent operation", vmUuid), e);
throw new CloudRuntimeException(String.format("Unable to stop vm: %s because of a concurrent operation", vmUuid), e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new CloudRuntimeException(String.format("Unable to stop vm: %s because of a concurrent operation", vmUuid), e);
throw new CloudRuntimeException(String.format("Unable to stop vm [%s] because of a concurrent operation", vmUuid), e);

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ protected boolean reprogramNetworkRules(final long networkId, final Account call
final List<FirewallRuleVO> firewallEgressRulesToApply = _firewallDao.listByNetworkPurposeTrafficType(networkId, Purpose.Firewall, FirewallRule.TrafficType.Egress);
final NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
final DataCenter zone = _dcDao.findById(network.getDataCenterId());
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Firewall) && _networkModel.areServicesSupportedInNetwork(network.getId(), Service.Firewall)
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Firewall)
&& (network.getGuestType() == Network.GuestType.Isolated || network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced)) {
// add default egress rule to accept the traffic
_firewallMgr.applyDefaultEgressFirewallRule(network.getId(), offering.isEgressDefaultPolicy(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public NetworkOfferingVO(String name, Network.GuestType guestType, boolean speci
true,
Availability.Optional,
null,
Network.GuestType.Isolated,
guestType,
true,
false,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,38 +324,33 @@ public void setUpdated(Date updated) {

public static final Map<String, MetadataTemplateDetails> NewTemplateMap = new HashMap<>();

public static final Map<Hypervisor.HypervisorType, String> RouterTemplateConfigurationNames = new HashMap<>() {
{
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
}
};

public static Map<Hypervisor.HypervisorType, Integer> hypervisorGuestOsMap = new HashMap<>() {
{
put(Hypervisor.HypervisorType.KVM, LINUX_12_ID);
put(Hypervisor.HypervisorType.XenServer, OTHER_LINUX_ID);
put(Hypervisor.HypervisorType.VMware, OTHER_LINUX_ID);
put(Hypervisor.HypervisorType.Hyperv, LINUX_12_ID);
put(Hypervisor.HypervisorType.LXC, LINUX_12_ID);
put(Hypervisor.HypervisorType.Ovm3, LINUX_12_ID);
}
};

public static final Map<Hypervisor.HypervisorType, ImageFormat> hypervisorImageFormat = new HashMap<Hypervisor.HypervisorType, ImageFormat>() {
{
put(Hypervisor.HypervisorType.KVM, ImageFormat.QCOW2);
put(Hypervisor.HypervisorType.XenServer, ImageFormat.VHD);
put(Hypervisor.HypervisorType.VMware, ImageFormat.OVA);
put(Hypervisor.HypervisorType.Hyperv, ImageFormat.VHD);
put(Hypervisor.HypervisorType.LXC, ImageFormat.QCOW2);
put(Hypervisor.HypervisorType.Ovm3, ImageFormat.RAW);
}
};
public static final Map<Hypervisor.HypervisorType, String> RouterTemplateConfigurationNames = Map.of(
Hypervisor.HypervisorType.KVM, "router.template.kvm",
Hypervisor.HypervisorType.VMware, "router.template.vmware",
Hypervisor.HypervisorType.XenServer, "router.template.xenserver",
Hypervisor.HypervisorType.Hyperv, "router.template.hyperv",
Hypervisor.HypervisorType.LXC, "router.template.lxc",
Hypervisor.HypervisorType.Ovm3, "router.template.ovm3"
);

public static Map<Hypervisor.HypervisorType, Integer> hypervisorGuestOsMap = new HashMap<>();
static {
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.KVM, LINUX_12_ID);
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.XenServer, OTHER_LINUX_ID);
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.VMware, OTHER_LINUX_ID);
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.Hyperv, LINUX_12_ID);
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.LXC, LINUX_12_ID);
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.Ovm3, LINUX_12_ID);
}

public static final Map<Hypervisor.HypervisorType, ImageFormat> hypervisorImageFormat = Map.of(
Hypervisor.HypervisorType.KVM, ImageFormat.QCOW2,
Hypervisor.HypervisorType.XenServer, ImageFormat.VHD,
Hypervisor.HypervisorType.VMware, ImageFormat.OVA,
Hypervisor.HypervisorType.Hyperv, ImageFormat.VHD,
Hypervisor.HypervisorType.LXC, ImageFormat.QCOW2,
Hypervisor.HypervisorType.Ovm3, ImageFormat.RAW
);

public boolean validateIfSeeded(TemplateDataStoreVO templDataStoreVO, String url, String path, String nfsVersion) {
String filePath = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public boolean indexExists(Connection conn, String tableName, String indexName)
return true;
}
} catch (SQLException e) {
logger.debug(String.format("Index %s doesn't exist, ignoring exception:", indexName, e.getMessage()));
logger.debug(String.format("Index %s doesn't exist, ignoring exception:", indexName), e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.debug(String.format("Index %s doesn't exist, ignoring exception:", indexName), e.getMessage());
logger.debug("Index {} doesn't exist, ignoring exception: {}", indexName, e.getMessage());

}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -98,49 +97,41 @@ public void updateSystemVmTemplates(final Connection conn) {
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting hypervisor types from clusters", e);
}

final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = new HashMap<Hypervisor.HypervisorType, String>() {
{
put(KVM, "systemvm-kvm-4.15.1");
put(VMware, "systemvm-vmware-4.15.1");
put(XenServer, "systemvm-xenserver-4.15.1");
put(Hyperv, "systemvm-hyperv-4.15.1");
put(LXC, "systemvm-lxc-4.15.1");
put(Ovm3, "systemvm-ovm3-4.15.1");
}
};

final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
{
put(KVM, "router.template.kvm");
put(VMware, "router.template.vmware");
put(XenServer, "router.template.xenserver");
put(Hyperv, "router.template.hyperv");
put(LXC, "router.template.lxc");
put(Ovm3, "router.template.ovm3");
}
};

final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {
{
put(KVM, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2");
put(VMware, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-vmware.ova");
put(XenServer, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-xen.vhd.bz2");
put(Hyperv, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-hyperv.vhd.zip");
put(LXC, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2");
put(Ovm3, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-ovm.raw.bz2");
}
};

final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {
{
put(KVM, "0e9f9a7d0957c3e0a2088e41b2da2cec");
put(XenServer, "86373992740b1eca8aff8b08ebf3aea5");
put(VMware, "4006982765846d373eb3719b2fe4d720");
put(Hyperv, "0b9514e4b6cba1f636fea2125f0f7a5f");
put(LXC, "0e9f9a7d0957c3e0a2088e41b2da2cec");
put(Ovm3, "ae3977e696b3e6c81bdcbb792d514d29");
}
};
final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = Map.of(
KVM, "systemvm-kvm-4.15.1",
VMware, "systemvm-vmware-4.15.1",
XenServer, "systemvm-xenserver-4.15.1",
Hyperv, "systemvm-hyperv-4.15.1",
LXC, "systemvm-lxc-4.15.1",
Ovm3, "systemvm-ovm3-4.15.1"
);

final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = Map.of(
KVM, "router.template.kvm",
VMware, "router.template.vmware",
XenServer, "router.template.xenserver",
Hyperv, "router.template.hyperv",
LXC, "router.template.lxc",
Ovm3, "router.template.ovm3"
);

final Map<Hypervisor.HypervisorType, String> newTemplateUrl = Map.of(
KVM, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2",
VMware, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-vmware.ova",
XenServer, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-xen.vhd.bz2",
Hyperv, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-hyperv.vhd.zip",
LXC, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2",
Ovm3, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-ovm.raw.bz2"
);

final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = Map.of(
KVM, "0e9f9a7d0957c3e0a2088e41b2da2cec",
XenServer, "86373992740b1eca8aff8b08ebf3aea5",
VMware, "4006982765846d373eb3719b2fe4d720",
Hyperv, "0b9514e4b6cba1f636fea2125f0f7a5f",
LXC, "0e9f9a7d0957c3e0a2088e41b2da2cec",
Ovm3, "ae3977e696b3e6c81bdcbb792d514d29"
);

for (final Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
logger.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
Expand Down
Loading
Loading