use of com.cloud.vm.VMInstanceVO in project cloudstack by apache.
the class SecurityGroupManagerImpl method postStateTransitionEvent.
@Override
public boolean postStateTransitionEvent(StateMachine2.Transition<State, Event> transition, VirtualMachine vm, boolean status, Object opaque) {
if (!status) {
return false;
}
State oldState = transition.getCurrentState();
State newState = transition.getToState();
Event event = transition.getEvent();
if (VirtualMachine.State.isVmStarted(oldState, event, newState)) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Security Group Mgr: handling start of vm id" + vm.getId());
}
handleVmStarted((VMInstanceVO) vm);
} else if (VirtualMachine.State.isVmStopped(oldState, event, newState)) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Security Group Mgr: handling stop of vm id" + vm.getId());
}
handleVmStopped((VMInstanceVO) vm);
} else if (VirtualMachine.State.isVmMigrated(oldState, event, newState)) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Security Group Mgr: handling migration of vm id" + vm.getId());
}
handleVmMigrated((VMInstanceVO) vm);
}
return true;
}
use of com.cloud.vm.VMInstanceVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfZoneIsDeletableFailureOnPodTest.
@Test(expected = CloudRuntimeException.class)
public void checkIfZoneIsDeletableFailureOnPodTest() {
HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
ArrayList<HostPodVO> arrayList = new ArrayList<HostPodVO>();
arrayList.add(hostPodVO);
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(arrayList);
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
}
use of com.cloud.vm.VMInstanceVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfZoneIsDeletableFailureOnVolumeTest.
@Test(expected = CloudRuntimeException.class)
public void checkIfZoneIsDeletableFailureOnVolumeTest() {
VolumeVO volumeVO = Mockito.mock(VolumeVO.class);
ArrayList<VolumeVO> arrayList = new ArrayList<VolumeVO>();
arrayList.add(volumeVO);
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(arrayList);
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
}
use of com.cloud.vm.VMInstanceVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnVolumeTest.
@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnVolumeTest() {
HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
VolumeVO volumeVO = Mockito.mock(VolumeVO.class);
ArrayList<VolumeVO> arrayList = new ArrayList<VolumeVO>();
arrayList.add(volumeVO);
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(arrayList);
Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<HostVO>());
Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<ClusterVO>());
configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
use of com.cloud.vm.VMInstanceVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfZoneIsDeletableFailureOnPhysicalNetworkTest.
@Test(expected = CloudRuntimeException.class)
public void checkIfZoneIsDeletableFailureOnPhysicalNetworkTest() {
PhysicalNetworkVO physicalNetworkVO = Mockito.mock(PhysicalNetworkVO.class);
ArrayList<PhysicalNetworkVO> arrayList = new ArrayList<PhysicalNetworkVO>();
arrayList.add(physicalNetworkVO);
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(arrayList);
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
}
Aggregations