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 */
|
||||
|
||||
@ -91,7 +91,7 @@ public class Networks {
|
||||
@Override
|
||||
public <T> URI toUri(T value) {
|
||||
try {
|
||||
return new URI("lswitch",value.toString(),null,null);
|
||||
return new URI("lswitch", value.toString(), null, null);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new CloudRuntimeException(
|
||||
"Unable to convert to broadcast URI: " + value);
|
||||
@ -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
|
||||
@ -99,7 +100,7 @@ import java.util.Map;
|
||||
* || Param Name | Description | Values | Default ||
|
||||
* }
|
||||
**/
|
||||
@Local(value={VirtualRoutingResource.class})
|
||||
@Local(value = {VirtualRoutingResource.class})
|
||||
public class VirtualRoutingResource implements Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualRoutingResource.class);
|
||||
private String _savepasswordPath; // This script saves a random password to the DomR file system
|
||||
@ -126,13 +127,13 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
public Answer executeRequest(final Command cmd) {
|
||||
try {
|
||||
if (cmd instanceof SetPortForwardingRulesVpcCommand ) {
|
||||
if (cmd instanceof SetPortForwardingRulesVpcCommand) {
|
||||
return execute((SetPortForwardingRulesVpcCommand)cmd);
|
||||
} else if (cmd instanceof SetPortForwardingRulesCommand){
|
||||
} else if (cmd instanceof SetPortForwardingRulesCommand) {
|
||||
return execute((SetPortForwardingRulesCommand)cmd);
|
||||
} else if (cmd instanceof SetStaticRouteCommand){
|
||||
} else if (cmd instanceof SetStaticRouteCommand) {
|
||||
return execute((SetStaticRouteCommand)cmd);
|
||||
} else if (cmd instanceof SetStaticNatRulesCommand){
|
||||
} else if (cmd instanceof SetStaticNatRulesCommand) {
|
||||
return execute((SetStaticNatRulesCommand)cmd);
|
||||
} else if (cmd instanceof LoadBalancerConfigCommand) {
|
||||
return execute((LoadBalancerConfigCommand)cmd);
|
||||
@ -140,22 +141,22 @@ public class VirtualRoutingResource implements Manager {
|
||||
return execute((IpAssocCommand)cmd);
|
||||
} else if (cmd instanceof CheckConsoleProxyLoadCommand) {
|
||||
return execute((CheckConsoleProxyLoadCommand)cmd);
|
||||
} else if(cmd instanceof WatchConsoleProxyLoadCommand) {
|
||||
} else if (cmd instanceof WatchConsoleProxyLoadCommand) {
|
||||
return execute((WatchConsoleProxyLoadCommand)cmd);
|
||||
} else if (cmd instanceof SavePasswordCommand) {
|
||||
return execute((SavePasswordCommand)cmd);
|
||||
} else if (cmd instanceof DhcpEntryCommand) {
|
||||
return execute((DhcpEntryCommand)cmd);
|
||||
} else if (cmd instanceof CreateIpAliasCommand) {
|
||||
return execute((CreateIpAliasCommand) cmd);
|
||||
return execute((CreateIpAliasCommand)cmd);
|
||||
} else if (cmd instanceof DnsMasqConfigCommand) {
|
||||
return execute((DnsMasqConfigCommand) cmd);
|
||||
return execute((DnsMasqConfigCommand)cmd);
|
||||
} else if (cmd instanceof DeleteIpAliasCommand) {
|
||||
return execute((DeleteIpAliasCommand) cmd);
|
||||
return execute((DeleteIpAliasCommand)cmd);
|
||||
} else if (cmd instanceof VmDataCommand) {
|
||||
return execute ((VmDataCommand)cmd);
|
||||
return execute((VmDataCommand)cmd);
|
||||
} else if (cmd instanceof CheckRouterCommand) {
|
||||
return execute ((CheckRouterCommand)cmd);
|
||||
return execute((CheckRouterCommand)cmd);
|
||||
} else if (cmd instanceof SetFirewallRulesCommand) {
|
||||
return execute((SetFirewallRulesCommand)cmd);
|
||||
} else if (cmd instanceof BumpUpPriorityCommand) {
|
||||
@ -180,13 +181,13 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
|
||||
private Answer execute(VpnUsersCfgCommand cmd) {
|
||||
for (VpnUsersCfgCommand.UsernamePassword userpwd: cmd.getUserpwds()) {
|
||||
for (VpnUsersCfgCommand.UsernamePassword userpwd : cmd.getUserpwds()) {
|
||||
String args = "";
|
||||
if (!userpwd.isAdd()) {
|
||||
args +="-U ";
|
||||
args +=userpwd.getUsername();
|
||||
args += "-U ";
|
||||
args += userpwd.getUsername();
|
||||
} else {
|
||||
args +="-u ";
|
||||
args += "-u ";
|
||||
args += userpwd.getUsernamePassword();
|
||||
}
|
||||
String result = routerProxy("vpn_l2tp.sh", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), args);
|
||||
@ -210,7 +211,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
args += cmd.getLocalIp();
|
||||
args += " -c ";
|
||||
} else {
|
||||
args +="-d ";
|
||||
args += "-d ";
|
||||
args += " -s ";
|
||||
args += cmd.getVpnServerIp();
|
||||
}
|
||||
@ -223,7 +224,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
private Answer execute(SetFirewallRulesCommand cmd) {
|
||||
String[] results = new String[cmd.getRules().length];
|
||||
for (int i =0; i < cmd.getRules().length; i++) {
|
||||
for (int i = 0; i < cmd.getRules().length; i++) {
|
||||
results[i] = "Failed";
|
||||
}
|
||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
@ -241,7 +242,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
command.add(routerIp);
|
||||
command.add("-F");
|
||||
|
||||
if (trafficType == FirewallRule.TrafficType.Egress){
|
||||
if (trafficType == FirewallRule.TrafficType.Egress) {
|
||||
command.add("-E");
|
||||
if (egressDefault.equals("true")) {
|
||||
command.add("-P ", "1");
|
||||
@ -267,7 +268,6 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
return new SetFirewallRulesAnswer(cmd, true, null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Answer execute(SetPortForwardingRulesCommand cmd) {
|
||||
@ -311,7 +311,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
String result = routerProxy("vpc_staticnat.sh", routerIp, args);
|
||||
|
||||
if(result == null) {
|
||||
if (result == null) {
|
||||
results[i++] = null;
|
||||
} else {
|
||||
results[i++] = "Failed";
|
||||
@ -323,7 +323,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
|
||||
private Answer execute(SetStaticNatRulesCommand cmd) {
|
||||
if ( cmd.getVpcId() != null ) {
|
||||
if (cmd.getVpcId() != null) {
|
||||
return SetVPCStaticNatRules(cmd);
|
||||
}
|
||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
@ -345,7 +345,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
|
||||
command.add(" -d ", rule.getStringSrcPortRange());
|
||||
command.add(" -G ") ;
|
||||
command.add(" -G ");
|
||||
|
||||
result = command.execute();
|
||||
if (result == null) {
|
||||
@ -426,7 +426,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
|
||||
private Answer execute(LoadBalancerConfigCommand cmd) {
|
||||
if ( cmd.getVpcId() != null ) {
|
||||
if (cmd.getVpcId() != null) {
|
||||
return VPCLoadBalancerConfig(cmd);
|
||||
}
|
||||
|
||||
@ -439,9 +439,8 @@ 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)));
|
||||
for (int i=0; i < config.length; i++) {
|
||||
final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(tmpCfgFile)));
|
||||
for (int i = 0; i < config.length; i++) {
|
||||
out.println(config[i]);
|
||||
}
|
||||
out.close();
|
||||
@ -492,19 +491,20 @@ 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);
|
||||
}
|
||||
|
||||
private String setLoadBalancerConfig(final String cfgFile,
|
||||
final String[] addRules, final String[] removeRules, final String[] statsRules,String routerIp) {
|
||||
final String[] addRules, final String[] removeRules, final String[] statsRules, String routerIp) {
|
||||
|
||||
if (routerIp == null) {
|
||||
routerIp = "none";
|
||||
@ -517,7 +517,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (addRules.length > 0) {
|
||||
for (int i=0; i< addRules.length; i++) {
|
||||
for (int i = 0; i < addRules.length; i++) {
|
||||
sb.append(addRules[i]).append(',');
|
||||
}
|
||||
command.add("-a", sb.toString());
|
||||
@ -525,7 +525,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
sb = new StringBuilder();
|
||||
if (removeRules.length > 0) {
|
||||
for (int i=0; i< removeRules.length; i++) {
|
||||
for (int i = 0; i < removeRules.length; i++) {
|
||||
sb.append(removeRules[i]).append(',');
|
||||
}
|
||||
command.add("-d", sb.toString());
|
||||
@ -533,7 +533,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
sb = new StringBuilder();
|
||||
if (statsRules.length > 0) {
|
||||
for (int i=0; i< statsRules.length; i++) {
|
||||
for (int i = 0; i < statsRules.length; i++) {
|
||||
sb.append(statsRules[i]).append(',');
|
||||
}
|
||||
command.add("-s", sb.toString());
|
||||
@ -558,7 +558,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
}
|
||||
|
||||
protected Answer execute (final DhcpEntryCommand cmd) {
|
||||
protected Answer execute(final DhcpEntryCommand cmd) {
|
||||
final Script command = new Script(_dhcpEntryPath, _timeout, s_logger);
|
||||
command.add("-r", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
||||
if (cmd.getVmIpAddress() != null) {
|
||||
@ -588,7 +588,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
|
||||
final String result = command.execute();
|
||||
return new Answer(cmd, result==null, result);
|
||||
return new Answer(cmd, result == null, result);
|
||||
}
|
||||
|
||||
protected Answer execute(final CreateIpAliasCommand cmd) {
|
||||
@ -598,39 +598,39 @@ public class VirtualRoutingResource implements Manager {
|
||||
String args = "";
|
||||
command.add(routerIp);
|
||||
for (IpAliasTO ipaliasto : ipAliasTOs) {
|
||||
args = args + ipaliasto.getAlias_count()+":"+ipaliasto.getRouterip()+":"+ipaliasto.getNetmask()+"-";
|
||||
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
|
||||
}
|
||||
command.add(args);
|
||||
final String result = command.execute();
|
||||
return new Answer(cmd, result==null, result);
|
||||
return new Answer(cmd, result == null, result);
|
||||
}
|
||||
|
||||
protected Answer execute(final DeleteIpAliasCommand cmd) {
|
||||
final Script command = new Script(_deleteIpAliasPath, _timeout, s_logger);
|
||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String args ="";
|
||||
String args = "";
|
||||
command.add(routerIp);
|
||||
List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
|
||||
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
|
||||
args = args + ipAliasTO.getAlias_count()+":"+ipAliasTO.getRouterip()+":"+ipAliasTO.getNetmask()+"-";
|
||||
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
|
||||
}
|
||||
args = args + "- " ;
|
||||
args = args + "- ";
|
||||
List<IpAliasTO> activeIpAliasTOs = cmd.getCreateIpAliasTos();
|
||||
for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
|
||||
args = args + ipAliasTO.getAlias_count()+":"+ipAliasTO.getRouterip()+":"+ipAliasTO.getNetmask()+"-";
|
||||
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
|
||||
}
|
||||
command.add(args);
|
||||
final String result = command.execute();
|
||||
return new Answer(cmd, result==null, result);
|
||||
return new Answer(cmd, result == null, result);
|
||||
}
|
||||
|
||||
protected Answer execute(final DnsMasqConfigCommand cmd) {
|
||||
final Script command = new Script(_callDnsMasqPath, _timeout, s_logger);
|
||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
List<DhcpTO> dhcpTos = cmd.getIps();
|
||||
String args ="";
|
||||
for(DhcpTO dhcpTo : dhcpTos) {
|
||||
args = args + dhcpTo.getRouterIp()+":"+dhcpTo.getGateway()+":"+dhcpTo.getNetmask()+":"+dhcpTo.getStartIpOfSubnet()+"-";
|
||||
String args = "";
|
||||
for (DhcpTO dhcpTo : dhcpTos) {
|
||||
args = args + dhcpTo.getRouterIp() + ":" + dhcpTo.getGateway() + ":" + dhcpTo.getNetmask() + ":" + dhcpTo.getStartIpOfSubnet() + "-";
|
||||
}
|
||||
command.add(routerIp);
|
||||
command.add(args);
|
||||
@ -642,13 +642,12 @@ 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();
|
||||
command.add(script);
|
||||
command.add(routerIP);
|
||||
if ( args != null ) {
|
||||
if (args != null) {
|
||||
command.add(args);
|
||||
}
|
||||
String result = command.execute(parser);
|
||||
@ -677,7 +676,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
final Script command = new Script(_routerProxyPath, _timeout, s_logger);
|
||||
command.add(script);
|
||||
command.add(routerIP);
|
||||
if ( args != null ) {
|
||||
if (args != null) {
|
||||
command.add(args);
|
||||
}
|
||||
return command.execute();
|
||||
@ -807,7 +806,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
} catch(final IOException e) {
|
||||
} catch (final IOException e) {
|
||||
s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp);
|
||||
success = false;
|
||||
}
|
||||
@ -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);
|
||||
@ -830,7 +826,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
public String assignGuestNetwork(final String dev, final String routerIP,
|
||||
final String routerGIP, final String gateway, final String cidr,
|
||||
final String netmask, final String dns, final String domainName){
|
||||
final String netmask, final String dns, final String domainName) {
|
||||
|
||||
String args = " -C";
|
||||
args += " -d " + dev;
|
||||
@ -838,17 +834,17 @@ public class VirtualRoutingResource implements Manager {
|
||||
args += " -g " + gateway;
|
||||
args += " -m " + cidr;
|
||||
args += " -n " + netmask;
|
||||
if ( dns != null && !dns.isEmpty() ) {
|
||||
if (dns != null && !dns.isEmpty()) {
|
||||
args += " -s " + dns;
|
||||
}
|
||||
if ( domainName != null && !domainName.isEmpty() ) {
|
||||
if (domainName != null && !domainName.isEmpty()) {
|
||||
args += " -e " + domainName;
|
||||
}
|
||||
return routerProxy("vpc_guestnw.sh", routerIP, args);
|
||||
}
|
||||
|
||||
public String assignNetworkACL(final String routerIP, final String dev,
|
||||
final String routerGIP, final String netmask, final String rule, String privateGw){
|
||||
final String routerGIP, final String netmask, final String rule, String privateGw) {
|
||||
String args = " -d " + dev;
|
||||
if (privateGw != null) {
|
||||
args += " -a " + rule;
|
||||
@ -922,7 +918,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
String result = routerProxy("vpc_ipassoc.sh", routerIP, args);
|
||||
if (result != null) {
|
||||
throw new InternalErrorException("KVM plugin \"vpc_ipassoc\" failed:"+result);
|
||||
throw new InternalErrorException("KVM plugin \"vpc_ipassoc\" failed:" + result);
|
||||
}
|
||||
if (sourceNat) {
|
||||
snatArgs += " -l " + pubIP;
|
||||
@ -930,7 +926,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
result = routerProxy("vpc_privateGateway.sh", routerIP, snatArgs);
|
||||
if (result != null) {
|
||||
throw new InternalErrorException("KVM plugin \"vpc_privateGateway\" failed:"+result);
|
||||
throw new InternalErrorException("KVM plugin \"vpc_privateGateway\" failed:" + result);
|
||||
}
|
||||
|
||||
}
|
||||
@ -940,7 +936,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
try {
|
||||
String[] results = new String[cmd.getStaticRoutes().length];
|
||||
String [][] rules = cmd.generateSRouteRules();
|
||||
String[][] rules = cmd.generateSRouteRules();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String[] srRules = rules[0];
|
||||
|
||||
@ -952,7 +948,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
String result = routerProxy("vpc_staticroute.sh", routerIP, args);
|
||||
|
||||
if (result != null) {
|
||||
for (int i=0; i < results.length; i++) {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
results[i] = "Failed";
|
||||
}
|
||||
return new SetStaticRouteAnswer(cmd, false, results);
|
||||
@ -966,12 +962,11 @@ 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 vlanNetmask, final String vifMacAddress, int nicNum, boolean newNic){
|
||||
final String broadcastUri, final String vlanGateway,
|
||||
final String vlanNetmask, final String vifMacAddress, int nicNum, boolean newNic) {
|
||||
|
||||
String args = "";
|
||||
if (add) {
|
||||
@ -981,7 +976,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
String cidrSize = Long.toString(NetUtils.getCidrSize(vlanNetmask));
|
||||
if (sourceNat) {
|
||||
args +=" -s";
|
||||
args += " -s";
|
||||
}
|
||||
if (firstIP) {
|
||||
args += " -f";
|
||||
@ -993,7 +988,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
args += " -c ";
|
||||
args += publicNic;
|
||||
|
||||
args +=" -g ";
|
||||
args += " -g ";
|
||||
args += vlanGateway;
|
||||
|
||||
if (newNic) {
|
||||
@ -1025,7 +1020,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
private void stopDnsmasq(String dnsmasqName) {
|
||||
Script cmd = new Script("/bin/sh", _timeout);
|
||||
cmd.add("-c");
|
||||
cmd.add("kill -9 `cat /var/run/libvirt/network/" + dnsmasqName +".pid`");
|
||||
cmd.add("kill -9 `cat /var/run/libvirt/network/" + dnsmasqName + ".pid`");
|
||||
cmd.execute();
|
||||
}
|
||||
|
||||
@ -1094,13 +1089,13 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
_scriptsDir = (String)params.get("domr.scripts.dir");
|
||||
if (_scriptsDir == null) {
|
||||
if(s_logger.isInfoEnabled()) {
|
||||
s_logger.info("VirtualRoutingResource _scriptDir can't be initialized from domr.scripts.dir param, use default" );
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("VirtualRoutingResource _scriptDir can't be initialized from domr.scripts.dir param, use default");
|
||||
}
|
||||
_scriptsDir = getDefaultScriptsDir();
|
||||
}
|
||||
|
||||
if(s_logger.isInfoEnabled()) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("VirtualRoutingResource _scriptDir to use: " + _scriptsDir);
|
||||
}
|
||||
|
||||
@ -1135,12 +1130,12 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
|
||||
_savepasswordPath = findScript("save_password_to_domr.sh");
|
||||
if(_savepasswordPath == null) {
|
||||
if (_savepasswordPath == null) {
|
||||
throw new ConfigurationException("Unable to find save_password_to_domr.sh");
|
||||
}
|
||||
|
||||
_dhcpEntryPath = findScript("dhcp_entry.sh");
|
||||
if(_dhcpEntryPath == null) {
|
||||
if (_dhcpEntryPath == null) {
|
||||
throw new ConfigurationException("Unable to find dhcp_entry.sh");
|
||||
}
|
||||
|
||||
@ -1157,7 +1152,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
_privateEthIf = _privateEthIf.toLowerCase();
|
||||
|
||||
_bumpUpPriorityPath = findScript("bumpUpPriority.sh");
|
||||
if(_bumpUpPriorityPath == null) {
|
||||
if (_bumpUpPriorityPath == null) {
|
||||
throw new ConfigurationException("Unable to find bumpUpPriority.sh");
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -75,7 +75,7 @@ import com.cloud.utils.db.ScriptRunner;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Local(value = { SystemIntegrityChecker.class })
|
||||
@Local(value = {SystemIntegrityChecker.class})
|
||||
public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
private final Logger s_logger = Logger.getLogger(DatabaseUpgradeChecker.class);
|
||||
|
||||
@ -85,114 +85,122 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
|
||||
public DatabaseUpgradeChecker() {
|
||||
_dao = new VersionDaoImpl();
|
||||
_upgradeMap.put("2.1.7", new DbUpgrade[] { new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(),
|
||||
_upgradeMap.put("2.1.7", new DbUpgrade[] {new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(),
|
||||
new UpgradeSnapshot217to224(), 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 Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(),
|
||||
_upgradeMap.put("2.1.8", new DbUpgrade[] {new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(),
|
||||
new Upgrade222to224(), new Upgrade218to224DomainVlans(), 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 Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.1.9", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(),
|
||||
_upgradeMap.put("2.1.9", new DbUpgrade[] {new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(),
|
||||
new Upgrade222to224(), new Upgrade218to224DomainVlans(), 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 Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new UpgradeSnapshot223to224(), new Upgrade222to224(),
|
||||
_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(),
|
||||
_upgradeMap.put("2.2.2", new DbUpgrade[] {new Upgrade222to224(), new UpgradeSnapshot223to224(), 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 Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.3", new DbUpgrade[] { new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(),
|
||||
_upgradeMap.put("2.2.3", new DbUpgrade[] {new Upgrade222to224(), new UpgradeSnapshot223to224(), 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 Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.4", new DbUpgrade[] { new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(),
|
||||
_upgradeMap.put("2.2.4", new DbUpgrade[] {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 Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.5", new DbUpgrade[] { new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(),
|
||||
_upgradeMap.put("2.2.5", new DbUpgrade[] {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 Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.6", new DbUpgrade[] { new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
|
||||
_upgradeMap.put("2.2.6", 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 Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.7", new DbUpgrade[] { new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
|
||||
_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(),
|
||||
_upgradeMap.put("2.2.8", new DbUpgrade[] {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 Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.9", new DbUpgrade[] { new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(),
|
||||
_upgradeMap.put("2.2.9", new DbUpgrade[] {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 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() });
|
||||
_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()});
|
||||
|
||||
_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() });
|
||||
_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()});
|
||||
|
||||
_upgradeMap.put("2.2.12", new DbUpgrade[] { new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(),
|
||||
new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("2.2.12", new DbUpgrade[] {new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(),
|
||||
new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.13", new DbUpgrade[] { new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(),
|
||||
new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("2.2.13", new DbUpgrade[] {new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(),
|
||||
new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("2.2.14", new DbUpgrade[] { new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
|
||||
new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_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.1", new DbUpgrade[] {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.2", new DbUpgrade[] {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() });
|
||||
_upgradeMap.put("4.0.0", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("3.0.2", new DbUpgrade[] { new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("4.0.1", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("4.0.0", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("4.0.2", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("4.0.1", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("4.1.0", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("4.0.2", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("4.1.1", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("4.1.0", new DbUpgrade[] { new Upgrade410to420(), new Upgrade420to430() });
|
||||
|
||||
_upgradeMap.put("4.2.0", new DbUpgrade[] { 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() });
|
||||
_upgradeMap.put("3.0.5", new DbUpgrade[] {new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("3.0.6", new DbUpgrade[] { new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_upgradeMap.put("3.0.6", new DbUpgrade[] {new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430()});
|
||||
|
||||
_upgradeMap.put("3.0.7", new DbUpgrade[] { new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to430() });
|
||||
_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()});
|
||||
_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()});
|
||||
|
||||
_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()});
|
||||
_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()});
|
||||
}
|
||||
|
||||
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();
|
||||
@ -289,10 +301,10 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
} catch (CloudRuntimeException e){
|
||||
} catch (CloudRuntimeException e) {
|
||||
s_logger.error("Unable to upgrade the database", e);
|
||||
throw new CloudRuntimeException("Unable to upgrade the database", e);
|
||||
}finally {
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
@ -375,7 +387,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
currentVersion = this.getClass().getSuperclass().getPackage().getImplementationVersion();
|
||||
}
|
||||
|
||||
if ( currentVersion == null )
|
||||
if (currentVersion == null)
|
||||
return;
|
||||
|
||||
s_logger.info("DB version = " + dbVersion + " Code Version = " + currentVersion);
|
||||
|
||||
@ -57,7 +57,7 @@ import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value = { NetworkGuru.class })
|
||||
@Local(value = {NetworkGuru.class})
|
||||
public class BaremetaNetworkGuru extends DirectPodBasedNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(BaremetaNetworkGuru.class);
|
||||
@Inject
|
||||
|
||||
@ -54,13 +54,12 @@ 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");
|
||||
String networkScriptsDir = (String)params.get("network.scripts.dir");
|
||||
if (networkScriptsDir == null) {
|
||||
networkScriptsDir = "scripts/vm/network/vnet";
|
||||
}
|
||||
|
||||
String value = (String) params.get("scripts.timeout");
|
||||
String value = (String)params.get("scripts.timeout");
|
||||
_timeout = NumbersUtil.parseInt(value, 30 * 60) * 1000;
|
||||
|
||||
_modifyVlanPath = Script.findScript(networkScriptsDir, "modifyvlan.sh");
|
||||
@ -94,10 +93,10 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
}
|
||||
String trafficLabel = nic.getName();
|
||||
if (nic.getType() == Networks.TrafficType.Guest) {
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1)? nic.getNetworkRateMbps().intValue() * 128: 0;
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan
|
||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||
if(trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
if (trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
s_logger.debug("creating a vlan dev and bridge for guest traffic per traffic label " + trafficLabel);
|
||||
String brName = createVlanBr(vlanId, _pifs.get(trafficLabel));
|
||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType), networkRateKBps);
|
||||
@ -113,10 +112,10 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
createControlNetwork();
|
||||
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
} else if (nic.getType() == Networks.TrafficType.Public) {
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1)? nic.getNetworkRateMbps().intValue() * 128: 0;
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan
|
||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||
if(trafficLabel != null && !trafficLabel.isEmpty()){
|
||||
if (trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
s_logger.debug("creating a vlan dev and bridge for public traffic per traffic label " + trafficLabel);
|
||||
String brName = createVlanBr(vlanId, _pifs.get(trafficLabel));
|
||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType), networkRateKBps);
|
||||
@ -143,7 +142,7 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
}
|
||||
|
||||
private String setVnetBrName(String pifName, String vnetId) {
|
||||
String brName = "br" + pifName + "-"+ vnetId;
|
||||
String brName = "br" + pifName + "-" + vnetId;
|
||||
String oldStyleBrName = "cloudVirBr" + vnetId;
|
||||
|
||||
String cmdout = Script.runSimpleBashScript("brctl show | grep " + oldStyleBrName);
|
||||
@ -179,7 +178,7 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteVnetBr(String brName){
|
||||
private void deleteVnetBr(String brName) {
|
||||
synchronized (_vnetBridgeMonitor) {
|
||||
String cmdout = Script.runSimpleBashScript("ls /sys/class/net/" + brName + "/brif | grep vnet");
|
||||
if (cmdout != null && cmdout.contains("vnet")) {
|
||||
@ -199,7 +198,7 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
pName = "undefined";
|
||||
vNetId = oldStyleBrNameMatcher.group(1);
|
||||
} else if (brNameMatcher.find()) {
|
||||
if(brNameMatcher.group(1) != null || !brNameMatcher.group(1).isEmpty()) {
|
||||
if (brNameMatcher.group(1) != null || !brNameMatcher.group(1).isEmpty()) {
|
||||
pName = brNameMatcher.group(1);
|
||||
} else {
|
||||
pName = "undefined";
|
||||
@ -208,7 +207,7 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
}
|
||||
|
||||
if (vNetId == null || vNetId.isEmpty()) {
|
||||
s_logger.debug("unable to get a vNet ID from name "+ brName);
|
||||
s_logger.debug("unable to get a vNet ID from name " + brName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -42,12 +42,12 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
public void configure(Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(params);
|
||||
|
||||
String networkScriptsDir = (String) params.get("network.scripts.dir");
|
||||
String networkScriptsDir = (String)params.get("network.scripts.dir");
|
||||
if (networkScriptsDir == null) {
|
||||
networkScriptsDir = "scripts/vm/network/vnet";
|
||||
}
|
||||
|
||||
String value = (String) params.get("scripts.timeout");
|
||||
String value = (String)params.get("scripts.timeout");
|
||||
_timeout = NumbersUtil.parseInt(value, 30 * 60) * 1000;
|
||||
|
||||
createControlNetwork(_bridges.get("linklocal"));
|
||||
@ -74,10 +74,10 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
}
|
||||
String trafficLabel = nic.getName();
|
||||
if (nic.getType() == Networks.TrafficType.Guest) {
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1)? nic.getNetworkRateMbps().intValue() * 128: 0;
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan)
|
||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||
if(trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
if (trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
s_logger.debug("creating a vlan dev and bridge for guest traffic per traffic label " + trafficLabel);
|
||||
intf.defBridgeNet(_pifs.get(trafficLabel), null, nic.getMac(), getGuestNicModel(guestOsType), networkRateKBps);
|
||||
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||
@ -99,10 +99,10 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
createControlNetwork(_bridges.get("linklocal"));
|
||||
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
} else if (nic.getType() == Networks.TrafficType.Public) {
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1)? nic.getNetworkRateMbps().intValue() * 128: 0;
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan
|
||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||
if(trafficLabel != null && !trafficLabel.isEmpty()){
|
||||
if (trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
s_logger.debug("creating a vlan dev and bridge for public traffic per traffic label " + trafficLabel);
|
||||
intf.defBridgeNet(_pifs.get(trafficLabel), null, nic.getMac(), getGuestNicModel(guestOsType), networkRateKBps);
|
||||
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||
@ -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;
|
||||
@ -681,7 +683,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
|
||||
state = State.Running;
|
||||
return new StartAnswer(cmd);
|
||||
} catch (Exception e ) {
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Start vm " + vmName + " failed", e);
|
||||
cleanup(vmDetails);
|
||||
return new StartAnswer(cmd, e.getMessage());
|
||||
@ -719,7 +721,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
public StopAnswer execute(StopCommand cmd) {
|
||||
String vmName = cmd.getVmName();
|
||||
State state = null;
|
||||
synchronized(_vms) {
|
||||
synchronized (_vms) {
|
||||
state = _vms.get(vmName);
|
||||
_vms.put(vmName, State.Stopping);
|
||||
}
|
||||
@ -743,7 +745,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
s_logger.debug("Stop " + vmName + "failed", e);
|
||||
return new StopAnswer(cmd, e.getMessage(), false);
|
||||
} finally {
|
||||
synchronized(_vms) {
|
||||
synchronized (_vms) {
|
||||
if (state != null) {
|
||||
_vms.put(vmName, state);
|
||||
} else {
|
||||
@ -756,7 +758,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
@Override
|
||||
public RebootAnswer execute(RebootCommand cmd) {
|
||||
String vmName = cmd.getVmName();
|
||||
synchronized(_vms) {
|
||||
synchronized (_vms) {
|
||||
_vms.put(vmName, State.Starting);
|
||||
}
|
||||
|
||||
@ -768,7 +770,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
s_logger.debug("Reboot " + vmName + " failed", e);
|
||||
return new RebootAnswer(cmd, e.getMessage(), false);
|
||||
} finally {
|
||||
synchronized(_vms) {
|
||||
synchronized (_vms) {
|
||||
_vms.put(cmd.getVmName(), State.Running);
|
||||
}
|
||||
}
|
||||
@ -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());
|
||||
@ -1360,9 +1365,9 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
||||
} else if (clazz == AttachIsoCommand.class) {
|
||||
return execute((AttachIsoCommand)cmd);
|
||||
} else if (clazz == SecurityGroupRulesCmd.class) {
|
||||
return execute((SecurityGroupRulesCmd) cmd);
|
||||
return execute((SecurityGroupRulesCmd)cmd);
|
||||
} else if (clazz == CleanupNetworkRulesCmd.class) {
|
||||
return execute((CleanupNetworkRulesCmd) cmd);
|
||||
return execute((CleanupNetworkRulesCmd)cmd);
|
||||
} else if (clazz == PrepareOCFS2NodesCommand.class) {
|
||||
return execute((PrepareOCFS2NodesCommand)cmd);
|
||||
} else if (clazz == CreatePrivateTemplateFromVolumeCommand.class) {
|
||||
|
||||
@ -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");
|
||||
@ -545,7 +547,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
||||
throw new CloudRuntimeException("A Cisco Vnmc device is already configured on this physical network");
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<String,String>();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("guid", UUID.randomUUID().toString());
|
||||
params.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
|
||||
params.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
|
||||
@ -554,7 +556,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
||||
params.put("username", cmd.getUsername());
|
||||
params.put("password", cmd.getPassword());
|
||||
|
||||
Map<String, Object> hostdetails = new HashMap<String,Object>();
|
||||
Map<String, Object> hostdetails = new HashMap<String, Object>();
|
||||
hostdetails.putAll(params);
|
||||
|
||||
ServerResource resource = new CiscoVnmcResource();
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -127,9 +127,9 @@ import com.cloud.vm.dao.NicDao;
|
||||
SourceNatServiceProvider.class, StaticNatServiceProvider.class,
|
||||
PortForwardingServiceProvider.class, IpDeployer.class} )
|
||||
public class NiciraNvpElement extends AdapterBase implements
|
||||
ConnectivityProvider, SourceNatServiceProvider,
|
||||
PortForwardingServiceProvider, StaticNatServiceProvider,
|
||||
NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
ConnectivityProvider, SourceNatServiceProvider,
|
||||
PortForwardingServiceProvider, StaticNatServiceProvider,
|
||||
NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(NiciraNvpElement.class);
|
||||
|
||||
@ -279,7 +279,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
.getDomain().getName()
|
||||
+ "-"
|
||||
+ context.getAccount().getAccountName());
|
||||
CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
|
||||
CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer)_agentMgr
|
||||
.easySend(niciraNvpHost.getId(), cmd);
|
||||
if (answer.getResult() == false) {
|
||||
s_logger.error("Failed to create Logical Router for network "
|
||||
@ -293,7 +293,6 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
_niciraNvpRouterMappingDao.persist(routermapping);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -331,7 +330,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
FindLogicalSwitchPortCommand findCmd = new FindLogicalSwitchPortCommand(
|
||||
existingNicMap.getLogicalSwitchUuid(),
|
||||
existingNicMap.getLogicalSwitchPortUuid());
|
||||
FindLogicalSwitchPortAnswer answer = (FindLogicalSwitchPortAnswer) _agentMgr
|
||||
FindLogicalSwitchPortAnswer answer = (FindLogicalSwitchPortAnswer)_agentMgr
|
||||
.easySend(niciraNvpHost.getId(), findCmd);
|
||||
|
||||
if (answer.getResult()) {
|
||||
@ -358,7 +357,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
BroadcastDomainType.getValue(network.getBroadcastUri()),
|
||||
nicVO.getUuid(), context.getDomain().getName() + "-"
|
||||
+ context.getAccount().getAccountName(), nic.getName());
|
||||
CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer) _agentMgr
|
||||
CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer)_agentMgr
|
||||
.easySend(niciraNvpHost.getId(), cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
@ -410,7 +409,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
DeleteLogicalSwitchPortCommand cmd = new DeleteLogicalSwitchPortCommand(
|
||||
nicMap.getLogicalSwitchUuid(),
|
||||
nicMap.getLogicalSwitchPortUuid());
|
||||
DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer) _agentMgr
|
||||
DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer)_agentMgr
|
||||
.easySend(niciraNvpHost.getId(), cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
@ -458,7 +457,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
|
||||
DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
|
||||
DeleteLogicalRouterAnswer answer =
|
||||
(DeleteLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
(DeleteLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
if (answer.getResult() == false) {
|
||||
s_logger.error("Failed to delete LogicalRouter for network "
|
||||
+ network.getDisplayText());
|
||||
@ -854,7 +853,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
}
|
||||
ConfigurePublicIpsOnLogicalRouterCommand cmd = new ConfigurePublicIpsOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(),
|
||||
niciraNvpHost.getDetail("l3gatewayserviceuuid"), cidrs);
|
||||
ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
//FIXME answer can be null if the host is down
|
||||
return answer.getResult();
|
||||
}
|
||||
@ -909,7 +908,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
|
||||
ConfigureStaticNatRulesOnLogicalRouterCommand cmd =
|
||||
new ConfigureStaticNatRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), staticNatRules);
|
||||
ConfigureStaticNatRulesOnLogicalRouterAnswer answer = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
ConfigureStaticNatRulesOnLogicalRouterAnswer answer = (ConfigureStaticNatRulesOnLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
|
||||
return answer.getResult();
|
||||
}
|
||||
@ -952,7 +951,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
|
||||
|
||||
ConfigurePortForwardingRulesOnLogicalRouterCommand cmd =
|
||||
new ConfigurePortForwardingRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), portForwardingRules);
|
||||
ConfigurePortForwardingRulesOnLogicalRouterAnswer answer = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
ConfigurePortForwardingRulesOnLogicalRouterAnswer answer = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
|
||||
return answer.getResult();
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -65,11 +65,10 @@ import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value=NetworkGuru.class)
|
||||
@Local(value = NetworkGuru.class)
|
||||
public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(NiciraNvpGuestNetworkGuru.class);
|
||||
|
||||
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
@ -95,7 +94,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
|
||||
public NiciraNvpGuestNetworkGuru() {
|
||||
super();
|
||||
_isolationMethods = new IsolationMethod[] { IsolationMethod.STT };
|
||||
_isolationMethods = new IsolationMethod[] {IsolationMethod.STT};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,7 +118,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
// Check of the isolation type of the related physical network is STT
|
||||
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
|
||||
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
|
||||
if (!canHandle(offering,dc.getNetworkType(),physnet)) {
|
||||
if (!canHandle(offering, dc.getNetworkType(), physnet)) {
|
||||
s_logger.debug("Refusing to design this network");
|
||||
return null;
|
||||
}
|
||||
@ -132,7 +131,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
s_logger.debug("Nicira Nvp " + devices.get(0).getUuid() + " found on physical network " + physnet.getId());
|
||||
|
||||
s_logger.debug("Physical isolation type is STT, asking GuestNetworkGuru to design this network");
|
||||
NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
|
||||
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
|
||||
if (networkObject == null) {
|
||||
return null;
|
||||
}
|
||||
@ -174,7 +173,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
if (name == null || name.isEmpty()) {
|
||||
name = ((NetworkVO)network).getUuid();
|
||||
}
|
||||
if (name.length() > 40 ) {
|
||||
if (name.length() > 40) {
|
||||
name = name.substring(0, 39); // max length 40
|
||||
}
|
||||
|
||||
@ -191,10 +190,10 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
|
||||
CreateLogicalSwitchCommand cmd = new CreateLogicalSwitchCommand(transportzoneuuid, transportzoneisotype, name,
|
||||
context.getDomain().getName() + "-" + context.getAccount().getAccountName());
|
||||
CreateLogicalSwitchAnswer answer = (CreateLogicalSwitchAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
CreateLogicalSwitchAnswer answer = (CreateLogicalSwitchAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.error ("CreateLogicalSwitchCommand failed");
|
||||
s_logger.error("CreateLogicalSwitchCommand failed");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -249,7 +248,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
DeleteLogicalSwitchAnswer answer = (DeleteLogicalSwitchAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.error ("DeleteLogicalSwitchCommand failed");
|
||||
s_logger.error("DeleteLogicalSwitchCommand failed");
|
||||
}
|
||||
|
||||
super.shutdown(profile, offering);
|
||||
@ -260,8 +259,4 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@Component
|
||||
@Local(value={OvsTunnelManager.class})
|
||||
@Local(value = {OvsTunnelManager.class})
|
||||
public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManager {
|
||||
public static final Logger s_logger =
|
||||
Logger.getLogger(OvsTunnelManagerImpl.class.getName());
|
||||
@ -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)
|
||||
@ -123,7 +132,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
|
||||
@DB
|
||||
protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
|
||||
String netmask,String mac,long hostId, String label) {
|
||||
String netmask, String mac, long hostId, String label) {
|
||||
OvsTunnelInterfaceVO ti = null;
|
||||
try {
|
||||
ti = new OvsTunnelInterfaceVO(ip, netmask, mac, hostId, label);
|
||||
@ -143,8 +152,8 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
return ti;
|
||||
}
|
||||
|
||||
private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId){
|
||||
OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer) answers[0];
|
||||
private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId) {
|
||||
OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer)answers[0];
|
||||
if (ans.getResult()) {
|
||||
if (ans.getIp() != null &&
|
||||
!("".equals(ans.getIp()))) {
|
||||
@ -160,8 +169,8 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleCreateTunnelAnswer(Answer[] answers){
|
||||
OvsCreateTunnelAnswer r = (OvsCreateTunnelAnswer) answers[0];
|
||||
private void handleCreateTunnelAnswer(Answer[] answers) {
|
||||
OvsCreateTunnelAnswer r = (OvsCreateTunnelAnswer)answers[0];
|
||||
String s = String.format(
|
||||
"(hostIP:%1$s, remoteIP:%2$s, bridge:%3$s," +
|
||||
"greKey:%4$s, portName:%5$s)",
|
||||
@ -203,7 +212,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
switch (hvType) {
|
||||
case XenServer:
|
||||
String label = physNetTT.getXenNetworkLabel();
|
||||
if ((label!=null) && (!label.equals(""))) {
|
||||
if ((label != null) && (!label.equals(""))) {
|
||||
physNetLabel = label;
|
||||
}
|
||||
break;
|
||||
@ -282,7 +291,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
State.Stopping, State.Unknown, State.Migrating);
|
||||
// Find routers for the network
|
||||
List<DomainRouterVO> routers = _routerDao.findByNetwork(nw.getId());
|
||||
List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
|
||||
List<VMInstanceVO> ins = new ArrayList<VMInstanceVO>();
|
||||
if (vms != null) {
|
||||
ins.addAll(vms);
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -89,7 +89,7 @@ import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
|
||||
@Component
|
||||
@Local(value = { ExternalDeviceUsageManager.class })
|
||||
@Local(value = {ExternalDeviceUsageManager.class})
|
||||
public class ExternalDeviceUsageManagerImpl extends ManagerBase implements ExternalDeviceUsageManager {
|
||||
|
||||
String _name;
|
||||
@ -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);
|
||||
@ -199,26 +198,26 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
if (fwDeviceForNetwork != null) {
|
||||
long fwDeviceId = fwDeviceForNetwork.getExternalFirewallDeviceId();
|
||||
ExternalFirewallDeviceVO fwDevice = _externalFirewallDeviceDao.findById(fwDeviceId);
|
||||
assert(fwDevice != null);
|
||||
assert (fwDevice != null);
|
||||
return fwDevice;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExternalLoadBalancerNetworkUsageStats(long loadBalancerRuleId){
|
||||
public void updateExternalLoadBalancerNetworkUsageStats(long loadBalancerRuleId) {
|
||||
|
||||
LoadBalancerVO lb = _loadBalancerDao.findById(loadBalancerRuleId);
|
||||
if(lb == null){
|
||||
if(s_logger.isDebugEnabled()){
|
||||
if (lb == null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cannot update usage stats, LB rule is not found");
|
||||
}
|
||||
return;
|
||||
}
|
||||
long networkId = lb.getNetworkId();
|
||||
Network network = _networkDao.findById(networkId);
|
||||
if(network == null){
|
||||
if(s_logger.isDebugEnabled()){
|
||||
if (network == null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cannot update usage stats, Network is not found");
|
||||
}
|
||||
return;
|
||||
@ -226,7 +225,7 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = getExternalLoadBalancerForNetwork(network);
|
||||
if (lbDeviceVO == null) {
|
||||
if(s_logger.isDebugEnabled()){
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cannot update usage stats, No external LB device found");
|
||||
}
|
||||
return;
|
||||
@ -237,7 +236,7 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
HostVO externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
|
||||
if (externalLoadBalancer != null) {
|
||||
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();
|
||||
lbAnswer = (ExternalNetworkResourceUsageAnswer) _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
lbAnswer = (ExternalNetworkResourceUsageAnswer)_agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
if (lbAnswer == null || !lbAnswer.getResult()) {
|
||||
String details = (lbAnswer != null) ? lbAnswer.getDetails() : "details unavailable";
|
||||
String msg = "Unable to get external load balancer stats for network" + networkId + " due to: " + details + ".";
|
||||
@ -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;
|
||||
@ -294,12 +294,13 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
txn.start();
|
||||
userStats = _userStatsDao.lock(accountId, zone.getId(), networkId, publicIp, externalLoadBalancer.getId(), externalLoadBalancer.getType().toString());
|
||||
|
||||
if(userStats != null){
|
||||
if (userStats != null) {
|
||||
long oldNetBytesSent = userStats.getNetBytesSent();
|
||||
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) {
|
||||
@ -318,12 +319,12 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
} else {
|
||||
s_logger.debug("Failed to update stats for " + statsEntryIdentifier);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
s_logger.warn("Unable to find user stats entry for " + statsEntryIdentifier);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
}catch (final Exception e) {
|
||||
} catch (final Exception e) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException("Problem getting stats after reboot/stop ", e);
|
||||
}
|
||||
@ -398,14 +399,14 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
// Get network stats from the external firewall
|
||||
ExternalNetworkResourceUsageAnswer firewallAnswer = null;
|
||||
HostVO externalFirewall = null;
|
||||
if(fwDeviceVO != null){
|
||||
if (fwDeviceVO != null) {
|
||||
externalFirewall = _hostDao.findById(fwDeviceVO.getHostId());
|
||||
if (externalFirewall != null) {
|
||||
Long fwDeviceId = new Long(externalFirewall.getId());
|
||||
if(!fwDeviceUsageAnswerMap.containsKey(fwDeviceId)){
|
||||
try{
|
||||
if (!fwDeviceUsageAnswerMap.containsKey(fwDeviceId)) {
|
||||
try {
|
||||
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();
|
||||
firewallAnswer = (ExternalNetworkResourceUsageAnswer) _agentMgr.easySend(externalFirewall.getId(), cmd);
|
||||
firewallAnswer = (ExternalNetworkResourceUsageAnswer)_agentMgr.easySend(externalFirewall.getId(), cmd);
|
||||
if (firewallAnswer == null || !firewallAnswer.getResult()) {
|
||||
String details = (firewallAnswer != null) ? firewallAnswer.getDetails() : "details unavailable";
|
||||
String msg = "Unable to get external firewall stats for network" + zone.getName() + " due to: " + details + ".";
|
||||
@ -413,7 +414,7 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
} else {
|
||||
fwDeviceUsageAnswerMap.put(fwDeviceId, firewallAnswer);
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
String msg = "Unable to get external firewall stats for network" + zone.getName();
|
||||
s_logger.error(msg, e);
|
||||
}
|
||||
@ -423,19 +424,20 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
}
|
||||
firewallAnswer = fwDeviceUsageAnswerMap.get(fwDeviceId);
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
// Get network stats from the external load balancer
|
||||
ExternalNetworkResourceUsageAnswer lbAnswer = null;
|
||||
HostVO externalLoadBalancer = null;
|
||||
if(lbDeviceVO !=null){
|
||||
if (lbDeviceVO != null) {
|
||||
externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
|
||||
if (externalLoadBalancer != null) {
|
||||
Long lbDeviceId = new Long(externalLoadBalancer.getId());
|
||||
if (!lbDeviceUsageAnswerMap.containsKey(lbDeviceId)) {
|
||||
try {
|
||||
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();
|
||||
lbAnswer = (ExternalNetworkResourceUsageAnswer) _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
lbAnswer = (ExternalNetworkResourceUsageAnswer)_agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
if (lbAnswer == null || !lbAnswer.getResult()) {
|
||||
String details = (lbAnswer != null) ? lbAnswer.getDetails() : "details unavailable";
|
||||
String msg = "Unable to get external load balancer stats for " + zone.getName() + " due to: " + details + ".";
|
||||
@ -443,7 +445,7 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
} else {
|
||||
lbDeviceUsageAnswerMap.put(lbDeviceId, lbAnswer);
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
String msg = "Unable to get external load balancer stats for " + zone.getName();
|
||||
s_logger.error(msg, e);
|
||||
}
|
||||
@ -456,7 +458,7 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
}
|
||||
}
|
||||
|
||||
if(firewallAnswer == null && lbAnswer == null){
|
||||
if (firewallAnswer == null && lbAnswer == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
@ -615,7 +619,7 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter
|
||||
}
|
||||
}
|
||||
|
||||
if(externalFirewall != null && firewallAnswer != null){
|
||||
if (externalFirewall != null && firewallAnswer != null) {
|
||||
if (!sharedSourceNat) {
|
||||
// Manage the entry for this network's source NAT IP address
|
||||
List<IPAddressVO> sourceNatIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), true);
|
||||
|
||||
@ -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
|
||||
@ -162,11 +161,11 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
@DB
|
||||
public ExternalFirewallDeviceVO addExternalFirewall(long physicalNetworkId, String url, String username, String password, String deviceName, ServerResource resource) {
|
||||
String guid;
|
||||
PhysicalNetworkVO pNetwork=null;
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
NetworkDevice ntwkDevice = NetworkDevice.getNetworkDevice(deviceName);
|
||||
long zoneId;
|
||||
|
||||
if ((ntwkDevice == null) || (url == null) || (username == null) || (resource == null) || (password == null) ) {
|
||||
if ((ntwkDevice == null) || (url == null) || (username == null) || (resource == null) || (password == null)) {
|
||||
throw new InvalidParameterValueException("Atleast one of the required parameters (url, username, password," +
|
||||
" server resource, zone id/physical network id) is not specified or a valid parameter.");
|
||||
}
|
||||
@ -277,7 +276,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
public List<Host> listExternalFirewalls(long physicalNetworkId, String deviceName) {
|
||||
List<Host> firewallHosts = new ArrayList<Host>();
|
||||
NetworkDevice fwNetworkDevice = NetworkDevice.getNetworkDevice(deviceName);
|
||||
PhysicalNetworkVO pNetwork=null;
|
||||
PhysicalNetworkVO pNetwork = null;
|
||||
|
||||
pNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (pNetwork == null) {
|
||||
@ -306,7 +305,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
if (fwDeviceForNetwork != null) {
|
||||
long fwDeviceId = fwDeviceForNetwork.getExternalFirewallDeviceId();
|
||||
ExternalFirewallDeviceVO fwDevice = _externalFirewallDeviceDao.findById(fwDeviceId);
|
||||
assert(fwDevice != null);
|
||||
assert (fwDevice != null);
|
||||
return fwDevice;
|
||||
}
|
||||
return null;
|
||||
@ -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
|
||||
@ -536,10 +535,11 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
}
|
||||
HostVO externalFirewall = _hostDao.findById(fwDeviceVO.getHostId());
|
||||
|
||||
assert(externalFirewall != null);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -578,10 +578,11 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
ExternalFirewallDeviceVO fwDeviceVO = getExternalFirewallForNetwork(network);
|
||||
HostVO externalFirewall = _hostDao.findById(fwDeviceVO.getHostId());
|
||||
|
||||
assert(externalFirewall != null);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -730,13 +732,13 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
Integer lowestVlanTag = null;
|
||||
List<Pair<Integer, Integer>> vnetList = pNetwork.getVnet();
|
||||
//finding the vlanrange in which the vlanTag lies.
|
||||
for (Pair <Integer,Integer> vnet : vnetList){
|
||||
if (vlanTag >= vnet.first() && vlanTag <= vnet.second()){
|
||||
for (Pair<Integer, Integer> vnet : vnetList) {
|
||||
if (vlanTag >= vnet.first() && vlanTag <= vnet.second()) {
|
||||
lowestVlanTag = vnet.first();
|
||||
}
|
||||
}
|
||||
if (lowestVlanTag == null) {
|
||||
throw new InvalidParameterValueException ("The vlan tag does not belong to any of the existing vlan ranges");
|
||||
throw new InvalidParameterValueException("The vlan tag does not belong to any of the existing vlan ranges");
|
||||
}
|
||||
return vlanTag - lowestVlanTag;
|
||||
}
|
||||
@ -782,10 +784,11 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
ExternalFirewallDeviceVO fwDeviceVO = getExternalFirewallForNetwork(network);
|
||||
HostVO externalFirewall = _hostDao.findById(fwDeviceVO.getHostId());
|
||||
|
||||
assert(externalFirewall != null);
|
||||
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) {
|
||||
@ -489,13 +493,14 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
CreateLoadBalancerApplianceCommand lbProvisionCmd = new CreateLoadBalancerApplianceCommand(lbIP, netmask, gateway);
|
||||
CreateLoadBalancerApplianceAnswer createLbAnswer = null;
|
||||
try {
|
||||
createLbAnswer = (CreateLoadBalancerApplianceAnswer) _agentMgr.easySend(lbProviderDevice.getHostId(), lbProvisionCmd);
|
||||
createLbAnswer = (CreateLoadBalancerApplianceAnswer)_agentMgr.easySend(lbProviderDevice.getHostId(), lbProvisionCmd);
|
||||
if (createLbAnswer == null || !createLbAnswer.getResult()) {
|
||||
s_logger.error("Could not provision load balancer instance on the load balancer device " + lbProviderDevice.getId());
|
||||
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) {
|
||||
@ -547,7 +553,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
DestroyLoadBalancerApplianceCommand lbDeleteCmd = new DestroyLoadBalancerApplianceCommand(lbIP);
|
||||
DestroyLoadBalancerApplianceAnswer answer = null;
|
||||
try {
|
||||
answer = (DestroyLoadBalancerApplianceAnswer) _agentMgr.easySend(lbProviderDevice.getHostId(), lbDeleteCmd);
|
||||
answer = (DestroyLoadBalancerApplianceAnswer)_agentMgr.easySend(lbProviderDevice.getHostId(), lbDeleteCmd);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.warn("Failed to destroy load balancer appliance created");
|
||||
} else {
|
||||
@ -684,7 +690,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
DestroyLoadBalancerApplianceCommand lbDeleteCmd = new DestroyLoadBalancerApplianceCommand(lbIP);
|
||||
DestroyLoadBalancerApplianceAnswer answer = null;
|
||||
try {
|
||||
answer = (DestroyLoadBalancerApplianceAnswer) _agentMgr.easySend(lbDevice.getParentHostId(), lbDeleteCmd);
|
||||
answer = (DestroyLoadBalancerApplianceAnswer)_agentMgr.easySend(lbDevice.getParentHostId(), lbDeleteCmd);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.warn("Failed to destoy load balancer appliance used by the network" + guestConfig.getId() + " due to " + answer.getDetails());
|
||||
}
|
||||
@ -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;
|
||||
@ -1193,7 +1203,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
long guestVlanTag = Integer.parseInt(BroadcastDomainType.getValue(network.getBroadcastUri()));
|
||||
cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag));
|
||||
|
||||
answer = (HealthCheckLBConfigAnswer) _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
answer = (HealthCheckLBConfigAnswer)_agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("Exception Occured ", ex);
|
||||
|
||||
@ -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,10 +78,9 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
@Inject
|
||||
IpAddressManager _ipAddrMgr;
|
||||
|
||||
|
||||
public ExternalGuestNetworkGuru() {
|
||||
super();
|
||||
_isolationMethods = new IsolationMethod[] { IsolationMethod.GRE, IsolationMethod.L3, IsolationMethod.VLAN };
|
||||
_isolationMethods = new IsolationMethod[] {IsolationMethod.GRE, IsolationMethod.L3, IsolationMethod.VLAN};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,7 +108,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
NetworkVO config = (NetworkVO) super.design(offering, plan, userSpecified, owner);
|
||||
NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, owner);
|
||||
if (config == null) {
|
||||
return null;
|
||||
} else if (_networkModel.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
|
||||
@ -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());
|
||||
@ -204,8 +204,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
}
|
||||
// Mask the destination address of all static nat rules in this network with the new guest VLAN offset
|
||||
// Here the private ip of the nic get updated. When secondary ip are present the gc will not triggered
|
||||
List <IPAddressVO> ipAddrsOfNw = _ipAddressDao.listStaticNatPublicIps(config.getId());
|
||||
for (IPAddressVO ip: ipAddrsOfNw) {
|
||||
List<IPAddressVO> ipAddrsOfNw = _ipAddressDao.listStaticNatPublicIps(config.getId());
|
||||
for (IPAddressVO ip : ipAddrsOfNw) {
|
||||
if (ip.getVmIp() != null) {
|
||||
long ipMask = getIpMask(ip.getVmIp(), cidrSize);
|
||||
String maskedVmIp = NetUtils.long2Ip(newCidrAddress | ipMask);
|
||||
@ -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) {
|
||||
@ -247,13 +247,13 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
Integer lowestVlanTag = null;
|
||||
List<Pair<Integer, Integer>> vnetList = pNetwork.getVnet();
|
||||
//finding the vlanrange in which the vlanTag lies.
|
||||
for (Pair <Integer,Integer> vnet : vnetList){
|
||||
if (vlanTag >= vnet.first() && vlanTag <= vnet.second()){
|
||||
for (Pair<Integer, Integer> vnet : vnetList) {
|
||||
if (vlanTag >= vnet.first() && vlanTag <= vnet.second()) {
|
||||
lowestVlanTag = vnet.first();
|
||||
}
|
||||
}
|
||||
if (lowestVlanTag == null) {
|
||||
throw new InvalidParameterValueException ("The vlan tag does not belong to any of the existing vlan ranges");
|
||||
throw new InvalidParameterValueException("The vlan tag does not belong to any of the existing vlan ranges");
|
||||
}
|
||||
return vlanTag - lowestVlanTag;
|
||||
}
|
||||
|
||||
@ -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,9 +186,8 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
return nic;
|
||||
}
|
||||
|
||||
|
||||
protected void getIp(NicProfile nic, DataCenter dc, Network network)
|
||||
throws InsufficientVirtualNetworkCapcityException,InsufficientAddressCapacityException {
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
if (nic.getIp4Address() == null) {
|
||||
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(network.getDataCenterId(), network.getId(), null);
|
||||
String vlanTag = BroadcastDomainType.getValue(network.getBroadcastUri());
|
||||
@ -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);
|
||||
@ -64,7 +71,7 @@ public class NetUtils {
|
||||
private final static Random _rand = new Random(System.currentTimeMillis());
|
||||
|
||||
public static long createSequenceBasedMacAddress(long macAddress) {
|
||||
return macAddress | 0x060000000000l | (((long) _rand.nextInt(32768) << 25) & 0x00fffe000000l);
|
||||
return macAddress | 0x060000000000l | (((long)_rand.nextInt(32768) << 25) & 0x00fffe000000l);
|
||||
}
|
||||
|
||||
public static String getHostName() {
|
||||
@ -131,7 +138,7 @@ public class NetUtils {
|
||||
int prefixLength = address.getNetworkPrefixLength();
|
||||
if (prefixLength < 32 && prefixLength > 0) {
|
||||
String ip = ipFromInetAddress(addr);
|
||||
if(ip.equalsIgnoreCase(defaultHostIp))
|
||||
if (ip.equalsIgnoreCase(defaultHostIp))
|
||||
cidrList.add(ipAndNetMaskToCidr(ip, getCidrNetmask(prefixLength)));
|
||||
}
|
||||
}
|
||||
@ -146,16 +153,14 @@ public class NetUtils {
|
||||
|
||||
private static boolean isWindows() {
|
||||
String os = System.getProperty("os.name");
|
||||
if(os != null && os.startsWith("Windows"))
|
||||
if (os != null && os.startsWith("Windows"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getDefaultHostIp() {
|
||||
if(SystemUtils.IS_OS_WINDOWS) {
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
Pattern pattern = Pattern.compile("\\s*0.0.0.0\\s*0.0.0.0\\s*(\\S*)\\s*(\\S*)\\s*");
|
||||
try {
|
||||
Process result = Runtime.getRuntime().exec("route print -4");
|
||||
@ -163,14 +168,14 @@ public class NetUtils {
|
||||
(new InputStreamReader(result.getInputStream()));
|
||||
|
||||
String line = output.readLine();
|
||||
while(line != null){
|
||||
while (line != null) {
|
||||
Matcher matcher = pattern.matcher(line);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(2);
|
||||
}
|
||||
line = output.readLine();
|
||||
}
|
||||
} catch( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
@ -212,8 +217,6 @@ public class NetUtils {
|
||||
return defaultRouteList[7];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static InetAddress getFirstNonLoopbackLocalInetAddress() {
|
||||
InetAddress[] addrs = getAllLocalInetAddresses();
|
||||
if (addrs != null) {
|
||||
@ -322,7 +325,7 @@ public class NetUtils {
|
||||
byte[] mac = ni.getHardwareAddress();
|
||||
|
||||
for (int i = 0; i < mac.length; i++) {
|
||||
macAddressAsLong |= ((long) (mac[i] & 0xff) << (mac.length - i - 1) * 8);
|
||||
macAddressAsLong |= ((long)(mac[i] & 0xff) << (mac.length - i - 1) * 8);
|
||||
}
|
||||
|
||||
} catch (SocketException e) {
|
||||
@ -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();
|
||||
@ -593,7 +597,7 @@ public class NetUtils {
|
||||
if (st.countTokens() == 4) {
|
||||
try {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
bytes[i] = (byte) Integer.parseInt(st.nextToken());
|
||||
bytes[i] = (byte)Integer.parseInt(st.nextToken());
|
||||
}
|
||||
return InetAddress.getByAddress(address, bytes);
|
||||
} catch (NumberFormatException nfe) {
|
||||
@ -646,7 +650,7 @@ public class NetUtils {
|
||||
end = (end << (32 - size)) - 2;
|
||||
int maxIps = 255; // get 255 ips as maximum
|
||||
while (start <= end && maxIps > 0) {
|
||||
if (!usedIps.contains(start)){
|
||||
if (!usedIps.contains(start)) {
|
||||
result.add(start);
|
||||
maxIps--;
|
||||
}
|
||||
@ -686,7 +690,7 @@ public class NetUtils {
|
||||
long startNetMask = ip2Long(getCidrNetmask(size));
|
||||
long startIp = (cidr & startNetMask) + 1; //exclude the first ip since it isnt valid, e.g., 192.168.10.0
|
||||
int range = 1 << (32 - size); //e.g., /24 = 2^8 = 256
|
||||
range = range -1; //exclude end of the range since that is the broadcast address, e.g., 192.168.10.255
|
||||
range = range - 1; //exclude end of the range since that is the broadcast address, e.g., 192.168.10.255
|
||||
|
||||
if (avoid.size() >= range) {
|
||||
return -1;
|
||||
@ -788,7 +792,7 @@ public class NetUtils {
|
||||
end++;
|
||||
end = (end << (32 - bits)) - 2;
|
||||
|
||||
return new String[] { long2Ip(start), long2Ip(end) };
|
||||
return new String[] {long2Ip(start), long2Ip(end)};
|
||||
|
||||
}
|
||||
|
||||
@ -804,10 +808,11 @@ public class NetUtils {
|
||||
sameSubnet,
|
||||
errorInCidrFormat
|
||||
}
|
||||
public static supersetOrSubset isNetowrkASubsetOrSupersetOfNetworkB (String cidrA, String cidrB) {
|
||||
|
||||
public static supersetOrSubset isNetowrkASubsetOrSupersetOfNetworkB(String cidrA, String cidrB) {
|
||||
Long[] cidrALong = cidrToLong(cidrA);
|
||||
Long[] cidrBLong = cidrToLong(cidrB);
|
||||
long shift =0;
|
||||
long shift = 0;
|
||||
if (cidrALong == null || cidrBLong == null) {
|
||||
//implies error in the cidr format
|
||||
return supersetOrSubset.errorInCidrFormat;
|
||||
@ -867,7 +872,7 @@ public class NetUtils {
|
||||
}
|
||||
long numericNetmask = (0xffffffff >> (32 - cidrSizeNum)) << (32 - cidrSizeNum);
|
||||
long ipAddr = ip2Long(cidrAddress);
|
||||
Long[] cidrlong = { ipAddr & numericNetmask, (long) cidrSizeNum };
|
||||
Long[] cidrlong = {ipAddr & numericNetmask, (long)cidrSizeNum};
|
||||
return cidrlong;
|
||||
|
||||
}
|
||||
@ -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),
|
||||
@ -1064,9 +1068,9 @@ public class NetUtils {
|
||||
}
|
||||
|
||||
// Check if 2 CIDRs have exactly same IP Range
|
||||
public static boolean isSameIpRange (String cidrA, String cidrB) {
|
||||
public static boolean isSameIpRange(String cidrA, String cidrB) {
|
||||
|
||||
if(!NetUtils.isValidCIDR(cidrA)) {
|
||||
if (!NetUtils.isValidCIDR(cidrA)) {
|
||||
s_logger.info("Invalid value of cidr " + cidrA);
|
||||
return false;
|
||||
}
|
||||
@ -1079,18 +1083,19 @@ public class NetUtils {
|
||||
|
||||
Long networkSizeFirst = Long.valueOf(cidrPairFirst[1]);
|
||||
Long networkSizeSecond = Long.valueOf(cidrPairSecond[1]);
|
||||
String ipRangeFirst [] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeFirst);
|
||||
String ipRangeSecond [] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeSecond);
|
||||
String ipRangeFirst[] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeFirst);
|
||||
String ipRangeSecond[] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeSecond);
|
||||
|
||||
long startIpFirst = NetUtils.ip2Long(ipRangeFirst[0]);
|
||||
long endIpFirst = NetUtils.ip2Long(ipRangeFirst[1]);
|
||||
long startIpSecond = NetUtils.ip2Long(ipRangeSecond[0]);
|
||||
long endIpSecond = NetUtils.ip2Long(ipRangeSecond[1]);
|
||||
if(startIpFirst == startIpSecond && endIpFirst == endIpSecond) {
|
||||
if (startIpFirst == startIpSecond && endIpFirst == endIpSecond) {
|
||||
return true;
|
||||
}
|
||||
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:
|
||||
@ -1181,7 +1186,7 @@ public class NetUtils {
|
||||
|
||||
public static boolean validateIcmpType(long icmpType) {
|
||||
//Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html
|
||||
if(!(icmpType >=0 && icmpType <=255)) {
|
||||
if (!(icmpType >= 0 && icmpType <= 255)) {
|
||||
s_logger.warn("impcType is not within 0-255 range");
|
||||
return false;
|
||||
}
|
||||
@ -1191,7 +1196,7 @@ public class NetUtils {
|
||||
public static boolean validateIcmpCode(long icmpCode) {
|
||||
|
||||
//Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html
|
||||
if(!(icmpCode >=0 && icmpCode <=15)) {
|
||||
if (!(icmpCode >= 0 && icmpCode <= 15)) {
|
||||
s_logger.warn("Icmp code should be within 0-15 range");
|
||||
return false;
|
||||
}
|
||||
@ -1356,7 +1361,7 @@ public class NetUtils {
|
||||
IPv6Address result = null;
|
||||
if (current.equals(end)) {
|
||||
result = start;
|
||||
} else{
|
||||
} else {
|
||||
result = current.add(1);
|
||||
}
|
||||
String resultIp = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user