mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.14'
This commit is contained in:
commit
2d1989fd76
@ -3987,6 +3987,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
// get all the hosts in this cluster
|
||||
final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(command.getClusterId());
|
||||
|
||||
String userNameWithoutSpaces = StringUtils.deleteWhitespace(command.getUsername());
|
||||
if (StringUtils.isBlank(userNameWithoutSpaces)) {
|
||||
throw new InvalidParameterValueException("Username should be non empty string");
|
||||
}
|
||||
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
@ -3996,7 +4001,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
}
|
||||
// update password for this host
|
||||
final DetailVO nv = _detailsDao.findDetail(h.getId(), ApiConstants.USERNAME);
|
||||
if (nv.getValue().equals(command.getUsername())) {
|
||||
if (nv == null) {
|
||||
final DetailVO nvu = new DetailVO(h.getId(), ApiConstants.USERNAME, userNameWithoutSpaces);
|
||||
_detailsDao.persist(nvu);
|
||||
final DetailVO nvp = new DetailVO(h.getId(), ApiConstants.PASSWORD, DBEncryptionUtil.encrypt(command.getPassword()));
|
||||
_detailsDao.persist(nvp);
|
||||
} else if (nv.getValue().equals(userNameWithoutSpaces)) {
|
||||
final DetailVO nvp = _detailsDao.findDetail(h.getId(), ApiConstants.PASSWORD);
|
||||
nvp.setValue(DBEncryptionUtil.encrypt(command.getPassword()));
|
||||
_detailsDao.persist(nvp);
|
||||
@ -4044,6 +4054,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
if (!supportedHypervisors.contains(host.getHypervisorType())) {
|
||||
throw new InvalidParameterValueException("This operation is not supported for this hypervisor type");
|
||||
}
|
||||
|
||||
String userNameWithoutSpaces = StringUtils.deleteWhitespace(cmd.getUsername());
|
||||
if (StringUtils.isBlank(userNameWithoutSpaces)) {
|
||||
throw new InvalidParameterValueException("Username should be non empty string");
|
||||
}
|
||||
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
@ -4052,7 +4068,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
}
|
||||
// update password for this host
|
||||
final DetailVO nv = _detailsDao.findDetail(host.getId(), ApiConstants.USERNAME);
|
||||
if (nv.getValue().equals(cmd.getUsername())) {
|
||||
if (nv == null) {
|
||||
final DetailVO nvu = new DetailVO(host.getId(), ApiConstants.USERNAME, userNameWithoutSpaces);
|
||||
_detailsDao.persist(nvu);
|
||||
final DetailVO nvp = new DetailVO(host.getId(), ApiConstants.PASSWORD, DBEncryptionUtil.encrypt(cmd.getPassword()));
|
||||
_detailsDao.persist(nvp);
|
||||
} else if (nv.getValue().equals(userNameWithoutSpaces)) {
|
||||
final DetailVO nvp = _detailsDao.findDetail(host.getId(), ApiConstants.PASSWORD);
|
||||
nvp.setValue(DBEncryptionUtil.encrypt(cmd.getPassword()));
|
||||
_detailsDao.persist(nvp);
|
||||
|
||||
@ -465,7 +465,7 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement
|
||||
}
|
||||
SnapshotInfo snapshotInfo = this.snapshotFactory.getSnapshot(snapshotId, store);
|
||||
snapshotInfo = (SnapshotInfo)store.create(snapshotInfo);
|
||||
SnapshotDataStoreVO snapshotOnPrimaryStore = this._snapshotStoreDao.findBySnapshot(snapshot.getId(), store.getRole());
|
||||
SnapshotDataStoreVO snapshotOnPrimaryStore = this._snapshotStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshot.getId());
|
||||
snapshotOnPrimaryStore.setState(ObjectInDataStoreStateMachine.State.Ready);
|
||||
snapshotOnPrimaryStore.setInstallPath(vmSnapshot.getName());
|
||||
_snapshotStoreDao.update(snapshotOnPrimaryStore.getId(), snapshotOnPrimaryStore);
|
||||
|
||||
@ -316,7 +316,7 @@ public class SnapshotManagerTest {
|
||||
when(snapshotStoreDao.findParent(any(DataStoreRole.class), nullable(Long.class), nullable(Long.class))).thenReturn(null);
|
||||
when(snapshotFactory.getSnapshot(nullable(Long.class), nullable(DataStore.class))).thenReturn(snapshotInfoMock);
|
||||
when(storeMock.create(snapshotInfoMock)).thenReturn(snapshotInfoMock);
|
||||
when(snapshotStoreDao.findBySnapshot(nullable(Long.class), nullable(DataStoreRole.class))).thenReturn(snapshotStoreMock);
|
||||
when(snapshotStoreDao.findByStoreSnapshot(nullable(DataStoreRole.class), nullable(Long.class), nullable(Long.class))).thenReturn(snapshotStoreMock);
|
||||
when(snapshotStoreDao.update(nullable(Long.class), nullable(SnapshotDataStoreVO.class))).thenReturn(true);
|
||||
when(_snapshotDao.update(nullable(Long.class), nullable(SnapshotVO.class))).thenReturn(true);
|
||||
when(vmMock.getAccountId()).thenReturn(2L);
|
||||
@ -333,7 +333,7 @@ public class SnapshotManagerTest {
|
||||
when(vmMock.getHypervisorType()).thenReturn(Hypervisor.HypervisorType.KVM);
|
||||
when(_vmSnapshotDao.findById(nullable(Long.class))).thenReturn(vmSnapshotMock);
|
||||
when(snapshotStoreDao.findParent(any(DataStoreRole.class), nullable(Long.class), nullable(Long.class))).thenReturn(snapshotStoreMock);
|
||||
when(snapshotStoreDao.findBySnapshot(nullable(Long.class), nullable(DataStoreRole.class))).thenReturn(snapshotStoreMock);
|
||||
when(snapshotStoreDao.findByStoreSnapshot(nullable(DataStoreRole.class), nullable(Long.class), nullable(Long.class))).thenReturn(snapshotStoreMock);
|
||||
when(snapshotStoreMock.getInstallPath()).thenReturn("VM_SNAPSHOT_NAME");
|
||||
when(vmSnapshotMock.getName()).thenReturn("VM_SNAPSHOT_NAME");
|
||||
Snapshot snapshot = _snapshotMgr.backupSnapshotFromVmSnapshot(TEST_SNAPSHOT_ID, TEST_VM_ID, TEST_VOLUME_ID, TEST_VM_SNAPSHOT_ID);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user