mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'apache/4.19' into 4.20
This commit is contained in:
commit
f99942cf9a
@ -209,4 +209,9 @@ public class CreateSnapshotFromVMSnapshotCmd extends BaseAsyncCreateCmd {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getApiResourceId() {
|
||||||
|
return getEntityId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,8 @@ import java.util.Map;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
|
import com.cloud.event.ActionEvent;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||||
@ -545,6 +547,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ActionEvent(eventType = EventTypes.EVENT_INTERNAL_LB_VM_STOP, eventDescription = "stopping internal LB VM", async = true)
|
||||||
public VirtualRouter stopInternalLbVm(final long vmId, final boolean forced, final Account caller, final long callerUserId) throws ConcurrentOperationException, ResourceUnavailableException {
|
public VirtualRouter stopInternalLbVm(final long vmId, final boolean forced, final Account caller, final long callerUserId) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||||
final DomainRouterVO internalLbVm = _internalLbVmDao.findById(vmId);
|
final DomainRouterVO internalLbVm = _internalLbVmDao.findById(vmId);
|
||||||
if (internalLbVm == null || internalLbVm.getRole() != Role.INTERNAL_LB_VM) {
|
if (internalLbVm == null || internalLbVm.getRole() != Role.INTERNAL_LB_VM) {
|
||||||
@ -974,6 +977,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ActionEvent(eventType = EventTypes.EVENT_INTERNAL_LB_VM_START, eventDescription = "starting internal LB VM", async = true)
|
||||||
public VirtualRouter startInternalLbVm(final long internalLbVmId, final Account caller, final long callerUserId) throws StorageUnavailableException, InsufficientCapacityException,
|
public VirtualRouter startInternalLbVm(final long internalLbVmId, final Account caller, final long callerUserId) throws StorageUnavailableException, InsufficientCapacityException,
|
||||||
ConcurrentOperationException, ResourceUnavailableException {
|
ConcurrentOperationException, ResourceUnavailableException {
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,9 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.internallbvmmgr;
|
package org.apache.cloudstack.internallbvmmgr;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.nullable;
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -24,13 +27,15 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import com.cloud.event.ActionEventUtils;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
|
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.BDDMockito;
|
||||||
|
import org.mockito.MockedStatic;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
@ -82,6 +87,8 @@ public class InternalLBVMServiceTest extends TestCase {
|
|||||||
@Inject
|
@Inject
|
||||||
AccountDao _accountDao;
|
AccountDao _accountDao;
|
||||||
|
|
||||||
|
private MockedStatic<ActionEventUtils> actionEventUtilsMocked;
|
||||||
|
|
||||||
long validVmId = 1L;
|
long validVmId = 1L;
|
||||||
long nonExistingVmId = 2L;
|
long nonExistingVmId = 2L;
|
||||||
long nonInternalLbVmId = 3L;
|
long nonInternalLbVmId = 3L;
|
||||||
@ -105,7 +112,7 @@ public class InternalLBVMServiceTest extends TestCase {
|
|||||||
|
|
||||||
Mockito.when(_accountMgr.getSystemUser()).thenReturn(new UserVO(1));
|
Mockito.when(_accountMgr.getSystemUser()).thenReturn(new UserVO(1));
|
||||||
Mockito.when(_accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
|
Mockito.when(_accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
|
||||||
Mockito.when(_accountDao.findByIdIncludingRemoved(ArgumentMatchers.anyLong())).thenReturn(new AccountVO(2));
|
Mockito.when(_accountDao.findByIdIncludingRemoved(anyLong())).thenReturn(new AccountVO(2));
|
||||||
CallContext.register(_accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
CallContext.register(_accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||||
|
|
||||||
final DomainRouterVO validVm =
|
final DomainRouterVO validVm =
|
||||||
@ -120,11 +127,16 @@ public class InternalLBVMServiceTest extends TestCase {
|
|||||||
Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(validVm);
|
Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(validVm);
|
||||||
Mockito.when(_domainRouterDao.findById(nonExistingVmId)).thenReturn(null);
|
Mockito.when(_domainRouterDao.findById(nonExistingVmId)).thenReturn(null);
|
||||||
Mockito.when(_domainRouterDao.findById(nonInternalLbVmId)).thenReturn(nonInternalLbVm);
|
Mockito.when(_domainRouterDao.findById(nonInternalLbVmId)).thenReturn(nonInternalLbVm);
|
||||||
|
|
||||||
|
actionEventUtilsMocked = Mockito.mockStatic(ActionEventUtils.class);
|
||||||
|
BDDMockito.given(ActionEventUtils.onStartedActionEvent(anyLong(), anyLong(), anyString(), anyString(), anyLong(), anyString(), anyBoolean(), anyLong()))
|
||||||
|
.willReturn(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
|
actionEventUtilsMocked.close();
|
||||||
CallContext.unregister();
|
CallContext.unregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -173,10 +173,10 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
}
|
}
|
||||||
} else if (template.getDownloadState() == Status.BYPASSED) {
|
} else if (template.getDownloadState() == Status.BYPASSED) {
|
||||||
templateStatus = "Bypassed Secondary Storage";
|
templateStatus = "Bypassed Secondary Storage";
|
||||||
}else if (template.getErrorString()==null){
|
} else if (template.getErrorString() == null) {
|
||||||
templateStatus = template.getTemplateState().toString();
|
templateStatus = template.getTemplateState().toString();
|
||||||
}else {
|
} else {
|
||||||
templateStatus = template.getErrorString();
|
templateStatus = template.getErrorString().trim();
|
||||||
}
|
}
|
||||||
} else if (template.getDownloadState() == Status.DOWNLOADED) {
|
} else if (template.getDownloadState() == Status.DOWNLOADED) {
|
||||||
templateStatus = "Download Complete";
|
templateStatus = "Download Complete";
|
||||||
|
|||||||
@ -1274,6 +1274,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@DB
|
||||||
|
@ActionEvent(eventType = EventTypes.EVENT_MAINTENANCE_CANCEL, eventDescription = "cancel maintenance for host", async = true)
|
||||||
public Host cancelMaintenance(final CancelMaintenanceCmd cmd) {
|
public Host cancelMaintenance(final CancelMaintenanceCmd cmd) {
|
||||||
final Long hostId = cmd.getId();
|
final Long hostId = cmd.getId();
|
||||||
|
|
||||||
@ -1297,6 +1299,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@DB
|
||||||
|
@ActionEvent(eventType = EventTypes.EVENT_HOST_RECONNECT, eventDescription = "reconnecting host", async = true)
|
||||||
public Host reconnectHost(ReconnectHostCmd cmd) throws AgentUnavailableException {
|
public Host reconnectHost(ReconnectHostCmd cmd) throws AgentUnavailableException {
|
||||||
Long hostId = cmd.getId();
|
Long hostId = cmd.getId();
|
||||||
|
|
||||||
@ -1500,6 +1504,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@DB
|
||||||
|
@ActionEvent(eventType = EventTypes.EVENT_MAINTENANCE_PREPARE, eventDescription = "prepare maintenance for host", async = true)
|
||||||
public Host maintain(final PrepareForMaintenanceCmd cmd) {
|
public Host maintain(final PrepareForMaintenanceCmd cmd) {
|
||||||
final Long hostId = cmd.getId();
|
final Long hostId = cmd.getId();
|
||||||
final HostVO host = _hostDao.findById(hostId);
|
final HostVO host = _hostDao.findById(hostId);
|
||||||
|
|||||||
@ -561,6 +561,8 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@DB
|
||||||
|
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "creating snapshot from VM snapshot", async = true)
|
||||||
public Snapshot backupSnapshotFromVmSnapshot(Long snapshotId, Long vmId, Long volumeId, Long vmSnapshotId) {
|
public Snapshot backupSnapshotFromVmSnapshot(Long snapshotId, Long vmId, Long volumeId, Long vmSnapshotId) {
|
||||||
VMInstanceVO vm = _vmDao.findById(vmId);
|
VMInstanceVO vm = _vmDao.findById(vmId);
|
||||||
if (vm == null) {
|
if (vm == null) {
|
||||||
|
|||||||
@ -226,8 +226,8 @@ export default {
|
|||||||
api('listDiskOfferings', {
|
api('listDiskOfferings', {
|
||||||
id: this.selectedOffering.diskofferingid
|
id: this.selectedOffering.diskofferingid
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
const diskOfferings = response.listdiskofferingsresponse.diskoffering || []
|
const diskOfferings = response?.listdiskofferingsresponse?.diskoffering || []
|
||||||
if (this.diskOfferings) {
|
if (diskOfferings?.length > 0) {
|
||||||
this.selectedDiskOffering = diskOfferings[0]
|
this.selectedDiskOffering = diskOfferings[0]
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user