mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
vpc,event: fix events for createVpc (#9055)
Fixes #8496 * vpc,event: fix events for createVpc
This commit is contained in:
parent
edf7394919
commit
ca59720015
@ -132,6 +132,8 @@ public interface VpcService {
|
||||
*/
|
||||
boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
void startVpc(CreateVPCCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Shuts down the VPC which includes shutting down all VPC provider and rules cleanup on the backend
|
||||
*
|
||||
|
||||
@ -210,11 +210,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
|
||||
public void execute() {
|
||||
Vpc vpc = null;
|
||||
try {
|
||||
if (isStart()) {
|
||||
_vpcService.startVpc(getEntityId(), true);
|
||||
} else {
|
||||
s_logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API");
|
||||
}
|
||||
_vpcService.startVpc(this);
|
||||
vpc = _entityMgr.findById(Vpc.class, getEntityId());
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
|
||||
@ -167,17 +167,16 @@ public class CreateVPCCmdTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testExecute() throws ResourceUnavailableException, InsufficientCapacityException {
|
||||
ReflectionTestUtils.setField(cmd, "start", true);
|
||||
Vpc vpc = Mockito.mock(Vpc.class);
|
||||
VpcResponse response = Mockito.mock(VpcResponse.class);
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "id", 1L);
|
||||
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
||||
Mockito.when(_vpcService.startVpc(1L, true)).thenReturn(true);
|
||||
Mockito.doNothing().when(_vpcService).startVpc(cmd);
|
||||
Mockito.when(_entityMgr.findById(Mockito.eq(Vpc.class), Mockito.any(Long.class))).thenReturn(vpc);
|
||||
cmd._responseGenerator = responseGenerator;
|
||||
Mockito.when(responseGenerator.createVpcResponse(ResponseObject.ResponseView.Restricted, vpc)).thenReturn(response);
|
||||
cmd.execute();
|
||||
Mockito.verify(_vpcService, Mockito.times(1)).startVpc(Mockito.anyLong(), Mockito.anyBoolean());
|
||||
Mockito.verify(_vpcService, Mockito.times(1)).startVpc(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1677,6 +1677,17 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", async = true)
|
||||
public void startVpc(final CreateVPCCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
if (!cmd.isStart()) {
|
||||
s_logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API");
|
||||
return;
|
||||
}
|
||||
startVpc(cmd.getEntityId(), true);
|
||||
}
|
||||
|
||||
protected boolean startVpc(final Vpc vpc, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException {
|
||||
// deploy provider
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user