Fix a number of issues related with vmware on new networking

This commit is contained in:
Kelven Yang 2010-12-09 19:30:52 -08:00
parent 2dd29d2110
commit 68e6706fbe
6 changed files with 99 additions and 24 deletions

View File

@ -68,9 +68,13 @@
<adapter name="VMwareGuru" class="com.cloud.hypervisor.VMwareGuru"/>
</adapters>
<adapters key="com.cloud.resource.Discoverer">
<!--
<adapter name="XCP Agent" class="com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer"/>
-->
<adapter name="SecondaryStorage" class="com.cloud.storage.secondary.SecondaryStorageDiscoverer"/>
<!--
<adapter name="KVM Agent" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer"/>
-->
</adapters>
<adapters key="com.cloud.deploy.DeploymentPlanner">
<adapter name="First Fit" class="com.cloud.deploy.FirstFitPlanner"/>

View File

@ -2495,7 +2495,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
@Override
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<ConsoleProxyVO> profile, DeployDestination dest, ReservationContext context) {
StringBuilder buf = profile.getBootArgsBuilder();
StringBuilder buf = profile.getBootArgsBuilder();
buf.append(" template=domP type=consoleproxy");
buf.append(" host=").append(_mgmt_host);
buf.append(" port=").append(_mgmt_port);
@ -2507,11 +2507,24 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
buf.append(" pod=").append(dest.getPod().getId());
buf.append(" guid=Proxy.").append(profile.getId());
buf.append(" proxy_vm=").append(profile.getId());
boolean externalDhcp = false;
String externalDhcpStr = _configDao.getValue("direct.attach.network.externalIpAllocator.enabled");
if(externalDhcpStr != null && externalDhcpStr.equalsIgnoreCase("true"))
externalDhcp = true;
NicProfile controlNic = null;
NicProfile managementNic = null;
for (NicProfile nic : profile.getNics()) {
int deviceId = nic.getDeviceId();
buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address());
buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask());
if(nic.getIp4Address() == null) {
buf.append(" eth").append(deviceId).append("ip=").append("0.0.0.0");
buf.append(" eth").append(deviceId).append("mask=").append("0.0.0.0");
} else {
buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address());
buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask());
}
if (nic.isDefaultNic()) {
buf.append(" gateway=").append(nic.getGateway());
buf.append(" dns1=").append(nic.getDns1());
@ -2519,14 +2532,25 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
buf.append(" dns2=").append(nic.getDns2());
}
}
if (nic.getTrafficType() == TrafficType.Management) {
buf.append(" localgw=").append(dest.getPod().getGateway());
managementNic = nic;
} else if (nic.getTrafficType() == TrafficType.Control) {
controlNic = nic;
if(nic.getIp4Address() != null)
controlNic = nic;
}
}
/*External DHCP mode*/
if(externalDhcp)
buf.append(" bootproto=dhcp");
if(controlNic == null) {
assert(managementNic != null);
controlNic = managementNic;
}
String bootArgs = buf.toString();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Boot Args for " + profile + ": " + bootArgs);
@ -2543,7 +2567,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
@Override
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile, DeployDestination dest, ReservationContext context) {
NicProfile controlNic = (NicProfile)profile.getParameter("control.nic");
NicProfile controlNic = (NicProfile)profile.getParameter("control.nic");
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
cmds.addCommand("checkSsh", check);
return true;

View File

@ -63,8 +63,16 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
@Override
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
if (config.getTrafficType() != TrafficType.Control) {
return null;
return null;
}
if(vm.getHypervisorType() == HypervisorType.VmWare && vm.getType() != VirtualMachine.Type.DomainRouter) {
NicProfile nicProf = new NicProfile(ReservationStrategy.Create, null, null, null, null);
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId());
nicProf.setMacAddress(mac);
return nicProf;
}
if (nic != null) {
@ -82,11 +90,15 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
public void reserve(NicProfile nic, Network config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
assert nic.getTrafficType() == TrafficType.Control;
if (dest.getHost().getHypervisorType() == HypervisorType.VmWare) {
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;
}
String ip = _dcDao.allocateLinkLocalIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vm.getId(), context.getReservationId());
nic.setIp4Address(ip);
nic.setMacAddress(NetUtils.long2Mac(NetUtils.ip2Long(ip) | (14l << 40)));
@ -98,9 +110,10 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
@Override
public boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId) {
assert nic.getTrafficType() == TrafficType.Control;
if (vm.getHypervisorType() == HypervisorType.VmWare) {
return super.release(nic, vm, reservationId);
if (vm.getHypervisorType() == HypervisorType.VmWare && vm.getType() == VirtualMachine.Type.DomainRouter) {
super.release(nic, vm, reservationId);
return true;
}
_dcDao.releaseLinkLocalIpAddress(nic.getId(), reservationId);

View File

@ -2192,6 +2192,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
buf.append(" template=domP type=" + type);
buf.append(" name=").append(profile.getHostName());
NicProfile controlNic = null;
NicProfile managementNic = null;
for (NicProfile nic : profile.getNics()) {
int deviceId = nic.getDeviceId();
buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address());
@ -2205,7 +2207,14 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
}
if (nic.getTrafficType() == TrafficType.Management) {
buf.append(" localgw=").append(dest.getPod().getGateway());
managementNic = nic;
} else if (nic.getTrafficType() == TrafficType.Control) {
// DOMR control command is sent over management server in VMware
if(dest.getHost().getHypervisorType() == HypervisorType.VmWare) {
buf.append(" mgmtcidr=").append(_mgmt_host);
buf.append(" localgw=").append(dest.getPod().getGateway());
}
controlNic = nic;
}
}

View File

@ -94,9 +94,12 @@ public class ConsoleProxyServlet extends HttpServlet {
}
} else {
// adjust to latest API refactoring changes
userId = ((Long)session.getAttribute("userid")).toString();
accountObj = (Account)session.getAttribute("accountobj");
account = "" + accountObj.getId();
if(session.getAttribute("userid") != null)
userId = ((Long)session.getAttribute("userid")).toString();
accountObj = (Account)session.getAttribute("accountobj");
if(accountObj != null)
account = "" + accountObj.getId();
}
// Do a sanity check here to make sure the user hasn't already been deleted

View File

@ -2080,7 +2080,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
public boolean finalizeVirtualMachineProfile(
VirtualMachineProfile<SecondaryStorageVmVO> profile,
DeployDestination dest, ReservationContext context) {
HostVO secHost = _hostDao.findSecondaryStorageHost(dest.getDataCenter().getId());
assert(secHost != null);
StringBuilder buf = profile.getBootArgsBuilder();
buf.append(" template=domP type=secstorage");
buf.append(" host=").append(_mgmt_host);
@ -2089,12 +2092,11 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
buf.append(" zone=").append(dest.getDataCenter().getId());
buf.append(" pod=").append(dest.getPod().getId());
buf.append(" guid=").append(_secHostUuid);
buf.append(" guid=").append(secHost.getGuid());
String nfsMountPoint = null;
try {
nfsMountPoint = NfsUtils.url2Mount(_nfsShare);
nfsMountPoint = NfsUtils.url2Mount(secHost.getStorageUrl());
} catch (Exception e) {
}
buf.append(" mount.path=").append(nfsMountPoint);
@ -2103,14 +2105,21 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
buf.append(" sslcopy=").append(Boolean.toString(_useSSlCopy));
NicProfile controlNic = null;
NicProfile managementNic = null;
boolean externalDhcp = false;
String externalDhcpStr = _configDao.getValue("direct.attach.network.externalIpAllocator.enabled");
if(externalDhcpStr != null && externalDhcpStr.equalsIgnoreCase("true"))
externalDhcp = true;
for (NicProfile nic : profile.getNics()) {
int deviceId = nic.getDeviceId();
if (nic.getIp4Address() == null) {
/*External DHCP mode*/
buf.append(" eth").append(deviceId).append("mask=").append("0.0.0.0");
buf.append(" eth").append(deviceId).append("ip=").append("0.0.0.0");
buf.append(" bootproto=dhcp");
} else {
buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address());
buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask());
}
buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask());
@ -2119,12 +2128,25 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
if (nic.getTrafficType() == TrafficType.Management) {
buf.append(" localgw=").append(dest.getPod().getGateway());
managementNic = nic;
buf.append(" private.network.device=").append("eth").append(deviceId);
} else if (nic.getTrafficType() == TrafficType.Control) {
controlNic = nic;
if(nic.getIp4Address() != null)
controlNic = nic;
} else if(nic.getTrafficType() == TrafficType.Public) {
buf.append(" public.network.device=").append("eth").append(deviceId);
}
}
/*External DHCP mode*/
if(externalDhcp)
buf.append(" bootproto=dhcp");
if(controlNic == null) {
assert(managementNic != null);
controlNic = managementNic;
}
DataCenterVO dc = _dcDao.findById(profile.getVirtualMachine().getDataCenterId());
buf.append(" dns1=").append(dc.getInternalDns1());
if (dc.getInternalDns2() != null) {