With basic zone and VMware hypervisor, VR fails to start since eth1 is getting empty instead of a private IP. (#3977)

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.
This commit is contained in:
harikrishna-patnala 2020-03-28 00:16:01 +05:30 committed by GitHub
parent d93c2459a4
commit 78fda2d163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 40 deletions

View File

@ -200,7 +200,6 @@ import com.cloud.agent.resource.virtualnetwork.VRScripts;
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 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
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;

View File

@ -138,22 +138,11 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
// 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());

View File

@ -1401,7 +1401,11 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
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 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
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;