diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in index 7164a764dd5..ecf7873ae79 100755 --- a/client/tomcatconf/components.xml.in +++ b/client/tomcatconf/components.xml.in @@ -68,9 +68,13 @@ + + diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 21b3cbca09c..042f94700d4 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -2495,7 +2495,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx @Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile 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 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; diff --git a/server/src/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/com/cloud/network/guru/ControlNetworkGuru.java index 2ad9c4a7d24..74f935b2ecc 100644 --- a/server/src/com/cloud/network/guru/ControlNetworkGuru.java +++ b/server/src/com/cloud/network/guru/ControlNetworkGuru.java @@ -63,8 +63,16 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu @Override public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile 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 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 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); diff --git a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java index bee773e50e6..5bfb6fd1534 100644 --- a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java +++ b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java @@ -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; } } diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java index 541d3294889..ba50ba38337 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java +++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java @@ -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 diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index 033ac5d399c..00801ec9abc 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -2080,7 +2080,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V public boolean finalizeVirtualMachineProfile( VirtualMachineProfile 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) {