diff --git a/api/src/main/java/com/cloud/agent/api/to/IpAddressTO.java b/api/src/main/java/com/cloud/agent/api/to/IpAddressTO.java index f63aab38842e..c6baf7c34e4b 100644 --- a/api/src/main/java/com/cloud/agent/api/to/IpAddressTO.java +++ b/api/src/main/java/com/cloud/agent/api/to/IpAddressTO.java @@ -39,12 +39,10 @@ public class IpAddressTO { private boolean newNic; private boolean isPrivateGateway; private NicTO nicTO; - - private Integer mtu; Map details; public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String broadcastUri, String vlanGateway, String vlanNetmask, - String vifMacAddress, Integer networkRate, boolean isOneToOneNat) { + String vifMacAddress, Integer networkRate, boolean isOneToOneNat) { this.accountId = accountId; this.publicIp = ipAddress; this.add = add; @@ -58,12 +56,6 @@ public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstI this.oneToOneNat = isOneToOneNat; } - public IpAddressTO(String ipAddress, Integer mtu, String vlanNetmask ) { - this.publicIp = ipAddress; - this.mtu = mtu; - this.vlanNetmask = vlanNetmask; - } - protected IpAddressTO() { } @@ -163,14 +155,6 @@ public void setNicTO(NicTO nicTO) { this.nicTO = nicTO; } - public Integer getMtu() { - return mtu; - } - - public void setMtu(Integer mtu) { - this.mtu = mtu; - } - public Map getDetails() { return details; diff --git a/api/src/main/java/com/cloud/agent/api/to/NicTO.java b/api/src/main/java/com/cloud/agent/api/to/NicTO.java index 3a616170d7e0..6a77f62cb07d 100644 --- a/api/src/main/java/com/cloud/agent/api/to/NicTO.java +++ b/api/src/main/java/com/cloud/agent/api/to/NicTO.java @@ -31,7 +31,6 @@ public class NicTO extends NetworkTO { List nicSecIps; Map details; boolean dpdkEnabled; - Integer mtu; public NicTO() { super(); @@ -119,12 +118,4 @@ public boolean isDpdkEnabled() { public void setDpdkEnabled(boolean dpdkEnabled) { this.dpdkEnabled = dpdkEnabled; } - - public Integer getMtu() { - return mtu; - } - - public void setMtu(Integer mtu) { - this.mtu = mtu; - } } diff --git a/api/src/main/java/com/cloud/network/Network.java b/api/src/main/java/com/cloud/network/Network.java index 256eec0f5dec..8fce2502a606 100644 --- a/api/src/main/java/com/cloud/network/Network.java +++ b/api/src/main/java/com/cloud/network/Network.java @@ -493,8 +493,4 @@ public void setIp6Address(String ip6Address) { String getIp6Dns2(); Date getCreated(); - - Integer getPublicMtu(); - - Integer getPrivateMtu(); } diff --git a/api/src/main/java/com/cloud/network/NetworkProfile.java b/api/src/main/java/com/cloud/network/NetworkProfile.java index 448530695750..5289bda62992 100644 --- a/api/src/main/java/com/cloud/network/NetworkProfile.java +++ b/api/src/main/java/com/cloud/network/NetworkProfile.java @@ -22,10 +22,8 @@ import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; -import org.apache.log4j.Logger; public class NetworkProfile implements Network { - static final Logger s_logger = Logger.getLogger(NetworkProfile.class); private final long id; private final String uuid; private final long dataCenterId; @@ -359,14 +357,4 @@ public Date getCreated() { return null; } - @Override - public Integer getPublicMtu() { - return null; - } - - @Override - public Integer getPrivateMtu() { - return null; - } - } diff --git a/api/src/main/java/com/cloud/network/NetworkService.java b/api/src/main/java/com/cloud/network/NetworkService.java index 85e25ba77323..bfc4479d7f69 100644 --- a/api/src/main/java/com/cloud/network/NetworkService.java +++ b/api/src/main/java/com/cloud/network/NetworkService.java @@ -34,7 +34,6 @@ import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd; import org.apache.cloudstack.api.command.user.vm.ListNicsCmd; import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse; -import org.apache.cloudstack.framework.config.ConfigKey; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientAddressCapacityException; @@ -60,21 +59,6 @@ */ public interface NetworkService { - public static final Integer DEFAULT_MTU = 1500; - public static final Integer MINIMUM_MTU = 68; - - public static final ConfigKey VRPublicInterfaceMtu = new ConfigKey<>("VirtualRouter", Integer.class, - "vr.public.interface.max.mtu", "1500", "The maximum value the MTU can have on the VR's public interfaces", - true, ConfigKey.Scope.Zone); - - public static final ConfigKey VRPrivateInterfaceMtu = new ConfigKey<>("VirtualRouter", Integer.class, - "vr.private.interface.max.mtu", "1500", "The maximum value the MTU can have on the VR's private interfaces", - true, ConfigKey.Scope.Zone); - - public static final ConfigKey AllowUsersToSpecifyVRMtu = new ConfigKey<>("Advanced", Boolean.class, - "allow.end.users.to.specify.vr.mtu", "false", "Allow end users to specify VR MTU", - true, ConfigKey.Scope.Zone); - List getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner); IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp, String ipaddress) throws ResourceAllocationException, InsufficientAddressCapacityException, diff --git a/api/src/main/java/com/cloud/network/vpc/Vpc.java b/api/src/main/java/com/cloud/network/vpc/Vpc.java index e9a831c9d839..664b6eb7e958 100644 --- a/api/src/main/java/com/cloud/network/vpc/Vpc.java +++ b/api/src/main/java/com/cloud/network/vpc/Vpc.java @@ -96,8 +96,6 @@ public enum State { Date getCreated(); - Integer getPublicMtu(); - String getIp4Dns1(); String getIp4Dns2(); diff --git a/api/src/main/java/com/cloud/network/vpc/VpcService.java b/api/src/main/java/com/cloud/network/vpc/VpcService.java index 7af9c5bdbce6..3829e5dbd7ae 100644 --- a/api/src/main/java/com/cloud/network/vpc/VpcService.java +++ b/api/src/main/java/com/cloud/network/vpc/VpcService.java @@ -53,7 +53,7 @@ public interface VpcService { * @throws ResourceAllocationException TODO */ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain, - String dns1, String dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu) + String dns1, String dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc) throws ResourceAllocationException; /** @@ -73,12 +73,11 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName * @param vpcId * @param vpcName * @param displayText - * @param customId TODO - * @param displayVpc TODO - * @param mtu + * @param customId TODO + * @param displayVpc TODO * @return */ - public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc, Integer mtu); + public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc); /** * Lists VPC(s) based on the parameters passed to the method call diff --git a/api/src/main/java/com/cloud/vm/Nic.java b/api/src/main/java/com/cloud/vm/Nic.java index afc44b8d39fa..7b8e27fd6560 100644 --- a/api/src/main/java/com/cloud/vm/Nic.java +++ b/api/src/main/java/com/cloud/vm/Nic.java @@ -160,6 +160,4 @@ public enum ReservationStrategy { String getIPv6Cidr(); String getIPv6Address(); - - Integer getMtu(); } diff --git a/api/src/main/java/com/cloud/vm/NicProfile.java b/api/src/main/java/com/cloud/vm/NicProfile.java index 3f37331b1e44..7781d710d3c2 100644 --- a/api/src/main/java/com/cloud/vm/NicProfile.java +++ b/api/src/main/java/com/cloud/vm/NicProfile.java @@ -70,7 +70,6 @@ public class NicProfile implements InternalIdentity, Serializable { String iPv6Dns1; String iPv6Dns2; String requestedIPv6; - Integer mtu; // // CONSTRUCTORS @@ -397,15 +396,6 @@ public void setOrderIndex(Integer orderIndex) { this.orderIndex = orderIndex; } - public Integer getMtu() { - return mtu; - } - - public void setMtu(Integer mtu) { - this.mtu = mtu; - } - - // // OTHER METHODS // @@ -436,7 +426,6 @@ public void deallocate() { isolationUri = null; orderIndex = null; - mtu = null; } diff --git a/api/src/main/java/org/apache/cloudstack/alert/AlertService.java b/api/src/main/java/org/apache/cloudstack/alert/AlertService.java index 5b29426e6eb9..ff176d8a82ea 100644 --- a/api/src/main/java/org/apache/cloudstack/alert/AlertService.java +++ b/api/src/main/java/org/apache/cloudstack/alert/AlertService.java @@ -71,8 +71,6 @@ private AlertType(short type, String name, boolean isDefault) { public static final AlertType ALERT_TYPE_HA_ACTION = new AlertType((short)30, "ALERT.HA.ACTION", true); public static final AlertType ALERT_TYPE_CA_CERT = new AlertType((short)31, "ALERT.CA.CERT", true); public static final AlertType ALERT_TYPE_VM_SNAPSHOT = new AlertType((short)32, "ALERT.VM.SNAPSHOT", true); - public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true); - public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true); public short getType() { return type; diff --git a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java index 96ed750852e3..e43572ae4899 100644 --- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java @@ -618,7 +618,6 @@ public class ApiConstants { public static final String RESTART_REQUIRED = "restartrequired"; public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects"; public static final String ALLOW_USER_DRIVEN_BACKUPS = "allowuserdrivenbackups"; - public static final String ALLOW_USER_SPECIFY_VR_MTU = "allowuserspecifyvrmtu"; public static final String CONSERVE_MODE = "conservemode"; public static final String TRAFFIC_TYPE_IMPLEMENTOR = "traffictypeimplementor"; public static final String KEYWORD = "keyword"; @@ -883,8 +882,6 @@ public class ApiConstants { public static final String ROUTER_CHECK_TYPE = "checktype"; public static final String ROUTER_IP = "routerip"; public static final String ROUTER_IPV6 = "routeripv6"; - public static final String ROUTER_PRIVATE_INTERFACE_MAX_MTU = "routerprivateinterfacemaxmtu"; - public static final String ROUTER_PUBLIC_INTERFACE_MAX_MTU = "routerpublicinterfacemaxmtu"; public static final String LAST_UPDATED = "lastupdated"; public static final String PERFORM_FRESH_CHECKS = "performfreshchecks"; public static final String CACHE_MODE = "cachemode"; @@ -923,7 +920,6 @@ public class ApiConstants { public static final String DYNAMIC_SCALING_ENABLED = "dynamicscalingenabled"; public static final String POOL_TYPE = "pooltype"; - public static final String REDUNDANT_STATE = "redundantstate"; public static final String ADMINS_ONLY = "adminsonly"; public static final String ANNOTATION_FILTER = "annotationfilter"; @@ -931,9 +927,6 @@ public class ApiConstants { public static final String LOGOUT = "logout"; public static final String LIST_IDPS = "listIdps"; - public static final String PUBLIC_MTU = "publicmtu"; - public static final String PRIVATE_MTU = "privatemtu"; - public static final String MTU = "mtu"; public enum BootType { UEFI, BIOS; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java index 276f59e7049c..9973af2db9e4 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java @@ -16,7 +16,6 @@ // under the License. package org.apache.cloudstack.api.command.user.network; -import com.cloud.network.NetworkService; import org.apache.log4j.Logger; import org.apache.cloudstack.acl.RoleType; @@ -158,14 +157,6 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd { description = "The network this network is associated to. only available if create a Shared network") private Long associatedNetworkId; - @Parameter(name = ApiConstants.PUBLIC_MTU, type = CommandType.INTEGER, - description = "MTU to be configured on the network VR's public facing interfaces", since = "4.18.0") - private Integer publicMtu; - - @Parameter(name = ApiConstants.PRIVATE_MTU, type = CommandType.INTEGER, - description = "MTU to be configured on the network VR's private interface(s)", since = "4.18.0") - private Integer privateMtu; - @Parameter(name = ApiConstants.DNS1, type = CommandType.STRING, description = "the first IPv4 DNS for the network", since = "4.18.0") private String ip4Dns1; @@ -347,13 +338,6 @@ public Long getAclId() { return aclId; } - public Integer getPublicMtu() { - return publicMtu != null ? publicMtu : NetworkService.DEFAULT_MTU; - } - - public Integer getPrivateMtu() { - return privateMtu != null ? privateMtu : NetworkService.DEFAULT_MTU; - } public String getIp4Dns1() { return ip4Dns1; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java index 3aef9730c1cd..49a23a145f41 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java @@ -78,20 +78,12 @@ public class UpdateNetworkCmd extends BaseAsyncCustomIdCmd implements UserCmd { @Parameter(name = ApiConstants.DISPLAY_NETWORK, type = CommandType.BOOLEAN, - description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin}) + description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayNetwork; @Parameter(name= ApiConstants.FORCED, type = CommandType.BOOLEAN, description = "Setting this to true will cause a forced network update,", authorized = {RoleType.Admin}) private Boolean forced; - @Parameter(name = ApiConstants.PUBLIC_MTU, type = CommandType.INTEGER, - description = "MTU to be configured on the network VR's public facing interfaces", since = "4.18.0") - private Integer publicMtu; - - @Parameter(name = ApiConstants.PRIVATE_MTU, type = CommandType.INTEGER, - description = "MTU to be configured on the network VR's public facing interfaces", since = "4.18.0") - private Integer privateMtu; - @Parameter(name = ApiConstants.DNS1, type = CommandType.STRING, description = "the first IPv4 DNS for the network. Empty string will update the first IPv4 DNS with the value from the zone", since = "4.18.0") private String ip4Dns1; @@ -157,14 +149,6 @@ public boolean getForced(){ return forced; } - public Integer getPublicMtu() { - return publicMtu; - } - - public Integer getPrivateMtu() { - return privateMtu; - } - public String getIp4Dns1() { return ip4Dns1; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java index af7004941b94..4df741f1d23a 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java @@ -16,7 +16,6 @@ // under the License. package org.apache.cloudstack.api.command.user.vpc; -import com.cloud.network.NetworkService; import org.apache.log4j.Logger; import org.apache.cloudstack.acl.RoleType; @@ -96,10 +95,6 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd { @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpc to the end user or not", since = "4.4", authorized = {RoleType.Admin}) private Boolean display; - @Parameter(name = ApiConstants.PUBLIC_MTU, type = CommandType.INTEGER, - description = "MTU to be configured on the network VR's public facing interfaces", since = "4.18.0") - private Integer publicMtu; - @Parameter(name = ApiConstants.DNS1, type = CommandType.STRING, description = "the first IPv4 DNS for the VPC", since = "4.18.0") private String ip4Dns1; @@ -148,10 +143,6 @@ public String getNetworkDomain() { return networkDomain; } - public Integer getPublicMtu() { - return publicMtu != null ? publicMtu : NetworkService.DEFAULT_MTU; - } - public String getIp4Dns1() { return ip4Dns1; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java index 4c3408e054e2..190a0e5cbc5d 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java @@ -59,10 +59,6 @@ public class UpdateVPCCmd extends BaseAsyncCustomIdCmd implements UserCmd { @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpc to the end user or not", since = "4.4", authorized = {RoleType.Admin}) private Boolean display; - @Parameter(name = ApiConstants.PUBLIC_MTU, type = CommandType.INTEGER, - description = "MTU to be configured on the network VR's public facing interfaces", since = "4.18.0") - private Integer publicMtu; - ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -83,10 +79,6 @@ public Boolean isDisplayVpc() { return display; } - public Integer getPublicMtu() { - return publicMtu; - } - ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -107,7 +99,7 @@ public long getEntityOwnerId() { @Override public void execute() { - Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), getCustomId(), isDisplayVpc(), getPublicMtu()); + Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), getCustomId(), isDisplayVpc()); if (result != null) { VpcResponse response = _responseGenerator.createVpcResponse(getResponseView(), result); response.setResponseName(getCommandName()); diff --git a/api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java index a40a5a475fef..51b3ade17ab0 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java @@ -291,14 +291,6 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement @Param(description = "The routes for the network to ease adding route in upstream router", since = "4.17.0") private Set ipv6Routes; - @SerializedName(ApiConstants.PUBLIC_MTU) - @Param(description = "MTU configured on the network VR's public facing interfaces") - private Integer publicMtu; - - @SerializedName(ApiConstants.PRIVATE_MTU) - @Param(description = "MTU configured on the network VR's private interfaces") - private Integer privateMtu; - @SerializedName(ApiConstants.IP6_DNS1) @Param(description = "the first IPv6 DNS for the network", since = "4.18.0") private String ipv6Dns1; @@ -615,22 +607,6 @@ public void addIpv6Route(Ipv6RouteResponse ipv6Route) { this.ipv6Routes.add(ipv6Route); } - public Integer getPublicMtu() { - return publicMtu; - } - - public void setPublicMtu(Integer publicMtu) { - this.publicMtu = publicMtu; - } - - public Integer getPrivateMtu() { - return privateMtu; - } - - public void setPrivateMtu(Integer privateMtu) { - this.privateMtu = privateMtu; - } - public void setIpv6Dns1(String ipv6Dns1) { this.ipv6Dns1 = ipv6Dns1; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java index c267323cb7a3..4521a82aebf5 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java @@ -134,10 +134,6 @@ public class NicResponse extends BaseResponse { @Param(description = "IP addresses associated with NIC found for unmanaged VM", since="4.14.0") private List ipAddresses; - @SerializedName(ApiConstants.MTU) - @Param(description = "MTU configured on the NIC", since="4.18.0") - private Integer mtu; - public void setVmId(String vmId) { this.vmId = vmId; } @@ -377,8 +373,8 @@ public void setIpAddresses(List ipAddresses) { this.ipAddresses = ipAddresses; } - public Integer getMtu() { - return mtu; + public String getVpcId() { + return vpcId; } public void setVpcId(String vpcId) { @@ -392,12 +388,4 @@ public String getVpcName() { public void setVpcName(String vpcName) { this.vpcName = vpcName; } - - public void setMtu(Integer mtu) { - this.mtu = mtu; - } - - public String getVpcId() { - return vpcId; - } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/VpcResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/VpcResponse.java index 610416d7b0e3..4ca594870ac6 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/VpcResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/VpcResponse.java @@ -136,10 +136,6 @@ public class VpcResponse extends BaseResponseWithAnnotations implements Controll @Param(description = "The routes for the network to ease adding route in upstream router", since = "4.17.0") private Set ipv6Routes; - @SerializedName(ApiConstants.PUBLIC_MTU) - @Param(description = "MTU configured on the public interfaces of the VPC VR", since = "4.18.0") - private Integer publicMtu; - @SerializedName(ApiConstants.DNS1) @Param(description = "the first IPv4 DNS for the VPC") private String dns1; @@ -278,10 +274,6 @@ public Set getIpv6Routes() { return ipv6Routes; } - public void setPublicMtu(Integer publicMtu) { - this.publicMtu = publicMtu; - } - public void setDns1(String dns1) { this.dns1 = dns1; } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java index f4728f946f68..676ca4a7dbf8 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java @@ -129,18 +129,6 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso @Param(description = "Base64 string representation of the resource icon", since = "4.16.0.0") ResourceIconResponse resourceIconResponse; - @SerializedName(ApiConstants.ALLOW_USER_SPECIFY_VR_MTU) - @Param(description = "Allow end users to specify VR MTU", since = "4.18.0") - private boolean allowUserSpecifyVRMtu; - - @SerializedName(ApiConstants.ROUTER_PRIVATE_INTERFACE_MAX_MTU) - @Param(description = "The maximum value the MTU can have on the VR's private interfaces", since = "4.18.0") - private Integer routerPrivateInterfaceMaxMtu; - - @SerializedName(ApiConstants.ROUTER_PUBLIC_INTERFACE_MAX_MTU) - @Param(description = "The maximum value the MTU can have on the VR's public interfaces", since = "4.18.0") - private Integer routerPublicInterfaceMaxMtu; - public ZoneResponse() { tags = new LinkedHashSet(); } @@ -340,16 +328,4 @@ public void setResourceIconResponse(ResourceIconResponse resourceIconResponse) { public ResourceIconResponse getResourceIconResponse() { return resourceIconResponse; } - - public void setAllowUserSpecifyVRMtu(boolean allowUserSpecifyVRMtu) { - this.allowUserSpecifyVRMtu = allowUserSpecifyVRMtu; - } - - public void setRouterPrivateInterfaceMaxMtu(Integer routerPrivateInterfaceMaxMtu) { - this.routerPrivateInterfaceMaxMtu = routerPrivateInterfaceMaxMtu; - } - - public void setRouterPublicInterfaceMaxMtu(Integer routerPublicInterfaceMaxMtu) { - this.routerPublicInterfaceMaxMtu = routerPublicInterfaceMaxMtu; - } } diff --git a/api/src/test/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmdTest.java deleted file mode 100644 index d7810dba28bf..000000000000 --- a/api/src/test/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmdTest.java +++ /dev/null @@ -1,298 +0,0 @@ -// 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 org.apache.cloudstack.api.command.user.network; - -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.network.Network; -import com.cloud.network.NetworkService; -import com.cloud.offering.NetworkOffering; -import com.cloud.utils.db.EntityManager; -import junit.framework.TestCase; -import org.apache.cloudstack.api.ResponseGenerator; -import org.apache.cloudstack.api.ResponseObject; -import org.apache.cloudstack.api.response.NetworkResponse; -import org.junit.Assert; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.test.util.ReflectionTestUtils; - -@RunWith(PowerMockRunner.class) -public class CreateNetworkCmdTest extends TestCase { - - @Mock - public EntityManager _entityMgr; - @Mock - public NetworkService networkService; - private ResponseGenerator responseGenerator; - - @InjectMocks - CreateNetworkCmd cmd = new CreateNetworkCmd(); - public void testGetNetworkOfferingId() { - Long networkOfferingId = 1L; - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - Assert.assertEquals(cmd.getNetworkOfferingId(), networkOfferingId); - } - - public void testGetGateway() { - String gateway = "10.10.10.1"; - ReflectionTestUtils.setField(cmd, "gateway", gateway); - Assert.assertEquals(cmd.getGateway(), gateway); - } - - public void testGetIsolatedPvlan() { - String isolatedPvlan = "1234"; - ReflectionTestUtils.setField(cmd, "isolatedPvlan", isolatedPvlan); - Assert.assertEquals(cmd.getIsolatedPvlan(), isolatedPvlan); - } - - public void testGetAccountName() { - String accountName = "admin"; - ReflectionTestUtils.setField(cmd, "accountName", accountName); - Assert.assertEquals(cmd.getAccountName(), accountName); - } - - public void testGetDomainId() { - Long domainId = 1L; - ReflectionTestUtils.setField(cmd, "domainId", domainId); - Assert.assertEquals(cmd.getDomainId(), domainId); - } - - public void testGetNetmask() { - String netmask = "255.255.255.0"; - ReflectionTestUtils.setField(cmd, "netmask", netmask); - Assert.assertEquals(cmd.getNetmask(), netmask); - } - - public void testGetStartIp() { - String startIp = "10.10.10.2"; - ReflectionTestUtils.setField(cmd, "startIp", startIp); - Assert.assertEquals(cmd.getStartIp(), startIp); - } - - public void testGetEndIp() { - String endIp = "10.10.10.10"; - ReflectionTestUtils.setField(cmd, "endIp", endIp); - Assert.assertEquals(cmd.getEndIp(), endIp); - } - - public void testGetNetworkName() { - String netName = "net-isolated"; - ReflectionTestUtils.setField(cmd, "name", netName); - Assert.assertEquals(cmd.getNetworkName(), netName); - } - - public void testGetDisplayText() { - String description = "Isolated Network"; - ReflectionTestUtils.setField(cmd, "displayText", description); - Assert.assertEquals(cmd.getDisplayText(), description); - } - - public void testGetNetworkDomain() { - String netDomain = "cs1cloud.internal"; - ReflectionTestUtils.setField(cmd, "networkDomain", netDomain); - Assert.assertEquals(cmd.getNetworkDomain(), netDomain); - } - - public void testGetProjectId() { - Long projectId = 1L; - ReflectionTestUtils.setField(cmd, "projectId", projectId); - Assert.assertEquals(cmd.getProjectId(), projectId); - } - - public void testGetAclType() { - String aclType = "account"; - ReflectionTestUtils.setField(cmd, "aclType", aclType); - Assert.assertEquals(cmd.getAclType(), aclType); - } - - public void testGetSubdomainAccess() { - Boolean subDomAccess = false; - ReflectionTestUtils.setField(cmd, "subdomainAccess", subDomAccess); - Assert.assertEquals(cmd.getSubdomainAccess(), subDomAccess); - } - - public void testGetVpcId() { - Long vpcId = 1L; - ReflectionTestUtils.setField(cmd, "vpcId", vpcId); - Assert.assertEquals(cmd.getVpcId(), vpcId); - } - - public void testGetDisplayNetwork() { - Boolean displayNet = true; - ReflectionTestUtils.setField(cmd, "displayNetwork", displayNet); - Assert.assertEquals(cmd.getDisplayNetwork(), displayNet); - } - - public void testGetExternalId() { - String externalId = "1"; - ReflectionTestUtils.setField(cmd, "externalId", externalId); - Assert.assertEquals(cmd.getExternalId(), externalId); - } - - public void testGetAssociatedNetworkId() { - Long associatedNetId = 1L; - ReflectionTestUtils.setField(cmd, "associatedNetworkId", associatedNetId); - Assert.assertEquals(cmd.getAssociatedNetworkId(), associatedNetId); - } - - public void testIsDisplayNullDefaultsToTrue() { - Boolean displayNetwork = null; - ReflectionTestUtils.setField(cmd, "displayNetwork", displayNetwork); - Assert.assertTrue(cmd.isDisplay()); - } - - public void testGetPhysicalNetworkIdForInvalidNetOfferingId() { - Long physicalNetworkId = 1L; - - ReflectionTestUtils.setField(cmd, "physicalNetworkId", physicalNetworkId); - Mockito.when(_entityMgr.findById(NetworkOffering.class, 1L)).thenReturn(null); - try { - cmd.getPhysicalNetworkId(); - } catch (Exception e) { - Assert.assertTrue(e.getMessage().startsWith("Unable to find network offering by ID")); - } - } - - public void testGetPhysicalNetworkIdForInvalidAssociatedNetId() { - Long physicalNetworkId = 1L; - Long networkOfferingId = 1L; - Long associatedNetworkId = 1L; - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - ReflectionTestUtils.setField(cmd, "associatedNetworkId", associatedNetworkId); - NetworkOffering networkOffering = Mockito.mock(NetworkOffering.class); - ReflectionTestUtils.setField(cmd, "physicalNetworkId", physicalNetworkId); - Mockito.when(_entityMgr.findById(NetworkOffering.class, networkOfferingId)).thenReturn(networkOffering); - Mockito.when(_entityMgr.findById(Network.class, associatedNetworkId)).thenReturn(null); - try { - cmd.getPhysicalNetworkId(); - } catch (Exception e) { - Assert.assertTrue(e.getMessage().startsWith("Unable to find network by ID")); - } - } - - public void testGetPhysicalNetworkIdForAssociatedNetIdForNonSharedNet() { - Long physicalNetworkId = 1L; - Long networkOfferingId = 1L; - Long associatedNetworkId = 1L; - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - ReflectionTestUtils.setField(cmd, "associatedNetworkId", associatedNetworkId); - NetworkOffering networkOffering = Mockito.mock(NetworkOffering.class); - Network network = Mockito.mock(Network.class); - ReflectionTestUtils.setField(cmd, "physicalNetworkId", physicalNetworkId); - Mockito.when(_entityMgr.findById(NetworkOffering.class, networkOfferingId)).thenReturn(networkOffering); - Mockito.when(_entityMgr.findById(Network.class, associatedNetworkId)).thenReturn(network); - Mockito.when(networkOffering.getGuestType()).thenReturn(Network.GuestType.Isolated); - try { - cmd.getPhysicalNetworkId(); - } catch (Exception e) { - Assert.assertTrue(e.getMessage().startsWith("Associated network ID can be specified for networks of guest IP type Shared only")); - } - } - - public void testGetPhysicalNetworkIdForNonSharedNet() { - Long physicalNetworkId = 1L; - Long networkOfferingId = 1L; - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - NetworkOffering networkOffering = Mockito.mock(NetworkOffering.class); - ReflectionTestUtils.setField(cmd, "physicalNetworkId", physicalNetworkId); - Mockito.when(_entityMgr.findById(NetworkOffering.class, networkOfferingId)).thenReturn(networkOffering); - Mockito.when(networkOffering.getGuestType()).thenReturn(Network.GuestType.Isolated); - try { - cmd.getPhysicalNetworkId(); - } catch (Exception e) { - Assert.assertTrue(e.getMessage().startsWith("Physical network ID can be specified for networks of guest IP type Shared only")); - } - } - - public void testGetPhysicalNetworkIdForSharedNet() { - Long physicalNetworkId = 1L; - Long networkOfferingId = 1L; - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - NetworkOffering networkOffering = Mockito.mock(NetworkOffering.class); - ReflectionTestUtils.setField(cmd, "physicalNetworkId", physicalNetworkId); - Mockito.when(_entityMgr.findById(NetworkOffering.class, networkOfferingId)).thenReturn(networkOffering); - Mockito.when(networkOffering.getGuestType()).thenReturn(Network.GuestType.Shared); - try { - Assert.assertEquals(cmd.getPhysicalNetworkId(), physicalNetworkId); - } catch (Exception e) { - Assert.fail("Failed to get physical network id"); - } - } - - public void testGetZoneId() { - Long physicalNetworkId = 1L; - Long networkOfferingId = 1L; - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - NetworkOffering networkOffering = Mockito.mock(NetworkOffering.class); - ReflectionTestUtils.setField(cmd, "physicalNetworkId", physicalNetworkId); - Mockito.when(_entityMgr.findById(NetworkOffering.class, networkOfferingId)).thenReturn(networkOffering); - Mockito.when(networkOffering.getGuestType()).thenReturn(Network.GuestType.Shared); - Long zoneId = 1L; - ReflectionTestUtils.setField(cmd, "zoneId", zoneId); - Assert.assertEquals(cmd.getZoneId(), zoneId); - } - - public void testGetPublicMtuWhenNotSet() { - Integer publicMtu = null; - ReflectionTestUtils.setField(cmd, "publicMtu", publicMtu); - Assert.assertEquals(NetworkService.DEFAULT_MTU, cmd.getPublicMtu()); - } - - public void testGetPublicMtuWhenSet() { - Integer publicMtu = 1450; - ReflectionTestUtils.setField(cmd, "publicMtu", publicMtu); - Assert.assertEquals(cmd.getPublicMtu(), publicMtu); - } - - public void testGetPrivateMtuWhenNotSet() { - Integer privateMtu = null; - ReflectionTestUtils.setField(cmd, "privateMtu", privateMtu); - Assert.assertEquals(NetworkService.DEFAULT_MTU, cmd.getPrivateMtu()); - } - - public void testGetPrivateMtuWhenSet() { - Integer privateMtu = 1250; - ReflectionTestUtils.setField(cmd, "privateMtu", privateMtu); - Assert.assertEquals(cmd.getPrivateMtu(), privateMtu); - } - - public void testExecute() throws InsufficientCapacityException, ResourceAllocationException { - ReflectionTestUtils.setField(cmd, "displayText", "testNetwork"); - ReflectionTestUtils.setField(cmd, "name", "testNetwork"); - ReflectionTestUtils.setField(cmd, "networkOfferingId", 1L); - ReflectionTestUtils.setField(cmd, "zoneId", 1L); - Network createdNetwork = Mockito.mock(Network.class); - NetworkResponse response = Mockito.mock(NetworkResponse.class); - responseGenerator = Mockito.mock(ResponseGenerator.class); - Mockito.when(networkService.createGuestNetwork(cmd)).thenReturn(createdNetwork); - Mockito.when(responseGenerator.createNetworkResponse(ResponseObject.ResponseView.Restricted, createdNetwork)).thenReturn(response); - cmd._responseGenerator = responseGenerator; - - try { - cmd.execute(); - Mockito.verify(networkService, Mockito.times(1)).createGuestNetwork(cmd); - } catch (Exception e) { - System.out.println(e); - Assert.fail("Should successfully create the network"); - } - } -} \ No newline at end of file diff --git a/api/src/test/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmdTest.java deleted file mode 100644 index ff8a605c24b5..000000000000 --- a/api/src/test/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmdTest.java +++ /dev/null @@ -1,176 +0,0 @@ -// 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 org.apache.cloudstack.api.command.user.network; - -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.network.Network; -import com.cloud.network.NetworkService; -import com.cloud.offering.NetworkOffering; -import com.cloud.utils.db.EntityManager; -import junit.framework.TestCase; -import org.apache.cloudstack.api.ResponseGenerator; -import org.apache.cloudstack.api.ResponseObject; -import org.apache.cloudstack.api.response.NetworkResponse; -import org.junit.Assert; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.test.util.ReflectionTestUtils; - -@RunWith(PowerMockRunner.class) -public class UpdateNetworkCmdTest extends TestCase { - - @Mock - NetworkService networkService; - @Mock - public EntityManager _entityMgr; - private ResponseGenerator responseGenerator; - @InjectMocks - UpdateNetworkCmd cmd = new UpdateNetworkCmd(); - - public void testGetId() { - Long id = 1L; - ReflectionTestUtils.setField(cmd, "id", id); - Assert.assertEquals(cmd.getId(), id); - } - - public void testGetNetworkName() { - String name = "testNetwork"; - ReflectionTestUtils.setField(cmd, "name", name); - Assert.assertEquals(cmd.getNetworkName(), name); - } - - public void testGetDisplayText() { - String displayText = "test network"; - ReflectionTestUtils.setField(cmd, "displayText", displayText); - Assert.assertEquals(cmd.getDisplayText(), displayText); - } - - public void testGetNetworkDomain() { - String netDomain = "cs1cloud.internal"; - ReflectionTestUtils.setField(cmd, "networkDomain", netDomain); - Assert.assertEquals(cmd.getNetworkDomain(), netDomain); - } - - public void testGetNetworkOfferingId() { - Long networkOfferingId = 1L; - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - Assert.assertEquals(cmd.getNetworkOfferingId(), networkOfferingId); - } - - public void testGetChangeCidr() { - Boolean changeCidr = true; - ReflectionTestUtils.setField(cmd, "changeCidr", changeCidr); - Assert.assertTrue(cmd.getChangeCidr()); - } - - public void testGetGuestVmCidr() { - String guestVmCidr = "10.10.0.0/24"; - ReflectionTestUtils.setField(cmd, "guestVmCidr", guestVmCidr); - Assert.assertEquals(cmd.getGuestVmCidr(), guestVmCidr); - } - - public void testGetDisplayNetwork() { - Boolean displayNetwork = true; - ReflectionTestUtils.setField(cmd, "displayNetwork", displayNetwork); - Assert.assertTrue(cmd.getDisplayNetwork()); - } - - public void testGetUpdateInSequenceIfNull() { - Boolean updateInSequence = null; - ReflectionTestUtils.setField(cmd, "updateInSequence", updateInSequence); - Assert.assertFalse(cmd.getUpdateInSequence()); - } - - public void testGetUpdateInSequenceIfValidValuePassed() { - Boolean updateInSequence = true; - ReflectionTestUtils.setField(cmd, "updateInSequence", updateInSequence); - Assert.assertTrue(cmd.getUpdateInSequence()); - } - - public void testGetForcedIfNull() { - Boolean forced = null; - ReflectionTestUtils.setField(cmd, "forced", forced); - Assert.assertFalse(cmd.getUpdateInSequence()); - } - - public void testGetForcedIfValidValuePassed() { - Boolean forced = true; - ReflectionTestUtils.setField(cmd, "forced", forced); - Assert.assertTrue(cmd.getForced()); - } - - public void testGetPublicMtu() { - Integer publicMtu = 1450; - ReflectionTestUtils.setField(cmd, "publicMtu", publicMtu); - Assert.assertEquals(cmd.getPublicMtu(), publicMtu); - } - - public void testGetPublicMtuIfNull() { - Integer publicMtu = null; - ReflectionTestUtils.setField(cmd, "publicMtu", publicMtu); - Assert.assertNull(cmd.getPublicMtu()); - } - - public void testGetPrivateMtu() { - Integer privateMtu = 1450; - ReflectionTestUtils.setField(cmd, "privateMtu", privateMtu); - Assert.assertEquals(cmd.getPrivateMtu(), privateMtu); - } - - public void testGetPrivateMtuIfNull() { - Integer privateMtu = null; - ReflectionTestUtils.setField(cmd, "privateMtu", privateMtu); - Assert.assertNull(cmd.getPrivateMtu()); - } - - public void testEventDescription() { - long networkOfferingId = 1L; - Network network = Mockito.mock(Network.class); - NetworkOffering offering = Mockito.mock(NetworkOffering.class); - ReflectionTestUtils.setField(cmd, "networkOfferingId", networkOfferingId); - ReflectionTestUtils.setField(cmd, "id", 1L); - Mockito.when(networkService.getNetwork(Mockito.any(Long.class))).thenReturn(network); - Mockito.when(network.getNetworkOfferingId()).thenReturn(networkOfferingId); - Mockito.when(_entityMgr.findById(NetworkOffering.class, networkOfferingId)).thenReturn(offering); - String msg = cmd.getEventDescription(); - Assert.assertTrue(msg.contains("Updating network")); - } - - public void testExecute() throws InsufficientCapacityException { - long networkId = 1L; - Integer publicmtu = 1200; - ReflectionTestUtils.setField(cmd, "id", networkId); - ReflectionTestUtils.setField(cmd, "publicMtu", publicmtu); - Network network = Mockito.mock(Network.class); - responseGenerator = Mockito.mock(ResponseGenerator.class); - NetworkResponse response = Mockito.mock(NetworkResponse.class); - response.setPublicMtu(publicmtu); - Mockito.when(networkService.getNetwork(networkId)).thenReturn(network); - Mockito.when(networkService.updateGuestNetwork(cmd)).thenReturn(network); - cmd._responseGenerator = responseGenerator; - Mockito.when(responseGenerator.createNetworkResponse(ResponseObject.ResponseView.Restricted, network)).thenReturn(response); - cmd.execute(); - Mockito.verify(responseGenerator).createNetworkResponse(Mockito.any(ResponseObject.ResponseView.class), Mockito.any(Network.class)); - NetworkResponse actualResponse = (NetworkResponse) cmd.getResponseObject(); - - Assert.assertEquals(response, actualResponse); - } -} \ No newline at end of file diff --git a/api/src/test/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmdTest.java deleted file mode 100644 index a52051cbd98c..000000000000 --- a/api/src/test/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmdTest.java +++ /dev/null @@ -1,165 +0,0 @@ -// 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 org.apache.cloudstack.api.command.user.vpc; - -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.NetworkService; -import com.cloud.network.vpc.Vpc; -import com.cloud.network.vpc.VpcService; -import com.cloud.user.AccountService; -import com.cloud.utils.db.EntityManager; -import junit.framework.TestCase; -import org.apache.cloudstack.api.ResponseGenerator; -import org.apache.cloudstack.api.ResponseObject; -import org.apache.cloudstack.api.response.VpcResponse; -import org.junit.Assert; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.test.util.ReflectionTestUtils; - -@RunWith(PowerMockRunner.class) -public class CreateVPCCmdTest extends TestCase { - - @Mock - public VpcService _vpcService; - @Mock - public EntityManager _entityMgr; - @Mock - public AccountService _accountService; - private ResponseGenerator responseGenerator; - @InjectMocks - CreateVPCCmd cmd = new CreateVPCCmd() { - @Override - public Long getEntityId() { - return 2L; - } - }; - - public void testGetAccountName() { - String accountName = "admin"; - ReflectionTestUtils.setField(cmd, "accountName", accountName); - Assert.assertEquals(cmd.getAccountName(), accountName); - } - - public void testGetDomainId() { - Long domainId = 1L; - ReflectionTestUtils.setField(cmd, "domainId", domainId); - Assert.assertEquals(cmd.getDomainId(), domainId); - } - - public void testGetZoneId() { - Long zoneId = 1L; - ReflectionTestUtils.setField(cmd, "zoneId", zoneId); - Assert.assertEquals(cmd.getZoneId(), zoneId); - } - - public void testGetVpcName() { - String vpcName = "vpcNet"; - ReflectionTestUtils.setField(cmd, "vpcName", vpcName); - Assert.assertEquals(cmd.getVpcName(), vpcName); - } - - public void testGetCidr() { - String cidr = "10.0.0.0/8"; - ReflectionTestUtils.setField(cmd, "cidr", cidr); - Assert.assertEquals(cmd.getCidr(), cidr); - } - - public void testGetDisplayText() { - String displayText = "VPC Network"; - ReflectionTestUtils.setField(cmd, "displayText", displayText); - Assert.assertEquals(cmd.getDisplayText(), displayText); - } - - public void testGetVpcOffering() { - Long vpcOffering = 1L; - ReflectionTestUtils.setField(cmd, "vpcOffering", vpcOffering); - Assert.assertEquals(cmd.getVpcOffering(), vpcOffering); - } - - public void testGetNetworkDomain() { - String netDomain = "cs1cloud.internal"; - ReflectionTestUtils.setField(cmd, "networkDomain", netDomain); - Assert.assertEquals(cmd.getNetworkDomain(), netDomain); - } - - public void testGetPublicMtuWhenNotSet() { - Integer publicMtu = null; - ReflectionTestUtils.setField(cmd, "publicMtu", publicMtu); - Assert.assertEquals(NetworkService.DEFAULT_MTU, cmd.getPublicMtu()); - } - - public void testGetPublicMtuWhenSet() { - Integer publicMtu = 1450; - ReflectionTestUtils.setField(cmd, "publicMtu", publicMtu); - Assert.assertEquals(cmd.getPublicMtu(), publicMtu); - } - - public void testIsStartWhenNull() { - Boolean start = null; - ReflectionTestUtils.setField(cmd, "start", start); - Assert.assertTrue(cmd.isStart()); - } - - public void testIsStartWhenValidValuePassed() { - Boolean start = true; - ReflectionTestUtils.setField(cmd, "start", start); - Assert.assertTrue(cmd.isStart()); - } - - public void testGetDisplayVpc() { - Boolean display = true; - ReflectionTestUtils.setField(cmd, "display", display); - Assert.assertTrue(cmd.getDisplayVpc()); - } - - public void testCreate() throws ResourceAllocationException { - Vpc vpc = Mockito.mock(Vpc.class); - ReflectionTestUtils.setField(cmd, "zoneId", 1L); - ReflectionTestUtils.setField(cmd, "vpcOffering", 1L); - ReflectionTestUtils.setField(cmd, "vpcName", "testVpc"); - ReflectionTestUtils.setField(cmd, "displayText", "Test Vpc Network"); - ReflectionTestUtils.setField(cmd, "cidr", "10.0.0.0/8"); - ReflectionTestUtils.setField(cmd, "networkDomain", "cs1cloud.internal"); - ReflectionTestUtils.setField(cmd, "display", true); - ReflectionTestUtils.setField(cmd, "publicMtu", 1450); - Mockito.when(_accountService.finalyzeAccountId(Mockito.anyString(), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyBoolean())).thenReturn(1L); - Mockito.when(cmd.getEntityOwnerId()).thenReturn(1L); - Mockito.when(_vpcService.createVpc(Mockito.any(CreateVPCCmd.class))).thenReturn(vpc); - cmd.create(); - Mockito.verify(_vpcService, Mockito.times(1)).createVpc(Mockito.any(CreateVPCCmd.class)); - } - - public void testExecute() throws ResourceUnavailableException, InsufficientCapacityException { - ReflectionTestUtils.setField(cmd, "start", true); - Vpc vpc = Mockito.mock(Vpc.class); - VpcResponse response = Mockito.mock(VpcResponse.class); - responseGenerator = Mockito.mock(ResponseGenerator.class); - Mockito.when(_vpcService.startVpc(1L, true)).thenReturn(true); - Mockito.when(_entityMgr.findById(Mockito.eq(Vpc.class), Mockito.any(Long.class))).thenReturn(vpc); - cmd._responseGenerator = responseGenerator; - Mockito.when(responseGenerator.createVpcResponse(ResponseObject.ResponseView.Restricted, vpc)).thenReturn(response); - cmd.execute(); - Mockito.verify(_vpcService, Mockito.times(1)).startVpc(Mockito.anyLong(), Mockito.anyBoolean()); - } -} \ No newline at end of file diff --git a/api/src/test/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmdTest.java deleted file mode 100644 index 39a41001f58b..000000000000 --- a/api/src/test/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmdTest.java +++ /dev/null @@ -1,94 +0,0 @@ -// 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 org.apache.cloudstack.api.command.user.vpc; - -import com.cloud.network.vpc.Vpc; -import com.cloud.network.vpc.VpcService; -import junit.framework.TestCase; -import org.apache.cloudstack.api.ResponseGenerator; -import org.apache.cloudstack.api.ResponseObject; -import org.apache.cloudstack.api.response.VpcResponse; -import org.junit.Assert; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.test.util.ReflectionTestUtils; - -@RunWith(PowerMockRunner.class) -public class UpdateVPCCmdTest extends TestCase { - - @Mock - VpcService _vpcService; - - private ResponseGenerator responseGenerator; - - @InjectMocks - UpdateVPCCmd cmd = new UpdateVPCCmd(); - - public void testGetVpcName() { - String vpcName = "updatedVpcName"; - ReflectionTestUtils.setField(cmd, "vpcName", vpcName); - Assert.assertEquals(cmd.getVpcName(), vpcName); - } - - public void testGetDisplayText() { - String displayText = "Updated VPC Name"; - ReflectionTestUtils.setField(cmd, "displayText", displayText); - Assert.assertEquals(cmd.getDisplayText(), displayText); - } - - public void testGetId() { - Long id = 1L; - ReflectionTestUtils.setField(cmd, "id", id); - Assert.assertEquals(cmd.getId(), id); - } - - public void testIsDisplayVpc() { - Boolean display = true; - ReflectionTestUtils.setField(cmd, "display", display); - Assert.assertEquals(cmd.isDisplayVpc(), display); - } - - public void testGetPublicMtu() { - Integer publicMtu = 1450; - ReflectionTestUtils.setField(cmd, "publicMtu", publicMtu); - Assert.assertEquals(cmd.getPublicMtu(), publicMtu); - } - - public void testExecute() { - ReflectionTestUtils.setField(cmd, "id", 1L); - ReflectionTestUtils.setField(cmd, "vpcName", "updatedVpcName"); - ReflectionTestUtils.setField(cmd, "displayText", "Updated VPC Name"); - ReflectionTestUtils.setField(cmd, "displayText", "Updated VPC Name"); - ReflectionTestUtils.setField(cmd, "customId", null); - ReflectionTestUtils.setField(cmd, "display", true); - ReflectionTestUtils.setField(cmd, "publicMtu", 1450); - Vpc vpc = Mockito.mock(Vpc.class); - VpcResponse response = Mockito.mock(VpcResponse.class); - responseGenerator = Mockito.mock(ResponseGenerator.class); - cmd._responseGenerator = responseGenerator; - Mockito.when(_vpcService.updateVpc(Mockito.anyLong(), Mockito.anyString(), Mockito.anyString(), - Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyInt())).thenReturn(vpc); - Mockito.when(responseGenerator.createVpcResponse(ResponseObject.ResponseView.Full, vpc)).thenReturn(response); - Mockito.verify(_vpcService, Mockito.times(0)).updateVpc(Mockito.anyLong(), Mockito.anyString(), Mockito.anyString(), - Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyInt()); - - } -} \ No newline at end of file diff --git a/core/src/main/java/com/cloud/agent/api/routing/UpdateNetworkCommand.java b/core/src/main/java/com/cloud/agent/api/routing/UpdateNetworkCommand.java deleted file mode 100644 index cc77204a6551..000000000000 --- a/core/src/main/java/com/cloud/agent/api/routing/UpdateNetworkCommand.java +++ /dev/null @@ -1,59 +0,0 @@ -// 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.agent.api.routing; - -import com.cloud.agent.api.to.IpAddressTO; - -import java.util.Arrays; - -public class UpdateNetworkCommand extends NetworkElementCommand{ - IpAddressTO[] ipAddresses; - - public UpdateNetworkCommand(IpAddressTO[] ips) { - this.ipAddresses = ips; - } - - @Override - public boolean executeInSequence() { - return false; - } - - public IpAddressTO[] getIpAddresses() { - return ipAddresses; - } - - @Override - public int getAnswersCount() { - return ipAddresses.length; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - UpdateNetworkCommand command = (UpdateNetworkCommand) o; - return Arrays.equals(ipAddresses, command.ipAddresses); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + Arrays.hashCode(ipAddresses); - return result; - } -} diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VRScripts.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VRScripts.java index 9dac04d7e022..4450dfe66f23 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VRScripts.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VRScripts.java @@ -78,7 +78,5 @@ public class VRScripts { public static final String RETRIEVE_DIAGNOSTICS = "get_diagnostics_files.py"; public static final String VR_FILE_CLEANUP = "cleanup.sh"; - public static final String VR_UPDATE_INTERFACE_CONFIG = "update_interface_config.sh"; - public static final String ROUTER_FILESYSTEM_WRITABLE_CHECK = "filesystem_writable_check.py"; } \ No newline at end of file diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index 4492947b2cc6..8a265a78123b 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java @@ -34,11 +34,7 @@ import javax.naming.ConfigurationException; -import com.cloud.agent.api.routing.UpdateNetworkCommand; -import com.cloud.agent.api.to.IpAddressTO; -import com.cloud.network.router.VirtualRouter; import com.cloud.utils.PasswordGenerator; -import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.ca.SetupCertificateAnswer; import org.apache.cloudstack.ca.SetupCertificateCommand; import org.apache.cloudstack.ca.SetupKeyStoreCommand; @@ -50,7 +46,6 @@ import org.apache.cloudstack.diagnostics.PrepareFilesCommand; import org.apache.cloudstack.utils.security.KeyStoreUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.net.util.SubnetUtils; import org.apache.log4j.Logger; import org.joda.time.Duration; @@ -139,10 +134,6 @@ public Answer executeRequest(final NetworkElementCommand cmd) { return execute((AggregationControlCommand)cmd); } - if (cmd instanceof UpdateNetworkCommand) { - return execute((UpdateNetworkCommand) cmd); - } - if (_vrAggregateCommandsSet.containsKey(routerName)) { _vrAggregateCommandsSet.get(routerName).add(cmd); aggregated = true; @@ -225,51 +216,6 @@ private Answer executeQueryCommand(NetworkElementCommand cmd) { } } - private static String getRouterSshControlIp(NetworkElementCommand cmd) { - String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - if (s_logger.isDebugEnabled()) - s_logger.debug("Use router's private IP for SSH control. IP : " + routerIp); - return routerIp; - } - - private Answer execute(UpdateNetworkCommand cmd) { - IpAddressTO[] ipAddresses = cmd.getIpAddresses(); - String routerIp = getRouterSshControlIp(cmd); - boolean finalResult = true; - for (IpAddressTO ipAddressTO : ipAddresses) { - try { - SubnetUtils util = new SubnetUtils(ipAddressTO.getPublicIp(), ipAddressTO.getVlanNetmask()); - String address = util.getInfo().getCidrSignature(); - String subnet = address.split("/")[1]; - ExecutionResult result = _vrDeployer.executeInVR(routerIp, VRScripts.VR_UPDATE_INTERFACE_CONFIG, - ipAddressTO.getPublicIp() + " " + subnet + " " + ipAddressTO.getMtu() + " " + 15); - if (s_logger.isDebugEnabled()) - s_logger.debug("result: " + result.isSuccess() + ", output: " + result.getDetails()); - if (!Boolean.TRUE.equals(result.isSuccess())) { - if (result.getDetails().contains(String.format("Interface with IP %s not found", ipAddressTO.getPublicIp()))) { - s_logger.warn(String.format("Skipping IP: %s as it isn't configured on router interface", ipAddressTO.getPublicIp())); - } else if (ipAddressTO.getDetails().get(ApiConstants.REDUNDANT_STATE).equals(VirtualRouter.RedundantState.PRIMARY.name())) { - s_logger.warn(String.format("Failed to update interface mtu to %s on interface with ip: %s", - ipAddressTO.getMtu(), ipAddressTO.getPublicIp())); - finalResult = false; - } - continue; - } - s_logger.info(String.format("Successfully updated mtu to %s on interface with ip: %s", - ipAddressTO.getMtu(), ipAddressTO.getPublicIp())); - finalResult &= true; - } catch (Exception e) { - String msg = "Prepare UpdateNetwork failed due to " + e.toString(); - s_logger.error(msg, e); - return new Answer(cmd, e); - } - } - if (finalResult) { - return new Answer(cmd, true, null); - } - return new Answer(cmd, new CloudRuntimeException("Failed to update interface mtu")); - } - private ExecutionResult applyConfigToVR(String routerAccessIp, ConfigItem c) { return applyConfigToVR(routerAccessIp, c, VRScripts.VR_SCRIPT_EXEC_TIMEOUT); } diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/IpAssociationConfigItem.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/IpAssociationConfigItem.java index e326f5cf18ab..36908536659e 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/IpAssociationConfigItem.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/IpAssociationConfigItem.java @@ -43,7 +43,6 @@ public List generateConfig(final NetworkElementCommand cmd) { final IpAddress ipAddress = new IpAddress(ip.getPublicIp(), ip.isSourceNat(), ip.isAdd(), ip.isOneToOneNat(), ip.isFirstIP(), ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(), ip.getNicDevId(), ip.isNewNic(), ip.getTrafficType().toString()); ipAddress.setPrivateGateway(ip.isPrivateGateway()); - ipAddress.setMtu(ip.getMtu()); ips.add(ipAddress); } diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetGuestNetworkConfigItem.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetGuestNetworkConfigItem.java index 021d47b068e3..cb5dc4586c10 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetGuestNetworkConfigItem.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetGuestNetworkConfigItem.java @@ -33,9 +33,11 @@ import com.cloud.utils.net.NetUtils; public class SetGuestNetworkConfigItem extends AbstractConfigItemFacade { + @Override public List generateConfig(final NetworkElementCommand cmd) { final SetupGuestNetworkCommand command = (SetupGuestNetworkCommand) cmd; + final NicTO nic = command.getNic(); final String routerGIP = command.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP); final String gateway = command.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY); @@ -71,7 +73,7 @@ public List generateConfig(final NetworkElementCommand cmd) { if (nic.getIp6Cidr() != null) { guestNetwork.setCidr6(String.valueOf(NetUtils.getIp6CidrSize(nic.getIp6Cidr()))); } - guestNetwork.setMtu(nic.getMtu()); + guestNetwork.setRouterIp6(command.getRouterIpv6()); guestNetwork.setRouterIp6Gateway(command.getRouterIpv6Gateway()); guestNetwork.setRouterIp6Cidr(command.getRouterIpv6Cidr()); diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java index d8f341239c6d..6589c7806df0 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java @@ -38,8 +38,6 @@ public class GuestNetwork extends ConfigBase { private String routerIp6Gateway; private String routerIp6Cidr; - private Integer mtu; - public GuestNetwork() { super(ConfigBase.GUEST_NETWORK); } @@ -194,12 +192,4 @@ public String getRouterIp6Cidr() { public void setRouterIp6Cidr(String routerIp6Cidr) { this.routerIp6Cidr = routerIp6Cidr; } - - public void setMtu(Integer mtu) { - this.mtu = mtu; - } - - public Integer getMtu() { - return mtu; - } } \ No newline at end of file diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/IpAddress.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/IpAddress.java index 582a5c63de8f..627bcf0daceb 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/IpAddress.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/IpAddress.java @@ -33,7 +33,7 @@ public class IpAddress { private boolean newNic; private String nwType; private boolean isPrivateGateway; - private Integer mtu; + public IpAddress() { // Empty constructor for (de)serialization } @@ -142,11 +142,4 @@ public void setPrivateGateway(boolean isPrivateGateway) { this.isPrivateGateway = isPrivateGateway; } - public void setMtu(Integer mtu) { - this.mtu = mtu; - } - - public Integer getMtu() { - return mtu; - } } diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java index bf58c72c133d..cde00df026e7 100644 --- a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java +++ b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java @@ -188,7 +188,7 @@ void prepare(VirtualMachineProfile profile, DeployDestination dest, ReservationC Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, boolean bypassVlanOverlapCheck, String networkDomain, Account owner, Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr, Boolean displayNetworkEnabled, String isolatedPvlan, Network.PVlanType isolatedPvlanType, String externalId, String routerIp, String routerIpv6, - String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Pair vrIfaceMTUs) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException; + String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException; UserDataServiceProvider getPasswordResetProvider(Network network); diff --git a/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java b/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java index 24012a2487b8..4974345d4e23 100644 --- a/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java +++ b/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java @@ -20,7 +20,6 @@ import java.util.Map; import java.util.Set; -import com.cloud.utils.Pair; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import com.cloud.exception.ConcurrentOperationException; @@ -110,7 +109,7 @@ public interface VpcManager { Network createVpcGuestNetwork(long ntwkOffId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId, PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, long vpcId, Long aclId, Account caller, - Boolean displayNetworkEnabled, String externalId, String ip6Gateway, String ip6Cidr, String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Pair vrIfaceMTUs) + Boolean displayNetworkEnabled, String externalId, String ip6Gateway, String ip6Cidr, String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException; /** diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index 1ecee8ecfda6..fe1829853b43 100755 --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@ -3510,7 +3510,6 @@ public int compare(NicVO nic1, NicVO nic2) { return nicId1.compareTo(nicId2); } }); - for (final NicVO nic : nics) { final Network network = _networkModel.getNetwork(nic.getNetworkId()); final NicProfile nicProfile = diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 527d982d72c9..bf7978e8abd6 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -77,8 +77,6 @@ import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.deployasis.OVFNetworkTO; import com.cloud.alert.AlertManager; -import com.cloud.api.query.dao.DomainRouterJoinDao; -import com.cloud.api.query.vo.DomainRouterJoinVO; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.Resource.ResourceType; import com.cloud.dc.ClusterVO; @@ -129,7 +127,6 @@ import com.cloud.network.NetworkMigrationResponder; import com.cloud.network.NetworkModel; import com.cloud.network.NetworkProfile; -import com.cloud.network.NetworkService; import com.cloud.network.NetworkStateListener; import com.cloud.network.Networks; import com.cloud.network.Networks.BroadcastDomainType; @@ -190,7 +187,6 @@ import com.cloud.network.vpc.NetworkACLManager; import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.VpcManager; -import com.cloud.network.vpc.VpcVO; import com.cloud.network.vpc.dao.PrivateIpDao; import com.cloud.network.vpn.RemoteAccessVpnService; import com.cloud.offering.NetworkOffering; @@ -317,8 +313,6 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra @Inject DomainRouterDao routerDao; @Inject - DomainRouterJoinDao routerJoinDao; - @Inject RemoteAccessVpnDao _remoteAccessVpnDao; @Inject VpcVirtualNetworkApplianceService _routerService; @@ -775,6 +769,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { final NetworkVO networkPersisted = _networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId())); networks.add(networkPersisted); + if (network.getPvlanType() != null) { NetworkDetailVO detailVO = new NetworkDetailVO(networkPersisted.getId(), ApiConstants.ISOLATED_PVLAN_TYPE, network.getPvlanType().toString(), true); networkDetailsDao.persist(detailVO); @@ -1031,71 +1026,14 @@ public Pair allocateNic(final NicProfile requested, final N } deviceId = applyProfileToNic(vo, profile, deviceId); + vo = _nicDao.persist(vo); final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId()); final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vm.getHypervisorType(), network)); - if (vm.getType() == Type.DomainRouter) { - Pair networks = getGuestNetworkRouterAndVpcDetails(vm.getId()); - setMtuDetailsInVRNic(networks, network, vo); - _nicDao.update(vo.getId(), vo); - setMtuInVRNicProfile(networks, network.getTrafficType(), vmNic); - } - return new Pair(vmNic, Integer.valueOf(deviceId)); - } - - private void setMtuDetailsInVRNic(final Pair networks, Network network, NicVO vo) { - if (TrafficType.Public == network.getTrafficType()) { - if (networks == null) { - return; - } - NetworkVO networkVO = networks.first(); - VpcVO vpcVO = networks.second(); - if (vpcVO != null) { - vo.setMtu(vpcVO.getPublicMtu()); - } else { - vo.setMtu(networkVO.getPublicMtu()); - } - } else if (TrafficType.Guest == network.getTrafficType()) { - vo.setMtu(network.getPrivateMtu()); - } - } - - private void setMtuInVRNicProfile(final Pair networks, TrafficType trafficType, NicProfile vmNic) { - if (networks == null) { - return; - } - NetworkVO networkVO = networks.first(); - VpcVO vpcVO = networks.second(); - if (networkVO != null) { - if (TrafficType.Public == trafficType) { - if (vpcVO != null) { - vmNic.setMtu(vpcVO.getPublicMtu()); - } else { - vmNic.setMtu(networkVO.getPublicMtu()); - } - } else if (TrafficType.Guest == trafficType) { - vmNic.setMtu(networkVO.getPrivateMtu()); - } - } - } - private Pair getGuestNetworkRouterAndVpcDetails(long routerId) { - List routerVo = routerJoinDao.getRouterByIdAndTrafficType(routerId, TrafficType.Guest); - if (routerVo.isEmpty()) { - routerVo = routerJoinDao.getRouterByIdAndTrafficType(routerId, TrafficType.Public); - if (routerVo.isEmpty()) { - return null; - } - } - DomainRouterJoinVO guestRouterDetails = routerVo.get(0); - VpcVO vpc = null; - if (guestRouterDetails.getVpcId() != 0) { - vpc = _entityMgr.findById(VpcVO.class, guestRouterDetails.getVpcId()); - } - long networkId = guestRouterDetails.getNetworkId(); - return new Pair<>(_networksDao.findById(networkId), vpc); + return new Pair(vmNic, Integer.valueOf(deviceId)); } /** @@ -1949,6 +1887,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { public void prepare(final VirtualMachineProfile vmProfile, final DeployDestination dest, final ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { final List nics = _nicDao.listByVmId(vmProfile.getId()); + // we have to implement default nics first - to ensure that default network elements start up first in multiple //nics case // (need for setting DNS on Dhcp to domR's Ip4 address) @@ -1972,10 +1911,6 @@ public int compare(final NicVO nic1, final NicVO nic2) { final NetworkVO network = implemented.second(); final NicProfile profile = prepareNic(vmProfile, dest, context, nic.getId(), network); - if (vmProfile.getType() == Type.DomainRouter) { - Pair networks = getGuestNetworkRouterAndVpcDetails(vmProfile.getId()); - setMtuInVRNicProfile(networks, network.getTrafficType(), profile); - } vmProfile.addNic(profile); } } @@ -2021,19 +1956,16 @@ public NicProfile prepareNic(final VirtualMachineProfile vmProfile, final Deploy if (profile.getReservationStrategy() != null) { nic.setReservationStrategy(profile.getReservationStrategy()); } + + updateNic(nic, network.getId(), 1); } else { profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vmProfile.getHypervisorType(), network)); guru.updateNicProfile(profile, network); nic.setState(Nic.State.Reserved); + updateNic(nic, network.getId(), 1); } - if (vmProfile.getType() == Type.DomainRouter) { - Pair networks = getGuestNetworkRouterAndVpcDetails(vmProfile.getId()); - setMtuDetailsInVRNic(networks, network, nic); - } - updateNic(nic, network.getId(), 1); - final List providersToImplement = getNetworkProviders(network.getId()); for (final NetworkElement element : networkElements) { if (providersToImplement.contains(element.getProvider())) { @@ -2532,7 +2464,7 @@ public Network createPrivateNetwork(final long networkOfferingId, final String n return createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId, bypassVlanOverlapCheck, null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, vpcId, null, null, true, null, null, null, true, null, null, - null, null, null, null, null); + null, null, null, null); } @Override @@ -2541,11 +2473,11 @@ public Network createGuestNetwork(final long networkOfferingId, final String nam boolean bypassVlanOverlapCheck, String networkDomain, final Account owner, final Long domainId, final PhysicalNetwork pNtwk, final long zoneId, final ACLType aclType, Boolean subdomainAccess, final Long vpcId, final String ip6Gateway, final String ip6Cidr, final Boolean isDisplayNetworkEnabled, final String isolatedPvlan, Network.PVlanType isolatedPvlanType, String externalId, - String routerIp, String routerIpv6, String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Pair vrIfaceMTUs) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { + String routerIp, String routerIpv6, String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { // create Isolated/Shared/L2 network return createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId, bypassVlanOverlapCheck, networkDomain, owner, domainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr, - isDisplayNetworkEnabled, isolatedPvlan, isolatedPvlanType, externalId, false, routerIp, routerIpv6, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2, vrIfaceMTUs); + isDisplayNetworkEnabled, isolatedPvlan, isolatedPvlanType, externalId, false, routerIp, routerIpv6, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2); } @DB @@ -2554,7 +2486,7 @@ private Network createGuestNetwork(final long networkOfferingId, final String na final long zoneId, final ACLType aclType, Boolean subdomainAccess, final Long vpcId, final String ip6Gateway, final String ip6Cidr, final Boolean isDisplayNetworkEnabled, final String isolatedPvlan, Network.PVlanType isolatedPvlanType, String externalId, final Boolean isPrivateNetwork, String routerIp, String routerIpv6, final String ip4Dns1, final String ip4Dns2, - final String ip6Dns1, final String ip6Dns2, Pair vrIfaceMTUs) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { + final String ip6Dns1, final String ip6Dns2) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { final NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId); final DataCenterVO zone = _dcDao.findById(zoneId); @@ -2829,23 +2761,6 @@ public Network doInTransaction(final TransactionStatus status) { userNetwork.setRouterIpv6(routerIpv6); } - if (vrIfaceMTUs != null) { - if (vrIfaceMTUs.first() != null && vrIfaceMTUs.first() > 0) { - userNetwork.setPublicMtu(vrIfaceMTUs.first()); - } else { - userNetwork.setPublicMtu(Integer.valueOf(NetworkService.VRPublicInterfaceMtu.defaultValue())); - } - - if (vrIfaceMTUs.second() != null && vrIfaceMTUs.second() > 0) { - userNetwork.setPrivateMtu(vrIfaceMTUs.second()); - } else { - userNetwork.setPrivateMtu(Integer.valueOf(NetworkService.VRPrivateInterfaceMtu.defaultValue())); - } - } else { - userNetwork.setPublicMtu(Integer.valueOf(NetworkService.VRPublicInterfaceMtu.defaultValue())); - userNetwork.setPrivateMtu(Integer.valueOf(NetworkService.VRPrivateInterfaceMtu.defaultValue())); - } - if (!GuestType.L2.equals(userNetwork.getGuestType())) { if (StringUtils.isNotBlank(ip4Dns1)) { userNetwork.setDns1(ip4Dns1); @@ -4583,10 +4498,6 @@ public NicVO doInTransaction(TransactionStatus status) { || vo.getVmType() == VirtualMachine.Type.DomainRouter && _networksDao.findById(network.getId()).getTrafficType() == TrafficType.Guest) { _networksDao.setCheckForGc(network.getId()); } - if (vm.getType() == Type.DomainRouter) { - Pair networks = getGuestNetworkRouterAndVpcDetails(vm.getId()); - setMtuDetailsInVRNic(networks, network, vo); - } return vo; } diff --git a/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDao.java b/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDao.java index eea6c3581102..5e71d543333b 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDao.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDao.java @@ -94,6 +94,4 @@ public interface IPAddressDao extends GenericDao { IPAddressVO findByVmIdAndNetworkId(long networkId, long vmId); IPAddressVO findByAccountIdAndZoneIdAndStateAndIpAddress(long accountId, long dcId, State state, String ipAddress); - - List listByNetworkId(long networkId); } diff --git a/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDaoImpl.java b/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDaoImpl.java index f50e3f83c8a8..42359d06047a 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/IPAddressDaoImpl.java @@ -500,12 +500,4 @@ public IPAddressVO findByAccountIdAndZoneIdAndStateAndIpAddress(long accountId, sc.setParameters("ipAddress", ipAddress); return findOneBy(sc); } - - @Override - public List listByNetworkId(long networkId) { - SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("network", networkId); - sc.setParameters("state", State.Allocated); - return listBy(sc); - } } diff --git a/engine/schema/src/main/java/com/cloud/network/dao/NetworkVO.java b/engine/schema/src/main/java/com/cloud/network/dao/NetworkVO.java index f24eec4931e3..e6869b4b264b 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/NetworkVO.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/NetworkVO.java @@ -39,7 +39,6 @@ import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.GenericDao; import com.cloud.utils.net.NetUtils; -import org.apache.log4j.Logger; /** * NetworkConfigurationVO contains information about a specific network. @@ -48,7 +47,6 @@ @Entity @Table(name = "networks") public class NetworkVO implements Network { - static final Logger s_logger = Logger.getLogger(NetworkVO.class); @Id @TableGenerator(name = "networks_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "networks_seq", allocationSize = 1) @Column(name = "id") @@ -199,12 +197,6 @@ public class NetworkVO implements Network { @Transient PVlanType pVlanType; - @Column(name = "public_mtu") - Integer publicMtu; - - @Column(name = "private_mtu") - Integer privateMtu; - public NetworkVO() { uuid = UUID.randomUUID().toString(); } @@ -283,8 +275,6 @@ public NetworkVO(long id, Network that, long offeringId, String guruName, long d this.ip6Dns2 = that.getIp6Dns2(); } this.externalId = externalId; - this.publicMtu = that.getPublicMtu(); - this.privateMtu = that.getPrivateMtu(); } /** @@ -741,20 +731,4 @@ public String getRouterIpv6() { public void setRouterIpv6(String routerIpv6) { this.routerIpv6 = routerIpv6; } - - public Integer getPublicMtu() { - return publicMtu; - } - - public void setPublicMtu(Integer publicMtu) { - this.publicMtu = publicMtu; - } - - public Integer getPrivateMtu() { - return privateMtu; - } - - public void setPrivateMtu(Integer privateMtu) { - this.privateMtu = privateMtu; - } } diff --git a/engine/schema/src/main/java/com/cloud/network/vpc/VpcVO.java b/engine/schema/src/main/java/com/cloud/network/vpc/VpcVO.java index c2024e06c51b..c2c57b11fbff 100644 --- a/engine/schema/src/main/java/com/cloud/network/vpc/VpcVO.java +++ b/engine/schema/src/main/java/com/cloud/network/vpc/VpcVO.java @@ -89,9 +89,6 @@ public class VpcVO implements Vpc { @Column(name = "region_level_vpc") boolean regionLevelVpc = false; - @Column(name = "public_mtu") - Integer publicMtu; - @Column(name = "dns1") String ip4Dns1; @@ -276,14 +273,6 @@ public boolean usesDistributedRouter() { return usesDistributedRouter; } - public Integer getPublicMtu() { - return publicMtu; - } - - public void setPublicMtu(Integer publicMtu) { - this.publicMtu = publicMtu; - } - @Override public String getIp4Dns1() { return ip4Dns1; diff --git a/engine/schema/src/main/java/com/cloud/vm/NicVO.java b/engine/schema/src/main/java/com/cloud/vm/NicVO.java index 8905ebf732b1..2a7c6962cbd4 100644 --- a/engine/schema/src/main/java/com/cloud/vm/NicVO.java +++ b/engine/schema/src/main/java/com/cloud/vm/NicVO.java @@ -124,9 +124,6 @@ protected NicVO() { @Column(name = "secondary_ip") boolean secondaryIp; - @Column(name = "mtu") - Integer mtu; - @Transient transient String nsxLogicalSwitchUuid; @@ -397,13 +394,4 @@ public String getNsxLogicalSwitchPortUuid() { public void setNsxLogicalSwitchPortUuid(String nsxLogicalSwitchPortUuid) { this.nsxLogicalSwitchPortUuid = nsxLogicalSwitchPortUuid; } - - @Override - public Integer getMtu() { - return mtu; - } - - public void setMtu(Integer mtu) { - this.mtu = mtu; - } } diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/NicDao.java b/engine/schema/src/main/java/com/cloud/vm/dao/NicDao.java index fc2da6124cfc..56f235432a73 100644 --- a/engine/schema/src/main/java/com/cloud/vm/dao/NicDao.java +++ b/engine/schema/src/main/java/com/cloud/vm/dao/NicDao.java @@ -90,8 +90,4 @@ public interface NicDao extends GenericDao { NicVO findByInstanceIdAndMacAddress(long instanceId, String macAddress); List findNicsByIpv6GatewayIpv6CidrAndReserver(String ipv6Gateway, String ipv6Cidr, String reserverName); - - NicVO findByIpAddressAndVmType(String ip, VirtualMachine.Type vmType); - - List listByNetworkIdAndType(long networkId, VirtualMachine.Type vmType); } diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/NicDaoImpl.java b/engine/schema/src/main/java/com/cloud/vm/dao/NicDaoImpl.java index 3b669aa526ba..6c72449e2af5 100644 --- a/engine/schema/src/main/java/com/cloud/vm/dao/NicDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/vm/dao/NicDaoImpl.java @@ -383,20 +383,4 @@ public List findNicsByIpv6GatewayIpv6CidrAndReserver(String ipv6Gateway, sc.setParameters("reserverName", reserverName); return listBy(sc); } - - @Override - public NicVO findByIpAddressAndVmType(String ip, VirtualMachine.Type vmType) { - SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("vmType", vmType); - sc.setParameters("address", ip); - return findOneBy(sc); - } - - @Override - public List listByNetworkIdAndType(long networkId, VirtualMachine.Type vmType) { - SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("network", networkId); - sc.setParameters("vmType", vmType); - return listBy(sc); - } } diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41720to41800.sql b/engine/schema/src/main/resources/META-INF/db/schema-41720to41800.sql index d1180c8f2c2b..c637f89a5546 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41720to41800.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41720to41800.sql @@ -24,116 +24,6 @@ UPDATE `cloud`.`service_offering` so SET so.limit_cpu_use = 1 WHERE so.default_use = 1 AND so.vm_type IN ('domainrouter', 'secondarystoragevm', 'consoleproxy', 'internalloadbalancervm', 'elasticloadbalancervm'); -ALTER TABLE `cloud`.`networks` ADD COLUMN `public_mtu` bigint unsigned comment "MTU for VR public interface" ; -ALTER TABLE `cloud`.`networks` ADD COLUMN `private_mtu` bigint unsigned comment "MTU for VR private interfaces" ; -ALTER TABLE `cloud`.`vpc` ADD COLUMN `public_mtu` bigint unsigned comment "MTU for VPC VR public interface" ; -ALTER TABLE `cloud`.`nics` ADD COLUMN `mtu` bigint unsigned comment "MTU for the VR interface" ; - -DROP VIEW IF EXISTS `cloud`.`domain_router_view`; -CREATE VIEW `cloud`.`domain_router_view` AS - select - vm_instance.id id, - vm_instance.name name, - account.id account_id, - account.uuid account_uuid, - account.account_name account_name, - account.type account_type, - domain.id domain_id, - domain.uuid domain_uuid, - domain.name domain_name, - domain.path domain_path, - projects.id project_id, - projects.uuid project_uuid, - projects.name project_name, - vm_instance.uuid uuid, - vm_instance.created created, - vm_instance.state state, - vm_instance.removed removed, - vm_instance.pod_id pod_id, - vm_instance.instance_name instance_name, - host_pod_ref.uuid pod_uuid, - data_center.id data_center_id, - data_center.uuid data_center_uuid, - data_center.name data_center_name, - data_center.networktype data_center_type, - data_center.dns1 dns1, - data_center.dns2 dns2, - data_center.ip6_dns1 ip6_dns1, - data_center.ip6_dns2 ip6_dns2, - host.id host_id, - host.uuid host_uuid, - host.name host_name, - host.hypervisor_type, - host.cluster_id cluster_id, - vm_template.id template_id, - vm_template.uuid template_uuid, - service_offering.id service_offering_id, - service_offering.uuid service_offering_uuid, - service_offering.name service_offering_name, - nics.id nic_id, - nics.uuid nic_uuid, - nics.network_id network_id, - nics.ip4_address ip_address, - nics.ip6_address ip6_address, - nics.ip6_gateway ip6_gateway, - nics.ip6_cidr ip6_cidr, - nics.default_nic is_default_nic, - nics.gateway gateway, - nics.netmask netmask, - nics.mac_address mac_address, - nics.broadcast_uri broadcast_uri, - nics.isolation_uri isolation_uri, - nics.mtu mtu, - vpc.id vpc_id, - vpc.uuid vpc_uuid, - vpc.name vpc_name, - networks.uuid network_uuid, - networks.name network_name, - networks.network_domain network_domain, - networks.traffic_type traffic_type, - networks.guest_type guest_type, - async_job.id job_id, - async_job.uuid job_uuid, - async_job.job_status job_status, - async_job.account_id job_account_id, - domain_router.template_version template_version, - domain_router.scripts_version scripts_version, - domain_router.is_redundant_router is_redundant_router, - domain_router.redundant_state redundant_state, - domain_router.stop_pending stop_pending, - domain_router.role role, - domain_router.software_version software_version - from - `cloud`.`domain_router` - inner join - `cloud`.`vm_instance` ON vm_instance.id = domain_router.id - inner join - `cloud`.`account` ON vm_instance.account_id = account.id - inner join - `cloud`.`domain` ON vm_instance.domain_id = domain.id - left join - `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id - left join - `cloud`.`projects` ON projects.project_account_id = account.id - left join - `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id - left join - `cloud`.`host` ON vm_instance.host_id = host.id - left join - `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id - left join - `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id - left join - `cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null - left join - `cloud`.`networks` ON nics.network_id = networks.id - left join - `cloud`.`vpc` ON domain_router.vpc_id = vpc.id and vpc.removed is null - left join - `cloud`.`async_job` ON async_job.instance_id = vm_instance.id - and async_job.instance_type = 'DomainRouter' - and async_job.job_status = 0; - -- Idempotent ADD COLUMN DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_ADD_COLUMN`; CREATE PROCEDURE `cloud`.`IDEMPOTENT_ADD_COLUMN` ( diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java index 6a91f93c2873..36fb30015244 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java @@ -765,7 +765,7 @@ private Network getKubernetesClusterNetworkIfMissing(final String clusterName, f network = networkMgr.createGuestNetwork(networkOffering.getId(), clusterName + "-network", owner.getAccountName() + "-network", null, null, null, false, null, owner, null, physicalNetwork, zone.getId(), ControlledEntity.ACLType.Account, null, null, null, null, true, null, - null, null, null, null, null, null, null, null, null); + null, null, null, null, null, null, null, null); } catch (ConcurrentOperationException | InsufficientCapacityException | ResourceAllocationException e) { logAndThrow(Level.ERROR, String.format("Unable to create network for the Kubernetes cluster: %s", clusterName)); } diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index c7cfda4fc672..e08ba5250e9e 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -2380,8 +2380,7 @@ public NetworkResponse createNetworkResponse(ResponseView view, Network network) response.setRelated(nw.getUuid()); } response.setNetworkDomain(network.getNetworkDomain()); - response.setPublicMtu(network.getPublicMtu()); - response.setPrivateMtu(network.getPrivateMtu()); + response.setDns1(profile.getDns1()); response.setDns2(profile.getDns2()); response.setIpv6Dns1(profile.getIp6Dns1()); @@ -3235,7 +3234,6 @@ public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) { response.setNetworks(networkResponses); response.setServices(serviceResponses); - response.setPublicMtu(vpc.getPublicMtu()); populateOwner(response, vpc); // set tag information diff --git a/server/src/main/java/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java index 899cf6d7a5d5..3762484f1765 100644 --- a/server/src/main/java/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java @@ -20,23 +20,23 @@ import javax.inject.Inject; +import com.cloud.resource.icon.ResourceIconVO; +import org.apache.cloudstack.api.response.ResourceIconResponse; import org.apache.cloudstack.annotation.AnnotationService; import org.apache.cloudstack.annotation.dao.AnnotationDao; -import org.apache.cloudstack.api.ResponseObject.ResponseView; -import org.apache.cloudstack.api.response.ResourceIconResponse; -import org.apache.cloudstack.api.response.ResourceTagResponse; -import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.response.ResourceTagResponse; +import org.apache.cloudstack.api.response.ZoneResponse; + import com.cloud.api.ApiDBUtils; import com.cloud.api.ApiResponseHelper; import com.cloud.api.query.vo.DataCenterJoinVO; import com.cloud.api.query.vo.ResourceTagJoinVO; import com.cloud.dc.DataCenter; -import com.cloud.network.NetworkService; -import com.cloud.resource.icon.ResourceIconVO; import com.cloud.server.ResourceTag.ResourceObjectType; import com.cloud.user.AccountManager; import com.cloud.utils.db.GenericDaoBase; @@ -120,9 +120,6 @@ public ZoneResponse newDataCenterResponse(ResponseView view, DataCenterJoinVO da zoneResponse.setResourceDetails(ApiDBUtils.getResourceDetails(dataCenter.getId(), ResourceObjectType.Zone)); zoneResponse.setHasAnnotation(annotationDao.hasAnnotations(dataCenter.getUuid(), AnnotationService.EntityType.ZONE.name(), _accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId()))); - zoneResponse.setAllowUserSpecifyVRMtu(NetworkService.AllowUsersToSpecifyVRMtu.valueIn(dataCenter.getId())); - zoneResponse.setRouterPrivateInterfaceMaxMtu(NetworkService.VRPrivateInterfaceMtu.valueIn(dataCenter.getId())); - zoneResponse.setRouterPublicInterfaceMaxMtu(NetworkService.VRPublicInterfaceMtu.valueIn(dataCenter.getId())); zoneResponse.setObjectName("zone"); return zoneResponse; diff --git a/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDao.java b/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDao.java index 509d02dd71c5..961ab40a88df 100644 --- a/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDao.java +++ b/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDao.java @@ -18,7 +18,6 @@ import java.util.List; -import com.cloud.network.Networks; import org.apache.cloudstack.api.response.DomainRouterResponse; import com.cloud.api.query.vo.DomainRouterJoinVO; @@ -35,6 +34,4 @@ public interface DomainRouterJoinDao extends GenericDao newDomainRouterView(VirtualRouter vr); List searchByIds(Long... ids); - - List getRouterByIdAndTrafficType(Long id, Networks.TrafficType... trafficType); } diff --git a/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java index feeaa8b952a3..235aa78df2f6 100644 --- a/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java @@ -62,7 +62,6 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase vrSearch; private final SearchBuilder vrIdSearch; - private final SearchBuilder vrIdTrafficSearch; protected DomainRouterJoinDaoImpl() { @@ -74,11 +73,6 @@ protected DomainRouterJoinDaoImpl() { vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ); vrIdSearch.done(); - vrIdTrafficSearch = createSearchBuilder(); - vrIdTrafficSearch.and("id", vrIdTrafficSearch.entity().getId(), SearchCriteria.Op.EQ); - vrIdTrafficSearch.and("trafficType", vrIdTrafficSearch.entity().getTrafficType(), SearchCriteria.Op.IN); - vrIdTrafficSearch.done(); - _count = "select count(distinct id) from domain_router_view WHERE "; } @@ -124,9 +118,7 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A routerResponse.setRequiresUpgrade(true); } - if (router.getHypervisorType() != null) { - routerResponse.setHypervisor(router.getHypervisorType().toString()); - } + routerResponse.setHypervisor(router.getHypervisorType().toString()); routerResponse.setHasAnnotation(annotationDao.hasAnnotations(router.getUuid(), AnnotationService.EntityType.VR.name(), _accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId()))); @@ -191,9 +183,6 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A if (router.getGuestType() != null) { nicResponse.setType(router.getGuestType().toString()); } - if (router.getMtu() != null){ - nicResponse.setMtu(router.getMtu()); - } nicResponse.setIsDefault(router.isDefaultNic()); nicResponse.setObjectName("nic"); routerResponse.addNic(nicResponse); @@ -287,9 +276,6 @@ public DomainRouterResponse setDomainRouterResponse(DomainRouterResponse vrData, if (vr.getGuestType() != null) { nicResponse.setType(vr.getGuestType().toString()); } - if (vr.getMtu() != null) { - nicResponse.setMtu(vr.getMtu()); - } nicResponse.setIsDefault(vr.isDefaultNic()); nicResponse.setObjectName("nic"); vrData.addNic(nicResponse); @@ -341,14 +327,6 @@ public List searchByIds(Long... vrIds) { return uvList; } - @Override - public List getRouterByIdAndTrafficType(Long id, TrafficType... trafficType) { - SearchCriteria sc = vrIdTrafficSearch.create(); - sc.setParameters("id", id); - sc.setParameters("trafficType", (Object[])trafficType); - return searchIncludingRemoved(sc, null, null, false); - } - @Override public List newDomainRouterView(VirtualRouter vr) { diff --git a/server/src/main/java/com/cloud/api/query/vo/DomainRouterJoinVO.java b/server/src/main/java/com/cloud/api/query/vo/DomainRouterJoinVO.java index 78a794009e60..51171ff6913a 100644 --- a/server/src/main/java/com/cloud/api/query/vo/DomainRouterJoinVO.java +++ b/server/src/main/java/com/cloud/api/query/vo/DomainRouterJoinVO.java @@ -254,9 +254,6 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti @Column(name = "software_version") private String softwareVersion; - @Column(name = "mtu") - private Integer mtu; - public DomainRouterJoinVO() { } @@ -544,8 +541,4 @@ public Class getEntityType() { public String getSoftwareVersion() { return softwareVersion; } - - public Integer getMtu() { - return mtu; - } } diff --git a/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java index 37b430a4cfcf..3c8b6c58d9bf 100644 --- a/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java +++ b/server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java @@ -143,7 +143,6 @@ public NicTO toNicTO(NicProfile profile) { to.setIp6Address(profile.getIPv6Address()); to.setIp6Gateway(profile.getIPv6Gateway()); to.setIp6Cidr(profile.getIPv6Cidr()); - to.setMtu(profile.getMtu()); to.setIp6Dns1(profile.getIPv6Dns1()); to.setIp6Dns2(profile.getIPv6Dns2()); diff --git a/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java b/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java index f6df85f23085..010925b70062 100644 --- a/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java +++ b/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java @@ -1801,10 +1801,9 @@ public Ternary, Network> doInTransaction(Transa s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process"); - guestNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, false, null, owner, null, physicalNetwork, zoneId, ACLType.Account, null, null, null, null, true, null, null, null, null, null, - null, null, null, null, null); + null, null, null, null); if (guestNetwork == null) { s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId); throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT " diff --git a/server/src/main/java/com/cloud/network/NetworkMigrationManagerImpl.java b/server/src/main/java/com/cloud/network/NetworkMigrationManagerImpl.java index e1f4fe7fb17b..1df42a54acd2 100644 --- a/server/src/main/java/com/cloud/network/NetworkMigrationManagerImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkMigrationManagerImpl.java @@ -299,8 +299,7 @@ public Long makeCopyOfVpc(long vpcId, long vpcOfferingId) { try { copyOfVpc = _vpcService.createVpc(vpc.getZoneId(), vpcOfferingId, vpc.getAccountId(), vpc.getName(), vpc.getDisplayText(), vpc.getCidr(), vpc.getNetworkDomain(), vpc.getIp4Dns1(), vpc.getIp4Dns2(), - vpc.getIp6Dns1(), vpc.getIp6Dns2(), vpc.isDisplay(), vpc.getPublicMtu()); - + vpc.getIp6Dns1(), vpc.getIp6Dns2(), vpc.isDisplay()); copyOfVpcId = copyOfVpc.getId(); //on resume of migration the uuid will be swapped already. So the copy will have the value of the original vpcid. _resourceTagDao.persist(new ResourceTagVO(MIGRATION, Long.toString(vpcId), vpc.getAccountId(), vpc.getDomainId(), copyOfVpcId, ResourceTag.ResourceObjectType.Vpc, null, vpc.getUuid())); diff --git a/server/src/main/java/com/cloud/network/NetworkModelImpl.java b/server/src/main/java/com/cloud/network/NetworkModelImpl.java index df6d8c61c3f5..7456ecd2a86d 100644 --- a/server/src/main/java/com/cloud/network/NetworkModelImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkModelImpl.java @@ -2177,12 +2177,6 @@ public NicProfile getNicProfile(VirtualMachine vm, long networkId, String broadc NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag( vm.getHypervisorType(), network)); - if (network.getTrafficType() == TrafficType.Public && network.getPublicMtu() != null) { - profile.setMtu(network.getPublicMtu()); - } - if (network.getTrafficType() == TrafficType.Guest && network.getPrivateMtu() != null) { - profile.setMtu(network.getPrivateMtu()); - } // guru.updateNicProfile(profile, network); return profile; } diff --git a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java index 8e5001ce6284..2cac85e99664 100644 --- a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java @@ -43,7 +43,6 @@ import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.acl.SecurityChecker.AccessType; -import org.apache.cloudstack.alert.AlertService; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.command.admin.address.ReleasePodIpCmdByAdmin; import org.apache.cloudstack.api.command.admin.network.CreateNetworkCmdByAdmin; @@ -78,18 +77,8 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; - -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.to.IpAddressTO; -import com.cloud.agent.manager.Commands; -import com.cloud.alert.AlertManager; + import com.cloud.api.ApiDBUtils; -import com.cloud.api.query.dao.DomainRouterJoinDao; -import com.cloud.api.query.vo.DomainRouterJoinVO; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.Resource; @@ -159,16 +148,12 @@ import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.network.dao.VirtualRouterProviderDao; import com.cloud.network.element.NetworkElement; import com.cloud.network.element.OvsProviderVO; import com.cloud.network.element.VirtualRouterElement; import com.cloud.network.element.VpcVirtualRouterElement; import com.cloud.network.guru.GuestNetworkGuru; import com.cloud.network.guru.NetworkGuru; -import com.cloud.network.router.CommandSetupHelper; -import com.cloud.network.router.NetworkHelper; -import com.cloud.network.router.VirtualRouter; import com.cloud.network.rules.FirewallRule.Purpose; import com.cloud.network.rules.FirewallRuleVO; import com.cloud.network.rules.RulesManager; @@ -178,7 +163,6 @@ import com.cloud.network.vpc.PrivateIpVO; import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.VpcManager; -import com.cloud.network.vpc.VpcVO; import com.cloud.network.vpc.dao.NetworkACLDao; import com.cloud.network.vpc.dao.PrivateIpDao; import com.cloud.network.vpc.dao.VpcDao; @@ -226,7 +210,6 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.ExceptionUtil; import com.cloud.utils.net.NetUtils; -import com.cloud.vm.DomainRouterVO; import com.cloud.vm.Nic; import com.cloud.vm.NicProfile; import com.cloud.vm.NicSecondaryIp; @@ -240,7 +223,6 @@ import com.cloud.vm.VirtualMachineManager; import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.VirtualMachineProfileImpl; -import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.NicSecondaryIpDao; import com.cloud.vm.dao.NicSecondaryIpVO; @@ -254,9 +236,9 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, Configurable { private static final Logger s_logger = Logger.getLogger(NetworkServiceImpl.class); - private static final ConfigKey AllowDuplicateNetworkName = new ConfigKey<>("Advanced", Boolean.class, + private static final ConfigKey AllowDuplicateNetworkName = new ConfigKey("Advanced", Boolean.class, "allow.duplicate.networkname", "true", "Allow creating networks with same name in account", true, ConfigKey.Scope.Account); - private static final ConfigKey AllowEmptyStartEndIpAddress = new ConfigKey<>("Advanced", Boolean.class, + private static final ConfigKey AllowEmptyStartEndIpAddress = new ConfigKey("Advanced", Boolean.class, "allow.empty.start.end.ipaddress", "true", "Allow creating network without mentioning start and end IP address", true, ConfigKey.Scope.Account); private static final long MIN_VLAN_ID = 0L; @@ -383,22 +365,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C Ipv6Service ipv6Service; @Inject Ipv6GuestPrefixSubnetNetworkMapDao ipv6GuestPrefixSubnetNetworkMapDao; - @Inject - AlertManager alertManager; - @Inject - VirtualRouterProviderDao vrProviderDao; - @Inject - DomainRouterDao routerDao; - @Inject - DomainRouterJoinDao routerJoinDao; - @Inject - CommandSetupHelper commandSetupHelper; - @Inject - AgentManager agentManager; - - @Autowired - @Qualifier("networkHelper") - protected NetworkHelper networkHelper; int _cidrLimit; boolean _allowSubdomainNetworkAccess; @@ -1372,8 +1338,6 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac String externalId = cmd.getExternalId(); String isolatedPvlanType = cmd.getIsolatedPvlanType(); Long associatedNetworkId = cmd.getAssociatedNetworkId(); - Integer publicMtu = cmd.getPublicMtu(); - Integer privateMtu = cmd.getPrivateMtu(); String ip4Dns1 = cmd.getIp4Dns1(); String ip4Dns2 = cmd.getIp4Dns2(); String ip6Dns1 = cmd.getIp6Dns1(); @@ -1700,9 +1664,6 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac throwInvalidIdException("Network offering with specified id doesn't support adding multiple ip ranges", ntwkOff.getUuid(), "networkOfferingId"); } - Pair interfaceMTUs = validateMtuConfig(publicMtu, privateMtu, zoneId); - mtuCheckForVpcNetwork(vpcId, interfaceMTUs, publicMtu, privateMtu); - Network associatedNetwork = null; if (associatedNetworkId != null) { if (vlanId != null) { @@ -1721,7 +1682,7 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac Network network = commitNetwork(networkOfferingId, gateway, startIP, endIP, netmask, networkDomain, vlanId, bypassVlanOverlapCheck, name, displayText, caller, physicalNetworkId, zoneId, domainId, isDomainSpecific, subdomainAccess, vpcId, startIPv6, endIPv6, ip6Gateway, ip6Cidr, displayNetwork, aclId, secondaryVlanId, privateVlanType, ntwkOff, pNtwk, aclType, owner, cidr, createVlan, - externalId, routerIp, routerIpv6, associatedNetwork, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2, interfaceMTUs); + externalId, routerIp, routerIpv6, associatedNetwork, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2); if (hideIpAddressUsage) { _networkDetailsDao.persist(new NetworkDetailVO(network.getId(), Network.hideIpAddressUsage, String.valueOf(hideIpAddressUsage), false)); @@ -1738,59 +1699,6 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac return network; } - protected void mtuCheckForVpcNetwork(Long vpcId, Pair interfaceMTUs, Integer publicMtu, Integer privateMtu) { - if (vpcId != null && publicMtu != null) { - VpcVO vpc = _vpcDao.findById(vpcId); - if (vpc == null) { - throw new CloudRuntimeException(String.format("VPC with id %s not found", vpcId)); - } - s_logger.warn(String.format("VPC public MTU already set at VPC creation phase to: %s. Ignoring public MTU " + - "passed during VPC network tier creation ", vpc.getPublicMtu())); - interfaceMTUs.set(vpc.getPublicMtu(), privateMtu); - } - } - - protected Pair validateMtuConfig(Integer publicMtu, Integer privateMtu, Long zoneId) { - Integer vrMaxMtuForPublicIfaces = VRPublicInterfaceMtu.valueIn(zoneId); - Integer vrMaxMtuForPrivateIfaces = VRPrivateInterfaceMtu.valueIn(zoneId); - if (!AllowUsersToSpecifyVRMtu.valueIn(zoneId)) { - privateMtu = vrMaxMtuForPrivateIfaces; - publicMtu = vrMaxMtuForPublicIfaces; - return new Pair<>(publicMtu, privateMtu); - } - - if (publicMtu > vrMaxMtuForPublicIfaces) { - String subject = "Incorrect MTU configured on network for public interfaces of the VR"; - String message = String.format("Configured MTU for network VR's public interfaces exceeds the upper limit " + - "enforced by zone level setting: %s. VR's public interfaces can be configured with a maximum MTU of %s", VRPublicInterfaceMtu.key(), VRPublicInterfaceMtu.valueIn(zoneId)); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PUBLIC_IFACE_MTU, zoneId, null, subject, message); - publicMtu = vrMaxMtuForPublicIfaces; - } else if (publicMtu < MINIMUM_MTU) { - String subject = "Incorrect MTU configured on network for public interfaces of the VR"; - String message = String.format("Configured MTU for network VR's public interfaces is lesser than the supported minimum of %s.", MINIMUM_MTU); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PUBLIC_IFACE_MTU, zoneId, null, subject, message); - publicMtu = MINIMUM_MTU; - } - - if (privateMtu > vrMaxMtuForPrivateIfaces) { - String subject = "Incorrect MTU configured on network for private interface of the VR"; - String message = String.format("Configured MTU for network VR's public interfaces exceeds the upper limit " + - "enforced by zone level setting: %s. VR's public interfaces can be configured with a maximum MTU of %s", VRPublicInterfaceMtu.key(), VRPublicInterfaceMtu.valueIn(zoneId)); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PRIVATE_IFACE_MTU, zoneId, null, subject, message); - privateMtu = vrMaxMtuForPrivateIfaces; - } else if (privateMtu < MINIMUM_MTU) { - String subject = "Incorrect MTU configured on network for private interfaces of the VR"; - String message = String.format("Configured MTU for network VR's private interfaces is lesser than the supported minimum of %s.", MINIMUM_MTU); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PRIVATE_IFACE_MTU, zoneId, null, subject, message); - privateMtu = MINIMUM_MTU; - } - return new Pair<>(publicMtu, privateMtu); - } - private Network implementAssociatedNetwork(Long associatedNetworkId, Account caller, Account owner, DataCenter zone, Long domainId, Long accountId, String cidr, String startIp, String endIp) throws InsufficientCapacityException { Network associatedNetwork = _networksDao.findById(associatedNetworkId); @@ -1916,7 +1824,7 @@ private Network commitNetwork(final Long networkOfferingId, final String gateway final boolean isDomainSpecific, final Boolean subdomainAccessFinal, final Long vpcId, final String startIPv6, final String endIPv6, final String ip6Gateway, final String ip6Cidr, final Boolean displayNetwork, final Long aclId, final String isolatedPvlan, final PVlanType isolatedPvlanType, final NetworkOfferingVO ntwkOff, final PhysicalNetwork pNtwk, final ACLType aclType, final Account ownerFinal, final String cidr, final boolean createVlan, final String externalId, String routerIp, String routerIpv6, - final Network associatedNetwork, final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2, Pair vrIfaceMTUs) throws InsufficientCapacityException, ResourceAllocationException { + final Network associatedNetwork, final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2) throws InsufficientCapacityException, ResourceAllocationException { try { Network network = Transaction.execute(new TransactionCallbackWithException() { @Override @@ -1975,7 +1883,7 @@ public Network doInTransaction(TransactionStatus status) throws InsufficientCapa } } network = _vpcMgr.createVpcGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId, networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, - subdomainAccess, vpcId, aclId, caller, displayNetwork, externalId, ip6Gateway, ip6Cidr, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2, vrIfaceMTUs); + subdomainAccess, vpcId, aclId, caller, displayNetwork, externalId, ip6Gateway, ip6Cidr, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2); } else { if (_configMgr.isOfferingForVpc(ntwkOff)) { throw new InvalidParameterValueException("Network offering can be used for VPC networks only"); @@ -1983,8 +1891,9 @@ public Network doInTransaction(TransactionStatus status) throws InsufficientCapa if (ntwkOff.isInternalLb()) { throw new InvalidParameterValueException("Internal Lb can be enabled on vpc networks only"); } + network = _networkMgr.createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId, bypassVlanOverlapCheck, networkDomain, owner, sharedDomainId, pNtwk, - zoneId, aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr, displayNetwork, isolatedPvlan, isolatedPvlanType, externalId, routerIp, routerIpv6, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2, vrIfaceMTUs); + zoneId, aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr, displayNetwork, isolatedPvlan, isolatedPvlanType, externalId, routerIp, routerIpv6, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2); } if (createVlan && network != null) { @@ -2748,8 +2657,6 @@ public Network updateGuestNetwork(final UpdateNetworkCmd cmd) { Boolean displayNetwork = cmd.getDisplayNetwork(); String customId = cmd.getCustomId(); boolean updateInSequence = cmd.getUpdateInSequence(); - Integer publicMtu = cmd.getPublicMtu(); - Integer privateMtu = cmd.getPrivateMtu(); boolean forced = cmd.getForced(); String ip4Dns1 = cmd.getIp4Dns1(); String ip4Dns2 = cmd.getIp4Dns2(); @@ -2890,7 +2797,7 @@ public Network updateGuestNetwork(final UpdateNetworkCmd cmd) { final Map newSvcProviders = networkOfferingChanged ? _networkMgr.finalizeServicesAndProvidersForNetwork(_entityMgr.findById(NetworkOffering.class, networkOfferingId), network.getPhysicalNetworkId()) - : new HashMap(); + : new HashMap(); // don't allow to modify network domain if the service is not supported if (domainSuffix != null) { @@ -3011,53 +2918,6 @@ public Network updateGuestNetwork(final UpdateNetworkCmd cmd) { s_logger.info("IP Reservation has been applied. The new CIDR for Guests Vms is " + guestVmCidr); } - Pair mtus = validateMtuOnUpdate(network, dc.getId(), publicMtu, privateMtu); - publicMtu = mtus.first(); - privateMtu = mtus.second(); - - // List all routers for the given network: - List routers = routerDao.findByNetwork(networkId); - - // Create Map to store the IPAddress List for each router - Map> routersToIpList = new HashMap<>(); - for (DomainRouterVO routerVO : routers) { - Set ips = new HashSet<>(); - List routerJoinVOS = routerJoinDao.getRouterByIdAndTrafficType(routerVO.getId(), TrafficType.Guest, TrafficType.Public); - for (DomainRouterJoinVO router : routerJoinVOS) { - IpAddressTO ip = null; - if (router.getTrafficType() == TrafficType.Guest && privateMtu != null) { - ip = new IpAddressTO(router.getIpAddress(), privateMtu, router.getNetmask()); - ip.setTrafficType(TrafficType.Guest); - } else if (router.getTrafficType() == TrafficType.Public && publicMtu != null) { - ip = new IpAddressTO(router.getIpAddress(), publicMtu, router.getNetmask()); - ip.setTrafficType(TrafficType.Public); - } - if (ip != null) { - ips.add(ip); - } - } - if (network.getGuestType() == GuestType.Isolated && network.getVpcId() == null && publicMtu != null) { - List addrs = _ipAddressDao.listByNetworkId(networkId); - for(IPAddressVO addr : addrs) { - VlanVO vlan = _vlanDao.findById(addr.getVlanId()); - IpAddressTO to = new IpAddressTO(addr.getAddress().addr(), publicMtu, vlan.getVlanNetmask()); - ips.add(to); - } - } - if (!ips.isEmpty()) { - routersToIpList.put(routerVO.getId(), ips); - } - } - - if (!routersToIpList.isEmpty() && !restartNetwork) { - boolean success = updateMtuOnVr(routersToIpList); - if (success) { - updateNetworkDetails(routersToIpList, network, publicMtu, privateMtu); - } else { - throw new CloudRuntimeException("Failed to update MTU on the network"); - } - } - ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount); // 1) Shutdown all the elements and cleanup all the rules. Don't allow to shutdown network in intermediate // states - Shutdown and Implementing @@ -3237,98 +3097,6 @@ public void doInTransactionWithoutResult(TransactionStatus status) { return getNetwork(network.getId()); } - protected Pair validateMtuOnUpdate(NetworkVO network, Long zoneId, Integer publicMtu, Integer privateMtu) { - if (!AllowUsersToSpecifyVRMtu.valueIn(zoneId)) { - return new Pair<>(null, null); - } - - if (publicMtu != null) { - if (publicMtu > VRPublicInterfaceMtu.valueIn(zoneId)) { - publicMtu = VRPublicInterfaceMtu.valueIn(zoneId); - } else if (publicMtu < MINIMUM_MTU) { - String subject = "Incorrect MTU configured on network for public interfaces of the VR"; - String message = String.format("Configured MTU for network VR's public interfaces is lesser than the supported minimum of %s.", MINIMUM_MTU); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PUBLIC_IFACE_MTU, zoneId, null, subject, message); - publicMtu = MINIMUM_MTU; - } - } - - if (privateMtu != null) { - if (privateMtu > VRPrivateInterfaceMtu.valueIn(zoneId)) { - privateMtu = VRPrivateInterfaceMtu.valueIn(zoneId); - } else if (privateMtu < MINIMUM_MTU) { - String subject = "Incorrect MTU configured on network for private interfaces of the VR"; - String message = String.format("Configured MTU for network VR's private interfaces is lesser than the supported minimum of %s.", MINIMUM_MTU); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PRIVATE_IFACE_MTU, zoneId, null, subject, message); - privateMtu = MINIMUM_MTU; - } - } - - if (publicMtu != null && network.getVpcId() != null) { - s_logger.warn("Cannot update VPC public interface MTU via network tiers. " + - "Please update the public interface MTU via the VPC. Skipping.. "); - publicMtu = null; - } - - return new Pair<>(publicMtu, privateMtu); - } - - private void updateNetworkDetails(Map> routerToIpList, NetworkVO network, Integer publicMtu, Integer privateMtu) { - for (Map.Entry> routerEntrySet : routerToIpList.entrySet()) { - for (IpAddressTO ipAddress : routerEntrySet.getValue()) { - NicVO nicVO = _nicDao.findByInstanceIdAndIpAddressAndVmtype(routerEntrySet.getKey(), ipAddress.getPublicIp(), VirtualMachine.Type.DomainRouter); - if (nicVO != null) { - if (ipAddress.getTrafficType() == TrafficType.Guest) { - nicVO.setMtu(privateMtu); - } else { - nicVO.setMtu(publicMtu); - } - _nicDao.update(nicVO.getId(), nicVO); - } - } - } - - if (publicMtu != null) { - network.setPublicMtu(publicMtu); - } - if (privateMtu != null) { - network.setPrivateMtu(privateMtu); - } - _networksDao.update(network.getId(), network); - } - - protected boolean updateMtuOnVr(Map> routersToIpList) { - boolean success = false; - for (Map.Entry> routerEntrySet : routersToIpList.entrySet()) { - Long routerId = routerEntrySet.getKey(); - DomainRouterVO router = routerDao.findById(routerId); - if (router == null) { - s_logger.error(String.format("Failed to find router with id: %s", routerId)); - continue; - } - Commands cmds = new Commands(Command.OnError.Stop); - Map state = new HashMap<>(); - Set ips = routerEntrySet.getValue(); - state.put(ApiConstants.REDUNDANT_STATE, router.getRedundantState() != null ? router.getRedundantState().name() : VirtualRouter.RedundantState.UNKNOWN.name()); - ips.forEach(ip -> ip.setDetails(state)); - commandSetupHelper.setupUpdateNetworkCommands(router, ips, cmds); - try { - networkHelper.sendCommandsToRouter(router, cmds); - Answer updateNetworkAnswer = cmds.getAnswer("updateNetwork"); - if (!(updateNetworkAnswer != null && updateNetworkAnswer.getResult())) { - s_logger.warn("Unable to update guest network on router " + router); - throw new CloudRuntimeException("Failed to update guest network with new MTU"); - } - success = true; - } catch (ResourceUnavailableException e) { - s_logger.error(String.format("Failed to update network MTU for router %s due to %s", router, e.getMessage())); - success = false; - } - } - return success; - } private void updateNetworkIpv6(NetworkVO network, Long networkOfferingId) { boolean isIpv6Supported = _networkOfferingDao.isIpv6Supported(network.getNetworkOfferingId()); boolean isIpv6SupportedNew = _networkOfferingDao.isIpv6Supported(networkOfferingId); @@ -5704,6 +5472,6 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu}; + return new ConfigKey[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress}; } } diff --git a/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java index 7763d5b1adba..7d7fb1564e89 100644 --- a/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java +++ b/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java @@ -220,14 +220,6 @@ public Network design(NetworkOffering offering, DeploymentPlan plan, Network use config.setRouterIpv6(userSpecified.getRouterIpv6()); } - if (userSpecified.getPublicMtu() != null) { - config.setPublicMtu(userSpecified.getPublicMtu()); - } - - if (userSpecified.getPrivateMtu() != null) { - config.setPrivateMtu(userSpecified.getPrivateMtu()); - } - if (StringUtils.isNotBlank(userSpecified.getDns1())) { config.setDns1(userSpecified.getDns1()); } diff --git a/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java index ff9303db34bd..47d90aa8816f 100644 --- a/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java +++ b/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java @@ -259,8 +259,6 @@ public Network design(final NetworkOffering offering, final DeploymentPlan plan, network.setPvlanType(userSpecified.getPvlanType()); } } - network.setPublicMtu(userSpecified.getPublicMtu()); - network.setPrivateMtu(userSpecified.getPrivateMtu()); if (StringUtils.isNotBlank(userSpecified.getDns1())) { network.setDns1(userSpecified.getDns1()); diff --git a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java index 75e8230f46a7..e3446c29b64f 100644 --- a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java +++ b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java @@ -23,13 +23,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import javax.inject.Inject; -import com.cloud.agent.api.routing.UpdateNetworkCommand; -import com.cloud.network.dao.VirtualRouterProviderDao; -import com.cloud.network.vpc.VpcVO; import com.cloud.domain.Domain; import com.cloud.domain.dao.DomainDao; import org.apache.cloudstack.api.ApiConstants; @@ -205,8 +201,6 @@ public class CommandSetupHelper { private NetworkDetailsDao networkDetailsDao; @Inject Ipv6Service ipv6Service; - @Inject - VirtualRouterProviderDao vrProviderDao; @Autowired @Qualifier("networkHelper") @@ -840,16 +834,8 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) { final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, ipAddr.isSourceNat(), BroadcastDomainType.fromString(ipAddr.getVlanTag()).toString(), ipAddr.getGateway(), ipAddr.getNetmask(), macAddress, networkRate, ipAddr.isOneToOneNat()); + setIpAddressNetworkParams(ip, network, router); - if (network.getPublicMtu() != null) { - ip.setMtu(network.getPublicMtu()); - } - if (router.getVpcId() != null) { - VpcVO vpc = _vpcDao.findById(router.getVpcId()); - if (vpc != null) { - ip.setMtu(vpc.getPublicMtu()); - } - } ipsToSend[i++] = ip; if (ipAddr.isSourceNat()) { sourceNatIpAdd = new Pair(ip, ipAddr.getNetworkId()); @@ -972,15 +958,6 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) { final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, networkRate, ipAddr.isOneToOneNat()); - NetworkVO networkVO = _networkDao.findById(ipAddr.getAssociatedWithNetworkId()); - if (networkVO != null && networkVO.getPublicMtu() != null) { - ip.setMtu(networkVO.getPublicMtu()); - } else if (router.getVpcId() != null) { - VpcVO vpc = _vpcDao.findById(router.getVpcId()); - if (vpc != null) { - ip.setMtu(vpc.getPublicMtu()); - } - } setIpAddressNetworkParams(ip, network, router); if (router.getHypervisorType() == Hypervisor.HypervisorType.VMware) { @@ -1119,9 +1096,7 @@ public void createVpcAssociatePrivateIPCommands(final VirtualRouter router, fina final Network network = _networkModel.getNetwork(ipAddr.getNetworkId()); final IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false, ipAddr.getSourceNat(), ipAddr.getBroadcastUri(), ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(), null, false); - if (network.getPrivateMtu() != null) { - ip.setMtu(network.getPublicMtu()); - } + setIpAddressNetworkParams(ip, network, router); ipsToSend[i++] = ip; @@ -1173,6 +1148,7 @@ public SetupGuestNetworkCommand createSetupGuestNetworkCommand(final DomainRoute final String dhcpRange = getGuestDhcpRange(guestNic, network, _entityMgr.findById(DataCenter.class, network.getDataCenterId())); final NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null); + final SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, router.getIsRedundantRouter(), defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, router.getHypervisorType())); @@ -1189,7 +1165,7 @@ public SetupGuestNetworkCommand createSetupGuestNetworkCommand(final DomainRoute setupCmd.setAccessDetail(NetworkElementCommand.GUEST_BRIDGE, brd); setupCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); - if (network.getBroadcastDomainType() == BroadcastDomainType.Vlan && network.getBroadcastUri() != null) { + if (network.getBroadcastDomainType() == BroadcastDomainType.Vlan) { final long guestVlanTag = Long.parseLong(BroadcastDomainType.Vlan.getValueFrom(network.getBroadcastUri())); setupCmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag)); } @@ -1336,6 +1312,7 @@ private void setIpAddressNetworkParams(IpAddressTO ipAddress, final Network netw ipAddress.setPrivateGateway(false); } ipAddress.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network)); + final NetworkOfferingVO networkOfferingVO = _networkOfferingDao.findById(network.getNetworkOfferingId()); NicTO nicTO = new NicTO(); nicTO.setMac(ipAddress.getVifMacAddress()); @@ -1372,15 +1349,4 @@ private Map getNicDetails(Network network) { return details; } - public void setupUpdateNetworkCommands(final VirtualRouter router, final Set ips, Commands cmds) { - IpAddressTO[] ipsToSend = ips.toArray(new IpAddressTO[0]); - if (!ips.isEmpty()) { - UpdateNetworkCommand cmd = new UpdateNetworkCommand(ipsToSend); - cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId())); - cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); - final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); - cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString()); - cmds.addCommand("updateNetwork", cmd); - } - } } diff --git a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 2cd377a04f9d..3c5069469940 100644 --- a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -2033,16 +2033,12 @@ public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile } } else if (nic.getTrafficType() == TrafficType.Guest) { - s_logger.info("Guest IP : " + nic.getIPv4Address()); dnsProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dns, Provider.VirtualRouter); dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter); - buf.append(" privateMtu=").append(nic.getMtu()); // build bootloader parameter for the guest buf.append(createGuestBootLoadArgs(nic, defaultDns1, defaultDns2, router)); } else if (nic.getTrafficType() == TrafficType.Public) { - s_logger.info("Public IP : " + nic.getIPv4Address()); publicNetwork = true; - buf.append(" publicMtu=").append(nic.getMtu()); } } @@ -2308,18 +2304,6 @@ public boolean finalizeDeployment(final Commands cmds, final VirtualMachineProfi return true; } - private Provider getVrProvider(DomainRouterVO router) { - final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId()); - if (vrProvider == null) { - throw new CloudRuntimeException("Cannot find related virtual router provider of router: " + router.getHostName()); - } - final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString()); - if (provider == null) { - throw new CloudRuntimeException("Cannot find related provider of virtual router provider: " + vrProvider.getType().toString()); - } - return provider; - } - @Override public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachineProfile profile) { final DomainRouterVO router = _routerDao.findById(profile.getId()); @@ -2339,7 +2323,14 @@ public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachine reprogramGuestNtwks = false; } - final Provider provider = getVrProvider(router); + final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId()); + if (vrProvider == null) { + throw new CloudRuntimeException("Cannot find related virtual router provider of router: " + router.getHostName()); + } + final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString()); + if (provider == null) { + throw new CloudRuntimeException("Cannot find related provider of virtual router provider: " + vrProvider.getType().toString()); + } final List routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId()); for (final Long guestNetworkId : routerGuestNtwkIds) { diff --git a/server/src/main/java/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/main/java/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java index 18801eb01fdf..ad20fb9a3a1c 100644 --- a/server/src/main/java/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java @@ -151,11 +151,6 @@ public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Netw _routerDao.addRouterToGuestNetwork(router, network); final NicProfile guestNic = _itMgr.addVmToNetwork(router, network, null); - if (network.getVpcId() != null) { - VpcVO vpc = _vpcDao.findById(network.getVpcId()); - guestNic.setMtu(vpc.getPublicMtu()); - } - // 2) setup guest network if (guestNic != null) { result = setupVpcGuestNetwork(network, router, true, guestNic); @@ -280,7 +275,7 @@ public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile final StringBuilder buf = profile.getBootArgsBuilder(); final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId); buf.append(" vpccidr=" + vpc.getCidr() + " domain=" + vpc.getNetworkDomain()); - buf.append(" publicMtu=").append(vpc.getPublicMtu()); + buf.append(" dns1=").append(defaultDns1); if (defaultDns2 != null) { buf.append(" dns2=").append(defaultDns2); diff --git a/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java index 3821cd672ff3..1065a10fb229 100644 --- a/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java @@ -27,7 +27,6 @@ import java.util.ListIterator; import java.util.Map; import java.util.Map.Entry; -import java.util.Objects; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -41,7 +40,6 @@ import javax.naming.ConfigurationException; import org.apache.cloudstack.acl.ControlledEntity.ACLType; -import org.apache.cloudstack.alert.AlertService; import org.apache.cloudstack.annotation.AnnotationService; import org.apache.cloudstack.annotation.dao.AnnotationDao; import org.apache.cloudstack.api.ApiConstants; @@ -62,14 +60,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.to.IpAddressTO; -import com.cloud.agent.manager.Commands; -import com.cloud.alert.AlertManager; + import com.cloud.api.query.dao.VpcOfferingJoinDao; import com.cloud.api.query.vo.VpcOfferingJoinVO; import com.cloud.configuration.Config; @@ -115,8 +106,6 @@ import com.cloud.network.element.NetworkElement; import com.cloud.network.element.StaticNatServiceProvider; import com.cloud.network.element.VpcProvider; -import com.cloud.network.router.CommandSetupHelper; -import com.cloud.network.router.NetworkHelper; import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.network.vpc.VpcOffering.State; import com.cloud.network.vpc.dao.NetworkACLDao; @@ -166,12 +155,9 @@ import com.cloud.utils.exception.ExceptionUtil; import com.cloud.utils.net.NetUtils; import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.NicVO; import com.cloud.vm.ReservationContext; import com.cloud.vm.ReservationContextImpl; -import com.cloud.vm.VirtualMachine; import com.cloud.vm.dao.DomainRouterDao; -import com.cloud.vm.dao.NicDao; public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvisioningService, VpcService { private static final Logger s_logger = Logger.getLogger(VpcManagerImpl.class); @@ -193,7 +179,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis @Inject VpcOfferingServiceMapDao _vpcOffSvcMapDao; @Inject - VpcDao vpcDao; + VpcDao _vpcDao; @Inject ConfigurationDao _configDao; @Inject @@ -243,22 +229,13 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis @Inject VpcVirtualNetworkApplianceManager _routerService; @Inject - DomainRouterDao routerDao; + DomainRouterDao _routerDao; @Inject DomainDao domainDao; @Inject private AnnotationDao annotationDao; @Inject NetworkOfferingDao _networkOfferingDao; - @Inject - NicDao nicDao; - @Inject - AlertManager alertManager; - @Inject - CommandSetupHelper commandSetupHelper; - @Autowired - @Qualifier("networkHelper") - protected NetworkHelper networkHelper; @Inject private VpcPrivateGatewayTransactionCallable vpcTxCallable; @@ -380,7 +357,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { final SearchBuilder virtualNetworkVlanSB = _vlanDao.createSearchBuilder(); virtualNetworkVlanSB.and("vlanType", virtualNetworkVlanSB.entity().getVlanType(), Op.EQ); IpAddressSearch - .join("virtualNetworkVlanSB", virtualNetworkVlanSB, IpAddressSearch.entity().getVlanId(), virtualNetworkVlanSB.entity().getId(), JoinBuilder.JoinType.INNER); + .join("virtualNetworkVlanSB", virtualNetworkVlanSB, IpAddressSearch.entity().getVlanId(), virtualNetworkVlanSB.entity().getId(), JoinBuilder.JoinType.INNER); IpAddressSearch.done(); return true; @@ -445,7 +422,7 @@ public VpcOffering createVpcOffering(CreateVPCOfferingCmd cmd) { @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CREATE, eventDescription = "creating vpc offering", create = true) public VpcOffering createVpcOffering(final String name, final String displayText, final List supportedServices, final Map> serviceProviders, - final Map serviceCapabilityList, final NetUtils.InternetProtocol internetProtocol, final Long serviceOfferingId, List domainIds, List zoneIds, State state) { + final Map serviceCapabilityList, final NetUtils.InternetProtocol internetProtocol, final Long serviceOfferingId, List domainIds, List zoneIds, State state) { if (!Ipv6Service.Ipv6OfferingCreationEnabled.value() && !(internetProtocol == null || NetUtils.InternetProtocol.IPv4.equals(internetProtocol))) { throw new InvalidParameterValueException(String.format("Configuration %s needs to be enabled for creating IPv6 supported VPC offering", Ipv6Service.Ipv6OfferingCreationEnabled.key())); @@ -557,8 +534,8 @@ public VpcOffering createVpcOffering(final String name, final String displayText @DB protected VpcOfferingVO createVpcOffering(final String name, final String displayText, final Map> svcProviderMap, - final boolean isDefault, final State state, final Long serviceOfferingId, final boolean supportsDistributedRouter, final boolean offersRegionLevelVPC, - final boolean redundantRouter) { + final boolean isDefault, final State state, final Long serviceOfferingId, final boolean supportsDistributedRouter, final boolean offersRegionLevelVPC, + final boolean redundantRouter) { return Transaction.execute(new TransactionCallback() { @Override @@ -681,7 +658,7 @@ private boolean isVpcOfferingRedundantRouter(final Map serviceCapabilitystList) @Override public Vpc getActiveVpc(final long vpcId) { - return vpcDao.getActiveVpcById(vpcId); + return _vpcDao.getActiveVpcById(vpcId); } @Override @@ -845,7 +822,7 @@ public boolean deleteVpcOffering(final long offId) { // don't allow to delete vpc offering if it's in use by existing vpcs // (the offering can be disabled though) - final int vpcCount = vpcDao.getVpcCountByOfferingId(offId); + final int vpcCount = _vpcDao.getVpcCountByOfferingId(offId); if (vpcCount > 0) { throw new InvalidParameterValueException("Can't delete vpc offering " + offId + " as its used by " + vpcCount + " vpcs. " + "To make the network offering unavailable, disable it"); @@ -1005,7 +982,7 @@ public List getVpcOfferingZones(Long vpcOfferingId) { @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create = true) public Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwnerId, final String vpcName, final String displayText, final String cidr, String networkDomain, - final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2, final Boolean displayVpc, Integer publicMtu) throws ResourceAllocationException { + final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2, final Boolean displayVpc) throws ResourceAllocationException { final Account caller = CallContext.current().getCallingAccount(); final Account owner = _accountMgr.getAccount(vpcOwnerId); @@ -1057,28 +1034,11 @@ public Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwner } } - if (publicMtu > NetworkService.VRPublicInterfaceMtu.valueIn(zoneId)) { - String subject = "Incorrect MTU configured on network for public interfaces of the VPC VR"; - String message = String.format("Configured MTU for network VR's public interfaces exceeds the upper limit " + - "enforced by zone level setting: %s. VR's public interfaces can be configured with a maximum MTU of %s", NetworkService.VRPublicInterfaceMtu.key(), - NetworkService.VRPublicInterfaceMtu.valueIn(zoneId)); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PUBLIC_IFACE_MTU, zoneId, null, subject, message); - publicMtu = NetworkService.VRPublicInterfaceMtu.valueIn(zoneId); - } else if (publicMtu < NetworkService.MINIMUM_MTU) { - String subject = "Incorrect MTU configured on network for public interfaces of the VPC VR"; - String message = String.format("Configured MTU for network VR's public interfaces is lesser than the supported minim MTU of %s", NetworkService.MINIMUM_MTU); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PUBLIC_IFACE_MTU, zoneId, null, subject, message); - publicMtu = NetworkService.MINIMUM_MTU; - } - checkVpcDns(vpcOff, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2); final boolean useDistributedRouter = vpcOff.isSupportsDistributedRouter(); final VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, owner.getId(), owner.getDomainId(), vpcOffId, cidr, networkDomain, useDistributedRouter, isRegionLevelVpcOff, vpcOff.isRedundantRouter(), ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2); - vpc.setPublicMtu(publicMtu); return createVpc(displayVpc, vpc); } @@ -1088,7 +1048,7 @@ public Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwner public Vpc createVpc(CreateVPCCmd cmd) throws ResourceAllocationException { return createVpc(cmd.getZoneId(), cmd.getVpcOffering(), cmd.getEntityOwnerId(), cmd.getVpcName(), cmd.getDisplayText(), cmd.getCidr(), cmd.getNetworkDomain(), cmd.getIp4Dns1(), cmd.getIp4Dns2(), cmd.getIp6Dns1(), - cmd.getIp6Dns2(), cmd.isDisplay(), cmd.getPublicMtu()); + cmd.getIp6Dns2(), cmd.isDisplay()); } @DB @@ -1118,7 +1078,7 @@ public VpcVO doInTransaction(final TransactionStatus status) { vpc.setDisplay(displayVpc); } - final VpcVO persistedVpc = vpcDao.persist(vpc, finalizeServicesAndProvidersForVpc(vpc.getZoneId(), vpc.getVpcOfferingId())); + final VpcVO persistedVpc = _vpcDao.persist(vpc, finalizeServicesAndProvidersForVpc(vpc.getZoneId(), vpc.getVpcOfferingId())); _resourceLimitMgr.incrementResourceCount(vpc.getAccountId(), ResourceType.vpc); s_logger.debug("Created VPC " + persistedVpc); CallContext.current().putContextParameter(Vpc.class, persistedVpc.getUuid()); @@ -1164,7 +1124,7 @@ public boolean deleteVpc(final long vpcId) throws ConcurrentOperationException, final CallContext ctx = CallContext.current(); // Verify vpc id - final Vpc vpc = vpcDao.findById(vpcId); + final Vpc vpc = _vpcDao.findById(vpcId); if (vpc == null) { throw new InvalidParameterValueException("unable to find VPC id=" + vpcId); } @@ -1193,13 +1153,13 @@ public boolean destroyVpc(final Vpc vpc, final Account caller, final Long caller // mark VPC as inactive if (vpc.getState() != Vpc.State.Inactive) { s_logger.debug("Updating VPC " + vpc + " with state " + Vpc.State.Inactive + " as a part of vpc delete"); - final VpcVO vpcVO = vpcDao.findById(vpc.getId()); + final VpcVO vpcVO = _vpcDao.findById(vpc.getId()); vpcVO.setState(Vpc.State.Inactive); Transaction.execute(new TransactionCallbackNoReturn() { @Override public void doInTransactionWithoutResult(final TransactionStatus status) { - vpcDao.update(vpc.getId(), vpcVO); + _vpcDao.update(vpc.getId(), vpcVO); // decrement resource count _resourceLimitMgr.decrementResourceCount(vpc.getAccountId(), ResourceType.vpc); @@ -1221,7 +1181,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { // update the instance with removed flag only when the cleanup is // executed successfully - if (vpcDao.remove(vpc.getId())) { + if (_vpcDao.remove(vpc.getId())) { s_logger.debug("Vpc " + vpc + " is destroyed successfully"); return true; } else { @@ -1232,19 +1192,19 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_UPDATE, eventDescription = "updating vpc") - public Vpc updateVpc(final long vpcId, final String vpcName, final String displayText, final String customId, final Boolean displayVpc, Integer mtu) { + public Vpc updateVpc(final long vpcId, final String vpcName, final String displayText, final String customId, final Boolean displayVpc) { CallContext.current().setEventDetails(" Id: " + vpcId); final Account caller = CallContext.current().getCallingAccount(); // Verify input parameters - final VpcVO vpcToUpdate = vpcDao.findById(vpcId); + final VpcVO vpcToUpdate = _vpcDao.findById(vpcId); if (vpcToUpdate == null) { throw new InvalidParameterValueException("Unable to find vpc by id " + vpcId); } _accountMgr.checkAccess(caller, null, false, vpcToUpdate); - final VpcVO vpc = vpcDao.createForUpdate(vpcId); + final VpcVO vpc = _vpcDao.createForUpdate(vpcId); if (vpcName != null) { vpc.setName(vpcName); @@ -1262,110 +1222,19 @@ public Vpc updateVpc(final long vpcId, final String vpcName, final String displa vpc.setDisplay(displayVpc); } - mtu = validateMtu(vpcToUpdate, mtu); - if (mtu != null) { - updateMtuOfVpcNetwork(vpcToUpdate, vpc, mtu); - } - - if (vpcDao.update(vpcId, vpc)) { + if (_vpcDao.update(vpcId, vpc)) { s_logger.debug("Updated VPC id=" + vpcId); - return vpcDao.findById(vpcId); + return _vpcDao.findById(vpcId); } else { return null; } } - protected Integer validateMtu(VpcVO vpcToUpdate, Integer mtu) { - Long zoneId = vpcToUpdate.getZoneId(); - if (mtu == null || NetworkService.AllowUsersToSpecifyVRMtu.valueIn(zoneId)) { - return null; - } - if (mtu > NetworkService.VRPublicInterfaceMtu.valueIn(zoneId)) { - String subject = "Incorrect MTU configured on network for public interfaces of the VPC VR"; - String message = String.format("Configured MTU for network VR's public interfaces exceeds the upper limit " + - "enforced by zone level setting: %s. VR's public interfaces can be configured with a maximum MTU of %s", NetworkService.VRPublicInterfaceMtu.key(), - NetworkService.VRPublicInterfaceMtu.valueIn(zoneId)); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PUBLIC_IFACE_MTU, zoneId, null, subject, message); - mtu = NetworkService.VRPublicInterfaceMtu.valueIn(zoneId); - } else if (mtu < NetworkService.MINIMUM_MTU) { - String subject = "Incorrect MTU configured on network for public interfaces of the VPC VR"; - String message = String.format("Configured MTU for network VR's public interfaces is lesser than the minimum MTU of %s", NetworkService.MINIMUM_MTU ); - s_logger.warn(message); - alertManager.sendAlert(AlertService.AlertType.ALERT_TYPE_VR_PUBLIC_IFACE_MTU, zoneId, null, subject, message); - mtu = NetworkService.MINIMUM_MTU; - } - if (Objects.equals(mtu, vpcToUpdate.getPublicMtu())) { - s_logger.info(String.format("Desired MTU of %s already configured on the VPC public interfaces", mtu)); - mtu = null; - } - return mtu; - } - - protected void updateMtuOfVpcNetwork(VpcVO vpcToUpdate, VpcVO vpc, Integer mtu) { - List ipAddresses = _ipAddressDao.listByAssociatedVpc(vpcToUpdate.getId(), null); - long vpcId = vpcToUpdate.getId(); - Set ips = new HashSet<>(ipAddresses.size()); - for (IPAddressVO ip : ipAddresses) { - VlanVO vlan = _vlanDao.findById(ip.getVlanId()); - String vlanNetmask = vlan.getVlanNetmask(); - IpAddressTO to = new IpAddressTO(ip.getAddress().addr(), mtu, vlanNetmask); - ips.add(to); - } - - if (!ips.isEmpty()) { - boolean success = updateMtuOnVpcVr(vpcId, ips); - if (success) { - updateVpcMtu(ips, mtu); - vpc.setPublicMtu(mtu); - List vpcTierNetworks = _ntwkDao.listByVpc(vpcId); - for (NetworkVO network : vpcTierNetworks) { - network.setPublicMtu(mtu); - _ntwkDao.update(network.getId(), network); - } - s_logger.info("Successfully update MTU of VPC network"); - } else { - throw new CloudRuntimeException("Failed to update MTU on the network"); - } - } - } - - private void updateVpcMtu(Set ips, Integer publicMtu) { - for (IpAddressTO ipAddress : ips) { - NicVO nicVO = nicDao.findByIpAddressAndVmType(ipAddress.getPublicIp(), VirtualMachine.Type.DomainRouter); - if (nicVO != null) { - nicVO.setMtu(publicMtu); - nicDao.update(nicVO.getId(), nicVO); - } - } - } - - protected boolean updateMtuOnVpcVr(Long vpcId, Set ips) { - boolean success = false; - List routers = routerDao.listByVpcId(vpcId); - for (DomainRouterVO router : routers) { - Commands cmds = new Commands(Command.OnError.Stop); - commandSetupHelper.setupUpdateNetworkCommands(router, ips, cmds); - try { - networkHelper.sendCommandsToRouter(router, cmds); - final Answer updateNetworkAnswer = cmds.getAnswer("updateNetwork"); - if (!(updateNetworkAnswer != null && updateNetworkAnswer.getResult())) { - s_logger.warn("Unable to update guest network on router " + router); - throw new CloudRuntimeException("Failed to update guest network with new MTU"); - } - success = true; - } catch (ResourceUnavailableException e) { - s_logger.error(String.format("Failed to update network MTU for router %s due to %s", router, e.getMessage())); - } - } - return success; - } - @Override public Pair, Integer> listVpcs(final Long id, final String vpcName, final String displayText, final List supportedServicesStr, final String cidr, - final Long vpcOffId, final String state, final String accountName, Long domainId, final String keyword, final Long startIndex, final Long pageSizeVal, - final Long zoneId, Boolean isRecursive, final Boolean listAll, final Boolean restartRequired, final Map tags, final Long projectId, - final Boolean display) { + final Long vpcOffId, final String state, final String accountName, Long domainId, final String keyword, final Long startIndex, final Long pageSizeVal, + final Long zoneId, Boolean isRecursive, final Boolean listAll, final Boolean restartRequired, final Map tags, final Long projectId, + final Boolean display) { final Account caller = CallContext.current().getCallingAccount(); final List permittedAccounts = new ArrayList(); final Ternary domainIdRecursiveListProject = new Ternary(domainId, isRecursive, @@ -1376,7 +1245,7 @@ public Pair, Integer> listVpcs(final Long id, final String v final ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); final Filter searchFilter = new Filter(VpcVO.class, "created", false, null, null); - final SearchBuilder sb = vpcDao.createSearchBuilder(); + final SearchBuilder sb = _vpcDao.createSearchBuilder(); _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); @@ -1406,7 +1275,7 @@ public Pair, Integer> listVpcs(final Long id, final String v _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); if (keyword != null) { - final SearchCriteria ssc = vpcDao.createSearchCriteria(); + final SearchCriteria ssc = _vpcDao.createSearchCriteria(); ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); sc.addAnd("name", SearchCriteria.Op.SC, ssc); @@ -1458,7 +1327,7 @@ public Pair, Integer> listVpcs(final Long id, final String v sc.addAnd("restartRequired", SearchCriteria.Op.EQ, restartRequired); } - final List vpcs = vpcDao.search(sc, searchFilter); + final List vpcs = _vpcDao.search(sc, searchFilter); // filter by supported services final boolean listBySupportedServices = supportedServicesStr != null && !supportedServicesStr.isEmpty() && !vpcs.isEmpty(); @@ -1564,7 +1433,7 @@ public boolean startVpc(final long vpcId, final boolean destroyOnFailure) throws } protected boolean startVpc(final Vpc vpc, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, - InsufficientCapacityException { + InsufficientCapacityException { // deploy provider boolean success = true; final List providersToImplement = getVpcProviders(vpc.getId()); @@ -1587,7 +1456,7 @@ public boolean shutdownVpc(final long vpcId) throws ConcurrentOperationException final Account caller = ctx.getCallingAccount(); // check if vpc exists - final Vpc vpc = vpcDao.findById(vpcId); + final Vpc vpc = _vpcDao.findById(vpcId); if (vpc == null) { throw new InvalidParameterValueException("Unable to find vpc by id " + vpcId); } @@ -1619,7 +1488,7 @@ public boolean shutdownVpc(final long vpcId) throws ConcurrentOperationException @DB @Override public void validateNtwkOffForNtwkInVpc(final Long networkId, final long newNtwkOffId, final String newCidr, final String newNetworkDomain, final Vpc vpc, - final String gateway, final Account networkOwner, final Long aclId) { + final String gateway, final Account networkOwner, final Long aclId) { final NetworkOffering guestNtwkOff = _entityMgr.findById(NetworkOffering.class, newNtwkOffId); @@ -1719,7 +1588,7 @@ protected void validateNewVpcGuestNetwork(final String cidr, final String gatewa Transaction.execute(new TransactionCallbackNoReturn() { @Override public void doInTransactionWithoutResult(final TransactionStatus status) { - final Vpc locked = vpcDao.acquireInLockTable(vpc.getId()); + final Vpc locked = _vpcDao.acquireInLockTable(vpc.getId()); if (locked == null) { throw new CloudRuntimeException("Unable to acquire lock on " + vpc); } @@ -1768,7 +1637,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { } } finally { s_logger.debug("Releasing lock for " + locked); - vpcDao.releaseFromLockTable(locked.getId()); + _vpcDao.releaseFromLockTable(locked.getId()); } } }); @@ -1791,7 +1660,7 @@ public List getVpcElements() { @Override public List getVpcsForAccount(final long accountId) { final List vpcs = new ArrayList(); - vpcs.addAll(vpcDao.listByAccountId(accountId)); + vpcs.addAll(_vpcDao.listByAccountId(accountId)); return vpcs; } @@ -1872,7 +1741,7 @@ public boolean cleanupVpcResources(final long vpcId, final Account caller, final } } - VpcVO vpc = vpcDao.findById(vpcId); + VpcVO vpc = _vpcDao.findById(vpcId); annotationDao.removeByEntityType(AnnotationService.EntityType.VPC.name(), vpc.getUuid()); return success; } @@ -1881,7 +1750,7 @@ public boolean cleanupVpcResources(final long vpcId, final Account caller, final @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_RESTART, eventDescription = "restarting vpc") public boolean restartVpc(final RestartVPCCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, - InsufficientCapacityException { + InsufficientCapacityException { final long vpcId = cmd.getId(); final boolean cleanUp = cmd.getCleanup(); final boolean makeRedundant = cmd.getMakeredundant(); @@ -1911,13 +1780,13 @@ public boolean restartVpc(Long vpcId, boolean cleanUp, boolean makeRedundant, bo if (!vpc.isRedundant() && makeRedundant) { final VpcOfferingVO redundantOffering = _vpcOffDao.findByUniqueName(VpcOffering.redundantVPCOfferingName); - final VpcVO entity = vpcDao.findById(vpcId); + final VpcVO entity = _vpcDao.findById(vpcId); entity.setRedundant(true); entity.setVpcOfferingId(redundantOffering.getId()); // Change the VPC in order to get it updated after the end of // the restart procedure. - if (vpcDao.update(vpc.getId(), entity)) { + if (_vpcDao.update(vpc.getId(), entity)) { vpc = entity; } @@ -1951,9 +1820,9 @@ public boolean restartVpc(Long vpcId, boolean cleanUp, boolean makeRedundant, bo return true; } finally { s_logger.debug("Updating VPC " + vpc + " with restartRequired=" + restartRequired); - final VpcVO vo = vpcDao.findById(vpcId); + final VpcVO vo = _vpcDao.findById(vpcId); vo.setRestartRequired(restartRequired); - vpcDao.update(vpc.getId(), vo); + _vpcDao.update(vpc.getId(), vo); } } @@ -2021,7 +1890,7 @@ public PrivateGateway createVpcPrivateGateway(CreatePrivateGatewayCmd command) t } private PrivateGateway createVpcPrivateGateway(final long vpcId, Long physicalNetworkId, final String broadcastUri, final String ipAddress, final String gateway, - final String netmask, final long gatewayOwnerId, final Long networkOfferingIdPassed, final Boolean isSourceNat, final Long aclId, final Boolean bypassVlanOverlapCheck, final Long associatedNetworkId) throws ResourceAllocationException, + final String netmask, final long gatewayOwnerId, final Long networkOfferingIdPassed, final Boolean isSourceNat, final Long aclId, final Boolean bypassVlanOverlapCheck, final Long associatedNetworkId) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException { // Validate parameters @@ -2468,7 +2337,7 @@ protected boolean applyStaticRoutes(final List routes) throw s_logger.debug("No static routes to apply"); return true; } - final Vpc vpc = vpcDao.findById(routes.get(0).getVpcId()); + final Vpc vpc = _vpcDao.findById(routes.get(0).getVpcId()); s_logger.debug("Applying static routes for vpc " + vpc); final String staticNatProvider = _vpcSrvcDao.getProviderForServiceInVpc(vpc.getId(), Service.StaticNat); @@ -2734,7 +2603,7 @@ protected void runInContext() { try { // Cleanup inactive VPCs - final List inactiveVpcs = vpcDao.listInactiveVpcs(); + final List inactiveVpcs = _vpcDao.listInactiveVpcs(); if (inactiveVpcs != null) { s_logger.info("Found " + inactiveVpcs.size() + " removed VPCs to cleanup"); for (final VpcVO vpc : inactiveVpcs) { @@ -2757,7 +2626,7 @@ protected void runInContext() { @Override @ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "associating Ip", async = true) public IpAddress associateIPToVpc(final long ipId, final long vpcId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException, - ConcurrentOperationException { + ConcurrentOperationException { final Account caller = CallContext.current().getCallingAccount(); Account owner = null; @@ -2770,7 +2639,7 @@ public IpAddress associateIPToVpc(final long ipId, final long vpcId) throws Reso return null; } - final Vpc vpc = vpcDao.findById(vpcId); + final Vpc vpc = _vpcDao.findById(vpcId); if (vpc == null) { throw new InvalidParameterValueException("Invalid VPC id provided"); } @@ -2842,7 +2711,7 @@ public boolean isIpAllocatedToVpc(final IpAddress ip) { @Override public Network createVpcGuestNetwork(final long ntwkOffId, final String name, final String displayText, final String gateway, final String cidr, final String vlanId, String networkDomain, final Account owner, final Long domainId, final PhysicalNetwork pNtwk, final long zoneId, final ACLType aclType, final Boolean subdomainAccess, - final long vpcId, final Long aclId, final Account caller, final Boolean isDisplayNetworkEnabled, String externalId, String ip6Gateway, String ip6Cidr, final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2, Pair vrIfaceMTUs) throws ConcurrentOperationException, InsufficientCapacityException, + final long vpcId, final Long aclId, final Account caller, final Boolean isDisplayNetworkEnabled, String externalId, String ip6Gateway, String ip6Cidr, final String ip4Dns1, final String ip4Dns2, final String ip6Dns1, final String ip6Dns2) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { final Vpc vpc = getActiveVpc(vpcId); @@ -2867,7 +2736,7 @@ public Network createVpcGuestNetwork(final long ntwkOffId, final String name, fi // 2) Create network final Network guestNetwork = _ntwkMgr.createGuestNetwork(ntwkOffId, name, displayText, gateway, cidr, vlanId, false, networkDomain, owner, domainId, pNtwk, zoneId, aclType, - subdomainAccess, vpcId, ip6Gateway, ip6Cidr, isDisplayNetworkEnabled, null, null, externalId, null, null, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2, vrIfaceMTUs); + subdomainAccess, vpcId, ip6Gateway, ip6Cidr, isDisplayNetworkEnabled, null, null, externalId, null, null, ip4Dns1, ip4Dns2, ip6Dns1, ip6Dns2); if (guestNetwork != null) { guestNetwork.setNetworkACLId(aclId); @@ -2984,10 +2853,10 @@ private boolean rollingRestartVpc(final Vpc vpc, final ReservationContext contex return false; } s_logger.debug("Performing rolling restart of routers of VPC " + vpc); - _ntwkMgr.destroyExpendableRouters(routerDao.listByVpcId(vpc.getId()), context); + _ntwkMgr.destroyExpendableRouters(_routerDao.listByVpcId(vpc.getId()), context); final DeployDestination dest = new DeployDestination(_dcDao.findById(vpc.getZoneId()), null, null, null); - final List oldRouters = routerDao.listByVpcId(vpc.getId()); + final List oldRouters = _routerDao.listByVpcId(vpc.getId()); // Create a new router if (oldRouters.size() > 0) { @@ -3018,7 +2887,7 @@ private boolean rollingRestartVpc(final Vpc vpc, final ReservationContext contex return false; } - return _ntwkMgr.areRoutersRunning(routerDao.listByVpcId(vpc.getId())); + return _ntwkMgr.areRoutersRunning(_routerDao.listByVpcId(vpc.getId())); } private List filterChildSubDomains(final List domainIds) { diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 2a95f26c1910..06b772ce08b0 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -3859,7 +3859,7 @@ private NetworkVO createDefaultNetworkForAccount(DataCenter zone, Account owner, s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process"); Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, false, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true, null, null, - null, null, null, null, null, null, null, null); + null, null, null, null, null, null, null); if (newNetwork != null) { defaultNetwork = _networkDao.findById(newNetwork.getId()); } @@ -7498,7 +7498,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) { Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null, null, false, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, - null, null, true, null, null, null, null, null, null, null, null, null, null); + null, null, true, null, null, null, null, null, null, null, null, null); // if the network offering has persistent set to true, implement the network if (requiredOfferings.get(0).isPersistent()) { DeployDestination dest = new DeployDestination(zone, null, null, null); diff --git a/server/src/test/java/com/cloud/network/CreatePrivateNetworkTest.java b/server/src/test/java/com/cloud/network/CreatePrivateNetworkTest.java index 0541da6449fc..93a1d30d1789 100644 --- a/server/src/test/java/com/cloud/network/CreatePrivateNetworkTest.java +++ b/server/src/test/java/com/cloud/network/CreatePrivateNetworkTest.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.UUID; -import com.cloud.utils.Pair; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; @@ -130,7 +129,7 @@ public void setup() throws Exception { ACLType.Account, false, 1L, false); when(networkService._networkMgr.createGuestNetwork(eq(ntwkOff.getId()), eq("bla"), eq("fake"), eq("10.1.1.1"), eq("10.1.1.0/24"), nullable(String.class), nullable(Boolean.class), nullable(String.class), eq(account), nullable(Long.class), eq(physicalNetwork), eq(physicalNetwork.getDataCenterId()), eq(ACLType.Account), nullable(Boolean.class), eq(1L), nullable(String.class), nullable(String.class), - nullable(Boolean.class), nullable(String.class), nullable(Network.PVlanType.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(Pair.class))).thenReturn(net); + nullable(Boolean.class), nullable(String.class), nullable(Network.PVlanType.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class), nullable(String.class))).thenReturn(net); when( networkService._networkMgr.createPrivateNetwork(eq(ntwkOff.getId()), eq("bla"), eq("fake"), eq("10.1.1.1"), eq("10.1.1.0/24"), anyString(), anyBoolean(), eq(account), eq(physicalNetwork), eq(1L))).thenReturn(net); diff --git a/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java b/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java index 1dfecd9680d5..30def99f1695 100644 --- a/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java +++ b/server/src/test/java/com/cloud/network/NetworkServiceImplTest.java @@ -16,91 +16,46 @@ // under the License. package com.cloud.network; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.nullable; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.when; - import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.UUID; -import org.apache.cloudstack.alert.AlertService; import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd; -import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; -import org.apache.cloudstack.framework.config.ConfigKey; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.test.util.ReflectionTestUtils; -import com.cloud.agent.api.to.IpAddressTO; -import com.cloud.alert.AlertManager; -import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; import com.cloud.network.dao.PhysicalNetworkDao; import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.network.router.CommandSetupHelper; -import com.cloud.network.router.NetworkHelper; -import com.cloud.network.vpc.VpcManager; -import com.cloud.network.vpc.VpcVO; -import com.cloud.network.vpc.dao.VpcDao; import com.cloud.offering.NetworkOffering; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.org.Grouping; import com.cloud.user.Account; import com.cloud.user.AccountManager; -import com.cloud.user.AccountManagerImpl; -import com.cloud.user.AccountService; import com.cloud.user.AccountVO; import com.cloud.user.User; import com.cloud.user.UserVO; -import com.cloud.user.dao.UserDao; import com.cloud.utils.Pair; import com.cloud.utils.component.ComponentContext; -import com.cloud.utils.db.EntityManager; import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.NicVO; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.dao.DomainRouterDao; -import com.cloud.vm.dao.NicDao; - -@PowerMockIgnore("javax.management.*") @RunWith(PowerMockRunner.class) -@PrepareForTest({ComponentContext.class, CallContext.class}) +@PrepareForTest(ComponentContext.class) public class NetworkServiceImplTest { @Mock AccountManager accountManager; @@ -118,60 +73,10 @@ public class NetworkServiceImplTest { NetworkModel networkModel; @Mock NetworkOfferingServiceMapDao networkOfferingServiceMapDao; - @Mock - AccountManager accountMgr; - @Mock - EntityManager entityMgr; - @Mock - NetworkService networkService; - @Mock - VpcManager vpcMgr; - @Mock - NetworkOrchestrationService networkManager; - @Mock - AlertManager alertManager; - @Mock - DataCenterDao dcDao; - @Mock - UserDao userDao; - @Mock - NetworkDao networkDao; - @Mock - NicDao nicDao; - @Mock - IPAddressDao ipAddressDao; - @Mock - ConfigurationManager configMgr; - @Mock - ConfigKey publicMtuKey; - @Mock - ConfigKey userChangeMtuKey; - @Mock - VpcDao vpcDao; - @Mock - DomainRouterDao routerDao; - @Mock - AccountService accountService; - @Mock - NetworkHelper networkHelper; - - @InjectMocks - AccountManagerImpl accountManagerImpl; - @Mock - ConfigKey privateMtuKey; - @Mock - private CallContext callContextMock; - @InjectMocks - CreateNetworkCmd createNetworkCmd = new CreateNetworkCmd(); - @InjectMocks - UpdateNetworkCmd updateNetworkCmd = new UpdateNetworkCmd(); - @Mock - CommandSetupHelper commandSetupHelper; - @Mock - private Account accountMock; @InjectMocks private NetworkServiceImpl service = new NetworkServiceImpl(); + private static final String VLAN_ID_900 = "900"; private static final String VLAN_ID_901 = "901"; private static final String VLAN_ID_902 = "902"; @@ -186,11 +91,6 @@ public class NetworkServiceImplTest { private AccountVO account; private UserVO user; - private NetworkOfferingVO offering; - private DataCenterVO dc; - private Network network; - private PhysicalNetworkVO phyNet; - private VpcVO vpc; private void registerCallContext() { account = new AccountVO("testaccount", 1L, "networkdomain", Account.Type.NORMAL, "uuid"); @@ -200,47 +100,6 @@ private void registerCallContext() { CallContext.register(user, account); } - @Before - public void setup() throws Exception { - MockitoAnnotations.initMocks(this); - replaceUserChangeMtuField(); - Mockito.when(userChangeMtuKey.valueIn(anyLong())).thenReturn(Boolean.TRUE); - offering = Mockito.mock(NetworkOfferingVO.class); - network = Mockito.mock(Network.class); - dc = Mockito.mock(DataCenterVO.class); - phyNet = Mockito.mock(PhysicalNetworkVO.class); - vpc = Mockito.mock(VpcVO.class); - service._networkOfferingDao = networkOfferingDao; - service._physicalNetworkDao = physicalNetworkDao; - service._dcDao = dcDao; - service._accountMgr = accountMgr; - service._networkMgr = networkManager; - service.alertManager = alertManager; - service._configMgr = configMgr; - service._vpcDao = vpcDao; - service._vpcMgr = vpcMgr; - service._accountService = accountService; - service._networksDao = networkDao; - service._nicDao = nicDao; - service._ipAddressDao = ipAddressDao; - service.routerDao = routerDao; - service.commandSetupHelper = commandSetupHelper; - service.networkHelper = networkHelper; - PowerMockito.mockStatic(CallContext.class); - CallContext callContextMock = PowerMockito.mock(CallContext.class); - PowerMockito.when(CallContext.current()).thenReturn(callContextMock); - accountMock = PowerMockito.mock(Account.class); - Mockito.when(service._accountMgr.finalizeOwner(any(Account.class), nullable(String.class), nullable(Long.class), nullable(Long.class))).thenReturn(accountMock); - PowerMockito.when(callContextMock.getCallingAccount()).thenReturn(accountMock); - NetworkOffering networkOffering = Mockito.mock(NetworkOffering.class); - Mockito.when(entityMgr.findById(NetworkOffering.class, 1L)).thenReturn(networkOffering); - Mockito.when(networkService.findPhysicalNetworkId(Mockito.anyLong(), ArgumentMatchers.nullable(String.class), Mockito.any(Networks.TrafficType.class))).thenReturn(1L); - Mockito.when(networkOfferingDao.findById(1L)).thenReturn(offering); - Mockito.when(physicalNetworkDao.findById(Mockito.anyLong())).thenReturn(phyNet); - Mockito.when(dcDao.findById(Mockito.anyLong())).thenReturn(dc); - Mockito.lenient().doNothing().when(accountMgr).checkAccess(accountMock, networkOffering, dc); - Mockito.when(accountMgr.isRootAdmin(accountMock.getId())).thenReturn(true); - } @Test public void testGetPrivateVlanPairNoVlans() { Pair pair = service.getPrivateVlanPair(null, null, null); @@ -329,164 +188,6 @@ public void testPerformBasicChecksPromiscuousTypeExpectedDifferentVlanIds() { service.performBasicPrivateVlanChecks(VLAN_ID_900, VLAN_ID_901, Network.PVlanType.Promiscuous); } - @Test - public void testCreateGuestNetwork() throws InsufficientCapacityException, ResourceAllocationException { - Integer publicMtu = 2450; - Integer privateMtu = 1200; - ReflectionTestUtils.setField(createNetworkCmd, "name", "testNetwork"); - ReflectionTestUtils.setField(createNetworkCmd, "displayText", "Test Network"); - ReflectionTestUtils.setField(createNetworkCmd, "networkOfferingId", 1L); - ReflectionTestUtils.setField(createNetworkCmd, "zoneId", 1L); - ReflectionTestUtils.setField(createNetworkCmd, "publicMtu", publicMtu); - ReflectionTestUtils.setField(createNetworkCmd, "privateMtu", privateMtu); - ReflectionTestUtils.setField(createNetworkCmd, "physicalNetworkId", null); - Mockito.when(offering.isSystemOnly()).thenReturn(false); - Mockito.when(dc.getAllocationState()).thenReturn(Grouping.AllocationState.Enabled); - Map networkProvidersMap = new HashMap(); - Mockito.when(networkManager.finalizeServicesAndProvidersForNetwork(ArgumentMatchers.any(NetworkOffering.class), anyLong())).thenReturn(networkProvidersMap); - lenient().doNothing().when(alertManager).sendAlert(any(AlertService.AlertType.class), anyLong(), anyLong(), anyString(), anyString()); - Mockito.when(configMgr.isOfferingForVpc(offering)).thenReturn(false); - Mockito.when(offering.isInternalLb()).thenReturn(false); - - service.createGuestNetwork(createNetworkCmd); - Mockito.verify(networkManager, times(1)).createGuestNetwork(1L, "testNetwork", "Test Network", null, - null, null, false, null, accountMock, null, phyNet, - 1L, null, null, null, null, null, - true, null, null, null, null, null, - null, null, null, null, new Pair<>(1500, privateMtu)); - } - @Test - public void testValidateMtuConfigWhenMtusExceedThreshold() { - Integer publicMtu = 2450; - Integer privateMtu = 1500; - Long zoneId = 1L; - when(publicMtuKey.valueIn(zoneId)).thenReturn(NetworkService.DEFAULT_MTU); - when(privateMtuKey.valueIn(zoneId)).thenReturn(NetworkService.DEFAULT_MTU); - Pair interfaceMtus = service.validateMtuConfig(publicMtu, privateMtu, zoneId); - Assert.assertNotNull(interfaceMtus); - Assert.assertEquals(NetworkService.DEFAULT_MTU, interfaceMtus.first()); - Assert.assertEquals(NetworkService.DEFAULT_MTU, interfaceMtus.second()); - Mockito.verify(alertManager, Mockito.times(1)).sendAlert(Mockito.any(AlertService.AlertType.class), - Mockito.anyLong(), nullable(Long.class), Mockito.anyString(), Mockito.anyString()); - } - - @Test - public void testValidatePrivateMtuExceedingThreshold() { - Integer publicMtu = 1500; - Integer privateMtu = 2500; - Long zoneId = 1L; - when(publicMtuKey.valueIn(zoneId)).thenReturn(NetworkService.DEFAULT_MTU); - when(privateMtuKey.valueIn(zoneId)).thenReturn(NetworkService.DEFAULT_MTU); - Pair interfaceMtus = service.validateMtuConfig(publicMtu, privateMtu, zoneId); - Assert.assertNotNull(interfaceMtus); - Assert.assertEquals(NetworkService.DEFAULT_MTU, interfaceMtus.first()); - Assert.assertEquals(NetworkService.DEFAULT_MTU, interfaceMtus.second()); - Mockito.verify(alertManager, Mockito.times(1)).sendAlert(Mockito.any(AlertService.AlertType.class), - Mockito.anyLong(), nullable(Long.class), Mockito.anyString(), Mockito.anyString()); - } - - @Test - public void testValidateBypassingPublicMtuPassedDuringNetworkTierCreationForVpcs() throws InsufficientCapacityException, ResourceAllocationException { - Integer publicMtu = 1250; - Integer privateMtu = 1000; - Long zoneId = 1L; - ReflectionTestUtils.setField(createNetworkCmd, "name", "testNetwork"); - ReflectionTestUtils.setField(createNetworkCmd, "displayText", "Test Network"); - ReflectionTestUtils.setField(createNetworkCmd, "networkOfferingId", 1L); - ReflectionTestUtils.setField(createNetworkCmd, "zoneId", zoneId); - ReflectionTestUtils.setField(createNetworkCmd, "publicMtu", publicMtu); - ReflectionTestUtils.setField(createNetworkCmd, "privateMtu", privateMtu); - ReflectionTestUtils.setField(createNetworkCmd, "physicalNetworkId", null); - ReflectionTestUtils.setField(createNetworkCmd, "vpcId", 1L); - Mockito.when(configMgr.isOfferingForVpc(offering)).thenReturn(true); - Mockito.when(vpcDao.findById(anyLong())).thenReturn(vpc); - - service.createGuestNetwork(createNetworkCmd); - Mockito.verify(vpcMgr, times(1)).createVpcGuestNetwork(1L, "testNetwork", "Test Network", null, - null, null, null, accountMock, null, phyNet, - 1L, null, null, 1L, null, accountMock, - true, null, null, null, null, null, null, null, new Pair<>(0, 1000)); - - } - - @Test - public void testUpdateSharedNetworkMtus() throws Exception { - Integer publicMtu = 1250; - Integer privateMtu = 1000; - Long networkId = 1L; - Long zoneId = 1L; - ReflectionTestUtils.setField(updateNetworkCmd, "id", networkId); - ReflectionTestUtils.setField(updateNetworkCmd, "publicMtu", publicMtu); - ReflectionTestUtils.setField(updateNetworkCmd, "privateMtu", privateMtu); - - User callingUser = mock(User.class); - UserVO userVO = mock(UserVO.class); - Account callingAccount = mock(Account.class); - NetworkVO networkVO = mock(NetworkVO.class); - NicVO nicVO = mock(NicVO.class); - List addresses = new ArrayList<>(); - List ips = new ArrayList<>(); - List routers = new ArrayList<>(); - DomainRouterVO routerPrimary = Mockito.mock(DomainRouterVO.class); - routers.add(routerPrimary); - - CallContext.register(callingUser, callingAccount); - PowerMockito.when(CallContext.current()).thenReturn(callContextMock); - Mockito.doReturn(1L).when(callContextMock).getCallingUserId(); - Mockito.when(userDao.findById(anyLong())).thenReturn(userVO); - Mockito.when(accountService.getActiveUser(1L)).thenReturn(callingUser); - Mockito.when(callingUser.getAccountId()).thenReturn(1L); - Mockito.when(accountService.getActiveAccountById(anyLong())).thenReturn(callingAccount); - Mockito.when(networkDao.findById(anyLong())).thenReturn(networkVO); - Mockito.when(networkOfferingDao.findByIdIncludingRemoved(anyLong())).thenReturn(offering); - Mockito.when(offering.isSystemOnly()).thenReturn(false); - Mockito.when(networkVO.getTrafficType()).thenReturn(Networks.TrafficType.Guest); - Mockito.when(networkVO.getGuestType()).thenReturn(Network.GuestType.Shared); - Mockito.when(nicDao.listByNetworkIdAndType(anyLong(), any(VirtualMachine.Type.class))).thenReturn(List.of(Mockito.mock(NicVO.class))); - Mockito.when(networkVO.getVpcId()).thenReturn(null); - Mockito.when(ipAddressDao.listByNetworkId(anyLong())).thenReturn(addresses); - - Pair updatedMtus = service.validateMtuOnUpdate(networkVO, zoneId, publicMtu, privateMtu); - Assert.assertEquals(publicMtu, updatedMtus.first()); - Assert.assertEquals(privateMtu, updatedMtus.second()); - } - - @Test - public void testUpdatePublicInterfaceMtuViaNetworkTiersForVpcNetworks() { - Integer vpcMtu = 1450; - Integer publicMtu = 1250; - Integer privateMtu = 1000; - Long vpcId = 1L; - Long zoneId = 1L; - ReflectionTestUtils.setField(createNetworkCmd, "name", "testNetwork"); - ReflectionTestUtils.setField(createNetworkCmd, "displayText", "Test Network"); - ReflectionTestUtils.setField(createNetworkCmd, "networkOfferingId", 1L); - ReflectionTestUtils.setField(createNetworkCmd, "zoneId", zoneId); - ReflectionTestUtils.setField(createNetworkCmd, "publicMtu", publicMtu); - ReflectionTestUtils.setField(createNetworkCmd, "privateMtu", privateMtu); - ReflectionTestUtils.setField(createNetworkCmd, "physicalNetworkId", null); - ReflectionTestUtils.setField(createNetworkCmd, "vpcId", vpcId); - - VpcVO vpcVO = Mockito.mock(VpcVO.class); - Mockito.when(vpcDao.findById(anyLong())).thenReturn(vpcVO); - Mockito.when(vpcVO.getPublicMtu()).thenReturn(vpcMtu); - - Pair updatedMtus = service.validateMtuConfig(publicMtu, privateMtu, zoneId); - service.mtuCheckForVpcNetwork(vpcId, updatedMtus, publicMtu, privateMtu); - Assert.assertEquals(vpcMtu, updatedMtus.first()); - Assert.assertEquals(privateMtu, updatedMtus.second()); - } - - private void replaceUserChangeMtuField() throws Exception { - Field field = NetworkService.class.getDeclaredField("AllowUsersToSpecifyVRMtu"); - field.setAccessible(true); - // remove final modifier from field - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - field.set(null, userChangeMtuKey); - } - private void prepareCreateNetworkDnsMocks(CreateNetworkCmd cmd, Network.GuestType guestType, boolean ipv6, boolean isVpc, boolean dnsServiceSupported) { long networkOfferingId = 1L; Mockito.when(cmd.getNetworkOfferingId()).thenReturn(networkOfferingId); @@ -496,6 +197,7 @@ private void prepareCreateNetworkDnsMocks(CreateNetworkCmd cmd, Network.GuestTyp Mockito.when(networkOfferingVO.getTrafficType()).thenReturn(Networks.TrafficType.Guest); Mockito.when(networkOfferingVO.isSpecifyIpRanges()).thenReturn(true); Mockito.when(networkOfferingDao.findById(networkOfferingId)).thenReturn(networkOfferingVO); + Mockito.when(accountManager.finalizeOwner(Mockito.any(), Mockito.any(), Mockito.anyLong(), Mockito.anyLong())).thenReturn(account); if (Network.GuestType.Shared.equals(guestType)) { Mockito.when(networkModel.isProviderForNetworkOffering(Mockito.any(), Mockito.anyLong())).thenReturn(true); Mockito.when(cmd.getGateway()).thenReturn(IP4_GATEWAY); @@ -538,11 +240,11 @@ public void testCreateL2NetworkDnsFailure() { } } - @Test + @Test(expected = InvalidParameterValueException.class) public void testCreateNetworkDnsVpcFailure() { registerCallContext(); CreateNetworkCmd cmd = Mockito.mock(CreateNetworkCmd.class); - prepareCreateNetworkDnsMocks(cmd, Network.GuestType.Isolated, false, false, true); + prepareCreateNetworkDnsMocks(cmd, Network.GuestType.Isolated, false, true, true); Mockito.when(cmd.getIp4Dns1()).thenReturn(ip4Dns[0]); try { service.createGuestNetwork(cmd); @@ -555,8 +257,6 @@ public void testCreateNetworkDnsVpcFailure() { public void testCreateNetworkDnsOfferingServiceFailure() { registerCallContext(); CreateNetworkCmd cmd = Mockito.mock(CreateNetworkCmd.class); - Mockito.when(cmd.getDomainId()).thenReturn(null); - Mockito.when(cmd.getProjectId()).thenReturn(null); prepareCreateNetworkDnsMocks(cmd, Network.GuestType.Isolated, false, false, false); Mockito.when(cmd.getIp4Dns1()).thenReturn(ip4Dns[0]); try { diff --git a/server/src/test/java/com/cloud/network/vpc/VpcManagerImplTest.java b/server/src/test/java/com/cloud/network/vpc/VpcManagerImplTest.java index 03d4c1659b3e..9109bed82983 100644 --- a/server/src/test/java/com/cloud/network/vpc/VpcManagerImplTest.java +++ b/server/src/test/java/com/cloud/network/vpc/VpcManagerImplTest.java @@ -20,15 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.nullable; -import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; - import static org.powermock.api.mockito.PowerMockito.when; import java.util.ArrayList; @@ -39,15 +31,9 @@ import java.util.Set; import java.util.UUID; - -import com.cloud.alert.AlertManager; -import org.apache.cloudstack.acl.SecurityChecker; -import org.apache.cloudstack.alert.AlertService; +import org.apache.cloudstack.api.command.admin.vpc.CreateVPCOfferingCmd; import org.apache.cloudstack.context.CallContext; -import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; -import org.junit.After; import org.junit.Assert; -import org.apache.cloudstack.api.command.admin.vpc.CreateVPCOfferingCmd; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -55,62 +41,30 @@ import org.mockito.MockitoAnnotations; import org.powermock.reflect.Whitebox; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.routing.UpdateNetworkCommand; -import com.cloud.agent.api.to.IpAddressTO; -import com.cloud.agent.manager.Commands; -import com.cloud.dc.VlanVO; -import com.cloud.dc.dao.VlanDao; import com.cloud.configuration.Resource; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; -import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network; import com.cloud.network.Network.Capability; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.NetworkModel; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkVO; import com.cloud.network.element.NetworkElement; -import com.cloud.network.router.CommandSetupHelper; -import com.cloud.network.router.NetworkHelper; -import com.cloud.network.router.VirtualRouter; -import com.cloud.network.vpc.dao.VpcDao; +import com.cloud.network.vpc.dao.VpcOfferingDao; import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingServiceMapVO; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; -import com.cloud.user.User; -import com.cloud.utils.Pair; -import com.cloud.utils.db.EntityManager; -import com.cloud.utils.net.Ip; -import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.NicVO; -import com.cloud.vm.dao.DomainRouterDao; -import com.cloud.vm.dao.NicDao; -import com.cloud.network.vpc.dao.VpcOfferingDao; import com.cloud.user.ResourceLimitService; +import com.cloud.user.User; import com.cloud.user.UserVO; import com.cloud.utils.net.NetUtils; + public class VpcManagerImplTest { - @Mock - VpcOfferingServiceMapDao vpcOffSvcMapDao; - @Mock - VpcDao vpcDao; - @Mock - NetworkOrchestrationService networkMgr; @Mock AccountManager accountManager; @Mock @@ -122,30 +76,6 @@ public class VpcManagerImplTest { @Mock VpcOfferingServiceMapDao vpcOfferingServiceMapDao; VpcManagerImpl manager; - @Mock - EntityManager entityMgr; - @Mock - NetworkDao networkDao; - @Mock - NetworkModel networkModel; - @Mock - NetworkOfferingServiceMapDao networkOfferingServiceMapDao; - @Mock - private CallContext callContextMock; - @Mock - IPAddressDao ipAddressDao; - @Mock - DomainRouterDao routerDao; - @Mock - CommandSetupHelper commandSetupHelper; - @Mock - NetworkHelper networkHelper; - @Mock - VlanDao vlanDao; - @Mock - NicDao nicDao; - @Mock - AlertManager alertManager; public static final long ACCOUNT_ID = 1; private AccountVO account; @@ -178,32 +108,14 @@ public void setup() { MockitoAnnotations.initMocks(this); manager = new VpcManagerImpl(); - manager._vpcOffSvcMapDao = vpcOfferingServiceMapDao; - manager.vpcDao = vpcDao; - manager._ntwkMgr = networkMgr; manager._accountMgr = accountManager; - manager._entityMgr = entityMgr; - manager._ntwkDao = networkDao; - manager._ntwkModel = networkModel; - manager._ntwkOffServiceDao = networkOfferingServiceMapDao; - manager._ipAddressDao = ipAddressDao; - manager.routerDao = routerDao; - manager.commandSetupHelper = commandSetupHelper; - manager.networkHelper = networkHelper; - manager._vlanDao = vlanDao; - manager.nicDao = nicDao; - manager.alertManager = alertManager; manager._resourceLimitMgr = resourceLimitService; manager._vpcOffDao = vpcOfferingDao; manager._dcDao = dataCenterDao; - CallContext.register(Mockito.mock(User.class), Mockito.mock(Account.class)); + manager._vpcOffSvcMapDao = vpcOfferingServiceMapDao; registerCallContext(); } - @After - public void tearDown() { - CallContext.unregister(); - } @Test public void getVpcOffSvcProvidersMapForEmptyServiceTest() { long vpcOffId = 1L; @@ -307,113 +219,6 @@ protected Set prepareVpcManagerForCheckingCapabilityPerService return providers; } - @Test - public void testCreateVpcNetwork() throws InsufficientCapacityException, ResourceAllocationException { - final long VPC_ID = 201L; - manager._maxNetworks = 3; - VpcVO vpcMockVO = Mockito.mock(VpcVO.class); - Vpc vpcMock = Mockito.mock(Vpc.class); - Account accountMock = Mockito.mock(Account.class); - PhysicalNetwork physicalNetwork = Mockito.mock(PhysicalNetwork.class); - NetworkOffering offering = Mockito.mock(NetworkOffering.class); - List services = new ArrayList<>(); - services.add(Service.SourceNat); - List serviceMap = new ArrayList<>(); - - Mockito.when(vpcDao.findById(anyLong())).thenReturn(vpcMockVO); - Mockito.when(manager.getActiveVpc(anyLong())).thenReturn(vpcMock); - lenient().doNothing().when(accountManager).checkAccess(any(Account.class), nullable(SecurityChecker.AccessType.class), anyBoolean(), any(Vpc.class)); - Mockito.when(vpcMock.isRegionLevelVpc()).thenReturn(true); - Mockito.when(entityMgr.findById(NetworkOffering.class, 1L)).thenReturn(offering); - Mockito.when(vpcMock.getId()).thenReturn(VPC_ID); - Mockito.when(vpcDao.acquireInLockTable(VPC_ID)).thenReturn(vpcMockVO); - Mockito.when(networkDao.countVpcNetworks(anyLong())).thenReturn(1L); - Mockito.when(offering.getGuestType()).thenReturn(Network.GuestType.Isolated); - Mockito.when(networkModel.listNetworkOfferingServices(anyLong())).thenReturn(services); - Mockito.when(networkOfferingServiceMapDao.listByNetworkOfferingId(anyLong())).thenReturn(serviceMap); - Mockito.when(vpcMock.getCidr()).thenReturn("10.0.0.0/8"); - Mockito.when(vpcMock.getNetworkDomain()).thenReturn("cs1cloud.internal"); - - manager.validateNewVpcGuestNetwork("10.10.10.0/24", "10.10.10.1", accountMock, vpcMock, "cs1cloud.internal"); - manager.validateNtwkOffForNtwkInVpc(2L, 1, "10.10.10.0/24", "111-", vpcMock, "10.1.1.1", new AccountVO(), null); - manager.validateNtwkOffForVpc(offering, services); - manager.createVpcGuestNetwork(1L, "vpcNet1", "vpc tier 1", null, - "10.10.10.0/24", null, null, accountMock, null, physicalNetwork, - 1L, null, null, 1L, null, accountMock, - true, null, null, null, null, null, null, null, new Pair<>(1000, 1000)); - - Mockito.verify(networkMgr, times(1)).createGuestNetwork(1L, "vpcNet1", "vpc tier 1", null, - "10.10.10.0/24", null, false, "cs1cloud.internal", accountMock, null, - physicalNetwork, zoneId, null, null, 1L, null, null, - true, null, null, null, null, - null, null, null, null, null, new Pair<>(1000, 1000)); - } - - @Test - public void testUpdateVpcNetwork() throws ResourceUnavailableException { - long vpcId = 1L; - Integer publicMtu = 1450; - Account accountMock = Mockito.mock(Account.class); - VpcVO vpcVO = new VpcVO(); - - Answer answer = Mockito.mock(Answer.class); - Mockito.when(answer.getResult()).thenReturn(true); - VirtualRouter routerMock = Mockito.mock(VirtualRouter.class); - List ipAddresses = new ArrayList<>(); - IPAddressVO ipAddressVO = Mockito.mock(IPAddressVO.class); - Mockito.when(ipAddressVO.getAddress()).thenReturn(Mockito.mock(Ip.class)); - ipAddresses.add(ipAddressVO); - List ips = new ArrayList<>(); - List routers = new ArrayList<>(); - DomainRouterVO router = Mockito.mock(DomainRouterVO.class); - routers.add(router); - - IpAddressTO[] ipsToSend = ips.toArray(new IpAddressTO[0]); - - Mockito.when(callContextMock.getCallingAccount()).thenReturn(accountMock); - Mockito.when(vpcDao.findById(vpcId)).thenReturn(vpcVO); - Mockito.when(vpcDao.createForUpdate(anyLong())).thenReturn(vpcVO); - Mockito.when(ipAddressDao.listByAssociatedVpc(anyLong(), nullable(Boolean.class))).thenReturn(ipAddresses); - Mockito.when(routerDao.listByVpcId(anyLong())).thenReturn(routers); - VlanVO vlanVO = Mockito.mock(VlanVO.class); - Mockito.when(vlanVO.getVlanNetmask()).thenReturn("netmask"); - Mockito.when(vlanDao.findById(anyLong())).thenReturn(vlanVO); - Mockito.doAnswer((org.mockito.stubbing.Answer) invocation -> { - Commands commands = (Commands)invocation.getArguments()[2]; - commands.addCommand("updateNetwork", new UpdateNetworkCommand(ipsToSend)); - return null; - }).when(commandSetupHelper).setupUpdateNetworkCommands(Mockito.any(), Mockito.any(), Mockito.any()); - Mockito.doAnswer((org.mockito.stubbing.Answer) invocation -> { - Commands commands = (Commands)invocation.getArguments()[1]; - commands.setAnswers(new Answer[]{answer}); - return true; - }).when(networkHelper).sendCommandsToRouter(Mockito.any(), Mockito.any()); - Mockito.when(nicDao.findByIpAddressAndVmType(anyString(), any())).thenReturn(Mockito.mock(NicVO.class)); - Mockito.when(nicDao.update(anyLong(), any())).thenReturn(true); - Mockito.when(networkDao.listByVpc(vpcId)).thenReturn(List.of(Mockito.mock(NetworkVO.class))); - Mockito.when(networkDao.update(anyLong(), any())).thenReturn(true); - Mockito.when(vpcDao.update(vpcId, vpcVO)).thenReturn(true); - - manager.updateVpc(vpcId, null, null, null, true, publicMtu); - Assert.assertEquals(publicMtu, vpcVO.getPublicMtu()); - - } - - @Test - public void testUpdatePublicMtuToGreaterThanThreshold() { - Integer publicMtu = 2500; - Integer expectedMtu = 1500; - Long vpcId = 1L; - - VpcVO vpcVO = new VpcVO(); - - Mockito.when(vpcDao.findById(vpcId)).thenReturn(vpcVO); - Mockito.when(vpcDao.createForUpdate(anyLong())).thenReturn(vpcVO); - lenient().doNothing().when(alertManager).sendAlert(any(AlertService.AlertType.class), anyLong(), anyLong(), anyString(), anyString()); - Integer mtu = manager.validateMtu(vpcVO, publicMtu); - Assert.assertEquals(expectedMtu, mtu); - } - @Test(expected = InvalidParameterValueException.class) public void testDisabledConfigCreateIpv6VpcOffering() { CreateVPCOfferingCmd cmd = Mockito.mock(CreateVPCOfferingCmd.class); @@ -446,7 +251,7 @@ public void testCreateVpcDnsOfferingServiceFailure() { try { Mockito.doNothing().when(resourceLimitService).checkResourceLimit(account, Resource.ResourceType.vpc); manager.createVpc(zoneId, vpcOfferingId, vpcOwnerId, vpcName, vpcName, ip4Cidr, vpcDomain, - ip4Dns[0], null, null, null, true, 1500); + ip4Dns[0], null, null, null, true); } catch (ResourceAllocationException e) { Assert.fail(String.format("failure with exception: %s", e.getMessage())); } @@ -458,7 +263,7 @@ public void testCreateVpcDnsIpv6OfferingFailure() { try { Mockito.doNothing().when(resourceLimitService).checkResourceLimit(account, Resource.ResourceType.vpc); manager.createVpc(zoneId, vpcOfferingId, vpcOwnerId, vpcName, vpcName, ip4Cidr, vpcDomain, - ip4Dns[0], ip4Dns[1], ip6Dns[0], null, true, 1500); + ip4Dns[0], ip4Dns[1], ip6Dns[0], null, true); } catch (ResourceAllocationException e) { Assert.fail(String.format("failure with exception: %s", e.getMessage())); } diff --git a/server/src/test/java/com/cloud/vpc/MockNetworkManagerImpl.java b/server/src/test/java/com/cloud/vpc/MockNetworkManagerImpl.java index c7cf7ecf3e54..f47386491077 100644 --- a/server/src/test/java/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/src/test/java/com/cloud/vpc/MockNetworkManagerImpl.java @@ -664,7 +664,7 @@ public Network createPrivateNetwork(final long networkOfferingId, final String n public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, boolean bypassVlanOverlapCheck, String networkDomain, Account owner, Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6, Boolean displayNetworkEnabled, String isolatedPvlan, Network.PVlanType isolatedPvlanType, String externalId, String routerIp, String routerIpv6, - String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Pair vrIfaceMTUs) throws ConcurrentOperationException, ResourceAllocationException { + String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2) throws ConcurrentOperationException, ResourceAllocationException { // TODO Auto-generated method stub return null; } diff --git a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py index 7c7f5e48d646..c6aeb9b58cef 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py @@ -296,7 +296,6 @@ def list(self): class CsIP: - DEFAULT_MTU = '1500' def __init__(self, dev, config): self.dev = dev @@ -321,8 +320,6 @@ def configure(self, address): logging.info("Configuring address %s on device %s", self.ip(), self.dev) cmd = "ip addr add dev %s %s brd +" % (self.dev, self.ip()) CsHelper.execute(cmd) - cmd = "ifconfig %s mtu %s" % (self.dev, self.mtu()) - CsHelper.execute(cmd) except Exception as e: logging.info("Exception occurred ==> %s" % e) @@ -393,12 +390,6 @@ def get_ip_address(self): return self.address['public_ip'] return "unknown" - def mtu(self): - logging.info(self.address) - if "mtu" in self.address: - return self.address['mtu'] - return CsIP.DEFAULT_MTU - def setup_router_control(self): if self.config.is_vpc(): return diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index d653093a9f28..bfa17404697b 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -19,11 +19,9 @@ import os from netaddr import * from random import randint -import json from CsGuestNetwork import CsGuestNetwork from cs.CsDatabag import CsDataBag from cs.CsFile import CsFile -from cs.CsAddress import CsIP LEASES = "/var/lib/misc/dnsmasq.leases" DHCP_HOSTS = "/etc/dhcphosts.txt" @@ -122,12 +120,7 @@ def configure_server(self): sline = "dhcp-option=tag:interface-%s-%s,3," % (device, idx) line = "dhcp-option=tag:interface-%s-%s,3,%s" % (device, idx, gateway) self.conf.search(sline, line) - - sline = "dhcp-option=%s,26" % device - line = "dhcp-option=%s,26,%s" % (device, i['mtu']) - self.conf.search(sline, line) - - # Netmask + # Netmask netmask = '' if self.config.is_vpc(): netmask = gn.get_netmask() diff --git a/systemvm/debian/opt/cloud/bin/cs/CsHelper.py b/systemvm/debian/opt/cloud/bin/cs/CsHelper.py index 2458402fc4f0..c892b5df9102 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsHelper.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsHelper.py @@ -115,16 +115,8 @@ def get_device_info(): list = [] for i in execute("ip addr show |grep -v secondary"): vals = i.strip().lstrip().rstrip().split() - if re.search('[0-9]:',vals[0]): - to={} - to['mtu'] = vals[4] - list.append(to) - if vals[0] == "inet": - if len(list) > 0: - to = list.pop(len(list)-1) - else: - to={} + to = {} to['ip'] = vals[1] to['dev'] = vals[-1] to['network'] = IPNetwork(to['ip']) diff --git a/systemvm/debian/opt/cloud/bin/cs_ip.py b/systemvm/debian/opt/cloud/bin/cs_ip.py index fbe7629970a9..a4e0c33e798b 100755 --- a/systemvm/debian/opt/cloud/bin/cs_ip.py +++ b/systemvm/debian/opt/cloud/bin/cs_ip.py @@ -55,8 +55,6 @@ def merge(dbag, ip): ip['cidr'] = str(ipo.ip) + '/' + str(ipo.prefixlen) ip['size'] = str(ipo.prefixlen) ip['network'] = str(ipo.network) + '/' + str(ipo.prefixlen) - if 'mtu' in ip: - ip['mtu'] = str(ip['mtu']) if 'nw_type' not in ip.keys(): ip['nw_type'] = 'public' else: diff --git a/systemvm/debian/opt/cloud/bin/merge.py b/systemvm/debian/opt/cloud/bin/merge.py index 2409df0e7e2b..caa3c6bff84b 100755 --- a/systemvm/debian/opt/cloud/bin/merge.py +++ b/systemvm/debian/opt/cloud/bin/merge.py @@ -155,7 +155,6 @@ def processGuestNetwork(self, dbag): dp['gateway'] = d['router_guest_gateway'] dp['nic_dev_id'] = d['device'][3:] dp['nw_type'] = 'guest' - dp['mtu'] = str(d['mtu']) qf = QueueFile() qf.load({'ip_address': [dp], 'type': 'ips'}) if 'domain_name' not in d.keys() or d['domain_name'] == '': diff --git a/systemvm/debian/opt/cloud/bin/setup/common.sh b/systemvm/debian/opt/cloud/bin/setup/common.sh index 26729adf5db4..c2524dd213a4 100755 --- a/systemvm/debian/opt/cloud/bin/setup/common.sh +++ b/systemvm/debian/opt/cloud/bin/setup/common.sh @@ -93,14 +93,6 @@ setup_interface() { echo " address $ip " >> /etc/network/interfaces echo " netmask $mask" >> /etc/network/interfaces fi - - if [ ! -z "$PRIVATEMTU" ] && [ $intf == "eth0" ]; then - echo " mtu $PRIVATEMTU" >> /etc/network/interfaces - fi - - if [ ! -z "$PUBLICMTU" ] && [ $intf == "eth2" ]; then - echo " mtu $PUBLICMTU" >> /etc/network/interfaces - fi fi if [ "$ip" == "0.0.0.0" -o "$ip" == "" ] @@ -912,12 +904,6 @@ parse_cmd_line() { logrotatefrequency) export LOGROTATE_FREQUENCY=$VALUE ;; - publicMtu) - export PUBLICMTU=$VALUE - ;; - privateMtu) - export PRIVATEMTU=$VALUE - ;; useHttpsToUpload) export USEHTTPS=$VALUE ;; diff --git a/systemvm/debian/opt/cloud/bin/update_config.py b/systemvm/debian/opt/cloud/bin/update_config.py index 8efe2ce664a9..518a31ca5eda 100755 --- a/systemvm/debian/opt/cloud/bin/update_config.py +++ b/systemvm/debian/opt/cloud/bin/update_config.py @@ -19,6 +19,8 @@ import sys from merge import QueueFile import logging +import subprocess +from subprocess import PIPE, STDOUT import os import os.path import configure diff --git a/systemvm/debian/opt/cloud/bin/update_interface_config.sh b/systemvm/debian/opt/cloud/bin/update_interface_config.sh deleted file mode 100644 index 4b1e96b8d3ce..000000000000 --- a/systemvm/debian/opt/cloud/bin/update_interface_config.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# 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. - -# used as a proxy to call script inside virtual router - -#set -x - -ip=$1 -netmask=$2 -mtu=$3 -timeout=$4 - -i=0 - -get_interface() { - for i in `seq 1 $(($timeout))` - do - #inf=$(ip route list ${1}/${2} | awk '{print $3}') - inf=$(ip addr show|egrep '^ *inet'|grep ${1}/${2} |grep brd|awk -- '{ print $NF; }') - if [ ! -z $inf ]; then - echo $inf - break - fi - sleep 0.1 - done -} - - -interfaceName=$(get_interface $ip $netmask) -echo $interfaceName -if [ ! -z $interfaceName ]; then - state=$(cat /sys/class/net/${interfaceName}/operstate) - if [[ "$state" == "up" ]]; then - ifconfig $interfaceName mtu $mtu up - else - ifconfig $interfaceName mtu $mtu - fi - if grep "dhcp-option=$interfaceName,26" /etc/dnsmasq.d/cloud.conf; then - sed -i "/dhcp-option=$interfaceName,26/c\dhcp-option=$interfaceName,26,$mtu" /etc/dnsmasq.d/cloud.conf - else - echo "dhcp-option=$interfaceName,26,$mtu" >> /etc/dnsmasq.d/cloud.conf - fi - systemctl restart dnsmasq - exit $? -fi - -echo "Interface with IP ${ip} not found" -exit 1 \ No newline at end of file diff --git a/test/integration/component/test_network_mtu.py b/test/integration/component/test_network_mtu.py deleted file mode 100644 index e163712b2081..000000000000 --- a/test/integration/component/test_network_mtu.py +++ /dev/null @@ -1,395 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# 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. -""" BVT tests for Network Life Cycle -""" -# Import Local Modules -from marvin.cloudstackTestCase import cloudstackTestCase -from marvin.lib.utils import cleanup_resources, get_process_status, get_host_credentials -from marvin.lib.base import (Account, - VirtualMachine, - ServiceOffering, - NATRule, - PublicIPAddress, - StaticNATRule, - FireWallRule, - Network, - NetworkOffering, - LoadBalancerRule, - Router, - NIC, - Cluster) -from marvin.lib.common import (get_domain, - get_free_vlan, - get_zone, - get_template, - get_test_template, - list_hosts, - list_publicIP, - list_nat_rules, - list_routers, - list_virtual_machines, - list_lb_rules, - list_configurations, - verifyGuestTrafficPortGroups, - verifyNetworkState) - -from nose.plugins.attrib import attr -import logging - -_multiprocess_shared_ = True - -logger = logging.getLogger('TestNetworkWithMtuConfiguration') -stream_handler = logging.StreamHandler() -logger.setLevel(logging.DEBUG) -logger.addHandler(stream_handler) - -class TestNetworkWithMtuConfiguration(cloudstackTestCase): - @classmethod - def setUpClass(cls): - cls.testClient = super(TestNetworkWithMtuConfiguration, cls).getClsTestClient() - cls.api_client = cls.testClient.getApiClient() - cls.dbclient = cls.testClient.getDbConnection() - cls.hypervisor = cls.testClient.getHypervisorInfo() - cls.domain = get_domain(cls.api_client) - cls.skip = False - if cls.hypervisor.lower() == 'simulator': - cls.skip = True - - cls.services = cls.testClient.getParsedTestDataConfig() - cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][ - 0].__dict__ - # Get Zone and templates - cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) - logger.debug("Creating Admin Account for domain %s on zone %s" % (cls.domain.id, cls.zone.id)) - cls.account = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain.id - ) - cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) - - cls.services["virtual_machine"]["zoneid"] = cls.zone.id - cls.services["virtual_machine"]["template"] = cls.template.id - cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offering"] - ) - cls.isolated_network_offering = NetworkOffering.create( - cls.api_client, - cls.services["network_offering"] - ) - cls.isolated_network_offering.update(cls.api_client, state='Enabled') - - cls._cleanup = [ - cls.service_offering, - cls.isolated_network_offering, - cls.account - ] - return - - @classmethod - def tearDownClass(cls): - try: - # Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) - return - - def setUp(self): - if self.skip: - self.skipTest("Skip test for simulator hypervisor") - - self.apiclient = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - self.hypervisor = self.testClient.getHypervisorInfo() - self.cleanup = [] - return - - def tearDown(self): - try: - # Clean up, terminate the resources created - cleanup_resources(self.apiclient, self.cleanup) - self.cleanup[:] = [] - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) - return - - ''' - This test performs the following: - 1. creates an Isolated network with Public and Private MTUs being configured on the respective interfaces - a. Set one of the MTUs to a value greater that the configured max - 1500 and observe that it gets set - to the maximum configurable value - 2. Check router nic MTUs - 3. Validates that the network has the right MTU set in the DB - ''' - - @attr(tags=["advanced", "isolated", "network", "xx"], required_hardware="false") - def test_01_create_isolated_network_with_mtu(self): - public_mtu = 1450 - private_mtu = 2000 - logger.debug("Creating an isolated network with MTU defined for both public and private interfaces") - self.isolated_network = Network.create( - self.apiclient, - self.services["isolated_network"], - networkofferingid=self.isolated_network_offering.id, - zoneid=self.zone.id, - publicmtu=public_mtu, - privatemtu=private_mtu) - - logger.debug("Deploying VM") - virtual_machine = VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - templateid=self.template.id, - serviceofferingid=self.service_offering.id, - networkids=[str(self.isolated_network.id)]) - self.cleanup.append(virtual_machine) - self.cleanup.append(self.isolated_network) - - # Validate network is in the Implemented state - - response = verifyNetworkState( - self.apiclient, - virtual_machine.nic[0].networkid, - "implemented") - exceptionOccurred = response[0] - isNetworkInDesiredState = response[1] - exceptionMessage = response[2] - - if (exceptionOccurred or (not isNetworkInDesiredState)): - self.fail(exceptionMessage) - - public_ips = list_publicIP( - self.apiclient, - associatednetworkid=self.isolated_network.id - ) - - self.assertEqual( - isinstance(public_ips, list), - True, - "Check for list public IPs response return valid data" - ) - - public_ip = public_ips[0] - - logger.debug("Creating Firewall rule for VM ID: %s" % virtual_machine.id) - FireWallRule.create( - self.apiclient, - ipaddressid=public_ip.id, - protocol=self.services["natrule"]["protocol"], - cidrlist=['0.0.0.0/0'], - startport=self.services["natrule"]["publicport"], - endport=self.services["natrule"]["publicport"] - ) - - logger.debug("Creating NAT rule for VM ID: %s" % virtual_machine.id) - nat_rule = NATRule.create( - self.apiclient, - virtual_machine, - self.services["natrule"], - public_ip.id - ) - - logger.debug("Ping the external network with packet size greater than configured mtu %s : %s", public_mtu, 1500) - expected = 1 - check_string = "Frag needed and DF set" - cmd = "ping -M do -s {mtu} 8.8.8.8 -c1" - result = self.check_router_command(virtual_machine, nat_rule.ipaddress, cmd.format(mtu="1500"), check_string, self) - self.assertEqual( - result, - expected, - "Ping to outside world from VM should be successful!" - ) - - logger.debug("Ping the external network with packet size lesser than configured mtu %s : %s", public_mtu, 1200) - expected = 1 - check_string = "0% packet loss" - cmd = "ping -M do -s {mtu} 8.8.8.8 -c1" - result = self.check_router_command(virtual_machine, nat_rule.ipaddress, cmd.format(mtu="1200"), check_string, self) - self.assertEqual( - result, - expected, - "Ping to outside world from VM should be successful!" - ) - - # Verify network mtu set - self.verify_network_mtu(self.isolated_network, public_mtu, 1500) - self.checkRouterNicMtus(self.isolated_network, public_mtu, 1500) - self.checkNetworkMtu(self.isolated_network, public_mtu, 1500) - - @attr(tags=["advanced", "isolated", "network", "xx"], required_hardware="false") - def test_02_update_isolated_network_with_mtu(self): - public_mtu = 1200 - private_mtu = 1100 - logger.debug("Creating an isolated network with MTU defined for both public and private interfaces") - isolated_network1 = Network.create( - self.apiclient, - self.services["isolated_network"], - networkofferingid=self.isolated_network_offering.id, - zoneid=self.zone.id, - publicmtu=public_mtu, - privatemtu=private_mtu) - - logger.debug("Deploying VM") - virtual_machine = VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - templateid=self.template.id, - serviceofferingid=self.service_offering.id, - networkids=[str(isolated_network1.id)]) - self.cleanup.append(virtual_machine) - self.cleanup.append(isolated_network1) - - # Validate network is in the Implemented state - response = verifyNetworkState( - self.apiclient, - virtual_machine.nic[0].networkid, - "implemented") - exceptionOccurred = response[0] - isNetworkInDesiredState = response[1] - exceptionMessage = response[2] - - if (exceptionOccurred or (not isNetworkInDesiredState)): - self.fail(exceptionMessage) - - public_ips = list_publicIP( - self.apiclient, - associatednetworkid=isolated_network1.id - ) - - self.assertEqual( - isinstance(public_ips, list), - True, - "Check for list public IPs response return valid data" - ) - - public_ip = public_ips[0] - - logger.debug("Creating Firewall rule for VM ID: %s" % virtual_machine.id) - FireWallRule.create( - self.apiclient, - ipaddressid=public_ip.id, - protocol=self.services["natrule"]["protocol"], - cidrlist=['0.0.0.0/0'], - startport=self.services["natrule"]["publicport"], - endport=self.services["natrule"]["publicport"] - ) - - logger.debug("Creating NAT rule for VM ID: %s" % virtual_machine.id) - nat_rule = NATRule.create( - self.apiclient, - virtual_machine, - self.services["natrule"], - public_ip.id - ) - # Verify network mtu set - self.verify_network_mtu(isolated_network1, public_mtu, private_mtu) - - self.checkRouterNicMtus(isolated_network1, public_mtu, private_mtu) - self.checkNetworkMtu(isolated_network1, public_mtu, private_mtu) - - logger.debug("Update the network's MTU") - updated_network = isolated_network1.update(self.apiclient, id=isolated_network1.id, public_mtu=1450) - - logger.debug("Ping the external network with packet size greater than configured mtu %s : %s", public_mtu, 1500) - expected = 1 - check_string = "Frag needed and DF set" - cmd = "ping -M do -s {mtu} 8.8.8.8 -c1" - result = self.check_router_command(virtual_machine, nat_rule.ipaddress, cmd.format(mtu="1500"), check_string, self) - self.assertEqual( - result, - expected, - "Ping to outside world from VM should be successful!" - ) - - logger.debug("Ping the external network with packet size lesser than configured mtu %s : %s", public_mtu, 1100) - expected = 1 - check_string = "0% packet loss" - cmd = "ping -M do -s {mtu} 8.8.8.8 -c1" - result = self.check_router_command(virtual_machine, nat_rule.ipaddress, cmd.format(mtu="1200"), check_string, self) - self.assertEqual( - result, - expected, - "Ping to outside world from VM should be successful!" - ) - - self.checkRouterNicMtus(updated_network, public_mtu, private_mtu) - self.checkNetworkMtu(updated_network, public_mtu, private_mtu) - - def verify_network_mtu(self, network, public_mtu, private_mtu): - # Verify network mtu set - result = self.dbclient.execute("select public_mtu, private_mtu from networks where uuid='%s'" - % str(network.id)) - self.assertEqual(isinstance(result, list), - True, - "Check DB query result set for valid data") - - self.assertNotEqual(len(result), - 0, - "Check DB Query result set") - self.assertEqual(result[0][0], - public_mtu if public_mtu < 1500 else 1500, - "DB results not matching, expected: %s found: %s " % (public_mtu, result[0][0])) - self.assertEqual(result[0][1], - private_mtu if private_mtu < 1500 else 1500, - "DB results not matching, expected: %s found: %s " % (private_mtu, result[0][1])) - - def check_router_command(self, virtual_machine, public_ip, ssh_command, check_string, test_case, retries=5): - result = 'failed' - try: - ssh = virtual_machine.get_ssh_client(ipaddress=public_ip, retries=retries) - result = str(ssh.execute(ssh_command)) - except Exception as e: - test_case.fail("Failed to SSH into the Virtual Machine: %s" % e) - - logging.debug("Result from SSH into the Virtual Machine: %s" % result) - return result.count(check_string) - - def checkRouterNicMtus(self, network, public_mtu, private_mtu): - self.debug("Listing routers for network: %s" % network.name) - self.routers = Router.list( - self.apiclient, - networkid=network.id, - listall=True - ) - self.assertTrue( - isinstance(self.routers, list), - "Check listRouters response returns a valid list" - ) - self.assertTrue( - len(self.routers) > 0, - "Router for the network isn't found" - ) - - for router in self.routers: - nics = router.nic - for nic in nics: - if nic.traffictype == 'Guest': - self.assertEqual(private_mtu, nic.mtu, "MTU not properly configured on private interface of VR") - if nic.traffictype == 'Public': - self.assertEqual(public_mtu, nic.mtu, "MTU not properly configured on public interface of VR") - - def checkNetworkMtu(self, network, expected_public_mtu, expected_private_mtu): - self.assertEqual(expected_public_mtu, network.publicmtu) - self.assertEqual(expected_private_mtu, network.privatemtu) diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index 0c37c0836b8c..84f4c67ec4c8 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -1,5 +1,4 @@ # Licensed to the Apache Software Foundation (ASF) under one -# 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 @@ -50,13 +49,10 @@ list_virtual_machines, list_lb_rules, list_configurations, - verifyGuestTrafficPortGroups, - verifyNetworkState) - + verifyGuestTrafficPortGroups) from nose.plugins.attrib import attr from marvin.lib.decoratorGenerators import skipTestIf from ddt import ddt, data -import unittest # Import System modules import time import logging @@ -69,7 +65,6 @@ logger.setLevel(logging.DEBUG) logger.addHandler(stream_handler) - class TestPublicIP(cloudstackTestCase): def setUp(self): @@ -238,9 +233,9 @@ def test_public_ip_admin_account(self): if list_pub_ip_addr_resp is None: return if (list_pub_ip_addr_resp) and ( - isinstance( - list_pub_ip_addr_resp, - list)) and ( + isinstance( + list_pub_ip_addr_resp, + list)) and ( len(list_pub_ip_addr_resp) > 0): self.fail("list public ip response is not empty") return @@ -446,10 +441,10 @@ def test_01_port_fwd_on_src_nat(self): # SSH virtual machine to test port forwarding try: logger.debug("SSHing into VM with IP address %s with NAT IP %s" % - ( - self.virtual_machine.ipaddress, - src_nat_ip_addr.ipaddress - )) + ( + self.virtual_machine.ipaddress, + src_nat_ip_addr.ipaddress + )) self.virtual_machine.get_ssh_client(src_nat_ip_addr.ipaddress) vm_response = VirtualMachine.list( @@ -574,10 +569,10 @@ def test_02_port_fwd_on_non_src_nat(self): try: logger.debug("SSHing into VM with IP address %s with NAT IP %s" % - ( - self.virtual_machine.ipaddress, - ip_address.ipaddress.ipaddress - )) + ( + self.virtual_machine.ipaddress, + ip_address.ipaddress.ipaddress + )) self.virtual_machine.get_ssh_client(ip_address.ipaddress.ipaddress) except Exception as e: self.fail( @@ -1092,8 +1087,7 @@ def setUpClass(cls): cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.hypervisor = testClient.getHypervisorInfo() - cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][ - 0].__dict__ + cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ template = get_test_template( cls.apiclient, cls.zone.id, @@ -1285,10 +1279,10 @@ def test_network_rules_acquired_public_ip(self, value): try: logger.debug("SSHing into VM with IP address %s with NAT IP %s" % - ( - self.virtual_machine.ipaddress, - self.ipaddress.ipaddress.ipaddress - )) + ( + self.virtual_machine.ipaddress, + self.ipaddress.ipaddress.ipaddress + )) self.virtual_machine.get_ssh_client( self.ipaddress.ipaddress.ipaddress) except Exception as e: @@ -1325,7 +1319,6 @@ def test_network_rules_acquired_public_ip(self, value): ) return - class TestL2Networks(cloudstackTestCase): def setUp(self): @@ -1418,7 +1411,7 @@ def test_deploy_vm_l2network(self): list_vm = list_virtual_machines( self.apiclient, - id=self.virtual_machine.id + id = self.virtual_machine.id ) self.assertEqual( isinstance(list_vm, list), @@ -1463,7 +1456,7 @@ def test_delete_network_while_vm_on_it(self): list_vm = list_virtual_machines( self.apiclient, - id=self.virtual_machine.id + id = self.virtual_machine.id ) self.assertEqual( isinstance(list_vm, list), @@ -1519,7 +1512,7 @@ def test_l2network_restart(self): list_vm = list_virtual_machines( self.apiclient, - id=self.virtual_machine.id + id = self.virtual_machine.id ) self.assertEqual( isinstance(list_vm, list), @@ -1549,7 +1542,6 @@ def test_l2network_restart(self): return - class TestPrivateVlansL2Networks(cloudstackTestCase): def setUp(self): @@ -1588,17 +1580,16 @@ def setUpClass(cls): # Supported hypervisor = KVM using OVS isKVM = cls.hypervisor.lower() in ["kvm"] isOVSEnabled = False - hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][ - 0].__dict__ - if isKVM: + hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ + if isKVM : # Test only if all the hosts use OVS grepCmd = 'grep "network.bridge.type=openvswitch" /etc/cloudstack/agent/agent.properties' hosts = list_hosts(cls.apiclient, type='Routing', hypervisor='kvm') - if len(hosts) > 0: + if len(hosts) > 0 : isOVSEnabled = True - for host in hosts: + for host in hosts : isOVSEnabled = isOVSEnabled and len(SshClient(host.ipaddress, port=22, user=hostConfig["username"], - passwd=hostConfig["password"]).execute(grepCmd)) != 0 + passwd=hostConfig["password"]).execute(grepCmd)) != 0 supported = isVmware and isDvSwitch or isKVM and isOVSEnabled cls.unsupportedHardware = not supported @@ -1606,6 +1597,7 @@ def setUpClass(cls): cls._cleanup = [] if supported: + cls.account = Account.create( cls.apiclient, cls.services["account"], @@ -1643,16 +1635,16 @@ def setUpClass(cls): "name": "Test Network L2 PVLAN Promiscuous", "displaytext": "Test Network L2 PVLAN Promiscuous", "vlan": 900, - "isolatedpvlan": "900", + "isolatedpvlan" : "900", "isolatedpvlantype": "promiscuous" } cls.services["l2-network-pvlan-isolated"] = { - "name": "Test Network L2 PVLAN Isolated", - "displaytext": "Test Network L2 PVLAN Isolated", - "vlan": 900, - "isolatedpvlan": "903", - "isolatedpvlantype": "isolated" - } + "name": "Test Network L2 PVLAN Isolated", + "displaytext": "Test Network L2 PVLAN Isolated", + "vlan": 900, + "isolatedpvlan": "903", + "isolatedpvlantype": "isolated" + } cls.l2_network_offering = NetworkOffering.create( cls.apiclient, @@ -1788,15 +1780,10 @@ def test_l2_network_pvlan_connectivity(self): vm_promiscuous2_ip, vm_promiscuous2_eth = self.enable_l2_nic(vm_promiscuous2) # Community PVLAN checks - different_community_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, vm_community1_one_eth, - vm_community2_ip) - same_community_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, vm_community1_one_eth, - vm_community1_two_ip) - community_to_promiscuous_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, - vm_community1_one_eth, - vm_promiscuous1_ip) - community_to_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, vm_community1_one_eth, - vm_isolated1_ip) + different_community_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, vm_community1_one_eth, vm_community2_ip) + same_community_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, vm_community1_one_eth, vm_community1_two_ip) + community_to_promiscuous_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, vm_community1_one_eth, vm_promiscuous1_ip) + community_to_isolated = self.is_vm_l2_isolated_from_dest(vm_community1_one, vm_community1_one_eth, vm_isolated1_ip) self.assertTrue( different_community_isolated, @@ -1820,10 +1807,8 @@ def test_l2_network_pvlan_connectivity(self): # Isolated PVLAN checks same_isolated = self.is_vm_l2_isolated_from_dest(vm_isolated1, vm_isolated1_eth, vm_isolated2_ip) - isolated_to_community_isolated = self.is_vm_l2_isolated_from_dest(vm_isolated1, vm_isolated1_eth, - vm_community1_one_ip) - isolated_to_promiscuous_isolated = self.is_vm_l2_isolated_from_dest(vm_isolated1, vm_isolated1_eth, - vm_promiscuous1_ip) + isolated_to_community_isolated = self.is_vm_l2_isolated_from_dest(vm_isolated1, vm_isolated1_eth, vm_community1_one_ip) + isolated_to_promiscuous_isolated = self.is_vm_l2_isolated_from_dest(vm_isolated1, vm_isolated1_eth, vm_promiscuous1_ip) self.assertTrue( same_isolated, @@ -1839,10 +1824,8 @@ def test_l2_network_pvlan_connectivity(self): ) # Promiscuous PVLAN checks - same_promiscuous = self.is_vm_l2_isolated_from_dest(vm_promiscuous1, vm_promiscuous1_eth, - vm_promiscuous2_ip) - prom_to_community_isolated = self.is_vm_l2_isolated_from_dest(vm_promiscuous1, vm_promiscuous1_eth, - vm_community1_one_ip) + same_promiscuous = self.is_vm_l2_isolated_from_dest(vm_promiscuous1, vm_promiscuous1_eth, vm_promiscuous2_ip) + prom_to_community_isolated = self.is_vm_l2_isolated_from_dest(vm_promiscuous1, vm_promiscuous1_eth, vm_community1_one_ip) prom_to_isolated = self.is_vm_l2_isolated_from_dest(vm_promiscuous1, vm_promiscuous1_eth, vm_isolated1_ip) self.assertFalse( diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 28dc33b92874..bdf8bbc43aa0 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -3472,7 +3472,7 @@ def create(cls, apiclient, services, accountid=None, domainid=None, networkofferingid=None, projectid=None, subdomainaccess=None, zoneid=None, gateway=None, netmask=None, vpcid=None, aclid=None, vlan=None, - externalid=None, bypassvlanoverlapcheck=None, associatednetworkid=None, publicmtu=None, privatemtu=None): + externalid=None, bypassvlanoverlapcheck=None, associatednetworkid=None): """Create Network for account""" cmd = createNetwork.createNetworkCmd() cmd.name = services["name"] @@ -3550,10 +3550,6 @@ def create(cls, apiclient, services, accountid=None, domainid=None, cmd.bypassvlanoverlapcheck = bypassvlanoverlapcheck if associatednetworkid: cmd.associatednetworkid = associatednetworkid - if publicmtu: - cmd.publicmtu = publicmtu - if privatemtu: - cmd.privatemtu = privatemtu return Network(apiclient.createNetwork(cmd).__dict__) def delete(self, apiclient): @@ -5046,7 +5042,7 @@ def create(cls, apiclient, services, vpcofferingid, [setattr(cmd, k, v) for k, v in list(kwargs.items())] return VPC(apiclient.createVPC(cmd).__dict__) - def update(self, apiclient, name=None, displaytext=None, **kwargs): + def update(self, apiclient, name=None, displaytext=None): """Updates VPC configurations""" cmd = updateVPC.updateVPCCmd() @@ -5055,8 +5051,7 @@ def update(self, apiclient, name=None, displaytext=None, **kwargs): cmd.name = name if displaytext: cmd.displaytext = displaytext - [setattr(cmd, k, v) for k, v in list(kwargs.items())] - return apiclient.updateVPC(cmd) + return (apiclient.updateVPC(cmd)) def migrate(self, apiclient, vpc_offering_id, vpc_network_offering_ids, resume=False): cmd = migrateVPC.migrateVPCCmd() diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index 222ac634a255..571f5f96faa3 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -1329,8 +1329,6 @@ "label.primary.storage.allocated": "Primary storage allocated", "label.primary.storage.used": "Primary storage used", "label.primarystoragelimit": "Primary storage limits (GiB)", -"label.primarystoragetotal": "Primary storage", -"label.privatemtu": "Private Interface MTU", "label.private.gateway": "Private gateway", "label.private.interface": "Private interface", "label.private.registry": "Private registry", @@ -1365,7 +1363,6 @@ "label.provisioningtype.fat": "Fat provisioning", "label.provisioningtype.sparse": "Sparse provisioning", "label.provisioningtype.thin": "Thin provisioning", -"label.publicmtu": "Public Interface MTU", "label.public.interface": "Public interface", "label.public.ip": "Public IP address", "label.public.ip.addresses": "Public IP addresses", @@ -2336,9 +2333,6 @@ "message.error.lun": "Please enter LUN #.", "message.error.macaddress": "Please enter a valid MAC Address.", "message.error.max.members.less.than.min.members": "The value of Max members must be larger than the value of Min members", -"message.error.mtu.below.min": "MTU is below the minimum supported value of %x", -"message.error.mtu.public.max.exceed": "The value entered exceeds the maximum allowed public MTU for this Zone, your value will be automatically lowered to match it.", -"message.error.mtu.private.max.exceed": "The value entered exceeds the maximum allowed private MTU for this Zone, your value will be automatically lowered to match it.", "message.error.name": "Please enter name.", "message.error.netmask": "Please enter Netmask.", "message.error.network.offering": "Please select network offering.", @@ -2750,7 +2744,6 @@ "message.vr.alert.upon.network.offering.creation.l2": "As virtual routers are not created for L2 networks, the compute offering will not be used.", "message.vr.alert.upon.network.offering.creation.others": "As none of the obligatory services for creating a virtual router (VPN, DHCP, DNS, Firewall, LB, UserData, SourceNat, StaticNat, PortForwarding) are enabled, the virtual router will not be created and the compute offering will not be used.", "message.warn.filetype": "jpg, jpeg, png, bmp and svg are the only supported image formats.", -"message.warn.zone.mtu.update": "Please note that this limit won't affect pre-existing network’s MTU settings", "message.zone.creation.complete": "Zone creation complete.", "message.zone.detail.description": "Populate zone details.", "message.zone.detail.hint": "A zone is the largest organizational unit in CloudStack, and it typically corresponds to a single datacenter. Zones provide physical isolation and redundancy. A zone consists of one or more pods (each of which contains hosts and primary storage servers) and a secondary storage server which is shared by all pods in the zone.", diff --git a/ui/src/components/view/DetailsTab.vue b/ui/src/components/view/DetailsTab.vue index ee5e0db38685..e58ea100fd7a 100644 --- a/ui/src/components/view/DetailsTab.vue +++ b/ui/src/components/view/DetailsTab.vue @@ -74,13 +74,6 @@
{{ ipV6Address }}
- -
- {{ $t('label.' + String(item).toLowerCase()) }} -
-
{{ dataResource[item] }}
-
-
@@ -135,7 +128,7 @@ export default { }, computed: { customDisplayItems () { - return ['ip6routes', 'privatemtu', 'publicmtu'] + return ['ip6routes'] }, ipV6Address () { if (this.dataResource.nic && this.dataResource.nic.length > 0) { diff --git a/ui/src/components/view/SettingsTab.vue b/ui/src/components/view/SettingsTab.vue index cddbe56b83a9..4c4e538c2f61 100644 --- a/ui/src/components/view/SettingsTab.vue +++ b/ui/src/components/view/SettingsTab.vue @@ -102,17 +102,7 @@ export default { editableValueKey: null, editableValue: '', tabLoading: false, - filter: '', - warningMessages: { - 'vr.private.interface.max.mtu': { - scope: 'zone', - warning: this.$t('message.warn.zone.mtu.update') - }, - 'vr.public.interface.max.mtu': { - scope: 'zone', - warning: this.$t('message.warn.zone.mtu.update') - } - } + filter: '' } }, created () { @@ -175,7 +165,7 @@ export default { value: this.editableValue }).then(() => { const message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.update.to')} ${this.editableValue}` - this.handleSuccessMessage(item.name, this.$route.meta.name, message) + this.$message.success(message) }).catch(error => { console.error(error) this.$message.error(this.$t('message.error.save.setting')) @@ -205,7 +195,7 @@ export default { name: item.name }).then(() => { const message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}` - this.handleSuccessMessage(item.name, this.$route.meta.name, message) + this.$message.success(message) }).catch(error => { console.error(error) this.$message.error(this.$t('message.error.reset.config')) @@ -219,14 +209,6 @@ export default { this.editableValueKey = null }) }) - }, - handleSuccessMessage (name, scope, message) { - var obj = this.warningMessages[name] - if (obj && obj.scope === scope) { - this.$warning({ title: message, content: obj.warning }) - } else { - this.$message.success(message) - } } } } diff --git a/ui/src/config/section/network.js b/ui/src/config/section/network.js index 9685fb058118..b83087396dcb 100644 --- a/ui/src/config/section/network.js +++ b/ui/src/config/section/network.js @@ -39,7 +39,7 @@ export default { return fields }, details: () => { - var fields = ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'egressdefaultpolicy', 'zonename', 'account', 'domain', 'associatednetwork', 'associatednetworkid', 'ip6firewall', 'ip6routing', 'ip6routes', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2', 'publicmtu', 'privatemtu'] + var fields = ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'egressdefaultpolicy', 'zonename', 'account', 'domain', 'associatednetwork', 'associatednetworkid', 'ip6firewall', 'ip6routing', 'ip6routes', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2'] if (!isAdmin()) { fields = fields.filter(function (e) { return e !== 'broadcasturi' }) } @@ -166,7 +166,7 @@ export default { permission: ['listVPCs'], resourceType: 'Vpc', columns: ['name', 'state', 'displaytext', 'cidr', 'account', 'zonename'], - details: ['name', 'id', 'displaytext', 'cidr', 'networkdomain', 'ip6routes', 'ispersistent', 'redundantvpcrouter', 'restartrequired', 'zonename', 'account', 'domain', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2', 'publicmtu'], + details: ['name', 'id', 'displaytext', 'cidr', 'networkdomain', 'ip6routes', 'ispersistent', 'redundantvpcrouter', 'restartrequired', 'zonename', 'account', 'domain', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2'], searchFilters: ['name', 'zoneid', 'domainid', 'account', 'tags'], related: [{ name: 'vm', @@ -200,7 +200,7 @@ export default { icon: 'edit-outlined', label: 'label.edit', dataView: true, - args: ['name', 'displaytext', 'publicmtu'] + args: ['name', 'displaytext'] }, { api: 'restartVPC', diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index abd29a737efa..f1ac57b7b964 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -1692,7 +1692,6 @@ export default { this.rules[field.name].push(rule) break case (this.currentAction.mapping && field.name in this.currentAction.mapping && 'options' in this.currentAction.mapping[field.name]): - console.log('op: ' + field) rule.required = field.required rule.message = this.$t('message.error.select') this.rules[field.name].push(rule) @@ -1703,20 +1702,17 @@ export default { this.rules[field.name].push(rule) break case (field.type === 'uuid'): - console.log('uuid: ' + field) rule.required = field.required rule.message = this.$t('message.error.select') this.rules[field.name].push(rule) break case (field.type === 'list'): - console.log('list: ' + field) rule.type = 'array' rule.required = field.required rule.message = this.$t('message.error.select') this.rules[field.name].push(rule) break case (field.type === 'long'): - console.log(field) rule.type = 'number' rule.required = field.required rule.message = this.$t('message.validate.number') @@ -1737,7 +1733,6 @@ export default { this.rules[field.name].push(rule) break default: - console.log('hererere') rule.required = field.required rule.message = this.$t('message.error.required.input') this.rules[field.name].push(rule) diff --git a/ui/src/views/network/CreateIsolatedNetworkForm.vue b/ui/src/views/network/CreateIsolatedNetworkForm.vue index c4b5fc83f38b..6ea2389880ab 100644 --- a/ui/src/views/network/CreateIsolatedNetworkForm.vue +++ b/ui/src/views/network/CreateIsolatedNetworkForm.vue @@ -104,38 +104,6 @@ - - - - - -
-
-
- - - - -
-
-
-
0) { params.domainid = this.selectedDomain.id if (this.isValidTextValueForKey(values, 'account')) { @@ -591,29 +541,6 @@ export default { this.formRef.value.scrollToField(error.errorFields[0].name) }) }, - updateMtu (isPublic) { - if (isPublic) { - if (this.form.publicmtu > this.publicMtuMax) { - this.errorPublicMtu = this.$t('message.error.mtu.public.max.exceed') - this.form.publicmtu = this.publicMtuMax - } else if (this.form.publicmtu < this.minMTU) { - this.errorPublicMtu = `${this.$t('message.error.mtu.below.min').replace('%x', this.minMTU)}` - this.form.publicmtu = this.minMTU - } else { - this.errorPublicMtu = '' - } - } else { - if (this.form.privatemtu > this.privateMtuMax) { - this.errorPrivateMtu = this.$t('message.error.mtu.private.max.exceed') - this.form.privatemtu = this.privateMtuMax - } else if (this.form.privatemtu < this.minMTU) { - this.errorPrivateMtu = `${this.$t('message.error.mtu.below.min').replace('%x', this.minMTU)}` - this.form.privatemtu = this.minMTU - } else { - this.errorPrivateMtu = '' - } - } - }, showInput () { this.inputVisible = true this.$nextTick(function () { diff --git a/ui/src/views/network/CreateSharedNetworkForm.vue b/ui/src/views/network/CreateSharedNetworkForm.vue index 6f4f61a4691e..1d26cf1b1efb 100644 --- a/ui/src/views/network/CreateSharedNetworkForm.vue +++ b/ui/src/views/network/CreateSharedNetworkForm.vue @@ -243,38 +243,6 @@ - - - - - -
-
-
- - - - -
-
-
-