Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2f50069
initial parameter organisation
DaanHoogland Jun 7, 2022
10e7b52
upgrade-path-fix
DaanHoogland Jun 8, 2022
055a9dd
add field to view
DaanHoogland Jun 8, 2022
b7db1fc
add router ip parameters to offerings
DaanHoogland Jun 16, 2022
2937941
add select snat ip option to offerings
DaanHoogland Jul 8, 2022
bc2d076
add SelectSnatIpAllowed to sourcenat capabilities
DaanHoogland Jul 11, 2022
a3aec15
sonar issues + tests
DaanHoogland Jul 11, 2022
427a3ea
label for select public source nat ip
DaanHoogland Jul 11, 2022
b129832
event handler fix
DaanHoogland Jul 12, 2022
9c28015
add select ip field
DaanHoogland Jul 12, 2022
1bf3c4a
fix add vpc offering
DaanHoogland Jul 13, 2022
7712a35
add routerip as valid field
DaanHoogland Jul 14, 2022
b189c84
router ips as parameters
DaanHoogland Jul 14, 2022
d13439a
sonarcloud stuff
DaanHoogland Jul 14, 2022
5a9733e
fix sql scripts
DaanHoogland Jan 16, 2023
9dce79b
renamings
DaanHoogland Jan 23, 2023
3cba1c7
logic of condition improved
DaanHoogland Feb 1, 2023
b3310e8
Update engine/schema/src/main/resources/META-INF/db/schema-41720to418…
NuxRo Feb 7, 2023
6cf7468
remove the requirement to have IP selection enabled by setting
DaanHoogland Feb 28, 2023
0924d35
address sonar warning: catch Throwable
DaanHoogland Feb 28, 2023
e683a1e
more revert and refactors, intermediate phase
DaanHoogland Mar 1, 2023
f525422
ip snat change for isolated nets v1
DaanHoogland Mar 6, 2023
4f9c419
fix update sourcenat on isguest nets
DaanHoogland Mar 27, 2023
5aea368
update source NAT IP for VPCs
DaanHoogland Mar 27, 2023
f518e2b
easy button switch of source NAT IP
DaanHoogland Mar 29, 2023
c90f3e4
addressing code smells
DaanHoogland Mar 29, 2023
30a5463
removed unused method
DaanHoogland Mar 30, 2023
18cc927
make SN for VPC button and error handling in UI
DaanHoogland Mar 31, 2023
7ceb34b
hasrules mechs to decide what IPs can be used
DaanHoogland Mar 31, 2023
b274354
labels and API cleanup
DaanHoogland Apr 4, 2023
d4a4b1a
merge-conflict+cleanup
DaanHoogland Apr 4, 2023
fbdd40b
unit tests
DaanHoogland Apr 5, 2023
d369924
case
DaanHoogland Apr 6, 2023
c823bed
validate routers and updateVpc unit tests
DaanHoogland Apr 6, 2023
d9a02ac
fix unit test
DaanHoogland Apr 6, 2023
8a685d8
Merge branch 'main' into selectPublicIp
DaanHoogland Apr 12, 2023
478477d
more unit tests
DaanHoogland Apr 13, 2023
f0520ad
reverse assertion condition creation
DaanHoogland Apr 14, 2023
dfcc213
review comments
DaanHoogland Apr 14, 2023
59d581f
Apply suggestions from code review
DaanHoogland Apr 25, 2023
edc7380
review/test outcomes
DaanHoogland Apr 27, 2023
e49a23d
integration tests
DaanHoogland May 1, 2023
1789a71
todo no longer valid
DaanHoogland May 1, 2023
3451f4d
warn network restart
DaanHoogland May 1, 2023
8745076
auto restart vpc and warn pop-up to user
DaanHoogland May 2, 2023
54e8e10
fix warning message and some minor issues
DaanHoogland May 2, 2023
c3bc8f9
integration test
DaanHoogland May 3, 2023
406a94a
javadoc
DaanHoogland May 3, 2023
0b8e080
bit of ui pollish
DaanHoogland May 3, 2023
9c6b92d
spello
DaanHoogland May 3, 2023
e8ebd71
spello
DaanHoogland May 3, 2023
6dbcee2
extra restart check
DaanHoogland May 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ jobs:
smoke/test_metrics_api
smoke/test_migration
smoke/test_multipleips_per_nic
smoke/test_nested_virtualization",
smoke/test_nested_virtualization
smoke/test_set_sourcenat",
"smoke/test_network
smoke/test_network_acl
smoke/test_network_ipv6
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static Provider getProvider(String providerName) {

public static class Capability {

private static List<Capability> supportedCapabilities = new ArrayList<Capability>();
private static List<Capability> supportedCapabilities = new ArrayList<>();

public static final Capability SupportedProtocols = new Capability("SupportedProtocols");
public static final Capability SupportedLBAlgorithms = new Capability("SupportedLbAlgorithms");
Expand Down
132 changes: 66 additions & 66 deletions api/src/main/java/com/cloud/network/vpc/VpcService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import org.apache.cloudstack.api.command.user.vpc.CreateVPCCmd;
import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd;
import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
import org.apache.cloudstack.api.command.user.vpc.ListVPCsCmd;
import org.apache.cloudstack.api.command.user.vpc.RestartVPCCmd;
import org.apache.cloudstack.api.command.user.vpc.UpdateVPCCmd;

import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
Expand All @@ -37,7 +39,6 @@

public interface VpcService {

public Vpc createVpc(CreateVPCCmd cmd) throws ResourceAllocationException;
/**
* Persists VPC record in the database
*
Expand All @@ -48,14 +49,25 @@ public interface VpcService {
* @param displayText
* @param cidr
* @param networkDomain TODO
* @param ip4Dns1
* @param ip4Dns2
* @param displayVpc TODO
* @return
* @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)
Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain,
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu)
throws ResourceAllocationException;

/**
* Persists VPC record in the database
*
* @param cmd the command with specification data for the new vpc
* @return a data object describing the new vpc
* @throws ResourceAllocationException the resources for this VPC cannot be allocated
*/
Vpc createVpc(CreateVPCCmd cmd) throws ResourceAllocationException;

/**
* Deletes a VPC
*
Expand All @@ -65,48 +77,48 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName
* @throws ResourceUnavailableException
* @throws ConcurrentOperationException
*/
public boolean deleteVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException;
boolean deleteVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException;

/**
* Persists VPC record in the database
*
* @param cmd the command with specification data for updating the vpc
* @return a data object describing the new vpc state
* @throws ResourceUnavailableException if during restart some resources may not be available
* @throws InsufficientCapacityException if for instance no address space, compute or storage is sufficiently available
*/
Vpc updateVpc(UpdateVPCCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;

/**
* Updates VPC with new name/displayText
*
* @param vpcId
* @param vpcName
* @param displayText
* @param customId TODO
* @param displayVpc TODO
* @param mtu
* @return
* @param vpcId the ID of the Vpc to update
* @param vpcName The new name to give the vpc
* @param displayText the new display text to use for describing the VPC
* @param customId A new custom (external) ID to associate this VPC with
* @param displayVpc should this VPC be displayed on public lists
* @param mtu what maximal transfer unit to us in this VPCs networks
* @param sourceNatIp the source NAT address to use for this VPC (must already be associated with the VPC)
* @return an object describing the current state of the VPC
* @throws ResourceUnavailableException if during restart some resources may not be available
* @throws InsufficientCapacityException if for instance no address space, compute or storage is sufficiently available
*/
public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc, Integer mtu);
Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc, Integer mtu, String sourceNatIp) throws ResourceUnavailableException, InsufficientCapacityException;

/**
* Lists VPC(s) based on the parameters passed to the method call
* Lists VPC(s) based on the parameters passed to the API call
*
* @param id
* @param vpcName
* @param displayText
* @param supportedServicesStr
* @param cidr
* @param state TODO
* @param accountName
* @param domainId
* @param keyword
* @param startIndex
* @param pageSizeVal
* @param zoneId TODO
* @param isRecursive TODO
* @param listAll TODO
* @param restartRequired TODO
* @param tags TODO
* @param projectId TODO
* @param display TODO
* @param vpc
* @return
* @param cmd object containing the search specs
* @return the List of VPCs
*/
public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, String displayText, List<String> supportedServicesStr, String cidr, Long vpcOffId, String state,
String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
Map<String, String> tags, Long projectId, Boolean display);
Pair<List<? extends Vpc>, Integer> listVpcs(ListVPCsCmd cmd);

/**
* Lists VPC(s) based on the parameters passed to the method call
*/
Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, String displayText, List<String> supportedServicesStr, String cidr, Long vpcOffId, String state,
String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
Map<String, String> tags, Long projectId, Boolean display);

/**
* Starts VPC which includes starting VPC provider and applying all the networking rules on the backend
Expand All @@ -130,17 +142,17 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
*/
boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException;

boolean restartVpc(RestartVPCCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;

/**
* Restarts the VPC. VPC gets shutdown and started as a part of it
*
* @param id
* @param cleanUp
* @param makeredundant
* @return
* @throws InsufficientCapacityException
* @param networkId the network to restart
* @param cleanup throw away the existing VR and rebuild a new one?
* @param makeRedundant create two VRs for this network
* @return success or not
* @throws InsufficientCapacityException when there is no suitable deployment plan possible
*/
boolean restartVpc(RestartVPCCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;

boolean restartVpc(Long networkId, boolean cleanup, boolean makeRedundant, boolean livePatch, User user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;

/**
Expand All @@ -154,23 +166,12 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
/**
* Persists VPC private gateway in the Database.
*
*
* @param vpcId TODO
* @param physicalNetworkId
* @param vlan
* @param ipAddress
* @param gateway
* @param netmask
* @param gatewayOwnerId
* @param networkOfferingId
* @param isSourceNat
* @param aclId
* @return
* @return data object describing the private gateway
* @throws InsufficientCapacityException
* @throws ConcurrentOperationException
* @throws ResourceAllocationException
*/
public PrivateGateway createVpcPrivateGateway(CreatePrivateGatewayCmd command) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
PrivateGateway createVpcPrivateGateway(CreatePrivateGatewayCmd command) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;

/**
* Applies VPC private gateway on the backend, so it becomes functional
Expand All @@ -181,12 +182,12 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
* @throws ResourceUnavailableException
* @throws ConcurrentOperationException
*/
public PrivateGateway applyVpcPrivateGateway(long gatewayId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException;
PrivateGateway applyVpcPrivateGateway(long gatewayId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException;

/**
* Deletes VPC private gateway
*
* @param id
* @param gatewayId
* @return
* @throws ResourceUnavailableException
* @throws ConcurrentOperationException
Expand All @@ -199,7 +200,7 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
* @param listPrivateGatewaysCmd
* @return
*/
public Pair<List<PrivateGateway>, Integer> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd);
Pair<List<PrivateGateway>, Integer> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd);

/**
* Returns Static Route found by Id
Expand All @@ -216,7 +217,7 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
* @return
* @throws ResourceUnavailableException
*/
public boolean applyStaticRoutesForVpc(long vpcId) throws ResourceUnavailableException;
boolean applyStaticRoutesForVpc(long vpcId) throws ResourceUnavailableException;

/**
* Deletes static route from the backend and the database
Expand All @@ -225,7 +226,7 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
* @return TODO
* @throws ResourceUnavailableException
*/
public boolean revokeStaticRoute(long routeId) throws ResourceUnavailableException;
boolean revokeStaticRoute(long routeId) throws ResourceUnavailableException;

/**
* Persists static route entry in the Database
Expand All @@ -234,15 +235,15 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
* @param cidr
* @return
*/
public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException;
StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException;

/**
* Lists static routes based on parameters passed to the call
*
* @param listStaticRoutesCmd
* @param cmd Command object with parameters for { @see ListStaticRoutesCmd }
* @return
*/
public Pair<List<? extends StaticRoute>, Integer> listStaticRoutes(ListStaticRoutesCmd cmd);
Pair<List<? extends StaticRoute>, Integer> listStaticRoutes(ListStaticRoutesCmd cmd);

/**
* Associates IP address from the Public network, to the VPC
Expand All @@ -262,6 +263,5 @@ IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationExcep
* @param routeId
* @return
*/
public boolean applyStaticRoute(long routeId) throws ResourceUnavailableException;

boolean applyStaticRoute(long routeId) throws ResourceUnavailableException;
}
4 changes: 4 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,10 @@ public class ApiConstants {
public static final String AUTO_ENABLE_KVM_HOST = "autoenablekvmhost";
public static final String LIST_APIS = "listApis";

public static final String SOURCE_NAT_IP = "sourcenatipaddress";
public static final String SOURCE_NAT_IP_ID = "sourcenatipaddressid";
public static final String HAS_RULES = "hasrules";

/**
* This enum specifies IO Drivers, each option controls specific policies on I/O.
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public String getCommandName() {
@Override
public void execute() {
Pair<List<? extends IpAddress>, Integer> result = _mgr.searchForIPAddresses(this);
ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
ListResponse<IPAddressResponse> response = new ListResponse<>();
List<IPAddressResponse> ipAddrResponses = new ArrayList<>();
for (IpAddress ipAddress : result.first()) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(getResponseView(), ipAddress);
ipResponse.setObjectName("publicipaddress");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.network;

import com.cloud.network.NetworkService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

import org.apache.cloudstack.acl.RoleType;
Expand All @@ -43,10 +43,10 @@
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.network.Network;
import com.cloud.network.NetworkService;
import com.cloud.network.Network.GuestType;
import com.cloud.offering.NetworkOffering;
import com.cloud.utils.net.NetUtils;
import org.apache.commons.lang3.StringUtils;

@APICommand(name = "createNetwork", description = "Creates a network", responseObject = NetworkResponse.class, responseView = ResponseView.Restricted, entityType = {Network.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
Expand Down Expand Up @@ -183,6 +183,14 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd {
@Parameter(name = ApiConstants.IP6_DNS2, type = CommandType.STRING, description = "the second IPv6 DNS for the network", since = "4.18.0")
private String ip6Dns2;

@Parameter(name = ApiConstants.SOURCE_NAT_IP,
type = CommandType.STRING,
description = "IPV4 address to be assigned to the public interface of the network router. " +
"This address will be used as source NAT address for the network. " +
"\nIf an address is given and it cannot be acquired, an error will be returned and the network won´t be implemented,",
since = "4.19")
private String sourceNatIP;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -266,6 +274,10 @@ public String getTungstenVirtualRouterUuid() {
return tungstenVirtualRouterUuid;
}

public String getSourceNatIP() {
return sourceNatIP;
}

@Override
public boolean isDisplay() {
if(displayNetwork == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public class UpdateNetworkCmd extends BaseAsyncCustomIdCmd implements UserCmd {
@Parameter(name = ApiConstants.IP6_DNS2, type = CommandType.STRING, description = "the second IPv6 DNS for the network. Empty string will update the second IPv6 DNS with the value from the zone", since = "4.18.0")
private String ip6Dns2;

@Parameter(name = ApiConstants.SOURCE_NAT_IP, type = CommandType.STRING, description = "IPV4 address to be assigned to the public interface of the network router. This address must already be acquired for this network", since = "4.19")
private String sourceNatIP;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -181,6 +184,10 @@ public String getIp6Dns2() {
return ip6Dns2;
}

public String getSourceNatIP() {
return sourceNatIP;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Loading