Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ec4efbe
api,server: custom dns for guest network
shwstppr May 26, 2022
78ca1c8
wip
shwstppr Jun 2, 2022
436d1fa
refactor
shwstppr Jun 3, 2022
014e715
response and fix
shwstppr Jun 6, 2022
5876736
fix
shwstppr Jun 7, 2022
2902013
Merge branch 'main' into add-network-custom-dns
shwstppr Jun 7, 2022
d53e63a
merge
shwstppr Jun 7, 2022
38ccf7c
ui fix, test
shwstppr Jun 8, 2022
b99c535
test fix
shwstppr Jun 9, 2022
61afadb
shared network fix
shwstppr Jun 9, 2022
68311aa
test
shwstppr Jun 9, 2022
3b38519
unit test
shwstppr Jun 10, 2022
143884c
marvin test
shwstppr Jun 10, 2022
2f067e9
ipv6 network test
shwstppr Jun 13, 2022
5d23282
custom dns for vpc
shwstppr Jun 14, 2022
3358af2
fix missing license
shwstppr Jun 14, 2022
2eea48e
refactor
shwstppr Jun 15, 2022
14c2821
fix
shwstppr Jun 15, 2022
8792270
vpc changes
shwstppr Jun 16, 2022
3d912c3
refactor and tests
shwstppr Jun 16, 2022
0fd0954
test for NetworkOrchestrator
shwstppr Jun 17, 2022
7b79fa2
test teardown fix
shwstppr Jun 17, 2022
6a975d7
test cleanup append refactor
shwstppr Jun 20, 2022
0e77ad9
ipv6 vpc ui fix
shwstppr Jun 20, 2022
2a10c88
review comments, deduplication
shwstppr Jun 21, 2022
a2caee0
Merge branch 'main' into add-network-custom-dns
shwstppr Jun 27, 2022
864af38
Merge branch 'main' into add-network-custom-dns
shwstppr Jul 25, 2022
ee34f80
fix
shwstppr Jul 25, 2022
c1205c8
Merge branch 'main' into add-network-custom-dns
shwstppr Aug 9, 2022
1ea09bf
Merge branch 'main' into add-network-custom-dns
shwstppr Aug 25, 2022
c07191e
changes for update network dns
shwstppr Aug 25, 2022
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
10 changes: 10 additions & 0 deletions api/src/main/java/com/cloud/agent/api/to/NetworkTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class NetworkTO {
protected String ip6address;
protected String ip6gateway;
protected String ip6cidr;
protected String ip6Dns1;
protected String ip6Dns2;

public NetworkTO() {
}
Expand Down Expand Up @@ -221,4 +223,12 @@ public void setIsolationuri(URI isolationUri) {
public boolean isSecurityGroupEnabled() {
return this.isSecurityGroupEnabled;
}

public void setIp6Dns1(String ip6Dns1) {
this.ip6Dns1 = ip6Dns1;
}

public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}
}
8 changes: 8 additions & 0 deletions api/src/main/java/com/cloud/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,5 +483,13 @@ public void setIp6Address(String ip6Address) {

String getRouterIpv6();

String getDns1();

String getDns2();

String getIp6Dns1();

String getIp6Dns2();

Date getCreated();
}
16 changes: 13 additions & 3 deletions api/src/main/java/com/cloud/network/NetworkModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

package com.cloud.network;

import com.google.common.collect.ImmutableMap;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.cloudstack.framework.config.ConfigKey;

import com.cloud.dc.DataCenter;
import com.cloud.dc.Vlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InvalidParameterValueException;
Expand All @@ -39,10 +40,11 @@
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.Detail;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachine;
import org.apache.cloudstack.framework.config.ConfigKey;
import com.google.common.collect.ImmutableMap;

/**
* The NetworkModel presents a read-only view into the Network data such as L2 networks,
Expand Down Expand Up @@ -323,4 +325,12 @@ List<String[]> generateVmData(String userData, String serviceOffering, long data

String getValidNetworkCidr(Network guestNetwork);

Pair<String, String> getNetworkIp4Dns(final Network network, final DataCenter zone);

Pair<String, String> getNetworkIp6Dns(final Network network, final DataCenter zone);

void verifyIp4DnsPair(final String ip4Dns1, final String ip4Dns2);

void verifyIp6DnsPair(final String ip6Dns1, final String ip6Dns2);

}
22 changes: 22 additions & 0 deletions api/src/main/java/com/cloud/network/NetworkProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class NetworkProfile implements Network {
private final long domainId;
private String dns1;
private String dns2;
private String ip6Dns1;
private String ip6Dns2;
private URI broadcastUri;
private final State state;
private boolean isRedundant;
Expand Down Expand Up @@ -98,10 +100,12 @@ public NetworkProfile(Network network) {
externalId = network.getExternalId();
}

@Override
public String getDns1() {
return dns1;
}

@Override
public String getDns2() {
return dns2;
}
Expand All @@ -114,6 +118,24 @@ public void setDns2(String dns2) {
this.dns2 = dns2;
}

@Override
public String getIp6Dns1() {
return ip6Dns1;
}

@Override
public String getIp6Dns2() {
return ip6Dns2;
}

public void setIp6Dns1(String ip6Dns1) {
this.ip6Dns1 = ip6Dns1;
}

public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}

@Override
public String getGuruName() {
return guruName;
Expand Down
12 changes: 10 additions & 2 deletions api/src/main/java/com/cloud/network/vpc/Vpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
// under the License.
package com.cloud.network.vpc;

import java.util.Date;

import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

import java.util.Date;

public interface Vpc extends ControlledEntity, Identity, InternalIdentity {

public enum State {
Expand Down Expand Up @@ -95,4 +95,12 @@ public enum State {
void setRollingRestart(boolean rollingRestart);

Date getCreated();

String getIp4Dns1();

String getIp4Dns2();

String getIp6Dns1();

String getIp6Dns2();
}
5 changes: 4 additions & 1 deletion api/src/main/java/com/cloud/network/vpc/VpcService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Map;

import org.apache.cloudstack.api.command.user.vpc.CreatePrivateGatewayCmd;
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.RestartVPCCmd;
Expand All @@ -36,6 +37,7 @@

public interface VpcService {

public Vpc createVpc(CreateVPCCmd cmd) throws ResourceAllocationException;
/**
* Persists VPC record in the database
*
Expand All @@ -50,7 +52,8 @@ public interface VpcService {
* @return
* @throws ResourceAllocationException TODO
*/
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain, Boolean displayVpc)
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)
throws ResourceAllocationException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ 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.DNS1, type = CommandType.STRING, description = "the first IPv4 DNS for the network", since = "4.18.0")
private String ip4Dns1;

@Parameter(name = ApiConstants.DNS2, type = CommandType.STRING, description = "the second IPv4 DNS for the network", since = "4.18.0")
private String ip4Dns2;

@Parameter(name = ApiConstants.IP6_DNS1, type = CommandType.STRING, description = "the first IPv6 DNS for the network", since = "4.18.0")
private String ip6Dns1;

@Parameter(name = ApiConstants.IP6_DNS2, type = CommandType.STRING, description = "the second IPv6 DNS for the network", since = "4.18.0")
private String ip6Dns2;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -326,6 +338,22 @@ public Long getAclId() {
return aclId;
}

public String getIp4Dns1() {
return ip4Dns1;
}

public String getIp4Dns2() {
return ip4Dns2;
}

public String getIp6Dns1() {
return ip6Dns1;
}

public String getIp6Dns2() {
return ip6Dns2;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ public class UpdateNetworkCmd extends BaseAsyncCustomIdCmd implements UserCmd {
@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.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;

@Parameter(name = ApiConstants.DNS2, type = CommandType.STRING, description = "the second IPv4 DNS for the network. Empty string will update the second IPv4 DNS with the value from the zone", since = "4.18.0")
private String ip4Dns2;

@Parameter(name = ApiConstants.IP6_DNS1, type = CommandType.STRING, description = "the first IPv6 DNS for the network. Empty string will update the first IPv6 DNS with the value from the zone", since = "4.18.0")
private String ip6Dns1;

@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;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -136,6 +148,23 @@ public boolean getForced(){
}
return forced;
}

public String getIp4Dns1() {
return ip4Dns1;
}

public String getIp4Dns2() {
return ip4Dns2;
}

public String getIp6Dns1() {
return ip6Dns1;
}

public String getIp6Dns2() {
return ip6Dns2;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ 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.DNS1, type = CommandType.STRING, description = "the first IPv4 DNS for the VPC", since = "4.18.0")
private String ip4Dns1;

@Parameter(name = ApiConstants.DNS2, type = CommandType.STRING, description = "the second IPv4 DNS for the VPC", since = "4.18.0")
private String ip4Dns2;

@Parameter(name = ApiConstants.IP6_DNS1, type = CommandType.STRING, description = "the first IPv6 DNS for the VPC", since = "4.18.0")
private String ip6Dns1;

@Parameter(name = ApiConstants.IP6_DNS2, type = CommandType.STRING, description = "the second IPv6 DNS for the VPC", since = "4.18.0")
private String ip6Dns2;

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
Expand Down Expand Up @@ -131,6 +143,22 @@ public String getNetworkDomain() {
return networkDomain;
}

public String getIp4Dns1() {
return ip4Dns1;
}

public String getIp4Dns2() {
return ip4Dns2;
}

public String getIp6Dns1() {
return ip6Dns1;
}

public String getIp6Dns2() {
return ip6Dns2;
}

public boolean isStart() {
if (start != null) {
return start;
Expand All @@ -144,7 +172,7 @@ public Boolean getDisplayVpc() {

@Override
public void create() throws ResourceAllocationException {
Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(), getCidr(), getNetworkDomain(), getDisplayVpc());
Vpc vpc = _vpcService.createVpc(this);
if (vpc != null) {
setEntityId(vpc.getId());
setEntityUuid(vpc.getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
private String broadcastUri;

@SerializedName(ApiConstants.DNS1)
@Param(description = "the first DNS for the network")
@Param(description = "the first IPv4 DNS for the network")
private String dns1;

@SerializedName(ApiConstants.DNS2)
@Param(description = "the second DNS for the network")
@Param(description = "the second IPv4 DNS for the network")
private String dns2;

@SerializedName(ApiConstants.TYPE)
Expand Down Expand Up @@ -287,6 +287,14 @@ 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<Ipv6RouteResponse> ipv6Routes;

@SerializedName(ApiConstants.IP6_DNS1)
@Param(description = "the first IPv6 DNS for the network", since = "4.18.0")
private String ipv6Dns1;

@SerializedName(ApiConstants.IP6_DNS2)
@Param(description = "the second IPv6 DNS for the network", since = "4.18.0")
private String ipv6Dns2;

public NetworkResponse() {}

public Boolean getDisplayNetwork() {
Expand Down Expand Up @@ -586,4 +594,12 @@ public void setIpv6Routes(Set<Ipv6RouteResponse> ipv6Routes) {
public void addIpv6Route(Ipv6RouteResponse ipv6Route) {
this.ipv6Routes.add(ipv6Route);
}

public void setIpv6Dns1(String ipv6Dns1) {
this.ipv6Dns1 = ipv6Dns1;
}

public void setIpv6Dns2(String ipv6Dns2) {
this.ipv6Dns2 = ipv6Dns2;
}
}
Loading