From 22e8fd338a6bc89dfba70a312e4e21ab5aa48940 Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Wed, 18 Mar 2020 15:00:17 +0530 Subject: [PATCH] With basic zone and VMware hypervisor, VR fails to start since eth1 is getting empty instead of a private IP. Though VMware does not support security groups, but in a basic zone with VMware and no isolation VMs should be able to deploy. Root cause: In case of VMware and basic zone control nic is set to 0.0.0.0 assuming control network will be shared with guest network. But to have access to VMware instances management/private needs to be assigned to it. Solution: Assing a private ip even in case of basic zone VMware. --- .../vmware/resource/VmwareResource.java | 11 ---------- .../network/guru/ControlNetworkGuru.java | 19 ++++------------ .../VirtualNetworkApplianceManagerImpl.java | 22 +++++++------------ 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index b5a1260a7230..26b0e7c2468b 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -200,7 +200,6 @@ import com.cloud.agent.resource.virtualnetwork.VirtualRouterDeployer; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.configuration.Resource.ResourceType; -import com.cloud.dc.DataCenter.NetworkType; import com.cloud.dc.Vlan; import com.cloud.exception.CloudException; import com.cloud.exception.InternalErrorException; @@ -6411,16 +6410,6 @@ private static HostStatsEntry getHyperHostStats(VmwareHypervisorHost hyperHost) private static String getRouterSshControlIp(NetworkElementCommand cmd) { String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - String routerGuestIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP); - String zoneNetworkType = cmd.getAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE); - - if (routerGuestIp != null && zoneNetworkType != null && NetworkType.valueOf(zoneNetworkType) == NetworkType.Basic) { - if (s_logger.isDebugEnabled()) - s_logger.debug("In Basic zone mode, use router's guest IP for SSH control. guest IP : " + routerGuestIp); - - return routerGuestIp; - } - if (s_logger.isDebugEnabled()) s_logger.debug("Use router's private IP for SSH control. IP : " + routerIp); return routerIp; diff --git a/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java index 717b3bd03994..99f4ad0f1f7f 100644 --- a/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java +++ b/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java @@ -138,22 +138,11 @@ public void reserve(NicProfile nic, Network config, VirtualMachineProfile vm, De // we have to get management/private ip for the control nic for vmware/hyperv due ssh issues. HypervisorType hType = vm.getHypervisorType(); if (((hType == HypervisorType.VMware) || (hType == HypervisorType.Hyperv)) && isRouterVm(vm)) { - if (dest.getDataCenter().getNetworkType() != NetworkType.Basic) { - super.reserve(nic, config, vm, dest, context); + 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.setIPv4Address("0.0.0.0"); - nic.setIPv4Netmask("0.0.0.0"); - nic.setFormat(AddressFormat.Ip4); - nic.setIPv4Gateway("0.0.0.0"); - return; - } + String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId()); + nic.setMacAddress(mac); + return; } String ip = _dcDao.allocateLinkLocalIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId(), context.getReservationId()); diff --git a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index b58f505213f4..4e750d250b24 100644 --- a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1401,7 +1401,11 @@ public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile if (dc.getNetworkType() == NetworkType.Basic) { // ask domR to setup SSH on guest network - buf.append(" sshonguest=true"); + if (profile.getHypervisorType() == HypervisorType.VMware) { + buf.append(" sshonguest=false"); + } else { + buf.append(" sshonguest=true"); + } } } @@ -1760,19 +1764,9 @@ protected NicProfile getControlNic(final VirtualMachineProfile profile) { final DomainRouterVO router = _routerDao.findById(profile.getId()); final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); NicProfile controlNic = null; - 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 (final NicProfile nic : profile.getNics()) { - if (nic.getTrafficType() == TrafficType.Guest && nic.getIPv4Address() != null) { - controlNic = nic; - } - } - } else { - for (final NicProfile nic : profile.getNics()) { - if (nic.getTrafficType() == TrafficType.Control && nic.getIPv4Address() != null) { - controlNic = nic; - } + for (final NicProfile nic : profile.getNics()) { + if (nic.getTrafficType() == TrafficType.Control && nic.getIPv4Address() != null) { + controlNic = nic; } } return controlNic;