Skip to content

Commit 26002ae

Browse files
Frank.Zhangchaturvedia
authored andcommitted
BUG-ID: CS-19152
[upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, destroy baremetal instance fail BUG-ID: CS-19150 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, unable to start baremetal instance BUG-ID: CS-19149 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, baremetal host remain in Disconnected state. But instance associated with baremetal host is running. BUG-ID: CS-19151 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, unable to reboot baremetal instance BUG-ID: CS-19156 [upgrade] Baremetal 4.2.0 -> 4.3. After upgrade, unable to stop baremetal instance reviewed-by: edison (cherry picked from commit 3787579) Signed-off-by: Animesh Chaturvedi <animesh@apache.org>
1 parent 9d6ba8e commit 26002ae

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

‎plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long p
170170
params.put(ApiConstants.PRIVATE_IP, ipmiIp);
171171
params.put(ApiConstants.USERNAME, username);
172172
params.put(ApiConstants.PASSWORD, password);
173+
params.put("vmDao", _vmDao);
174+
params.put("configDao", _configDao);
173175

174176
String resourceClassName = _configDao.getValue(Config.ExternalBaremetalResourceClassName.key());
175177
BareMetalResourceBase resource = null;
@@ -284,6 +286,8 @@ protected HashMap<String, Object> buildConfigParams(HostVO host) {
284286
HashMap<String, Object> params = super.buildConfigParams(host);
285287
params.put("hostId", host.getId());
286288
params.put("ipaddress", host.getPrivateIpAddress());
289+
params.put("vmDao", _vmDao);
290+
params.put("configDao", _configDao);
287291
return params;
288292
}
289293

‎plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.cloud.hypervisor.Hypervisor;
3535
import com.cloud.resource.ServerResource;
3636
import com.cloud.utils.Pair;
37-
import com.cloud.utils.component.ComponentContext;
3837
import com.cloud.utils.component.ManagerBase;
3938
import com.cloud.utils.exception.CloudRuntimeException;
4039
import com.cloud.utils.script.OutputInterpreter;
@@ -86,9 +85,10 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
8685
protected Script2 _forcePowerOffCommand;
8786
protected Script2 _bootOrRebootCommand;
8887
protected String _vmName;
89-
protected VMInstanceDao vmDao;
9088
protected int ipmiRetryTimes = 5;
9189

90+
protected ConfigurationDao configDao;
91+
protected VMInstanceDao vmDao;
9292

9393
private void changeVmState(String vmName, VirtualMachine.State state) {
9494
synchronized (_vms) {
@@ -126,6 +126,8 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
126126
_password = (String) params.get(ApiConstants.PASSWORD);
127127
_vmName = (String) params.get("vmName");
128128
String echoScAgent = (String) params.get(BaremetalManager.EchoSecurityGroupAgent);
129+
vmDao = (VMInstanceDao) params.get("vmDao");
130+
configDao = (ConfigurationDao) params.get("configDao");
129131

130132
if (_pod == null) {
131133
throw new ConfigurationException("Unable to get the pod");
@@ -156,7 +158,6 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
156158
_isEchoScAgent = Boolean.valueOf(echoScAgent);
157159
}
158160

159-
ConfigurationDao configDao = ComponentContext.getComponent(ConfigurationDao.class);
160161
String ipmiIface = "default";
161162
try {
162163
ipmiIface = configDao.getValue(Config.BaremetalIpmiLanInterface.key());
@@ -330,7 +331,6 @@ protected State getVmState() {
330331
protected Map<String, State> fullSync() {
331332
Map<String, State> states = new HashMap<String, State>();
332333
if (hostId != null) {
333-
vmDao = ComponentContext.getComponent(VMInstanceDao.class);
334334
final List<? extends VMInstanceVO> vms = vmDao.listByHostId(hostId);
335335
for (VMInstanceVO vm : vms) {
336336
states.put(vm.getInstanceName(), vm.getState());
@@ -349,7 +349,6 @@ protected Map<String, State> fullSync() {
349349
protected Map<String, HostVmStateReportEntry> getHostVmStateReport() {
350350
Map<String, HostVmStateReportEntry> states = new HashMap<String, HostVmStateReportEntry>();
351351
if (hostId != null) {
352-
vmDao = ComponentContext.getComponent(VMInstanceDao.class);
353352
final List<? extends VMInstanceVO> vms = vmDao.listByHostId(hostId);
354353
for (VMInstanceVO vm : vms) {
355354
states.put(
@@ -412,7 +411,6 @@ public PingCommand getCurrentStatus(long id) {
412411
}
413412

414413
if (hostId != null) {
415-
vmDao = ComponentContext.getComponent(VMInstanceDao.class);
416414
final List<? extends VMInstanceVO> vms = vmDao.listByHostId(hostId);
417415
if (vms.isEmpty()) {
418416
return new PingRoutingCommand(getType(), id, deltaSync(), getHostVmStateReport());

‎plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd)
184184

185185
@Override
186186
public boolean addUserData(NicProfile nic, VirtualMachineProfile profile) {
187-
UserVmVO vm = (UserVmVO) profile.getVirtualMachine();
187+
UserVmVO vm = _vmDao.findById(profile.getVirtualMachine().getId());
188188
_vmDao.loadDetails(vm);
189-
189+
190190
String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId()).getDisplayText();
191191
String zoneName = _dcDao.findById(vm.getDataCenterId()).getName();
192192
NicVO nvo = _nicDao.findById(nic.getId());

‎server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
299299
+ ", pod: " + host.getPodId() + ", cluster: " + host.getClusterId());
300300
}
301301

302+
Pod pod = _podDao.findById(host.getPodId());
303+
Cluster cluster = _clusterDao.findById(host.getClusterId());
304+
305+
if (vm.getHypervisorType() == HypervisorType.BareMetal) {
306+
DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap<Volume, StoragePool>());
307+
s_logger.debug("Returning Deployment Destination: " + dest);
308+
return dest;
309+
}
310+
302311
// search for storage under the zone, pod, cluster of the host.
303312
DataCenterDeployment lastPlan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(),
304313
host.getClusterId(), hostIdSpecified, plan.getPoolId(), null, plan.getReservationContext());
@@ -315,8 +324,6 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
315324
Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(
316325
suitableHosts, suitableVolumeStoragePools, avoids, getPlannerUsage(planner,vmProfile, plan ,avoids), readyAndReusedVolumes);
317326
if (potentialResources != null) {
318-
Pod pod = _podDao.findById(host.getPodId());
319-
Cluster cluster = _clusterDao.findById(host.getClusterId());
320327
Map<Volume, StoragePool> storageVolMap = potentialResources.second();
321328
// remove the reused vol<->pool from destination, since
322329
// we don't have to prepare this volume.
@@ -362,6 +369,17 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
362369
+ ", pod: " + host.getPodId() + ", cluster: " + host.getClusterId());
363370
// search for storage under the zone, pod, cluster of
364371
// the last host.
372+
373+
374+
Pod pod = _podDao.findById(host.getPodId());
375+
Cluster cluster = _clusterDao.findById(host.getClusterId());
376+
377+
if (vm.getHypervisorType() == HypervisorType.BareMetal) {
378+
DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap<Volume, StoragePool>());
379+
s_logger.debug("Returning Deployment Destination: " + dest);
380+
return dest;
381+
}
382+
365383
DataCenterDeployment lastPlan = new DataCenterDeployment(host.getDataCenterId(),
366384
host.getPodId(), host.getClusterId(), host.getId(), plan.getPoolId(), null);
367385
Pair<Map<Volume, List<StoragePool>>, List<Volume>> result = findSuitablePoolsForVolumes(
@@ -376,8 +394,6 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
376394
Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(
377395
suitableHosts, suitableVolumeStoragePools, avoids, getPlannerUsage(planner,vmProfile, plan ,avoids), readyAndReusedVolumes);
378396
if (potentialResources != null) {
379-
Pod pod = _podDao.findById(host.getPodId());
380-
Cluster cluster = _clusterDao.findById(host.getClusterId());
381397
Map<Volume, StoragePool> storageVolMap = potentialResources.second();
382398
// remove the reused vol<->pool from
383399
// destination, since we don't have to prepare

0 commit comments

Comments
 (0)