mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
tuna
This commit is contained in:
parent
3df8b912fc
commit
9f82757eb9
@ -247,14 +247,6 @@ public class OvsElement extends AdapterBase implements NetworkElement,
|
||||
// L2 Support : SDN provisioning
|
||||
capabilities.put(Service.Connectivity, null);
|
||||
|
||||
// L3 Support : SourceNat
|
||||
// Map<Capability, String> sourceNatCapabilities = new
|
||||
// HashMap<Capability, String>();
|
||||
// sourceNatCapabilities.put(Capability.SupportedSourceNatTypes,
|
||||
// "peraccount");
|
||||
// sourceNatCapabilities.put(Capability.RedundantRouter, "false");
|
||||
// capabilities.put(Service.SourceNat, sourceNatCapabilities);
|
||||
|
||||
// L3 Support : Port Forwarding
|
||||
capabilities.put(Service.PortForwarding, null);
|
||||
|
||||
|
||||
@ -81,29 +81,28 @@ 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)
|
||||
throws ConfigurationException {
|
||||
// _isEnabled =
|
||||
// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
|
||||
//
|
||||
// if (_isEnabled) {
|
||||
// _executorPool = Executors.newScheduledThreadPool(10, new
|
||||
// NamedThreadFactory("OVS"));
|
||||
// _cleanupExecutor = Executors.newScheduledThreadPool(1, new
|
||||
// NamedThreadFactory("OVS-Cleanup"));
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,8 +111,8 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
OvsTunnelNetworkVO ta = null;
|
||||
try {
|
||||
ta = new OvsTunnelNetworkVO(from, to, key, networkId);
|
||||
OvsTunnelNetworkVO lock =
|
||||
_tunnelNetworkDao.acquireInLockTable(Long.valueOf(1));
|
||||
OvsTunnelNetworkVO lock = _tunnelNetworkDao.acquireInLockTable(Long
|
||||
.valueOf(1));
|
||||
if (lock == null) {
|
||||
s_logger.warn("Cannot lock table ovs_tunnel_account");
|
||||
return null;
|
||||
@ -121,21 +120,21 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
_tunnelNetworkDao.persist(ta);
|
||||
_tunnelNetworkDao.releaseFromLockTable(lock.getId());
|
||||
} catch (EntityExistsException e) {
|
||||
s_logger.debug("A record for the tunnel from " + from +
|
||||
" to " + to + " already exists");
|
||||
s_logger.debug("A record for the tunnel from " + from + " to " + to
|
||||
+ " already exists");
|
||||
}
|
||||
return ta;
|
||||
}
|
||||
|
||||
@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);
|
||||
//TODO: Is locking really necessary here?
|
||||
OvsTunnelInterfaceVO lock =
|
||||
_tunnelInterfaceDao.acquireInLockTable(Long.valueOf(1));
|
||||
// TODO: Is locking really necessary here?
|
||||
OvsTunnelInterfaceVO lock = _tunnelInterfaceDao
|
||||
.acquireInLockTable(Long.valueOf(1));
|
||||
if (lock == null) {
|
||||
s_logger.warn("Cannot lock table ovs_tunnel_account");
|
||||
return null;
|
||||
@ -143,26 +142,24 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
_tunnelInterfaceDao.persist(ti);
|
||||
_tunnelInterfaceDao.releaseFromLockTable(lock.getId());
|
||||
} catch (EntityExistsException e) {
|
||||
s_logger.debug("A record for the interface for network " + label +
|
||||
" on host id " + hostId + " already exists");
|
||||
s_logger.debug("A record for the interface for network " + label
|
||||
+ " on host id " + hostId + " already exists");
|
||||
}
|
||||
return ti;
|
||||
}
|
||||
|
||||
private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId){
|
||||
private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId) {
|
||||
OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer) answers[0];
|
||||
if (ans.getResult()) {
|
||||
if (ans.getIp() != null &&
|
||||
!("".equals(ans.getIp()))) {
|
||||
OvsTunnelInterfaceVO ti =
|
||||
createInterfaceRecord(ans.getIp(), ans.getNetmask(),
|
||||
ans.getMac(), hostId, ans.getLabel());
|
||||
if (ans.getIp() != null && !("".equals(ans.getIp()))) {
|
||||
OvsTunnelInterfaceVO ti = createInterfaceRecord(ans.getIp(),
|
||||
ans.getNetmask(), ans.getMac(), hostId, ans.getLabel());
|
||||
return ti.getIp();
|
||||
}
|
||||
}
|
||||
// Fetch interface failed!
|
||||
s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint" +
|
||||
ans.getDetails());
|
||||
s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint"
|
||||
+ ans.getDetails());
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -241,19 +238,18 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
}
|
||||
if (!r.getResult()) {
|
||||
tunnel.setState("FAILED");
|
||||
s_logger.warn("Create GRE tunnel failed due to " +
|
||||
r.getDetails() + s);
|
||||
s_logger.warn("Create GRE tunnel failed due to " + r.getDetails()
|
||||
+ s);
|
||||
} else {
|
||||
tunnel.setState("SUCCESS");
|
||||
tunnel.setPortName(r.getInPortName());
|
||||
s_logger.warn("Create GRE tunnel " +
|
||||
r.getDetails() + s);
|
||||
s_logger.warn("Create GRE tunnel " + r.getDetails() + s);
|
||||
}
|
||||
_tunnelNetworkDao.update(tunnel.getId(), tunnel);
|
||||
}
|
||||
|
||||
private String getGreEndpointIP(Host host, Network nw) throws
|
||||
AgentUnavailableException, OperationTimedoutException {
|
||||
private String getGreEndpointIP(Host host, Network nw)
|
||||
throws AgentUnavailableException, OperationTimedoutException {
|
||||
String endpointIp = null;
|
||||
// Fetch fefault name for network label from configuration
|
||||
String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
|
||||
@ -317,12 +313,12 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
key = Integer.valueOf(keyStr);
|
||||
return key;
|
||||
} catch (NumberFormatException e) {
|
||||
s_logger.debug("Well well, how did '" + key +
|
||||
"' end up in the broadcast URI for the network?");
|
||||
throw new CloudRuntimeException(
|
||||
String.format("Invalid GRE key parsed from" +
|
||||
"network broadcast URI (%s)",
|
||||
network.getBroadcastUri().toString()));
|
||||
s_logger.debug("Well well, how did '" + key
|
||||
+ "' end up in the broadcast URI for the network?");
|
||||
throw new CloudRuntimeException(String.format(
|
||||
"Invalid GRE key parsed from"
|
||||
+ "network broadcast URI (%s)", network
|
||||
.getBroadcastUri().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,8 +328,8 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
s_logger.debug("Creating tunnels with OVS tunnel manager");
|
||||
if (instance.getType() != VirtualMachine.Type.User
|
||||
&& instance.getType() != VirtualMachine.Type.DomainRouter) {
|
||||
s_logger.debug("Will not work if you're not" +
|
||||
"an instance or a virtual router");
|
||||
s_logger.debug("Will not work if you're not"
|
||||
+ "an instance or a virtual router");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -341,11 +337,11 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
int key = getGreKey(nw);
|
||||
// Find active VMs with a NIC on the target network
|
||||
List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(nw.getId(),
|
||||
State.Running, State.Starting,
|
||||
State.Stopping, State.Unknown, State.Migrating);
|
||||
State.Running, State.Starting, 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);
|
||||
}
|
||||
@ -396,14 +392,15 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
HostVO rHost = _hostDao.findById(i);
|
||||
String otherIp = getGreEndpointIP(rHost, nw);
|
||||
if (otherIp == null)
|
||||
throw new GreTunnelException("Unable to retrieve the remote " +
|
||||
"endpoint for the GRE tunnel." +
|
||||
"Failure is on host:" + rHost.getId());
|
||||
throw new GreTunnelException(
|
||||
"Unable to retrieve the remote "
|
||||
+ "endpoint for the GRE tunnel."
|
||||
+ "Failure is on host:" + rHost.getId());
|
||||
Commands cmds = new Commands(
|
||||
new OvsCreateTunnelCommand(otherIp, key,
|
||||
Long.valueOf(hostId), i, nw.getId(), myIp));
|
||||
s_logger.debug("Ask host " + hostId +
|
||||
" to create gre tunnel to " + i);
|
||||
s_logger.debug("Ask host " + hostId
|
||||
+ " to create gre tunnel to " + i);
|
||||
Answer[] answers = _agentMgr.send(hostId, cmds);
|
||||
handleCreateTunnelAnswer(answers);
|
||||
noHost = false;
|
||||
@ -412,23 +409,22 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
for (Long i : fromHostIds) {
|
||||
HostVO rHost = _hostDao.findById(i);
|
||||
String otherIp = getGreEndpointIP(rHost, nw);
|
||||
Commands cmds = new Commands(
|
||||
new OvsCreateTunnelCommand(myIp, key, i,
|
||||
Long.valueOf(hostId),
|
||||
nw.getId(), otherIp));
|
||||
s_logger.debug("Ask host " + i +
|
||||
" to create gre tunnel to " + hostId);
|
||||
Commands cmds = new Commands(new OvsCreateTunnelCommand(myIp,
|
||||
key, i, Long.valueOf(hostId), nw.getId(), otherIp));
|
||||
s_logger.debug("Ask host " + i + " to create gre tunnel to "
|
||||
+ hostId);
|
||||
Answer[] answers = _agentMgr.send(i, cmds);
|
||||
handleCreateTunnelAnswer(answers);
|
||||
noHost = false;
|
||||
}
|
||||
// If no tunnels have been configured, perform the bridge setup anyway
|
||||
// If no tunnels have been configured, perform the bridge setup
|
||||
// anyway
|
||||
// This will ensure VIF rules will be triggered
|
||||
if (noHost) {
|
||||
Commands cmds = new Commands(
|
||||
new OvsSetupBridgeCommand(key, hostId, nw.getId()));
|
||||
s_logger.debug("Ask host " + hostId +
|
||||
" to configure bridge for network:" + nw.getId());
|
||||
Commands cmds = new Commands(new OvsSetupBridgeCommand(key,
|
||||
hostId, nw.getId()));
|
||||
s_logger.debug("Ask host " + hostId
|
||||
+ " to configure bridge for network:" + nw.getId());
|
||||
Answer[] answers = _agentMgr.send(hostId, cmds);
|
||||
handleSetupBridgeAnswer(answers);
|
||||
}
|
||||
|
||||
@ -295,14 +295,6 @@ public enum Config {
|
||||
"false",
|
||||
"Direct Network Dhcp Server should not send a default route",
|
||||
"true/false"),
|
||||
OvsTunnelNetwork(
|
||||
"Network",
|
||||
ManagementServer.class,
|
||||
Boolean.class,
|
||||
"sdn.ovs.controller",
|
||||
"false",
|
||||
"Enable/Disable Open vSwitch SDN controller for L2-in-L3 overlay networks",
|
||||
null),
|
||||
OvsTunnelNetworkDefaultLabel(
|
||||
"Network",
|
||||
ManagementServer.class,
|
||||
|
||||
@ -435,13 +435,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
if (oldElement instanceof IpDeployingRequester && newElement instanceof IpDeployingRequester) {
|
||||
IpDeployer oldIpDeployer = ((IpDeployingRequester)oldElement).getIpDeployer(network);
|
||||
IpDeployer newIpDeployer = ((IpDeployingRequester)newElement).getIpDeployer(network);
|
||||
// if
|
||||
// (!oldIpDeployer.getProvider().getName().equals(newIpDeployer.getProvider().getName()))
|
||||
// {
|
||||
// throw new
|
||||
// InvalidParameterException("There would be multiple providers for IP "
|
||||
// + publicIp.getAddress() + "!");
|
||||
// }
|
||||
// FIXME: I ignored this check
|
||||
} else {
|
||||
throw new InvalidParameterException("Ip cannot be applied for new provider!");
|
||||
}
|
||||
|
||||
@ -993,18 +993,6 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
|
||||
@Override
|
||||
public boolean verifyServicesCombination(Set<Service> services) {
|
||||
// if (!services.contains(Service.SourceNat)) {
|
||||
// if (services.contains(Service.StaticNat) || services.contains(Service.Firewall) || services.contains(Service.Lb) ||
|
||||
// services.contains(Service.PortForwarding) || services.contains(Service.Vpn)) {
|
||||
// String servicesList = "[";
|
||||
// for (Service service : services) {
|
||||
// servicesList += service.getName() + " ";
|
||||
// }
|
||||
// servicesList += "]";
|
||||
// s_logger.warn("Virtual router can't enable services " + servicesList + " without source NAT service");
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -99,9 +99,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||
|
||||
if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
|
||||
return null;
|
||||
}
|
||||
// if
|
||||
// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, owner);
|
||||
if (config == null) {
|
||||
@ -119,9 +121,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
assert (config.getState() == State.Implementing) : "Why are we implementing " + config;
|
||||
|
||||
if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
|
||||
return null;
|
||||
}
|
||||
// if
|
||||
// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
if (!_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
return super.implement(config, offering, dest, context);
|
||||
@ -225,10 +229,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
|
||||
NicProfile profile = super.allocate(config, nic, vm);
|
||||
|
||||
boolean _isEnabled = Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
|
||||
if (_isEnabled) {
|
||||
return null;
|
||||
}
|
||||
// boolean _isEnabled =
|
||||
// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
|
||||
// if (_isEnabled) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
profile.setStrategy(ReservationStrategy.Start);
|
||||
@ -246,9 +251,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
public void deallocate(Network config, NicProfile nic, VirtualMachineProfile vm) {
|
||||
super.deallocate(config, nic, vm);
|
||||
|
||||
if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
|
||||
return;
|
||||
}
|
||||
// if
|
||||
// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
nic.setIp4Address(null);
|
||||
@ -263,10 +270,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
public void reserve(NicProfile nic, Network config, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
assert (nic.getReservationStrategy() == ReservationStrategy.Start) : "What can I do for nics that are not allocated at start? ";
|
||||
boolean _isEnabled = Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
|
||||
if (_isEnabled) {
|
||||
return;
|
||||
}
|
||||
// boolean _isEnabled =
|
||||
// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
|
||||
// if (_isEnabled) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
DataCenter dc = _dcDao.findById(config.getDataCenterId());
|
||||
|
||||
@ -299,9 +307,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
@Override
|
||||
public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
|
||||
|
||||
if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
|
||||
return true;
|
||||
}
|
||||
// if
|
||||
// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user