mirror of https://github.com/apache/cloudstack.git
bug 10214: merge fix from 2.2.4 branch
This commit is contained in:
parent
49550aff44
commit
5f7f885c6a
|
|
@ -26,6 +26,8 @@ public abstract class NetworkElementCommand extends Command {
|
|||
|
||||
public static final String ROUTER_NAME = "router.name";
|
||||
public static final String ROUTER_IP = "router.ip";
|
||||
public static final String ROUTER_GUEST_IP = "router.guest.ip";
|
||||
public static final String ZONE_NETWORK_TYPE = "zone.network.type";
|
||||
|
||||
protected NetworkElementCommand() {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -326,7 +326,12 @@ setup_dhcpsrvr() {
|
|||
sed -i /gateway/d /etc/hosts
|
||||
echo "$ETH0_IP $NAME" >> /etc/hosts
|
||||
|
||||
setup_sshd $ETH1_IP
|
||||
if [ "$SSHONGUEST" == "true" ]
|
||||
then
|
||||
setup_sshd $ETH0_IP
|
||||
else
|
||||
setup_sshd $ETH1_IP
|
||||
fi
|
||||
|
||||
enable_svc dnsmasq 1
|
||||
enable_svc haproxy 0
|
||||
|
|
@ -334,7 +339,12 @@ setup_dhcpsrvr() {
|
|||
enable_svc cloud 0
|
||||
enable_fwding 0
|
||||
chkconfig nfs-common off
|
||||
cp /etc/iptables/iptables-router /etc/iptables/rules
|
||||
if [ "$SSHONGUEST" == "true" ]
|
||||
then
|
||||
sed '/3922/i -A INPUT -i eth0 -p tcp -m state --state NEW --dport 3922 -j ACCEPT' /etc/iptables/iptables-router > /etc/iptables/rules
|
||||
else
|
||||
cp /etc/iptables/iptables-router /etc/iptables/rules
|
||||
fi
|
||||
}
|
||||
|
||||
setup_secstorage() {
|
||||
|
|
@ -489,6 +499,9 @@ for i in $CMDLINE
|
|||
template)
|
||||
TEMPLATE=$VALUE
|
||||
;;
|
||||
sshonguest)
|
||||
SSHONGUEST=$VALUE
|
||||
;;
|
||||
name)
|
||||
NAME=$VALUE
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
|
|
@ -119,11 +121,22 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
|||
assert nic.getTrafficType() == TrafficType.Control;
|
||||
|
||||
if (dest.getHost().getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
super.reserve(nic, config, vm, dest, context);
|
||||
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId());
|
||||
nic.setMacAddress(mac);
|
||||
return;
|
||||
if(dest.getDataCenter().getNetworkType() != NetworkType.Basic) {
|
||||
super.reserve(nic, config, vm, dest, context);
|
||||
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId());
|
||||
nic.setMacAddress(mac);
|
||||
return;
|
||||
} else {
|
||||
// in basic mode and in VMware case, control network will be shared with guest network
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId());
|
||||
nic.setMacAddress(mac);
|
||||
nic.setIp4Address("0.0.0.0");
|
||||
nic.setNetmask("0.0.0.0");
|
||||
nic.setFormat(AddressFormat.Ip4);
|
||||
nic.setGateway("0.0.0.0");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String ip = _dcDao.allocateLinkLocalIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId(), context.getReservationId());
|
||||
|
|
@ -139,8 +152,15 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
|||
assert nic.getTrafficType() == TrafficType.Control;
|
||||
|
||||
if (vm.getHypervisorType() == HypervisorType.VMware && vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
super.release(nic, vm, reservationId);
|
||||
return true;
|
||||
long dcId = vm.getVirtualMachine().getDataCenterIdToDeployIn();
|
||||
DataCenterVO dcVo = _dcDao.findById(dcId);
|
||||
if(dcVo.getNetworkType() != NetworkType.Basic) {
|
||||
super.release(nic, vm, reservationId);
|
||||
return true;
|
||||
} else {
|
||||
nic.deallocate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_dcDao.releaseLinkLocalIpAddress(nic.getId(), reservationId);
|
||||
|
|
|
|||
|
|
@ -17,18 +17,12 @@
|
|||
*/
|
||||
package com.cloud.network.router;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
@ -73,6 +67,7 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||
import com.cloud.configuration.dao.ResourceLimitDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
|
|
@ -393,7 +388,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
s_logger.warn("Unable save password, router doesn't exist in network " + network.getId());
|
||||
throw new CloudRuntimeException("Unable to save password to router");
|
||||
}
|
||||
|
||||
|
||||
UserVm userVm = profile.getVirtualMachine();
|
||||
String password = (String) profile.getParameter(Param.VmPassword);
|
||||
String encodedPassword = PasswordGenerator.rot13(password);
|
||||
|
|
@ -401,7 +396,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
Commands cmds = new Commands(OnError.Continue);
|
||||
SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(), userVm.getHostName());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand("password", cmd);
|
||||
|
||||
return sendCommandsToRouter(router, cmds);
|
||||
|
|
@ -603,8 +603,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
VmDataCommand cmd = new VmDataCommand(vmPrivateIpAddress, vmName);
|
||||
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmd.addVmData("userdata", "user-data", userData);
|
||||
cmd.addVmData("metadata", "service-offering", StringUtils.unicodeEscape(serviceOffering));
|
||||
cmd.addVmData("metadata", "availability-zone", StringUtils.unicodeEscape(zoneName));
|
||||
|
|
@ -938,16 +942,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
buf.append(" mgmtcidr=").append(_mgmt_cidr);
|
||||
buf.append(" localgw=").append(dest.getPod().getGateway());
|
||||
}
|
||||
|
||||
/*
|
||||
* if(!NetUtils.sameSubnetCIDR(_mgmt_host, dest.getPod().getGateway(), dest.getPod().getCidrSize())) {
|
||||
* if(s_logger.isInfoEnabled()) { s_logger.info("Add management server explicit route to DomR."); }
|
||||
*
|
||||
* _mgmt_cidr = _configDao.getValue(Config.ManagementNetwork.key()); if (NetUtils.isValidCIDR(_mgmt_cidr)) {
|
||||
* buf.append(" mgmtcidr=").append(_mgmt_cidr); buf.append(" localgw=").append(dest.getPod().getGateway());
|
||||
* } } else { if(s_logger.isInfoEnabled()) {
|
||||
* s_logger.info("Management server host is at same subnet at pod private network"); } }
|
||||
*/
|
||||
|
||||
|
||||
if (dc.getNetworkType() == NetworkType.Basic) {
|
||||
// ask domR to setup SSH on guest network
|
||||
buf.append(" sshonguest=true");
|
||||
}
|
||||
}
|
||||
|
||||
controlNic = nic;
|
||||
|
|
@ -1017,12 +1017,24 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
@Override
|
||||
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<DomainRouterVO> profile) {
|
||||
DomainRouterVO router = profile.getVirtualMachine();
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
|
||||
NicProfile controlNic = null;
|
||||
for (NicProfile nic : profile.getNics()) {
|
||||
if (nic.getTrafficType() == TrafficType.Control && nic.getIp4Address() != null) {
|
||||
controlNic = nic;
|
||||
}
|
||||
|
||||
if(profile.getHypervisorType() == HypervisorType.VMware && dcVo.getNetworkType() == NetworkType.Basic) {
|
||||
// TODO this is a ugly to test hypervisor type here
|
||||
// for basic network mode, we will use the guest NIC for control NIC
|
||||
for (NicProfile nic : profile.getNics()) {
|
||||
if (nic.getTrafficType() == TrafficType.Guest && nic.getIp4Address() != null) {
|
||||
controlNic = nic;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (NicProfile nic : profile.getNics()) {
|
||||
if (nic.getTrafficType() == TrafficType.Control && nic.getIp4Address() != null) {
|
||||
controlNic = nic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (controlNic == null) {
|
||||
|
|
@ -1208,7 +1220,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
RemoteAccessVpnCfgCommand removeVpnCmd = new RemoteAccessVpnCfgCommand(false, ip.getAddress().addr(), vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
|
||||
removeVpnCmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
removeVpnCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
removeVpnCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
removeVpnCmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand(removeVpnCmd);
|
||||
|
||||
return sendCommandsToRouter(router, cmds);
|
||||
|
|
@ -1262,7 +1279,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), profile.getVirtualMachine().getHostName());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlIpAddress);
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand("dhcp", dhcpCommand);
|
||||
|
||||
// password should be set only on default network element
|
||||
|
|
@ -1270,7 +1292,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
final String encodedPassword = PasswordGenerator.rot13(password);
|
||||
SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(), profile.getVirtualMachine().getHostName());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand("password", cmd);
|
||||
}
|
||||
|
||||
|
|
@ -1338,7 +1363,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
VpnUsersCfgCommand cmd = new VpnUsersCfgCommand(addUsers, removeUsers);
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getPodIdToDeployIn());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand(cmd);
|
||||
|
||||
// Currently we receive just one answer from the agent. In the future we have to parse individual answers and set
|
||||
|
|
@ -1463,7 +1492,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
IPAssocCommand cmd = new IPAssocCommand(ipsToSend);
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand("IPAssocCommand", cmd);
|
||||
}
|
||||
}
|
||||
|
|
@ -1481,7 +1514,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
SetPortForwardingRulesCommand cmd = new SetPortForwardingRulesCommand(rulesTO);
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -1498,7 +1535,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO);
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
cmds.addCommand(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -1520,7 +1560,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs);
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
cmds.addCommand(cmd);
|
||||
|
||||
}
|
||||
|
|
@ -1539,13 +1582,17 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
VpnUsersCfgCommand addUsersCmd = new VpnUsersCfgCommand(addUsers, removeUsers);
|
||||
addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
IpAddress ip = _networkMgr.getIp(vpn.getServerAddressId());
|
||||
|
||||
RemoteAccessVpnCfgCommand startVpnCmd = new RemoteAccessVpnCfgCommand(true, ip.getAddress().addr(), vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
|
||||
startVpnCmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
startVpnCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
startVpnCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
startVpnCmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand("users", addUsersCmd);
|
||||
cmds.addCommand("startVpn", startVpnCmd);
|
||||
|
|
@ -1581,6 +1628,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand("dhcp", dhcpCommand);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue