Search in sources :

Example 76 with VMInstanceVO

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;
}
Also used : State(com.cloud.vm.VirtualMachine.State) Event(com.cloud.vm.VirtualMachine.Event) ActionEvent(com.cloud.event.ActionEvent) VMInstanceVO(com.cloud.vm.VMInstanceVO)

Example 77 with VMInstanceVO

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());
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) Random(java.util.Random) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) VMInstanceVO(com.cloud.vm.VMInstanceVO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Example 78 with VMInstanceVO

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());
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) Random(java.util.Random) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) VMInstanceVO(com.cloud.vm.VMInstanceVO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Example 79 with VMInstanceVO

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());
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) Random(java.util.Random) VolumeVO(com.cloud.storage.VolumeVO) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Example 80 with VMInstanceVO

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());
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) Random(java.util.Random) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Aggregations

VMInstanceVO (com.cloud.vm.VMInstanceVO)131 ArrayList (java.util.ArrayList)40 HostVO (com.cloud.host.HostVO)34 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)30 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)28 Account (com.cloud.user.Account)28 VolumeVO (com.cloud.storage.VolumeVO)24 Test (org.junit.Test)24 HostPodVO (com.cloud.dc.HostPodVO)15 HashMap (java.util.HashMap)14 NetworkVO (com.cloud.network.dao.NetworkVO)13 User (com.cloud.user.User)13 NicVO (com.cloud.vm.NicVO)13 VmWorkJobVO (org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO)13 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)12 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)12 ActionEvent (com.cloud.event.ActionEvent)11 Random (java.util.Random)11 Answer (com.cloud.agent.api.Answer)10 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)10