mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
sdn hosted vpc gateways (using lswitch)
This commit is contained in:
parent
62b0ad03c8
commit
2614b00c51
@ -26,7 +26,7 @@ public class IpAddressTO {
|
||||
private boolean add;
|
||||
private boolean oneToOneNat;
|
||||
private boolean firstIP;
|
||||
private String vlanId;
|
||||
private String broadcastUri;
|
||||
private String vlanGateway;
|
||||
private String vlanNetmask;
|
||||
private String vifMacAddress;
|
||||
@ -34,14 +34,14 @@ public class IpAddressTO {
|
||||
private TrafficType trafficType;
|
||||
private String networkName;
|
||||
|
||||
public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String vlanId,
|
||||
public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String broadcastUri,
|
||||
String vlanGateway, String vlanNetmask, String vifMacAddress, Integer networkRate, boolean isOneToOneNat) {
|
||||
this.accountId = accountId;
|
||||
this.publicIp = ipAddress;
|
||||
this.add = add;
|
||||
this.firstIP = firstIP;
|
||||
this.sourceNat = sourceNat;
|
||||
this.vlanId = vlanId;
|
||||
this.broadcastUri = broadcastUri;
|
||||
this.vlanGateway = vlanGateway;
|
||||
this.vlanNetmask = vlanNetmask;
|
||||
this.vifMacAddress = vifMacAddress;
|
||||
@ -97,8 +97,8 @@ public class IpAddressTO {
|
||||
return sourceNat;
|
||||
}
|
||||
|
||||
public String getVlanId() {
|
||||
return vlanId;
|
||||
public String getBroadcastUri() {
|
||||
return broadcastUri;
|
||||
}
|
||||
|
||||
public String getVlanGateway() {
|
||||
|
||||
@ -163,6 +163,10 @@ public class NetworkTO {
|
||||
}
|
||||
|
||||
public void setBroadcastUri(URI broadcastUri) {
|
||||
// only do this if the scheme needs aligning with the broadcastUri
|
||||
if(broadcastUri != null && getBroadcastType() == null) {
|
||||
setBroadcastType(BroadcastDomainType.getSchemeValue(broadcastUri));
|
||||
}
|
||||
this.broadcastUri = broadcastUri;
|
||||
}
|
||||
|
||||
|
||||
@ -19,11 +19,12 @@ package com.cloud.network;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.*;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -34,6 +35,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.GuestVlan;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -156,7 +158,7 @@ public interface NetworkService {
|
||||
* @param networkName
|
||||
* @param displayText
|
||||
* @param physicalNetworkId
|
||||
* @param vlan
|
||||
* @param broadcastUri TODO set the guru name based on the broadcastUri?
|
||||
* @param startIp
|
||||
* @param endIP TODO
|
||||
* @param gateway
|
||||
@ -169,8 +171,8 @@ public interface NetworkService {
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceAllocationException
|
||||
*/
|
||||
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
|
||||
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
|
||||
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String broadcastUri,
|
||||
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId)
|
||||
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
|
||||
|
||||
/* Requests an IP address for the guest nic */
|
||||
|
||||
@ -181,6 +181,7 @@ public class Networks {
|
||||
* @return the value of this
|
||||
*/
|
||||
public static BroadcastDomainType toEnumValue(String scheme) {
|
||||
// scheme might be null and some of the enumvalue.scheme are as well, so
|
||||
if (scheme == null) {
|
||||
return UnDecided;
|
||||
}
|
||||
@ -242,7 +243,7 @@ public class Networks {
|
||||
try {
|
||||
URI uri = new URI(candidate);
|
||||
BroadcastDomainType tiep = getSchemeValue(uri);
|
||||
if (tiep.scheme.equals(uri.getScheme())) {
|
||||
if (tiep.scheme != null && tiep.scheme.equals(uri.getScheme())) {
|
||||
return uri;
|
||||
} else {
|
||||
throw new CloudRuntimeException("string '" + candidate + "' has an unknown BroadcastDomainType.");
|
||||
|
||||
@ -26,7 +26,7 @@ public interface PrivateIp {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getVlanTag();
|
||||
String getBroadcastUri();
|
||||
|
||||
/**
|
||||
* @return
|
||||
|
||||
@ -41,7 +41,7 @@ public class StaticRouteProfile implements StaticRoute {
|
||||
this.gatewayId = staticRoute.getVpcGatewayId();
|
||||
this.state = staticRoute.getState();
|
||||
this.vpcId = staticRoute.getVpcId();
|
||||
this.vlanTag = gateway.getVlanTag();
|
||||
this.vlanTag = gateway.getBroadcastUri();
|
||||
this.gateway = gateway.getGateway();
|
||||
this.netmask = gateway.getNetmask();
|
||||
this.ipAddress = gateway.getIp4Address();
|
||||
|
||||
@ -71,7 +71,7 @@ public interface VpcGateway extends Identity, ControlledEntity, InternalIdentity
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getVlanTag();
|
||||
String getBroadcastUri();
|
||||
|
||||
/**
|
||||
* @return
|
||||
|
||||
@ -150,6 +150,7 @@ public interface VpcService {
|
||||
* @param gateway
|
||||
* @param netmask
|
||||
* @param gatewayOwnerId
|
||||
* @param networkOfferingId
|
||||
* @param isSourceNat
|
||||
* @param aclId
|
||||
* @return
|
||||
@ -157,7 +158,7 @@ public interface VpcService {
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceAllocationException
|
||||
*/
|
||||
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId,
|
||||
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId, Long networkOfferingId,
|
||||
Boolean isSoruceNat, Long aclId) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
|
||||
@ -27,6 +27,7 @@ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
@ -64,8 +65,12 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
|
||||
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, required=true, description="the IP address of the Private gateaway")
|
||||
private String ipAddress;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, required=true, description="the Vlan for the private gateway")
|
||||
private String vlan;
|
||||
@Parameter(name = ApiConstants.VLAN, type = CommandType.STRING, required = true, description = "the network implementation uri for the private gateway")
|
||||
private String broadcastUri;
|
||||
|
||||
@Parameter(name = ApiConstants.NETWORK_OFFERING_ID, type = CommandType.UUID, required = false, entityType = NetworkOfferingResponse.class,
|
||||
description = "the uuid of the network offering to use for the private gateways network connection")
|
||||
private Long networkOfferingId;
|
||||
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType = VpcResponse.class,
|
||||
required=true, description="the VPC network belongs to")
|
||||
@ -89,8 +94,8 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
public String getBroadcastUri() {
|
||||
return broadcastUri;
|
||||
}
|
||||
|
||||
public String getNetmask() {
|
||||
@ -105,6 +110,10 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
private Long getNetworkOfferingId() {
|
||||
return networkOfferingId;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
@ -135,7 +144,7 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
|
||||
PrivateGateway result = null;
|
||||
try {
|
||||
result = _vpcService.createVpcPrivateGateway(getVpcId(), getPhysicalNetworkId(),
|
||||
getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(), getIsSourceNat(), getAclId());
|
||||
getBroadcastUri(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(), getNetworkOfferingId(), getIsSourceNat(), getAclId());
|
||||
} catch (InsufficientCapacityException ex){
|
||||
s_logger.info(ex);
|
||||
s_logger.trace(ex);
|
||||
|
||||
@ -45,8 +45,8 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
|
||||
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the zone the private gateway belongs to")
|
||||
private String zoneName;
|
||||
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the vlan of the private gateway")
|
||||
private String vlan;
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the network implementation uri for the private gateway")
|
||||
private String broadcastUri;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the private gateaway belongs to")
|
||||
private String vpcId;
|
||||
@ -105,8 +105,8 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public void setVlan(String vlan) {
|
||||
this.vlan = vlan;
|
||||
public void setBroadcastUri(String broadcastUri) {
|
||||
this.broadcastUri = broadcastUri;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.junit.Assert;
|
||||
@ -24,6 +25,7 @@ import org.junit.Test;
|
||||
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
/**
|
||||
* @author dhoogland
|
||||
@ -49,13 +51,10 @@ public class NetworksTest {
|
||||
Long value2 = 2L;
|
||||
String uri2 = BroadcastDomainType.Vlan.toUri(value2).toString();
|
||||
BroadcastDomainType type1 = BroadcastDomainType.getTypeOf(uri1);
|
||||
BroadcastDomainType type2 = BroadcastDomainType.getTypeOf(uri2);
|
||||
String id1 = BroadcastDomainType.getValue(uri1);
|
||||
String id2 = BroadcastDomainType.getValue(uri2);
|
||||
Assert.assertEquals("uri1 should be of broadcasttype vlan",
|
||||
BroadcastDomainType.Vlan, type1);
|
||||
Assert.assertEquals("uri2 should be of broadcasttype vlan",
|
||||
BroadcastDomainType.Vlan, type2);
|
||||
Assert.assertEquals("id1 should be \"1\"", "1", id1);
|
||||
Assert.assertEquals("id2 should be \"2\"", "2", id2);
|
||||
}
|
||||
@ -71,17 +70,44 @@ public class NetworksTest {
|
||||
|
||||
@Test
|
||||
public void otherTypesTest() throws URISyntaxException {
|
||||
String bogeyUri = "lswitch://1";
|
||||
String bogeyUri = "lswitch://0";
|
||||
String uri1 = "lswitch:1";
|
||||
String uri2 = "mido://2";
|
||||
BroadcastDomainType type1 = BroadcastDomainType.getTypeOf(bogeyUri);
|
||||
BroadcastDomainType type2 = BroadcastDomainType.getTypeOf(uri2);
|
||||
String id1 = BroadcastDomainType.getValue(bogeyUri);
|
||||
String id2 = BroadcastDomainType.getValue(uri2);
|
||||
Assert.assertEquals("uri1 should be of broadcasttype lswitch",
|
||||
BroadcastDomainType.Lswitch, type1);
|
||||
Assert.assertEquals("uri2 should be of broadcasttype mido",
|
||||
BroadcastDomainType.Mido, type2);
|
||||
Assert.assertEquals("id1 should be \"//1\"", "//1", id1);
|
||||
Assert.assertEquals("id1 should be \"2\"", "2", id2);
|
||||
BroadcastDomainType type = BroadcastDomainType.getTypeOf(bogeyUri);
|
||||
String id = BroadcastDomainType.getValue(bogeyUri);
|
||||
Assert.assertEquals("uri0 should be of broadcasttype vlan",
|
||||
BroadcastDomainType.Lswitch, type);
|
||||
Assert.assertEquals("id0 should be \"//0\"", "//0", id);
|
||||
type = BroadcastDomainType.getTypeOf(uri1);
|
||||
id = BroadcastDomainType.getValue(uri1);
|
||||
Assert.assertEquals("uri1 should be of broadcasttype vlan",
|
||||
BroadcastDomainType.Lswitch, type);
|
||||
Assert.assertEquals("id1 should be \"1\"", "1", id);
|
||||
type = BroadcastDomainType.getTypeOf(uri2);
|
||||
id = BroadcastDomainType.getValue(uri2);
|
||||
Assert.assertEquals("uri2 should be of broadcasttype vlan",
|
||||
BroadcastDomainType.Mido, type);
|
||||
Assert.assertEquals("id2 should be \"2\"", "2", id);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidTypesTest() throws URISyntaxException {
|
||||
String uri1 = "https://1";
|
||||
String uri2 = "bla:0";
|
||||
BroadcastDomainType type = BroadcastDomainType.getTypeOf(uri1);
|
||||
try {
|
||||
/* URI result = */ BroadcastDomainType.fromString(uri1);
|
||||
} catch (CloudRuntimeException e) {
|
||||
Assert.assertEquals("unexpected parameter exception",
|
||||
"string 'https://1' has an unknown BroadcastDomainType.",
|
||||
e.getMessage());
|
||||
}
|
||||
try {
|
||||
/* URI result = */ BroadcastDomainType.fromString(uri2);
|
||||
} catch (CloudRuntimeException e) {
|
||||
Assert.assertEquals("unexpected parameter exception",
|
||||
"string 'bla:0' has an unknown BroadcastDomainType.",
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,28 @@
|
||||
// under the License.
|
||||
package com.cloud.agent.resource.virtualnetwork;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
@ -69,27 +91,6 @@ import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.utils.script.OutputInterpreter;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SshHelper;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* VirtualNetworkResource controls and configures virtual networking
|
||||
@ -267,7 +268,6 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
return new SetFirewallRulesAnswer(cmd, true, null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Answer execute(SetPortForwardingRulesCommand cmd) {
|
||||
@ -439,8 +439,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
String[][] rules = cfgtr.generateFwRules(cmd);
|
||||
if (routerIp != null) {
|
||||
tmpCfgFile = File.createTempFile(routerIp.replace('.', '_'), "cfg");
|
||||
final PrintWriter out
|
||||
= new PrintWriter(new BufferedWriter(new FileWriter(tmpCfgFile)));
|
||||
final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(tmpCfgFile)));
|
||||
for (int i = 0; i < config.length; i++) {
|
||||
out.println(config[i]);
|
||||
}
|
||||
@ -492,12 +491,13 @@ public class VirtualRoutingResource implements Manager {
|
||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
for (IpAddressTO ip : ips) {
|
||||
result = assignPublicIpAddress(routerName, routerIp, ip.getPublicIp(), ip.isAdd(),
|
||||
ip.isFirstIP(), ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(), ip.getVlanNetmask(),
|
||||
ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(), ip.getVlanGateway(), ip.getVlanNetmask(),
|
||||
ip.getVifMacAddress(), 2, false);
|
||||
if (result != null) {
|
||||
results[i++] = IpAssocAnswer.errorResult;
|
||||
} else {
|
||||
results[i++] = ip.getPublicIp() + " - success";;
|
||||
results[i++] = ip.getPublicIp() + " - success";
|
||||
;
|
||||
}
|
||||
}
|
||||
return new IpAssocAnswer(cmd, results);
|
||||
@ -642,7 +642,6 @@ public class VirtualRoutingResource implements Manager {
|
||||
return routerProxyWithParser("checkrouter.sh", routerIP, null);
|
||||
}
|
||||
|
||||
|
||||
public String routerProxyWithParser(String script, String routerIP, String args) {
|
||||
final Script command = new Script(_routerProxyPath, _timeout, s_logger);
|
||||
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
||||
@ -815,9 +814,6 @@ public class VirtualRoutingResource implements Manager {
|
||||
return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String savePassword(final String privateIpAddress, final String vmIpAddress, final String password, final String localPath) {
|
||||
final Script command = new Script(_savepasswordPath, _startTimeout, s_logger);
|
||||
command.add("-r", privateIpAddress);
|
||||
@ -966,11 +962,10 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String assignPublicIpAddress(final String vmName,
|
||||
final String privateIpAddress, final String publicIpAddress,
|
||||
final boolean add, final boolean firstIP, final boolean sourceNat,
|
||||
final String vlanId, final String vlanGateway,
|
||||
final String broadcastUri, final String vlanGateway,
|
||||
final String vlanNetmask, final String vifMacAddress, int nicNum, boolean newNic) {
|
||||
|
||||
String args = "";
|
||||
@ -1181,7 +1176,6 @@ public class VirtualRoutingResource implements Manager {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String connect(final String ipAddress) {
|
||||
return connect(ipAddress, _port);
|
||||
}
|
||||
@ -1207,7 +1201,8 @@ public class VirtualRoutingResource implements Manager {
|
||||
if (sch != null) {
|
||||
try {
|
||||
sch.close();
|
||||
} catch (final IOException e) {}
|
||||
} catch (final IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
@ -1221,7 +1216,6 @@ public class VirtualRoutingResource implements Manager {
|
||||
return "Unable to connect";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
@ -1232,7 +1226,6 @@ public class VirtualRoutingResource implements Manager {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
@ -1269,5 +1262,3 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long> , StateDao<State
|
||||
|
||||
List<NetworkVO> listByVpc(long vpcId);
|
||||
|
||||
NetworkVO getPrivateNetwork(String broadcastUri, String cidr, long accountId, long zoneId);
|
||||
NetworkVO getPrivateNetwork(String broadcastUri, String cidr, long accountId, long zoneId, Long networkOfferingId);
|
||||
|
||||
long countVpcNetworks(long vpcId);
|
||||
|
||||
|
||||
@ -562,13 +562,16 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
|
||||
|
||||
@Override
|
||||
public NetworkVO getPrivateNetwork(String broadcastUri, String cidr, long accountId, long zoneId) {
|
||||
public NetworkVO getPrivateNetwork(String broadcastUri, String cidr, long accountId, long zoneId, Long networkOfferingId) {
|
||||
if (networkOfferingId == null) {
|
||||
networkOfferingId = _ntwkOffDao.findByUniqueName(NetworkOffering.SystemPrivateGatewayNetworkOffering).getId();
|
||||
}
|
||||
SearchCriteria<NetworkVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("datacenter", zoneId);
|
||||
sc.setParameters("broadcastUri", broadcastUri);
|
||||
sc.setParameters("cidr", cidr);
|
||||
sc.setParameters("account", accountId);
|
||||
sc.setParameters("offering", _ntwkOffDao.findByUniqueName(NetworkOffering.SystemPrivateGatewayNetworkOffering).getId());
|
||||
sc.setParameters("offering", networkOfferingId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ public class VpcGatewayVO implements VpcGateway {
|
||||
String netmask;
|
||||
|
||||
@Column(name="vlan_tag")
|
||||
String vlanTag;
|
||||
String broadcastUri;
|
||||
|
||||
@Column(name = "type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@ -102,7 +102,7 @@ public class VpcGatewayVO implements VpcGateway {
|
||||
* @param vpcId
|
||||
* @param zoneId
|
||||
* @param networkId
|
||||
* @param vlanTag TODO
|
||||
* @param broadcastUri TODO
|
||||
* @param gateway TODO
|
||||
* @param netmask TODO
|
||||
* @param accountId TODO
|
||||
@ -110,14 +110,14 @@ public class VpcGatewayVO implements VpcGateway {
|
||||
* @param account_id
|
||||
* @param sourceNat
|
||||
*/
|
||||
public VpcGatewayVO(String ip4Address, Type type, long vpcId, long zoneId, long networkId, String vlanTag,
|
||||
public VpcGatewayVO(String ip4Address, Type type, long vpcId, long zoneId, long networkId, String broadcastUri,
|
||||
String gateway, String netmask, long accountId, long domainId, boolean sourceNat, long networkACLId) {
|
||||
this.ip4Address = ip4Address;
|
||||
this.type = type;
|
||||
this.vpcId = vpcId;
|
||||
this.zoneId = zoneId;
|
||||
this.networkId = networkId;
|
||||
this.vlanTag = vlanTag;
|
||||
this.broadcastUri = broadcastUri;
|
||||
this.gateway = gateway;
|
||||
this.netmask = netmask;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
@ -182,8 +182,8 @@ public class VpcGatewayVO implements VpcGateway {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVlanTag() {
|
||||
return vlanTag;
|
||||
public String getBroadcastUri() {
|
||||
return broadcastUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -106,7 +106,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
_upgradeMap.put("2.2.1", new DbUpgrade[] {new Upgrade221to222(), new UpgradeSnapshot223to224(), new Upgrade222to224(),
|
||||
new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(),
|
||||
new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(),
|
||||
new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(),
|
||||
new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.2", new DbUpgrade[] {new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(),
|
||||
new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
|
||||
@ -134,7 +135,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
|
||||
_upgradeMap.put("2.2.7", new DbUpgrade[] {new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
|
||||
new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(),
|
||||
new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(),
|
||||
new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.8", new DbUpgrade[] {new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(),
|
||||
new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30()
|
||||
@ -145,7 +147,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.10", new DbUpgrade[] {new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(),
|
||||
new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(),
|
||||
new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.11", new DbUpgrade[] {new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(),
|
||||
new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
@ -159,9 +162,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
_upgradeMap.put("2.2.14", new DbUpgrade[] {new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
|
||||
new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
|
||||
|
||||
_upgradeMap.put("3.0.0", new DbUpgrade[] { new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("3.0.0", new DbUpgrade[] {new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(),
|
||||
new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("3.0.1", new DbUpgrade[] {new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
@ -175,12 +177,16 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
|
||||
_upgradeMap.put("4.1.0", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("4.1.1", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("4.2.0", new DbUpgrade[] {new Upgrade420to430()});
|
||||
|
||||
//CP Upgrades
|
||||
_upgradeMap.put("3.0.3", new DbUpgrade[] { new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("3.0.3", new DbUpgrade[] {new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(),
|
||||
new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("3.0.4", new DbUpgrade[] { new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("3.0.4", new DbUpgrade[] {new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(),
|
||||
new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("3.0.5", new DbUpgrade[] {new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
@ -189,10 +195,12 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
_upgradeMap.put("3.0.7", new DbUpgrade[] {new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.15", new DbUpgrade[] {new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
|
||||
new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(),new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(),
|
||||
new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.16", new DbUpgrade[] {new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
|
||||
new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(),new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(),
|
||||
new Upgrade420to430()});
|
||||
}
|
||||
|
||||
protected void runScript(Connection conn, File file) {
|
||||
@ -225,8 +233,10 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
}
|
||||
|
||||
if (Version.compare(trimmedCurrentVersion, upgrades[upgrades.length - 1].getUpgradedVersion()) != 0) {
|
||||
s_logger.error("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion() + " but our management server code version is at " + currentVersion);
|
||||
throw new CloudRuntimeException("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion() + " but our management server code version is at "
|
||||
s_logger.error("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion() + " but our management server code version is at "
|
||||
+ currentVersion);
|
||||
throw new CloudRuntimeException("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion()
|
||||
+ " but our management server code version is at "
|
||||
+ currentVersion);
|
||||
}
|
||||
|
||||
@ -241,11 +251,13 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
if (!supportsRollingUpgrade && false) { // FIXME: Needs to detect if there are management servers running
|
||||
// ClusterManagerImpl.arePeersRunning(null)) {
|
||||
s_logger.error("Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running");
|
||||
throw new CloudRuntimeException("Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running");
|
||||
throw new CloudRuntimeException(
|
||||
"Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running");
|
||||
}
|
||||
|
||||
for (DbUpgrade upgrade : upgrades) {
|
||||
s_logger.debug("Running upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + upgrade.getUpgradableVersionRange()[1]
|
||||
s_logger.debug("Running upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-"
|
||||
+ upgrade.getUpgradableVersionRange()[1]
|
||||
+ " to " + upgrade.getUpgradedVersion());
|
||||
Transaction txn = Transaction.open("Upgrade");
|
||||
txn.start();
|
||||
|
||||
@ -54,7 +54,6 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
// Set the domr scripts directory
|
||||
params.put("domr.scripts.dir", "scripts/network/domr/kvm");
|
||||
|
||||
|
||||
String networkScriptsDir = (String)params.get("network.scripts.dir");
|
||||
if (networkScriptsDir == null) {
|
||||
networkScriptsDir = "scripts/vm/network/vnet";
|
||||
|
||||
@ -1720,15 +1720,15 @@ ServerResource {
|
||||
return new Answer(cmd, true, result);
|
||||
}
|
||||
|
||||
private void VifHotPlug(Connect conn, String vmName, String vlanId,
|
||||
private void VifHotPlug(Connect conn, String vmName, String broadcastUri,
|
||||
String macAddr) throws InternalErrorException, LibvirtException {
|
||||
NicTO nicTO = new NicTO();
|
||||
nicTO.setMac(macAddr);
|
||||
nicTO.setType(TrafficType.Public);
|
||||
if (vlanId == null) {
|
||||
if (broadcastUri == null) {
|
||||
nicTO.setBroadcastType(BroadcastDomainType.Native);
|
||||
} else {
|
||||
URI uri = BroadcastDomainType.fromString(vlanId);
|
||||
URI uri = BroadcastDomainType.fromString(broadcastUri);
|
||||
nicTO.setBroadcastType(BroadcastDomainType.getSchemeValue(uri));
|
||||
nicTO.setBroadcastUri(uri);
|
||||
}
|
||||
@ -1908,7 +1908,7 @@ ServerResource {
|
||||
try {
|
||||
conn = LibvirtConnection.getConnectionByVmName(routerName);
|
||||
Integer devNum = 0;
|
||||
String pubVlan = pubIP.getVlanId();
|
||||
String pubVlan = pubIP.getBroadcastUri();
|
||||
List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
|
||||
|
||||
for (InterfaceDef pluggedNic : pluggedNics) {
|
||||
@ -1972,7 +1972,7 @@ ServerResource {
|
||||
}
|
||||
|
||||
for (IpAddressTO ip : ips) {
|
||||
String nicName = "eth" + vlanToNicNum.get(ip.getVlanId());
|
||||
String nicName = "eth" + vlanToNicNum.get(ip.getBroadcastUri());
|
||||
String netmask = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
|
||||
String subnet = NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
|
||||
_virtRouterResource.assignVpcIpToRouter(routerIP, ip.isAdd(), ip.getPublicIp(),
|
||||
@ -2023,18 +2023,18 @@ ServerResource {
|
||||
int nicNum = 0;
|
||||
boolean newNic = false;
|
||||
for (IpAddressTO ip : ips) {
|
||||
if (!vlanAllocatedToVM.containsKey(ip.getVlanId())) {
|
||||
if (!vlanAllocatedToVM.containsKey(ip.getBroadcastUri())) {
|
||||
/* plug a vif into router */
|
||||
VifHotPlug(conn, routerName, ip.getVlanId(),
|
||||
VifHotPlug(conn, routerName, ip.getBroadcastUri(),
|
||||
ip.getVifMacAddress());
|
||||
vlanAllocatedToVM.put(ip.getVlanId(), nicPos++);
|
||||
vlanAllocatedToVM.put(ip.getBroadcastUri(), nicPos++);
|
||||
newNic = true;
|
||||
}
|
||||
nicNum = vlanAllocatedToVM.get(ip.getVlanId());
|
||||
nicNum = vlanAllocatedToVM.get(ip.getBroadcastUri());
|
||||
networkUsage(routerIp, "addVif", "eth" + nicNum);
|
||||
result = _virtRouterResource.assignPublicIpAddress(routerName,
|
||||
routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(),
|
||||
ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(),
|
||||
ip.isSourceNat(), ip.getBroadcastUri(), ip.getVlanGateway(),
|
||||
ip.getVlanNetmask(), ip.getVifMacAddress(), nicNum, newNic);
|
||||
|
||||
if (result != null) {
|
||||
|
||||
@ -128,18 +128,6 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
// Libvirt apparently takes care of this, see BridgeVifDriver unplug
|
||||
}
|
||||
|
||||
private String setVnetBrName(String pifName, String vnetId) {
|
||||
String brName = "br" + pifName + "-"+ vnetId;
|
||||
String oldStyleBrName = "cloudVirBr" + vnetId;
|
||||
|
||||
if (isBridgeExists(oldStyleBrName)) {
|
||||
s_logger.info("Using old style bridge name for vlan " + vnetId + " because existing bridge " + oldStyleBrName + " was found");
|
||||
brName = oldStyleBrName;
|
||||
}
|
||||
|
||||
return brName;
|
||||
}
|
||||
|
||||
private void deleteExitingLinkLocalRouteTable(String linkLocalBr) {
|
||||
Script command = new Script("/bin/bash", _timeout);
|
||||
command.add("-c");
|
||||
|
||||
@ -34,6 +34,8 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
import com.cloud.agent.IAgentControl;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
@ -102,9 +104,9 @@ import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||
import com.cloud.ovm.object.Connection;
|
||||
import com.cloud.ovm.object.OvmBridge;
|
||||
import com.cloud.ovm.object.OvmDisk;
|
||||
@ -1092,7 +1094,8 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
OvmVif.Details vif = getVifFromVm(cmd.getVmName(), null);
|
||||
String vifDeviceName = vif.name;
|
||||
String bridgeName = vif.bridge;
|
||||
result = addNetworkRules(cmd.getVmName(), Long.toString(cmd.getVmId()), cmd.getGuestIp(), cmd.getSignature(), String.valueOf(cmd.getSeqNum()), cmd.getGuestMac(), cmd.stringifyRules(), vifDeviceName, bridgeName);
|
||||
result = addNetworkRules(cmd.getVmName(), Long.toString(cmd.getVmId()), cmd.getGuestIp(), cmd.getSignature(), String.valueOf(cmd.getSeqNum()), cmd.getGuestMac(),
|
||||
cmd.stringifyRules(), vifDeviceName, bridgeName);
|
||||
} catch (XmlRpcException e) {
|
||||
s_logger.error(e);
|
||||
result = false;
|
||||
@ -1102,7 +1105,8 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
s_logger.warn("Failed to program network rules for vm " + cmd.getVmName());
|
||||
return new SecurityGroupRuleAnswer(cmd, false, "programming network rules failed");
|
||||
} else {
|
||||
s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ":ingress num rules=" + cmd.getIngressRuleSet().length + ":egress num rules=" + cmd.getEgressRuleSet().length);
|
||||
s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ":ingress num rules=" + cmd.getIngressRuleSet().length
|
||||
+ ":egress num rules=" + cmd.getEgressRuleSet().length);
|
||||
return new SecurityGroupRuleAnswer(cmd);
|
||||
}
|
||||
}
|
||||
@ -1146,7 +1150,8 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
return OvmSecurityGroup.deleteAllNetworkRulesForVm(_conn, vmName, vif);
|
||||
}
|
||||
|
||||
protected boolean addNetworkRules(String vmName, String vmId, String guestIp, String signature, String seqno, String vifMacAddress, String rules, String vifDeviceName, String bridgeName) throws XmlRpcException {
|
||||
protected boolean addNetworkRules(String vmName, String vmId, String guestIp, String signature, String seqno, String vifMacAddress, String rules, String vifDeviceName,
|
||||
String bridgeName) throws XmlRpcException {
|
||||
if (!_canBridgeFirewall) {
|
||||
return false;
|
||||
}
|
||||
@ -1168,7 +1173,6 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
}
|
||||
|
||||
protected OvmVif.Details getVifFromVm(String vmName, Integer deviceId) throws XmlRpcException {
|
||||
String vif = null;
|
||||
List<OvmVif.Details> vifs = null;
|
||||
|
||||
try {
|
||||
@ -1227,7 +1231,8 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
|
||||
String installPath = "template/tmpl/" + accountId + "/" + templateId;
|
||||
Map<String, String> res = OvmStoragePool.createTemplateFromVolume(_conn, secondaryStorageMountPath, installPath, volumePath, wait);
|
||||
return new CreatePrivateTemplateAnswer(cmd, true, null, res.get("installPath"), Long.valueOf(res.get("virtualSize")), Long.valueOf(res.get("physicalSize")), res.get("templateFileName"), ImageFormat.RAW);
|
||||
return new CreatePrivateTemplateAnswer(cmd, true, null, res.get("installPath"), Long.valueOf(res.get("virtualSize")), Long.valueOf(res.get("physicalSize")),
|
||||
res.get("templateFileName"), ImageFormat.RAW);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Create template failed", e);
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage());
|
||||
|
||||
@ -1793,7 +1793,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
}
|
||||
|
||||
protected void assignPublicIpAddress(VirtualMachineMO vmMo, final String vmName, final String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP,
|
||||
final boolean sourceNat, final String vlanId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {
|
||||
final boolean sourceNat, final String broadcastId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {
|
||||
|
||||
/**
|
||||
* TODO support other networks
|
||||
*/
|
||||
URI broadcastUri = BroadcastDomainType.fromString(broadcastId);
|
||||
if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
|
||||
throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + broadcastId);
|
||||
}
|
||||
String vlanId = BroadcastDomainType.getValue(broadcastUri);
|
||||
|
||||
String publicNeworkName = HypervisorHostHelper.getPublicNetworkNamePrefix(vlanId);
|
||||
Pair<Integer, VirtualDevice> publicNicInfo = vmMo.getNicDeviceIndex(publicNeworkName);
|
||||
@ -2011,7 +2020,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
}
|
||||
|
||||
for (IpAddressTO ip : ips) {
|
||||
assignPublicIpAddress(vmMo, routerName, controlIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(), ip.getVlanNetmask(),
|
||||
assignPublicIpAddress(vmMo, routerName, controlIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(), ip.getVlanGateway(), ip.getVlanNetmask(),
|
||||
ip.getVifMacAddress());
|
||||
results[i++] = ip.getPublicIp() + " - success";
|
||||
}
|
||||
|
||||
@ -1062,7 +1062,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
return network.getNetwork();
|
||||
} else if (type == BroadcastDomainType.Pvlan) {
|
||||
assert BroadcastDomainType.getSchemeValue(uri) == BroadcastDomainType.Pvlan;
|
||||
// TODO considder moving this NetUtils method to BroadcastDomainType
|
||||
// should we consider moving this NetUtils method to BroadcastDomainType?
|
||||
long vlan = Long.parseLong(NetUtils.getPrimaryPvlanFromUri(uri));
|
||||
return enableVlanNetwork(conn, vlan, network);
|
||||
}
|
||||
@ -2445,7 +2445,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
IpAddressTO[] ips = cmd.getIpAddresses();
|
||||
for (IpAddressTO ip : ips) {
|
||||
|
||||
assignPublicIpAddress(conn, routerName, routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getVlanId(),
|
||||
assignPublicIpAddress(conn, routerName, routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(),
|
||||
ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(), ip.getNetworkRate(), ip.getTrafficType(), ip.getNetworkName());
|
||||
results[i++] = ip.getPublicIp() + " - success";
|
||||
}
|
||||
@ -4202,10 +4202,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
NicTO nic = new NicTO();
|
||||
nic.setType(ip.getTrafficType());
|
||||
nic.setName(ip.getNetworkName());
|
||||
if (ip.getVlanId() == null) {
|
||||
if (ip.getBroadcastUri() == null) {
|
||||
nic.setBroadcastType(BroadcastDomainType.Native);
|
||||
} else {
|
||||
URI uri = BroadcastDomainType.fromString(ip.getVlanId());
|
||||
URI uri = BroadcastDomainType.fromString(ip.getBroadcastUri());
|
||||
nic.setBroadcastType(BroadcastDomainType.getSchemeValue(uri));
|
||||
nic.setBroadcastUri(uri);
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
||||
String tenantId = profile.getNetworkDomain();
|
||||
|
||||
DeleteVnsNetworkCommand cmd = new DeleteVnsNetworkCommand(tenantId,
|
||||
networkObject.getBroadcastUri().getSchemeSpecificPart());
|
||||
BroadcastDomainType.getValue(networkObject.getBroadcastUri()));
|
||||
_agentMgr.easySend(bigswitchVnsHost.getId(), cmd);
|
||||
|
||||
super.shutdown(profile, offering);
|
||||
|
||||
@ -375,7 +375,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
||||
try {
|
||||
outsideIp = _ipAddrMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(), true);
|
||||
} catch (ResourceAllocationException e) {
|
||||
s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details " + e);
|
||||
s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details "
|
||||
+ e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -532,7 +533,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
||||
}
|
||||
long zoneId = physicalNetwork.getDataCenterId();
|
||||
|
||||
PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(), networkDevice.getNetworkServiceProvder());
|
||||
PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(),
|
||||
networkDevice.getNetworkServiceProvder());
|
||||
if (ntwkSvcProvider == null) {
|
||||
throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() +
|
||||
" is not enabled in the physical network: " + physicalNetworkId + "to add this device");
|
||||
@ -687,7 +689,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
||||
}
|
||||
|
||||
if (network.getState() == Network.State.Allocated) {
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId()
|
||||
+ "; this network is not implemented. Skipping backend commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -745,7 +748,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
||||
}
|
||||
|
||||
if (network.getState() == Network.State.Allocated) {
|
||||
s_logger.debug("External firewall was asked to apply port forwarding rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
|
||||
s_logger.debug("External firewall was asked to apply port forwarding rules for network with ID " + network.getId()
|
||||
+ "; this network is not implemented. Skipping backend commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -800,7 +804,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
||||
}
|
||||
|
||||
if (network.getState() == Network.State.Allocated) {
|
||||
s_logger.debug("External firewall was asked to apply static NAT rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
|
||||
s_logger.debug("External firewall was asked to apply static NAT rules for network with ID " + network.getId()
|
||||
+ "; this network is not implemented. Skipping backend commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -294,8 +294,9 @@ public class F5BigIpResource implements ServerResource {
|
||||
try {
|
||||
IpAddressTO[] ips = cmd.getIpAddresses();
|
||||
for (IpAddressTO ip : ips) {
|
||||
// TODO BroadcastDomain.getValue(ip.getVlanId) ???
|
||||
long guestVlanTag = Long.valueOf(ip.getVlanId());
|
||||
// is it saver to use Long.valueOf(BroadcastDomain.getValue(ip.getBroadcastUri())) ???
|
||||
// i.o.w. can this contain vlan:// then change !!!
|
||||
long guestVlanTag = Long.valueOf(ip.getBroadcastUri());
|
||||
// It's a hack, using isOneToOneNat field for indicate if it's inline or not
|
||||
boolean inline = ip.isOneToOneNat();
|
||||
String vlanSelfIp = inline ? tagAddressWithRouteDomain(ip.getVlanGateway(), guestVlanTag) : ip.getVlanGateway();
|
||||
|
||||
@ -68,6 +68,7 @@ import com.cloud.host.Host;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
@ -697,11 +698,11 @@ public class JuniperSrxResource implements ServerResource {
|
||||
String guestVlanSubnet = NetUtils.getCidrSubNet(guestVlanGateway, cidrSize);
|
||||
|
||||
Long publicVlanTag = null;
|
||||
if (ip.getVlanId() != null && !ip.getVlanId().equals("untagged")) {
|
||||
if (ip.getBroadcastUri() != null && !ip.getBroadcastUri().equals("untagged")) {
|
||||
try {
|
||||
publicVlanTag = Long.parseLong(BroadcastDomainType.getValue(ip.getVlanId()));
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException("Could not parse public VLAN tag: " + ip.getVlanId());
|
||||
throw new ExecutionException("Could not parse public VLAN tag: " + ip.getBroadcastUri());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -442,7 +442,7 @@ public class NetscalerResource implements ServerResource {
|
||||
try {
|
||||
IpAddressTO[] ips = cmd.getIpAddresses();
|
||||
for (IpAddressTO ip : ips) {
|
||||
long guestVlanTag = Long.valueOf(ip.getVlanId());
|
||||
long guestVlanTag = Long.valueOf(ip.getBroadcastUri());
|
||||
String vlanSelfIp = ip.getVlanGateway();
|
||||
String vlanNetmask = ip.getVlanNetmask();
|
||||
|
||||
|
||||
@ -293,7 +293,6 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
_niciraNvpRouterMappingDao.persist(routermapping);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -41,11 +41,11 @@ import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.NiciraNvpDeviceVO;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
@ -69,7 +69,6 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(NiciraNvpGuestNetworkGuru.class);
|
||||
|
||||
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
@ -260,8 +259,4 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -77,15 +77,24 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
ScheduledExecutorService _executorPool;
|
||||
ScheduledExecutorService _cleanupExecutor;
|
||||
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject PhysicalNetworkTrafficTypeDao _physNetTTDao;
|
||||
@Inject UserVmDao _userVmDao;
|
||||
@Inject DomainRouterDao _routerDao;
|
||||
@Inject OvsTunnelNetworkDao _tunnelNetworkDao;
|
||||
@Inject OvsTunnelInterfaceDao _tunnelInterfaceDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
NicDao _nicDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
PhysicalNetworkTrafficTypeDao _physNetTTDao;
|
||||
@Inject
|
||||
UserVmDao _userVmDao;
|
||||
@Inject
|
||||
DomainRouterDao _routerDao;
|
||||
@Inject
|
||||
OvsTunnelNetworkDao _tunnelNetworkDao;
|
||||
@Inject
|
||||
OvsTunnelInterfaceDao _tunnelInterfaceDao;
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
|
||||
@ -2942,7 +2942,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
public PrivateGatewayResponse createPrivateGatewayResponse(PrivateGateway result) {
|
||||
PrivateGatewayResponse response = new PrivateGatewayResponse();
|
||||
response.setId(result.getUuid());
|
||||
response.setVlan(result.getVlanTag());
|
||||
response.setBroadcastUri(result.getBroadcastUri());
|
||||
response.setGateway(result.getGateway());
|
||||
response.setNetmask(result.getNetmask());
|
||||
if (result.getVpcId() != null) {
|
||||
|
||||
@ -1906,7 +1906,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
|| zone.getNetworkType() == NetworkType.Basic) {
|
||||
broadcastDomainType = BroadcastDomainType.Vlan;
|
||||
} else {
|
||||
continue;
|
||||
continue; // so broadcastDomainType remains null! why have None/Undecided/UnKnown?
|
||||
}
|
||||
} else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||
continue;
|
||||
@ -2434,6 +2434,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
String newVlanGateway = cmd.getGateway();
|
||||
String newVlanNetmask = cmd.getNetmask();
|
||||
String vlanId = cmd.getVlan();
|
||||
// TODO decide if we should be forgiving or demand a valid and complete URI
|
||||
if (!((vlanId == null)
|
||||
|| ("".equals(vlanId))
|
||||
|| vlanId.startsWith(BroadcastDomainType.Vlan.scheme())))
|
||||
vlanId = BroadcastDomainType.Vlan.toUri(vlanId).toString();
|
||||
Boolean forVirtualNetwork = cmd.isForVirtualNetwork();
|
||||
Long networkId = cmd.getNetworkID();
|
||||
Long physicalNetworkId = cmd.getPhysicalNetworkId();
|
||||
|
||||
@ -150,7 +150,6 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
|
||||
|
||||
ScheduledExecutorService _executor;
|
||||
private int _externalNetworkStatsInterval;
|
||||
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalDeviceUsageManagerImpl.class);
|
||||
@ -255,7 +254,8 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
|
||||
String publicIp = _networkModel.getIp(lb.getSourceIpAddressId()).getAddress().addr();
|
||||
DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
|
||||
String statsEntryIdentifier = "account " + account.getAccountName() + ", zone " + zone.getName() + ", network ID " + networkId + ", host ID " + externalLoadBalancer.getName();
|
||||
String statsEntryIdentifier = "account " + account.getAccountName() + ", zone " + zone.getName() + ", network ID " + networkId + ", host ID "
|
||||
+ externalLoadBalancer.getName();
|
||||
|
||||
long newCurrentBytesSent = 0;
|
||||
long newCurrentBytesReceived = 0;
|
||||
@ -299,7 +299,8 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
long oldNetBytesReceived = userStats.getNetBytesReceived();
|
||||
long oldCurrentBytesSent = userStats.getCurrentBytesSent();
|
||||
long oldCurrentBytesReceived = userStats.getCurrentBytesReceived();
|
||||
String warning = "Received an external network stats byte count that was less than the stored value. Zone ID: " + userStats.getDataCenterId() + ", account ID: " + userStats.getAccountId() + ".";
|
||||
String warning = "Received an external network stats byte count that was less than the stored value. Zone ID: " + userStats.getDataCenterId()
|
||||
+ ", account ID: " + userStats.getAccountId() + ".";
|
||||
|
||||
userStats.setCurrentBytesSent(newCurrentBytesSent);
|
||||
if (oldCurrentBytesSent > newCurrentBytesSent) {
|
||||
@ -423,7 +424,8 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
}
|
||||
firewallAnswer = fwDeviceUsageAnswerMap.get(fwDeviceId);
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
// Get network stats from the external load balancer
|
||||
ExternalNetworkResourceUsageAnswer lbAnswer = null;
|
||||
@ -483,7 +485,8 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
long oldNetBytesReceived = userStats.getNetBytesReceived();
|
||||
long oldCurrentBytesSent = userStats.getCurrentBytesSent();
|
||||
long oldCurrentBytesReceived = userStats.getCurrentBytesReceived();
|
||||
String warning = "Received an external network stats byte count that was less than the stored value. Zone ID: " + userStats.getDataCenterId() + ", account ID: " + userStats.getAccountId() + ".";
|
||||
String warning = "Received an external network stats byte count that was less than the stored value. Zone ID: " + userStats.getDataCenterId() + ", account ID: "
|
||||
+ userStats.getAccountId() + ".";
|
||||
|
||||
userStats.setCurrentBytesSent(newCurrentBytesSent);
|
||||
if (oldCurrentBytesSent > newCurrentBytesSent) {
|
||||
@ -584,7 +587,8 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
}
|
||||
}
|
||||
|
||||
private boolean createOrUpdateStatsEntry(boolean create, long accountId, long zoneId, long networkId, String publicIp, long hostId, ExternalNetworkResourceUsageAnswer answer, boolean inline) {
|
||||
private boolean createOrUpdateStatsEntry(boolean create, long accountId, long zoneId, long networkId, String publicIp, long hostId,
|
||||
ExternalNetworkResourceUsageAnswer answer, boolean inline) {
|
||||
if (create) {
|
||||
return createStatsEntry(accountId, zoneId, networkId, publicIp, hostId);
|
||||
} else {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
// 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
|
||||
@ -518,12 +517,12 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
}
|
||||
|
||||
String action = add ? "implemented" : "shut down";
|
||||
s_logger.debug("External firewall has " + action + " the guest network for account " + account.getAccountName() + "(id = " + account.getAccountId() + ") with VLAN tag " + guestVlanTag);
|
||||
s_logger.debug("External firewall has " + action + " the guest network for account " + account.getAccountName() + "(id = " + account.getAccountId() + ") with VLAN tag "
|
||||
+ guestVlanTag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applyFirewallRules(Network network, List<? extends FirewallRule> rules) throws ResourceUnavailableException {
|
||||
// Find the external firewall in this zone
|
||||
@ -539,7 +538,8 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
assert (externalFirewall != null);
|
||||
|
||||
if (network.getState() == Network.State.Allocated) {
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId()
|
||||
+ "; this network is not implemented. Skipping backend commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -581,7 +581,8 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
assert (externalFirewall != null);
|
||||
|
||||
if (network.getState() == Network.State.Allocated) {
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId()
|
||||
+ "; this network is not implemented. Skipping backend commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -591,7 +592,8 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());
|
||||
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(0,vlan.getVlanTag(), sourceIp.getAddress().addr(), -1, -1, rule.getDestIpAddress(), -1, -1, "any", rule.isForRevoke(), false);
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(0, vlan.getVlanTag(), sourceIp.getAddress().addr(), -1, -1, rule.getDestIpAddress(), -1, -1, "any", rule.isForRevoke(),
|
||||
false);
|
||||
staticNatRules.add(ruleTO);
|
||||
}
|
||||
|
||||
@ -785,7 +787,8 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
assert (externalFirewall != null);
|
||||
|
||||
if (network.getState() == Network.State.Allocated) {
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
|
||||
s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId()
|
||||
+ "; this network is not implemented. Skipping backend commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -106,6 +106,7 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.resource.ResourceStateAdapter;
|
||||
import com.cloud.resource.ResourceStateAdapter.DeleteHostAnswer;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.resource.UnableDeleteHostException;
|
||||
import com.cloud.user.Account;
|
||||
@ -264,7 +265,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
Host host = _resourceMgr.addHost(zoneId, resource, Host.Type.ExternalLoadBalancer, hostDetails);
|
||||
if (host != null) {
|
||||
|
||||
boolean dedicatedUse = (configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED) != null) ? Boolean.parseBoolean(configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED)) : false;
|
||||
boolean dedicatedUse = (configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED) != null) ? Boolean.parseBoolean(configParams
|
||||
.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED)) : false;
|
||||
long capacity = NumbersUtil.parseLong(configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_CAPACITY), 0);
|
||||
if (capacity == 0) {
|
||||
capacity = _defaultLbCapacity;
|
||||
@ -310,7 +312,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
if (lbDevices != null) {
|
||||
for (ExternalLoadBalancerDeviceVO lbDevice : lbDevices) {
|
||||
if (lbDevice.getParentHostId() == hostId) {
|
||||
throw new CloudRuntimeException("This load balancer device can not be deleted as there are one or more load balancers applainces provisioned by cloudstack on the device.");
|
||||
throw new CloudRuntimeException(
|
||||
"This load balancer device can not be deleted as there are one or more load balancers applainces provisioned by cloudstack on the device.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -469,7 +472,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
// a new LB appliance
|
||||
if (tryLbProvisioning) {
|
||||
// check if LB appliance can be dynamically provisioned
|
||||
List<ExternalLoadBalancerDeviceVO> providerLbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider, LBDeviceAllocationState.Provider);
|
||||
List<ExternalLoadBalancerDeviceVO> providerLbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider,
|
||||
LBDeviceAllocationState.Provider);
|
||||
if ((providerLbDevices != null) && (!providerLbDevices.isEmpty())) {
|
||||
for (ExternalLoadBalancerDeviceVO lbProviderDevice : providerLbDevices) {
|
||||
if (lbProviderDevice.getState() == LBDeviceState.Enabled) {
|
||||
@ -495,7 +499,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
continue;
|
||||
}
|
||||
} catch (Exception agentException) {
|
||||
s_logger.error("Could not provision load balancer instance on the load balancer device " + lbProviderDevice.getId() + " due to " + agentException.getMessage());
|
||||
s_logger.error("Could not provision load balancer instance on the load balancer device " + lbProviderDevice.getId() + " due to "
|
||||
+ agentException.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -532,7 +537,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
createLbAnswer.getDeviceName(), createLbAnswer.getServerResource(), false,
|
||||
null, null);
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Failed to add load balancer appliance in to cloudstack due to " + e.getMessage() + ". So provisioned load balancer appliance will be destroyed.");
|
||||
s_logger.error("Failed to add load balancer appliance in to cloudstack due to " + e.getMessage()
|
||||
+ ". So provisioned load balancer appliance will be destroyed.");
|
||||
}
|
||||
|
||||
if (lbAppliance != null) {
|
||||
@ -726,7 +732,6 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void applyStaticNatRuleForInlineLBRule(DataCenterVO zone, Network network, boolean revoked, String publicIp, String privateIp) throws ResourceUnavailableException {
|
||||
List<StaticNat> staticNats = new ArrayList<StaticNat>();
|
||||
IPAddressVO ipVO = _ipAddressDao.listByDcIdIpAddress(zone.getId(), publicIp).get(0);
|
||||
@ -754,9 +759,11 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
public void setNic(Nic nic) {
|
||||
this.nic = nic;
|
||||
}
|
||||
|
||||
public MappingState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(MappingState state) {
|
||||
this.state = state;
|
||||
}
|
||||
@ -861,7 +868,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
boolean externalLoadBalancerIsInline = _networkMgr.isNetworkInlineMode(network);
|
||||
|
||||
if (network.getState() == Network.State.Allocated) {
|
||||
s_logger.debug("External load balancer was asked to apply LB rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
|
||||
s_logger.debug("External load balancer was asked to apply LB rules for network with ID " + network.getId()
|
||||
+ "; this network is not implemented. Skipping backend commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -893,7 +901,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
|
||||
if ((destinations != null && !destinations.isEmpty()) || rule.isAutoScaleConfig()) {
|
||||
boolean inline = _networkMgr.isNetworkInlineMode(network);
|
||||
LoadBalancerTO loadBalancer = new LoadBalancerTO(uuid, srcIp, srcPort, protocol, algorithm, revoked, false, inline, destinations, rule.getStickinessPolicies(), rule.getHealthCheckPolicies());
|
||||
LoadBalancerTO loadBalancer = new LoadBalancerTO(uuid, srcIp, srcPort, protocol, algorithm, revoked, false, inline, destinations, rule.getStickinessPolicies(),
|
||||
rule.getHealthCheckPolicies());
|
||||
if (rule.isAutoScaleConfig()) {
|
||||
loadBalancer.setAutoScaleVmGroup(rule.getAutoScaleVmGroup());
|
||||
}
|
||||
@ -1048,7 +1057,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
Account account = _accountDao.findByIdIncludingRemoved(guestConfig.getAccountId());
|
||||
String action = add ? "implemented" : "shut down";
|
||||
s_logger.debug("External load balancer has " + action + " the guest network for account " + account.getAccountName() + "(id = " + account.getAccountId() + ") with VLAN tag " + guestVlanTag);
|
||||
s_logger.debug("External load balancer has " + action + " the guest network for account " + account.getAccountName() + "(id = " + account.getAccountId()
|
||||
+ ") with VLAN tag " + guestVlanTag);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -18,6 +18,7 @@ package com.cloud.network;
|
||||
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -1124,8 +1125,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
} else {
|
||||
ipv4 = true;
|
||||
}
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
} catch (UnknownHostException e) {
|
||||
s_logger.error("Unable to convert gateway IP to a InetAddress", e);
|
||||
throw new InvalidParameterValueException("Gateway parameter is invalid");
|
||||
}
|
||||
@ -3805,13 +3805,21 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
|
||||
@Override @DB
|
||||
public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId,
|
||||
String vlan, String startIp, String endIp, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
|
||||
String broadcastUriString, String startIp, String endIp, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId)
|
||||
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
|
||||
|
||||
Account owner = _accountMgr.getAccount(networkOwnerId);
|
||||
|
||||
// Get system network offeirng
|
||||
NetworkOfferingVO ntwkOff = findSystemNetworkOffering(NetworkOffering.SystemPrivateGatewayNetworkOffering);
|
||||
// Get system network offering
|
||||
NetworkOfferingVO ntwkOff = null;
|
||||
if (networkOfferingId != null)
|
||||
{
|
||||
ntwkOff = _networkOfferingDao.findById(networkOfferingId);
|
||||
}
|
||||
if (ntwkOff == null)
|
||||
{
|
||||
ntwkOff = findSystemNetworkOffering(NetworkOffering.SystemPrivateGatewayNetworkOffering);
|
||||
}
|
||||
|
||||
// Validate physical network
|
||||
PhysicalNetwork pNtwk = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
@ -3843,6 +3851,15 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
|
||||
cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
|
||||
|
||||
URI uri = BroadcastDomainType.fromString(broadcastUriString);
|
||||
String uriString = uri.toString();
|
||||
BroadcastDomainType tiep = BroadcastDomainType.getSchemeValue(uri);
|
||||
// numeric vlan or vlan uri are ok for now
|
||||
// TODO make a test for any supported scheme
|
||||
if (!(tiep == BroadcastDomainType.Vlan
|
||||
|| tiep == BroadcastDomainType.Lswitch)) {
|
||||
throw new InvalidParameterValueException("unsupported type of broadcastUri specified: " + broadcastUriString);
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
@ -3851,18 +3868,18 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
DataCenterVO dc = _dcDao.lockRow(pNtwk.getDataCenterId(), true);
|
||||
|
||||
//check if we need to create guest network
|
||||
Network privateNetwork = _networksDao.getPrivateNetwork(BroadcastDomainType.Vlan.toUri(vlan).toString(), cidr,
|
||||
networkOwnerId, pNtwk.getDataCenterId());
|
||||
Network privateNetwork = _networksDao.getPrivateNetwork(uriString, cidr,
|
||||
networkOwnerId, pNtwk.getDataCenterId(), null);
|
||||
if (privateNetwork == null) {
|
||||
//create Guest network
|
||||
privateNetwork = _networkMgr.createGuestNetwork(ntwkOff.getId(), networkName, displayText, gateway, cidr, vlan,
|
||||
privateNetwork = _networkMgr.createGuestNetwork(ntwkOff.getId(), networkName, displayText, gateway, cidr, uriString,
|
||||
null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, vpcId, null, null, true, null);
|
||||
s_logger.debug("Created private network " + privateNetwork);
|
||||
} else {
|
||||
s_logger.debug("Private network already exists: " + privateNetwork);
|
||||
//Do not allow multiple private gateways with same Vlan within a VPC
|
||||
if(vpcId.equals(privateNetwork.getVpcId())){
|
||||
throw new InvalidParameterValueException("Private network for the vlan: " + vlan + " and cidr "+ cidr +" already exists " +
|
||||
throw new InvalidParameterValueException("Private network for the vlan: " + uriString + " and cidr "+ cidr +" already exists " +
|
||||
"for Vpc "+vpcId+" in zone " + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
@Inject
|
||||
IpAddressManager _ipAddrMgr;
|
||||
|
||||
|
||||
public ExternalGuestNetworkGuru() {
|
||||
super();
|
||||
_isolationMethods = new IsolationMethod[] {IsolationMethod.GRE, IsolationMethod.L3, IsolationMethod.VLAN};
|
||||
@ -151,7 +150,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
}
|
||||
|
||||
implemented.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlanTag));
|
||||
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), config.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + config.getId(), 0);
|
||||
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), config.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN,
|
||||
"Assigned Zone Vlan: " + vnet + " Network Id: " + config.getId(), 0);
|
||||
} else {
|
||||
vlanTag = Integer.parseInt(BroadcastDomainType.getValue(config.getBroadcastUri()));
|
||||
implemented.setBroadcastUri(config.getBroadcastUri());
|
||||
@ -243,7 +243,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public void deallocate(Network config, NicProfile nic, VirtualMachineProfile vm) {
|
||||
super.deallocate(config, nic, vm);
|
||||
|
||||
|
||||
@ -215,7 +215,8 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
return network;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) {
|
||||
if (network.getSpecifyIpRanges()) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -234,7 +235,6 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getVlanOffset(long physicalNetworkId, int vlanTag) {
|
||||
PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (pNetwork == null) {
|
||||
|
||||
@ -106,7 +106,16 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
NetworkVO network = new NetworkVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(),
|
||||
BroadcastDomainType broadcastType;
|
||||
if (userSpecified != null)
|
||||
{
|
||||
broadcastType = userSpecified.getBroadcastDomainType();
|
||||
}
|
||||
else
|
||||
{
|
||||
broadcastType = BroadcastDomainType.Vlan;
|
||||
}
|
||||
NetworkVO network = new NetworkVO(offering.getTrafficType(), Mode.Static, broadcastType, offering.getId(),
|
||||
State.Allocated, plan.getDataCenterId(), plan.getPhysicalNetworkId());
|
||||
if (userSpecified != null) {
|
||||
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
|
||||
@ -146,7 +155,6 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
nic.deallocate();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering, DeployDestination dest,
|
||||
ReservationContext context) throws InsufficientVirtualNetworkCapcityException {
|
||||
@ -178,7 +186,6 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
return nic;
|
||||
}
|
||||
|
||||
|
||||
protected void getIp(NicProfile nic, DataCenter dc, Network network)
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
if (nic.getIp4Address() == null) {
|
||||
@ -191,11 +198,11 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
nic.setIp4Address(ip.getIpAddress());
|
||||
nic.setGateway(ip.getGateway());
|
||||
nic.setNetmask(ip.getNetmask());
|
||||
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
||||
nic.setBroadcastUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
||||
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getBroadcastUri()));
|
||||
nic.setBroadcastUri(IsolationType.Vlan.toUri(ip.getBroadcastUri()));
|
||||
nic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
nic.setFormat(AddressFormat.Ip4);
|
||||
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
||||
nic.setReservationId(String.valueOf(ip.getBroadcastUri()));
|
||||
nic.setMacAddress(ip.getMacAddress());
|
||||
}
|
||||
|
||||
@ -203,7 +210,6 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateNicProfile(NicProfile profile, Network network) {
|
||||
DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
||||
|
||||
@ -433,7 +433,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
for (final PublicIpAddress ipAddr : ipAddrList) {
|
||||
boolean add = (ipAddr.getState() == IpAddress.State.Releasing ? false : true);
|
||||
|
||||
String macAddress = vlanMacAddress.get(ipAddr.getVlanTag());
|
||||
String macAddress = vlanMacAddress.get(BroadcastDomainType.getValue(BroadcastDomainType.fromString(ipAddr.getVlanTag())));
|
||||
|
||||
IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, false,
|
||||
ipAddr.isSourceNat(), ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(), macAddress,
|
||||
@ -580,7 +580,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
" as its nic is already gone from VPC router " + router);
|
||||
} else {
|
||||
macAddress = nic.getMacAddress();
|
||||
vlanMacAddress.put(ipAddr.getVlanTag(), macAddress);
|
||||
vlanMacAddress.put(BroadcastDomainType.getValue(BroadcastDomainType.fromString(ipAddr.getVlanTag())), macAddress);
|
||||
ipsToSend.add(ipAddr);
|
||||
}
|
||||
}
|
||||
@ -653,7 +653,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected boolean sendNetworkACLs(VirtualRouter router, List<? extends NetworkACLItem> rules, long guestNetworkId, boolean isPrivateGateway)
|
||||
throws ResourceUnavailableException {
|
||||
Commands cmds = new Commands(Command.OnError.Continue);
|
||||
@ -1118,7 +1117,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
// Ensure that in multiple vlans case we first send all ip addresses of vlan1, then all ip addresses of vlan2, etc..
|
||||
Map<String, ArrayList<PrivateIpAddress>> vlanIpMap = new HashMap<String, ArrayList<PrivateIpAddress>>();
|
||||
for (final PrivateIpAddress ipAddress : ips) {
|
||||
String vlanTag = ipAddress.getVlanTag();
|
||||
String vlanTag = ipAddress.getBroadcastUri();
|
||||
ArrayList<PrivateIpAddress> ipList = vlanIpMap.get(vlanTag);
|
||||
if (ipList == null) {
|
||||
ipList = new ArrayList<PrivateIpAddress>();
|
||||
@ -1136,7 +1135,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
for (final PrivateIpAddress ipAddr : ipAddrList) {
|
||||
Network network = _networkModel.getNetwork(ipAddr.getNetworkId());
|
||||
IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false,
|
||||
ipAddr.getSourceNat(), ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(),
|
||||
ipAddr.getSourceNat(), ipAddr.getBroadcastUri(), ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(),
|
||||
null, false);
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
@ -1229,20 +1228,21 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
|
||||
_networkModel.getNetworkTag(vm.getHypervisorType(), privateNetwork));
|
||||
} else {
|
||||
String vlanTag = BroadcastDomainType.getValue(privateNetwork.getBroadcastUri());
|
||||
String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
|
||||
PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, privateNetwork.getGateway(), netmask,
|
||||
PrivateIpAddress ip = new PrivateIpAddress(ipVO, privateNetwork.getBroadcastUri().toString(), privateNetwork.getGateway(), netmask,
|
||||
NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
|
||||
|
||||
URI netUri = BroadcastDomainType.fromString(ip.getVlanTag());
|
||||
URI netUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
|
||||
privateNicProfile.setIp4Address(ip.getIpAddress());
|
||||
privateNicProfile.setGateway(ip.getGateway());
|
||||
privateNicProfile.setNetmask(ip.getNetmask());
|
||||
privateNicProfile.setIsolationUri(netUri);
|
||||
privateNicProfile.setBroadcastUri(netUri);
|
||||
privateNicProfile.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
// can we solve this in setBroadcastUri()???
|
||||
// or more plugable construct is desirable
|
||||
privateNicProfile.setBroadcastType(BroadcastDomainType.getSchemeValue(netUri));
|
||||
privateNicProfile.setFormat(AddressFormat.Ip4);
|
||||
privateNicProfile.setReservationId(String.valueOf(ip.getVlanTag()));
|
||||
privateNicProfile.setReservationId(String.valueOf(ip.getBroadcastUri()));
|
||||
privateNicProfile.setMacAddress(ip.getMacAddress());
|
||||
}
|
||||
|
||||
|
||||
@ -67,8 +67,8 @@ public class PrivateGatewayProfile implements PrivateGateway {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVlanTag() {
|
||||
return vpcGateway.getVlanTag();
|
||||
public String getBroadcastUri() {
|
||||
return vpcGateway.getBroadcastUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -19,7 +19,7 @@ package com.cloud.network.vpc;
|
||||
|
||||
|
||||
public class PrivateIpAddress implements PrivateIp{
|
||||
String vlanTag;
|
||||
String broadcastUri;
|
||||
String gateway;
|
||||
String netmask;
|
||||
String ipAddress;
|
||||
@ -29,16 +29,16 @@ public class PrivateIpAddress implements PrivateIp{
|
||||
|
||||
/**
|
||||
* @param privateIp
|
||||
* @param vlanTag
|
||||
* @param broadcastUri
|
||||
* @param gateway
|
||||
* @param netmask
|
||||
* @param macAddress TODO
|
||||
* @param physicalNetworkId TODO
|
||||
*/
|
||||
public PrivateIpAddress(PrivateIpVO privateIp, String vlanTag, String gateway, String netmask, String macAddress) {
|
||||
public PrivateIpAddress(PrivateIpVO privateIp, String broadcastUri, String gateway, String netmask, String macAddress) {
|
||||
super();
|
||||
this.ipAddress = privateIp.getIpAddress();
|
||||
this.vlanTag = vlanTag;
|
||||
this.broadcastUri = broadcastUri;
|
||||
this.gateway = gateway;
|
||||
this.netmask = netmask;
|
||||
this.macAddress = macAddress;
|
||||
@ -47,8 +47,8 @@ public class PrivateIpAddress implements PrivateIp{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVlanTag() {
|
||||
return vlanTag;
|
||||
public String getBroadcastUri() {
|
||||
return broadcastUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -45,6 +45,7 @@ import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
@ -297,6 +298,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
Map<Network.Service, Set<Network.Provider>> svcProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
defaultProviders.add(Provider.VPCVirtualRouter);
|
||||
// Just here for 4.1, replaced by commit 836ce6c1 in newer versions
|
||||
Set<Network.Provider> sdnProviders = new HashSet<Network.Provider>();
|
||||
sdnProviders.add(Provider.NiciraNvp);
|
||||
|
||||
boolean sourceNatSvc = false;
|
||||
boolean firewallSvs = false;
|
||||
@ -308,7 +312,13 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
throw new InvalidParameterValueException("Service " + serviceName + " is not supported in VPC");
|
||||
}
|
||||
|
||||
if (service == Service.Connectivity) {
|
||||
s_logger.debug("Applying Connectivity workaround, setting provider to NiciraNvp");
|
||||
svcProviderMap.put(service, sdnProviders);
|
||||
}
|
||||
else {
|
||||
svcProviderMap.put(service, defaultProviders);
|
||||
}
|
||||
if (service == Service.NetworkACL) {
|
||||
firewallSvs = true;
|
||||
}
|
||||
@ -319,7 +329,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
}
|
||||
|
||||
if (!sourceNatSvc) {
|
||||
throw new InvalidParameterValueException("SourceNat service is required by VPC offering");
|
||||
s_logger.debug("Automatically adding source nat service to the list of VPC services");
|
||||
svcProviderMap.put(Service.SourceNat, defaultProviders);
|
||||
}
|
||||
|
||||
if (!firewallSvs) {
|
||||
@ -1327,7 +1338,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
List<VpcGatewayVO> gateways = _vpcGatewayDao.listByVpcIdAndType(vpcId, VpcGateway.Type.Private);
|
||||
|
||||
if (gateways != null) {
|
||||
List<PrivateGateway> pvtGateway = new ArrayList();
|
||||
List<PrivateGateway> pvtGateway = new ArrayList<PrivateGateway>();
|
||||
for (VpcGatewayVO gateway: gateways) {
|
||||
pvtGateway.add(getPrivateGatewayProfile(gateway));
|
||||
}
|
||||
@ -1355,8 +1366,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription = "creating vpc private gateway", create=true)
|
||||
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress,
|
||||
String gateway, String netmask, long gatewayOwnerId, Boolean isSourceNat, Long aclId) throws ResourceAllocationException,
|
||||
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String broadcastUri, String ipAddress,
|
||||
String gateway, String netmask, long gatewayOwnerId, Long networkOfferingId, Boolean isSourceNat, Long aclId) throws ResourceAllocationException,
|
||||
ConcurrentOperationException, InsufficientCapacityException {
|
||||
|
||||
//Validate parameters
|
||||
@ -1367,22 +1378,58 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
throw ex;
|
||||
}
|
||||
|
||||
PhysicalNetwork physNet = null;
|
||||
//Validate physical network
|
||||
if (physicalNetworkId == null) {
|
||||
List<? extends PhysicalNetwork> pNtwks = _ntwkModel.getPhysicalNtwksSupportingTrafficType(vpc.getZoneId(), TrafficType.Guest);
|
||||
if (pNtwks.isEmpty() || pNtwks.size() != 1) {
|
||||
throw new InvalidParameterValueException("Physical network can't be determined; pass physical network id");
|
||||
}
|
||||
physicalNetworkId = pNtwks.get(0).getId();
|
||||
physNet = pNtwks.get(0);
|
||||
physicalNetworkId = physNet.getId();
|
||||
}
|
||||
|
||||
if (physNet == null) {
|
||||
physNet = _entityMgr.findById(PhysicalNetwork.class,physicalNetworkId);
|
||||
}
|
||||
Long dcId = physNet.getDataCenterId();
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
s_logger.debug("Creating Private gateway for VPC " + vpc);
|
||||
//1) create private network
|
||||
//1) create private network unless it is existing and lswitch'd
|
||||
Network privateNtwk = null;
|
||||
if (BroadcastDomainType.getSchemeValue(BroadcastDomainType.fromString(broadcastUri)) == BroadcastDomainType.Lswitch) {
|
||||
String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
|
||||
|
||||
privateNtwk = _ntwkDao.getPrivateNetwork(broadcastUri, cidr,
|
||||
gatewayOwnerId, dcId, networkOfferingId);
|
||||
s_logger.info("found and using existing network for vpc " + vpc + ": " + broadcastUri);
|
||||
}
|
||||
if (privateNtwk == null) {
|
||||
s_logger.info("creating new network for vpc " + vpc + " using broadcast uri: " + broadcastUri);
|
||||
String networkName = "vpc-" + vpc.getName() + "-privateNetwork";
|
||||
Network privateNtwk = _ntwkSvc.createPrivateNetwork(networkName, networkName, physicalNetworkId,
|
||||
vlan, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId, isSourceNat);
|
||||
privateNtwk = _ntwkSvc.createPrivateNetwork(networkName, networkName, physicalNetworkId,
|
||||
broadcastUri, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId, isSourceNat, networkOfferingId);
|
||||
} else { // create the nic/ip as createPrivateNetwork doesn''t do that work for us now
|
||||
DataCenterVO dc = _dcDao.lockRow(physNet.getDataCenterId(), true);
|
||||
|
||||
//add entry to private_ip_address table
|
||||
PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkId(privateNtwk.getId(), ipAddress);
|
||||
if (privateIp != null) {
|
||||
throw new InvalidParameterValueException("Private ip address " + ipAddress + " already used for private gateway" +
|
||||
" in zone " + _entityMgr.findById(DataCenter.class,dcId).getName());
|
||||
}
|
||||
|
||||
Long mac = dc.getMacAddress();
|
||||
Long nextMac = mac + 1;
|
||||
dc.setMacAddress(nextMac);
|
||||
|
||||
privateIp = new PrivateIpVO(ipAddress, privateNtwk.getId(), nextMac, vpcId, true);
|
||||
_privateIpDao.persist(privateIp);
|
||||
|
||||
_dcDao.update(dc.getId(), dc);
|
||||
}
|
||||
|
||||
long networkAclId = NetworkACL.DEFAULT_DENY;
|
||||
if (aclId != null) {
|
||||
@ -1399,7 +1446,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
|
||||
//2) create gateway entry
|
||||
VpcGatewayVO gatewayVO = new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(),
|
||||
privateNtwk.getId(), vlan, gateway, netmask, vpc.getAccountId(), vpc.getDomainId(), isSourceNat, networkAclId);
|
||||
privateNtwk.getId(), broadcastUri, gateway, netmask, vpc.getAccountId(), vpc.getDomainId(), isSourceNat, networkAclId);
|
||||
_vpcGatewayDao.persist(gatewayVO);
|
||||
|
||||
s_logger.debug("Created vpc gateway entry " + gatewayVO);
|
||||
|
||||
@ -24,6 +24,8 @@ import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import junit.framework.Assert;
|
||||
@ -61,8 +63,9 @@ import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Ignore("Requires database to be set up")
|
||||
//@Ignore("Requires database to be set up")
|
||||
public class CreatePrivateNetworkTest {
|
||||
|
||||
private static final Logger s_logger = Logger
|
||||
@ -109,6 +112,10 @@ public class CreatePrivateNetworkTest {
|
||||
false, false, false, false);
|
||||
when(networkService._networkOfferingDao.findById(anyLong()))
|
||||
.thenReturn(ntwkOff);
|
||||
List<NetworkOfferingVO>netofferlist = new ArrayList<NetworkOfferingVO>();
|
||||
netofferlist.add(ntwkOff);
|
||||
when(networkService._networkOfferingDao.listSystemNetworkOfferings())
|
||||
.thenReturn(netofferlist);
|
||||
|
||||
PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L,
|
||||
"2-5", "200", 1L, null, "testphysicalnetwork");
|
||||
@ -122,7 +129,7 @@ public class CreatePrivateNetworkTest {
|
||||
.thenReturn(dc);
|
||||
|
||||
when(networkService._networksDao.getPrivateNetwork(anyString(),
|
||||
anyString(), eq(1L), eq(1L))).thenReturn(null);
|
||||
anyString(), eq(1L), eq(1L), anyLong())).thenReturn(null);
|
||||
|
||||
Network net = new NetworkVO(1L, TrafficType.Guest, Mode.None,
|
||||
BroadcastDomainType.Vlan, 1L, 1L, 1L, 1L, "bla", "fake",
|
||||
@ -139,6 +146,7 @@ public class CreatePrivateNetworkTest {
|
||||
|
||||
when(networkService._privateIpDao.findByIpAndSourceNetworkId(
|
||||
net.getId(), "10.1.1.2")).thenReturn(null);
|
||||
when(networkService._privateIpDao.findByIpAndSourceNetworkIdAndVpcId(eq(1L), anyString(), eq(1L))).thenReturn(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -149,26 +157,26 @@ public class CreatePrivateNetworkTest {
|
||||
/* Network nw; */
|
||||
try {
|
||||
/* nw = */
|
||||
networkService.createPrivateNetwork("bla", "fake", 1L, "vlan:1", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1L, 1L, null);
|
||||
networkService.createPrivateNetwork("bla", "fake", 1L, "vlan:1", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1L, 1L, true, 1L);
|
||||
/* nw = */
|
||||
networkService.createPrivateNetwork("bla", "fake", 1L, "lswitch:3", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1L, 1L, null);
|
||||
networkService.createPrivateNetwork("bla", "fake", 1L, "lswitch:3", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1L, 1L, false, 1L);
|
||||
boolean invalid = false;
|
||||
boolean unsupported = false;
|
||||
try {
|
||||
/* nw = */
|
||||
networkService.createPrivateNetwork("bla", "fake", 1, "bla:2", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1, 1L, null);
|
||||
} catch (InvalidParameterValueException e) {
|
||||
networkService.createPrivateNetwork("bla", "fake", 1, "bla:2", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1, 1L, true, 1L);
|
||||
} catch (CloudRuntimeException e) {
|
||||
Assert.assertEquals("unexpected parameter exception",
|
||||
"unsupported type of broadcastUri specified: bla:2",
|
||||
"string 'bla:2' has an unknown BroadcastDomainType.",
|
||||
e.getMessage());
|
||||
invalid = true;
|
||||
}
|
||||
try {
|
||||
/* nw = */
|
||||
networkService.createPrivateNetwork("bla", "fake", 1, "mido:4", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1, 1L, null);
|
||||
networkService.createPrivateNetwork("bla", "fake", 1, "mido://4", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1, 1L, false, 1L);
|
||||
} catch (InvalidParameterValueException e) {
|
||||
Assert.assertEquals("unexpected parameter exception",
|
||||
"unsupported type of broadcastUri specified: mido:4",
|
||||
"unsupported type of broadcastUri specified: mido://4",
|
||||
e.getMessage());
|
||||
unsupported = true;
|
||||
}
|
||||
|
||||
@ -640,7 +640,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
|
||||
*/
|
||||
@Override
|
||||
public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
|
||||
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
|
||||
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId)
|
||||
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
@ -328,7 +328,7 @@ public class MockNetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implemen
|
||||
* @see com.cloud.network.dao.NetworkDao#getPrivateNetwork(java.lang.String, java.lang.String, long, long)
|
||||
*/
|
||||
@Override
|
||||
public NetworkVO getPrivateNetwork(String broadcastUri, String cidr, long accountId, long zoneId) {
|
||||
public NetworkVO getPrivateNetwork(String broadcastUri, String cidr, long accountId, long zoneId, Long netofferid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -26,10 +26,18 @@ import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Formatter;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.googlecode.ipv6.IPv6Address;
|
||||
@ -39,7 +47,6 @@ import com.googlecode.ipv6.IPv6Network;
|
||||
import com.cloud.utils.IteratorUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.script.Script;
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
|
||||
public class NetUtils {
|
||||
protected final static Logger s_logger = Logger.getLogger(NetUtils.class);
|
||||
@ -152,8 +159,6 @@ public class NetUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getDefaultHostIp() {
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
Pattern pattern = Pattern.compile("\\s*0.0.0.0\\s*0.0.0.0\\s*(\\S*)\\s*(\\S*)\\s*");
|
||||
@ -212,8 +217,6 @@ public class NetUtils {
|
||||
return defaultRouteList[7];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static InetAddress getFirstNonLoopbackLocalInetAddress() {
|
||||
InetAddress[] addrs = getAllLocalInetAddresses();
|
||||
if (addrs != null) {
|
||||
@ -451,7 +454,8 @@ public class NetUtils {
|
||||
public static String long2Mac(long macAddress) {
|
||||
StringBuilder result = new StringBuilder(17);
|
||||
Formatter formatter = new Formatter(result);
|
||||
formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", (macAddress >> 40) & 0xff, (macAddress >> 32) & 0xff, (macAddress >> 24) & 0xff, (macAddress >> 16) & 0xff, (macAddress >> 8) & 0xff,
|
||||
formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", (macAddress >> 40) & 0xff, (macAddress >> 32) & 0xff, (macAddress >> 24) & 0xff, (macAddress >> 16) & 0xff,
|
||||
(macAddress >> 8) & 0xff,
|
||||
(macAddress & 0xff));
|
||||
|
||||
return result.toString();
|
||||
@ -804,6 +808,7 @@ public class NetUtils {
|
||||
sameSubnet,
|
||||
errorInCidrFormat
|
||||
}
|
||||
|
||||
public static supersetOrSubset isNetowrkASubsetOrSupersetOfNetworkB(String cidrA, String cidrB) {
|
||||
Long[] cidrALong = cidrToLong(cidrA);
|
||||
Long[] cidrBLong = cidrToLong(cidrB);
|
||||
@ -1008,7 +1013,6 @@ public class NetUtils {
|
||||
return Integer.toString(portRange[0]) + ":" + Integer.toString(portRange[1]);
|
||||
}
|
||||
|
||||
|
||||
public static boolean verifyDomainNameLabel(String hostName, boolean isHostName) {
|
||||
// must be between 1 and 63 characters long and may contain only the ASCII letters 'a' through 'z' (in a
|
||||
// case-insensitive manner),
|
||||
@ -1091,6 +1095,7 @@ public class NetUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean validateGuestCidr(String cidr) {
|
||||
// RFC 1918 - The Internet Assigned Numbers Authority (IANA) has reserved the
|
||||
// following three blocks of the IP address space for private internets:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user