jayapalu commented on a change in pull request #1990: CLOUDSTACK-9674:
Baremetal deployment improvements
URL: https://github.com/apache/cloudstack/pull/1990#discussion_r118675575
##########
File path:
plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalPlanner.java
##########
@@ -85,67 +104,74 @@ public DeployDestination plan(VirtualMachineProfile
vmProfile, DeploymentPlan pl
return new DeployDestination(dc, pod, c, h);
}
- if (haVmTag != null) {
- hostTag = haVmTag;
- } else if (offering.getHostTag() != null) {
- String[] tags = offering.getHostTag().split(",");
- if (tags.length > 0) {
- hostTag = tags[0];
- }
+ if (offering.getHostTag() == null) {
+ throw new CloudRuntimeException("baremetal computing offering must
have a host tag");
}
+ String[] tags = offering.getHostTag().split(",");
+ if (tags.length == 0) {
+ throw new CloudRuntimeException("baremetal computing offering must
have a host tag");
+ }
+
+ String hostTag = tags[0];
List<ClusterVO> clusters =
_clusterDao.listByDcHyType(vm.getDataCenterId(),
HypervisorType.BareMetal.toString());
- int cpu_requested;
- long ram_requested;
- HostVO target = null;
List<HostVO> hosts;
for (ClusterVO cluster : clusters) {
- hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing,
cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
- if (hostTag != null) {
- for (HostVO h : hosts) {
- _hostDao.loadDetails(h);
- if (h.getDetail("hostTag") != null &&
h.getDetail("hostTag").equalsIgnoreCase(hostTag)) {
- target = h;
- break;
- }
+ hosts = _hostDao.listByHostTag(Host.Type.Routing, cluster.getId(),
cluster.getPodId(), cluster.getDataCenterId(), hostTag);
+ for (HostVO h : hosts) {
+ _hostDao.loadDetails(h);
+ if (h.getDetail("vmName") != null) {
+ s_logger.debug(String.format("skip baremetal host[id:%s]
as it already has vm[%s]", h.getId(), h.getDetail("vmName")));
+ continue;
}
- }
- }
- if (target == null) {
- s_logger.warn("Cannot find host with tag " + hostTag + " use
capacity from service offering");
- cpu_requested = offering.getCpu() * offering.getSpeed();
- ram_requested = offering.getRamSize() * 1024L * 1024L;
- } else {
- cpu_requested = target.getCpus() * target.getSpeed().intValue();
- ram_requested = target.getTotalMemory();
- }
+ List <String> macsList = new ArrayList<String>();
- for (ClusterVO cluster : clusters) {
- if (haVmTag == null) {
- hosts =
_resourceMgr.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, cluster.getId(),
cluster.getPodId(), cluster.getDataCenterId());
- } else {
- s_logger.warn("Cannot find HA host with tag " + haVmTag + " in
cluster id=" + cluster.getId() + ", pod id=" + cluster.getPodId() + ", data
center id=" +
- cluster.getDataCenterId());
- return null;
- }
- for (HostVO h : hosts) {
- long cluster_id = h.getClusterId();
- ClusterDetailsVO cluster_detail_cpu =
_clusterDetailsDao.findDetail(cluster_id, "cpuOvercommitRatio");
- ClusterDetailsVO cluster_detail_ram =
_clusterDetailsDao.findDetail(cluster_id, "memoryOvercommitRatio");
- Float cpuOvercommitRatio =
Float.parseFloat(cluster_detail_cpu.getValue());
- Float memoryOvercommitRatio =
Float.parseFloat(cluster_detail_ram.getValue());
-
- if (_capacityMgr.checkIfHostHasCapacity(h.getId(),
cpu_requested, ram_requested, false, cpuOvercommitRatio, memoryOvercommitRatio,
true)) {
- s_logger.debug("Find host " + h.getId() + " has enough
capacity");
- DataCenter dc = _dcDao.findById(h.getDataCenterId());
- Pod pod = _podDao.findById(h.getPodId());
- return new DeployDestination(dc, pod, cluster, h);
+ String macs = h.getDetail("additionalmacs");
+ if (macs != null) {
+ macsList.addAll(Arrays.asList(macs.split(",")));
+ }
+
+ int nicsCount = vmNics.size();
+ // host nics should be less than or equal to the vm nics
+ s_logger.debug(" ======== macs = " + macsList + " vm nics
count: " + nicsCount);
Review comment:
Update the log msg, include baremetal string.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services