mirror of https://github.com/apache/cloudstack.git
CS-19377
[Baremetal] After deploy VM on Baremetal host, BM host fail to be PXE booted
(cherry picked from commit 793a6a7177)
Signed-off-by: Animesh Chaturvedi <animesh@apache.org>
This commit is contained in:
parent
e9a3d41285
commit
9e1525c032
|
|
@ -25,6 +25,8 @@ import java.util.Set;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.baremetal.database.BaremetalDhcpVO;
|
||||
|
|
@ -64,12 +66,14 @@ public class BaremetalDhcpElement extends AdapterBase implements DhcpServiceProv
|
|||
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject BaremetalDhcpManager _dhcpMgr;
|
||||
@Inject
|
||||
PhysicalNetworkDao phyNwDao;
|
||||
|
||||
static {
|
||||
Capability cap = new Capability(BaremetalDhcpManager.BAREMETAL_DHCP_SERVICE_CAPABITLITY);
|
||||
Map<Capability, String> baremetalCaps = new HashMap<Capability, String>();
|
||||
baremetalCaps.put(cap, null);
|
||||
baremetalCaps.put(Capability.DhcpAccrossMultipleSubnets, Boolean.TRUE.toString());
|
||||
baremetalCaps.put(cap, null);
|
||||
baremetalCaps.put(Capability.DhcpAccrossMultipleSubnets, Boolean.TRUE.toString());
|
||||
capabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
capabilities.put(Service.Dhcp, baremetalCaps);
|
||||
}
|
||||
|
|
@ -87,8 +91,12 @@ public class BaremetalDhcpElement extends AdapterBase implements DhcpServiceProv
|
|||
private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType) {
|
||||
Pod pod = dest.getPod();
|
||||
if (pod != null && dest.getDataCenter().getNetworkType() == NetworkType.Basic && trafficType == TrafficType.Guest) {
|
||||
QueryBuilder<PhysicalNetworkVO> phyq = QueryBuilder.create(PhysicalNetworkVO.class);
|
||||
phyq.and(phyq.entity().getDataCenterId(), Op.EQ, dest.getDataCenter().getId());
|
||||
PhysicalNetworkVO phynw = phyq.find();
|
||||
|
||||
QueryBuilder<BaremetalDhcpVO> sc = QueryBuilder.create(BaremetalDhcpVO.class);
|
||||
sc.and(sc.entity().getPodId(), Op.EQ,pod.getId());
|
||||
sc.and(sc.entity().getPhysicalNetworkId(), Op.EQ, phynw.getId());
|
||||
return sc.find() != null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,14 +133,13 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
|
|||
public boolean addVirtualMachineIntoNetwork(Network network, NicProfile nic, VirtualMachineProfile profile,
|
||||
DeployDestination dest, ReservationContext context) throws ResourceUnavailableException {
|
||||
Long zoneId = profile.getVirtualMachine().getDataCenterId();
|
||||
Long podId = profile.getVirtualMachine().getPodIdToDeployIn();
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Type.BaremetalDhcp, null, podId, zoneId);
|
||||
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Type.BaremetalDhcp, null, null, zoneId);
|
||||
if (hosts.size() == 0) {
|
||||
throw new CloudRuntimeException("No external Dhcp found in zone " + zoneId + " pod " + podId);
|
||||
throw new CloudRuntimeException("No external Dhcp found in zone " + zoneId);
|
||||
}
|
||||
|
||||
if (hosts.size() > 1) {
|
||||
throw new CloudRuntimeException("Something wrong, more than 1 external Dhcp found in zone " + zoneId + " pod " + podId);
|
||||
throw new CloudRuntimeException("Something wrong, more than 1 external Dhcp found in zone " + zoneId);
|
||||
}
|
||||
|
||||
HostVO h = hosts.get(0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue