Repository: cloudstack Updated Branches: refs/heads/4.3-forward 930acdde3 -> 793a6a717
CS-19377 [Baremetal] After deploy VM on Baremetal host, BM host fail to be PXE booted Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/793a6a71 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/793a6a71 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/793a6a71 Branch: refs/heads/4.3-forward Commit: 793a6a7177e7b2737b01c328951c86da1ba1808b Parents: 930acdd Author: frank <frank.zh...@citrix.com> Authored: Thu Feb 27 15:17:38 2014 -0800 Committer: frank <frank.zh...@citrix.com> Committed: Thu Feb 27 15:18:01 2014 -0800 ---------------------------------------------------------------------- .../networkservice/BaremetalDhcpElement.java | 14 +++++++++++--- .../networkservice/BaremetalDhcpManagerImpl.java | 7 +++---- 2 files changed, 14 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793a6a71/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java index 8057cd4..b3fdab5 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java @@ -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; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793a6a71/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java index 82397f5..e507b4d 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java @@ -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);