diff --git a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/CephSnapshotStrategy.java b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/CephSnapshotStrategy.java index 6fbb15c7f58..59ce3eca741 100644 --- a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/CephSnapshotStrategy.java +++ b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/CephSnapshotStrategy.java @@ -78,8 +78,10 @@ public class CephSnapshotStrategy extends StorageSystemSnapshotStrategy { protected boolean isSnapshotStoredOnRbdStoragePool(Snapshot snapshot) { SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); - long snapshotStoragePoolId = snapshotStore.getDataStoreId(); - StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(snapshotStoragePoolId); - return storagePoolVO.getPoolType() == StoragePoolType.RBD; + if (snapshotStore == null) { + return false; + } + StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(snapshotStore.getDataStoreId()); + return storagePoolVO != null && storagePoolVO.getPoolType() == StoragePoolType.RBD; } } \ No newline at end of file diff --git a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java index 9ea2b984264..f9ffeb99d67 100644 --- a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java +++ b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java @@ -1062,7 +1062,7 @@ public class CommandSetupHelper { final NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId); // check if DNS provider is the domR - if (!_networkModel.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) { + if (defaultNic == null || !_networkModel.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) { return null; } diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 7f9f3d44974..4cb409245ac 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -1476,7 +1476,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vmInstance.getAccountId(), vmInstance.getDataCenterId(), vmInstance.getId(), oldNicIdString, oldNetworkOfferingId, null, 0L, VirtualMachine.class.getName(), vmInstance.getUuid(), vmInstance.isDisplay()); - if (vmInstance.getState() != State.Stopped) { + if (vmInstance.getState() == State.Running) { try { VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(vmInstance); User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId()); @@ -4806,7 +4806,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (!(userVm.getHypervisorType().equals(HypervisorType.KVM) || userVm.getHypervisorType().equals(HypervisorType.VMware))) { return; } - s_logger.debug("Collect vm disk statistics from host before stopping Vm"); + s_logger.debug("Collect vm disk statistics from host before stopping VM"); + if (userVm.getHostId() == null) { + s_logger.error("Unable to collect vm disk statistics for VM as the host is null, skipping VM disk statistics collection"); + return; + } long hostId = userVm.getHostId(); List vmNames = new ArrayList(); vmNames.add(userVm.getInstanceName()); diff --git a/systemvm/debian/opt/cloud/bin/merge.py b/systemvm/debian/opt/cloud/bin/merge.py index eccb194d9e2..54d86c5e8bb 100755 --- a/systemvm/debian/opt/cloud/bin/merge.py +++ b/systemvm/debian/opt/cloud/bin/merge.py @@ -56,8 +56,8 @@ class DataBag: with open(self.fpath, 'r') as _fh: logging.debug("Loading data bag type %s", self.key) data = json.load(_fh) - except IOError: - logging.debug("Creating data bag type %s", self.key) + except (IOError, ValueError): + logging.debug("Caught load error, creating empty data bag type %s", self.key) data.update({"id": self.key}) finally: self.dbag = data diff --git a/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh b/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh index 6bb8b3f00b6..0fb317b3203 100755 --- a/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh +++ b/systemvm/debian/opt/cloud/bin/setup/bootstrap.sh @@ -68,6 +68,7 @@ config_guest() { xen-pv|xen-domU) systemctl stop ntpd systemctl disable ntpd + systemctl enable xe-daemon systemctl start xe-daemon cat /proc/cmdline > $CMDLINE @@ -76,6 +77,7 @@ config_guest() { xen-hvm) systemctl stop ntpd systemctl disable ntpd + systemctl enable xe-daemon systemctl start xe-daemon if [ ! -f /usr/bin/xenstore-read ]; then @@ -114,12 +116,14 @@ config_guest() { # system time sync'd with host via vmware tools systemctl stop ntpd systemctl disable ntpd + systemctl enable open-vm-tools systemctl start open-vm-tools vmtoolsd --cmd 'machine.id.get' > $CMDLINE ;; virtualpc|hyperv) # Hyper-V is recognized as virtualpc hypervisor type. Boot args are passed using KVP Daemon + systemctl enable hyperv-daemons.hv-fcopy-daemon.service hyperv-daemons.hv-kvp-daemon.service hyperv-daemons.hv-vss-daemon.service systemctl start hyperv-daemons.hv-fcopy-daemon.service hyperv-daemons.hv-kvp-daemon.service hyperv-daemons.hv-vss-daemon.service sleep 5 cp -f /var/opt/hyperv/.kvp_pool_0 $CMDLINE