Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/host/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public static String[] toStrings(Host.Type... types) {
String HOST_VIRTV2V_VERSION = "host.virtv2v.version";
String HOST_SSH_PORT = "host.ssh.port";
String HOST_CDROM_MAX_COUNT = "host.cdrom.max.count";
String HOST_VLAN_FILTERING_ENABLED = "vlan.filtering.enabled";
String HOST_VLAN_TRUNK_XML_SUPPORTED = "vlan.trunk.xml.supported";
String GUEST_OS_CATEGORY_ID = "guest.os.category.id";
String GUEST_OS_RULE = "guest.os.rule";

Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/vm/Nic.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public enum ReservationStrategy {

boolean getSecondaryIp();

boolean getMultiNetwork();

//
// IPv4
//
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ public class ApiConstants {
public static final String MOVE_ACL_CONSISTENCY_HASH = "aclconsistencyhash";
public static final String IMAGE_PATH = "imagepath";
public static final String INSTANCE_CONVERSION_SUPPORTED = "instanceconversionsupported";
public static final String VLAN_FILTERING_ENABLED = "vlanfilteringenabled";
public static final String VLAN_TRUNK_XML_SUPPORTED = "vlantrunkxmlsupported";
public static final String INTERNAL_DNS1 = "internaldns1";
public static final String INTERNAL_DNS2 = "internaldns2";
public static final String INTERNET_PROTOCOL = "internetprotocol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ public class HostResponse extends BaseResponseWithAnnotations {
@Param(description = "true if the host supports instance conversion (using virt-v2v)", since = "4.19.1")
private Boolean instanceConversionSupported;

@SerializedName(ApiConstants.VLAN_FILTERING_ENABLED)
@Param(description = "true if vlan_filtering is enabled on this host's guest bridge, so it can accept multi-VLAN trunk nics", since = "24.0.0")
private Boolean vlanFilteringEnabled;

@SerializedName(ApiConstants.VLAN_TRUNK_XML_SUPPORTED)
@Param(description = "true if this host's libvirt version supports trunk vlan tap membership natively", since = "24.0.0")
private Boolean vlanTrunkXmlSupported;

@SerializedName(ApiConstants.ARCH)
@Param(description = "CPU Arch of the host", since = "4.20")
private String arch;
Expand Down Expand Up @@ -904,6 +912,14 @@ public void setInstanceConversionSupported(Boolean instanceConversionSupported)
this.instanceConversionSupported = instanceConversionSupported;
}

public void setVlanFilteringEnabled(Boolean vlanFilteringEnabled) {
this.vlanFilteringEnabled = vlanFilteringEnabled;
}

public void setVlanTrunkXmlSupported(Boolean vlanTrunkXmlSupported) {
this.vlanTrunkXmlSupported = vlanTrunkXmlSupported;
}

public Boolean getIsTagARule() {
return isTagARule;
}
Expand Down Expand Up @@ -1000,6 +1016,14 @@ public Boolean getInstanceConversionSupported() {
return instanceConversionSupported;
}

public Boolean getVlanFilteringEnabled() {
return vlanFilteringEnabled;
}

public Boolean getVlanTrunkXmlSupported() {
return vlanTrunkXmlSupported;
}

public void setExtensionId(String extensionId) {
this.extensionId = extensionId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,10 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
String vddkSupport = detailsMap.get(Host.HOST_VDDK_SUPPORT);
String vddkLibDir = detailsMap.get(Host.HOST_VDDK_LIB_DIR);
String vddkVersion = detailsMap.get(Host.HOST_VDDK_VERSION);
String vlanFilteringEnabled = detailsMap.get(Host.HOST_VLAN_FILTERING_ENABLED);
String vlanTrunkXmlSupported = detailsMap.get(Host.HOST_VLAN_TRUNK_XML_SUPPORTED);
logger.debug("Got HOST_UEFI_ENABLE [{}] for host [{}]:", uefiEnabled, host);
if (ObjectUtils.anyNotNull(uefiEnabled, diskOnlyVmSnapshotNvramSupport, virtv2vVersion, ovftoolVersion, vddkSupport, vddkLibDir, vddkVersion)) {
if (ObjectUtils.anyNotNull(uefiEnabled, diskOnlyVmSnapshotNvramSupport, virtv2vVersion, ovftoolVersion, vddkSupport, vddkLibDir, vddkVersion, vlanFilteringEnabled, vlanTrunkXmlSupported)) {
boolean updateNeeded = false;
if (syncBooleanHostCapability(host, Host.HOST_UEFI_ENABLE, uefiEnabled)) {
updateNeeded = true;
Expand All @@ -838,6 +840,12 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
host.getDetails().put(Host.HOST_VDDK_SUPPORT, vddkSupport);
updateNeeded = true;
}
if (syncBooleanHostCapability(host, Host.HOST_VLAN_FILTERING_ENABLED, vlanFilteringEnabled)) {
updateNeeded = true;
}
if (syncBooleanHostCapability(host, Host.HOST_VLAN_TRUNK_XML_SUPPORTED, vlanTrunkXmlSupported)) {
updateNeeded = true;
}
if (!StringUtils.defaultString(vddkLibDir).equals(StringUtils.defaultString(host.getDetails().get(Host.HOST_VDDK_LIB_DIR)))) {
if (StringUtils.isBlank(vddkLibDir)) {
host.getDetails().remove(Host.HOST_VDDK_LIB_DIR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@
import com.cloud.upgrade.dao.Upgrade42020to42030;
import com.cloud.upgrade.dao.Upgrade42030to42040;
import com.cloud.upgrade.dao.Upgrade42040to42100;
import com.cloud.upgrade.dao.Upgrade42100to42200;
import com.cloud.upgrade.dao.Upgrade42200to42210;
import com.cloud.upgrade.dao.Upgrade420to421;
import com.cloud.upgrade.dao.Upgrade42100to42200;
import com.cloud.upgrade.dao.Upgrade421to430;
import com.cloud.upgrade.dao.Upgrade42200to42210;
import com.cloud.upgrade.dao.Upgrade42210to42300;
import com.cloud.upgrade.dao.Upgrade42300to2400;
import com.cloud.upgrade.dao.Upgrade430to440;
import com.cloud.upgrade.dao.Upgrade431to440;
import com.cloud.upgrade.dao.Upgrade432to440;
Expand Down Expand Up @@ -248,6 +249,7 @@
.next("4.21.0.0", new Upgrade42100to42200())
.next("4.22.0.0", new Upgrade42200to42210())
.next("4.22.1.0", new Upgrade42210to42300())
.next("4.23.0.0", new Upgrade42300to2400())

Check warning on line 252 in engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make sure using this hardcoded IP address is safe here.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHPMdBIFDwPvW32e&open=AaChtHPMdBIFDwPvW32e&pullRequest=14166
.build();
}

Expand Down Expand Up @@ -513,8 +515,13 @@
String csVersion = parseSystemVmMetadata();
final CloudStackVersion sysVmVersion = CloudStackVersion.parse(csVersion);
final CloudStackVersion currentVersion = CloudStackVersion.parse(currentVersionValue);
SystemVmTemplateRegistration.CS_MAJOR_VERSION = sysVmVersion.getMajorRelease() + "." + sysVmVersion.getMinorRelease();
SystemVmTemplateRegistration.CS_TINY_VERSION = String.valueOf(sysVmVersion.getPatchRelease());
if (sysVmVersion.usesNewVersioning()) {
SystemVmTemplateRegistration.CS_MAJOR_VERSION = String.valueOf(sysVmVersion.getMajorRelease());

Check failure on line 519 in engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the enclosing method "static" or remove this set.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHPMdBIFDwPvW32f&open=AaChtHPMdBIFDwPvW32f&pullRequest=14166
SystemVmTemplateRegistration.CS_TINY_VERSION = String.valueOf(sysVmVersion.getMajorRelease());

Check failure on line 520 in engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the enclosing method "static" or remove this set.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHPMdBIFDwPvW32g&open=AaChtHPMdBIFDwPvW32g&pullRequest=14166
} else {
SystemVmTemplateRegistration.CS_MAJOR_VERSION = String.format("%d.%d", sysVmVersion.getMajorRelease(), sysVmVersion.getMinorRelease());

Check failure on line 522 in engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the enclosing method "static" or remove this set.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHPMdBIFDwPvW32h&open=AaChtHPMdBIFDwPvW32h&pullRequest=14166
SystemVmTemplateRegistration.CS_TINY_VERSION = String.valueOf(sysVmVersion.getPatchRelease());
}

LOGGER.info("DB version = {} Code Version = {}", dbVersion, currentVersion);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.upgrade.dao;

public class Upgrade42300to2400 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {

@Override
public String[] getUpgradableVersionRange() {
return new String[]{"4.23.0.0", "24.0.0"};

Check warning on line 23 in engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42300to2400.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make sure using this hardcoded IP address is safe here.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHJVdBIFDwPvW32d&open=AaChtHJVdBIFDwPvW32d&pullRequest=14166
}

@Override
public String getUpgradedVersion() {
return "24.0.0";
}
}
14 changes: 13 additions & 1 deletion engine/schema/src/main/java/com/cloud/vm/NicVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ protected NicVO() {
@Column(name = "secondary_ip")
boolean secondaryIp;

@Column(name = "multi_network")
boolean multiNetwork;

@Column(name = "mtu")
Integer mtu;

Expand Down Expand Up @@ -337,7 +340,7 @@ public String toString() {
return String.format("Nic %s",
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "id", "uuid", "instanceId",
"deviceId", "broadcastUri", "reservationId", "iPv4Address"));
"deviceId", "broadcastUri", "reservationId", "iPv4Address", "multiNetwork"));
}

@Override
Expand Down Expand Up @@ -381,6 +384,15 @@ public void setSecondaryIp(boolean secondaryIp) {
this.secondaryIp = secondaryIp;
}

@Override
public boolean getMultiNetwork() {
return multiNetwork;
}

public void setMultiNetwork(boolean multiNetwork) {
this.multiNetwork = multiNetwork;
}

public void setVmType(VirtualMachine.Type vmType) {
this.vmType = vmType;
}
Expand Down
32 changes: 32 additions & 0 deletions engine/schema/src/main/java/com/cloud/vm/dao/NicNetworkMapDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.vm.dao;

import java.util.List;

import com.cloud.utils.db.GenericDao;

public interface NicNetworkMapDao extends GenericDao<NicNetworkMapVO, Long> {

List<NicNetworkMapVO> listByNicId(long nicId);

List<NicNetworkMapVO> listByNetworkId(long networkId);

NicNetworkMapVO findByNicIdAndNetworkId(long nicId, long networkId);

List<Long> listNicIdsByNetworkId(long networkId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.vm.dao;

import java.util.List;

import org.springframework.stereotype.Component;

import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.GenericSearchBuilder;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Func;
import com.cloud.utils.db.SearchCriteria.Op;

@Component
public class NicNetworkMapDaoImpl extends GenericDaoBase<NicNetworkMapVO, Long> implements NicNetworkMapDao {

private final SearchBuilder<NicNetworkMapVO> AllFieldsSearch;

Check warning on line 33 in engine/schema/src/main/java/com/cloud/vm/dao/NicNetworkMapDaoImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "AllFieldsSearch" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHQjdBIFDwPvW32l&open=AaChtHQjdBIFDwPvW32l&pullRequest=14166
private final GenericSearchBuilder<NicNetworkMapVO, Long> NicIdsByNetworkSearch;

Check warning on line 34 in engine/schema/src/main/java/com/cloud/vm/dao/NicNetworkMapDaoImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "NicIdsByNetworkSearch" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHQjdBIFDwPvW32m&open=AaChtHQjdBIFDwPvW32m&pullRequest=14166

public NicNetworkMapDaoImpl() {
super();
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("nicId", AllFieldsSearch.entity().getNicId(), Op.EQ);

Check failure on line 39 in engine/schema/src/main/java/com/cloud/vm/dao/NicNetworkMapDaoImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "nicId" 3 times.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHQjdBIFDwPvW32k&open=AaChtHQjdBIFDwPvW32k&pullRequest=14166
AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), Op.EQ);

Check failure on line 40 in engine/schema/src/main/java/com/cloud/vm/dao/NicNetworkMapDaoImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "networkId" 5 times.

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaChtHQjdBIFDwPvW32j&open=AaChtHQjdBIFDwPvW32j&pullRequest=14166
AllFieldsSearch.done();

NicIdsByNetworkSearch = createSearchBuilder(Long.class);
NicIdsByNetworkSearch.select(null, Func.DISTINCT, NicIdsByNetworkSearch.entity().getNicId());
NicIdsByNetworkSearch.and("networkId", NicIdsByNetworkSearch.entity().getNetworkId(), Op.EQ);
NicIdsByNetworkSearch.done();
}

@Override
public List<NicNetworkMapVO> listByNicId(long nicId) {
SearchCriteria<NicNetworkMapVO> sc = AllFieldsSearch.create();
sc.setParameters("nicId", nicId);
return listBy(sc);
}

@Override
public List<NicNetworkMapVO> listByNetworkId(long networkId) {
SearchCriteria<NicNetworkMapVO> sc = AllFieldsSearch.create();
sc.setParameters("networkId", networkId);
return listBy(sc);
}

@Override
public NicNetworkMapVO findByNicIdAndNetworkId(long nicId, long networkId) {
SearchCriteria<NicNetworkMapVO> sc = AllFieldsSearch.create();
sc.setParameters("nicId", nicId);
sc.setParameters("networkId", networkId);
return findOneBy(sc);
}

@Override
public List<Long> listNicIdsByNetworkId(long networkId) {
SearchCriteria<Long> sc = NicIdsByNetworkSearch.create();
sc.setParameters("networkId", networkId);
return customSearch(sc, null);
}
}
Loading
Loading