Search in sources :

Example 21 with MockVMVO

use of com.cloud.simulator.MockVMVO in project cloudstack by apache.

the class MockVmManagerImpl method cleanupNetworkRules.

@Override
public Answer cleanupNetworkRules(final CleanupNetworkRulesCmd cmd, final SimulatorInfo info) {
    TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
    try {
        txn.start();
        final List<MockSecurityRulesVO> rules = _mockSecurityDao.findByHost(info.getHostUuid());
        for (final MockSecurityRulesVO rule : rules) {
            final MockVMVO vm = _mockVmDao.findByVmNameAndHost(rule.getVmName(), info.getHostUuid());
            if (vm == null) {
                _mockSecurityDao.remove(rule.getId());
            }
        }
        txn.commit();
        return new Answer(cmd);
    } catch (final Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("unable to clean up rules", ex);
    } finally {
        txn.close();
        txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
        txn.close();
    }
}
Also used : MockVMVO(com.cloud.simulator.MockVMVO) TransactionLegacy(com.cloud.utils.db.TransactionLegacy) FenceAnswer(com.cloud.agent.api.FenceAnswer) StopAnswer(com.cloud.agent.api.StopAnswer) CreateVMSnapshotAnswer(com.cloud.agent.api.CreateVMSnapshotAnswer) Answer(com.cloud.agent.api.Answer) DeleteVMSnapshotAnswer(com.cloud.agent.api.DeleteVMSnapshotAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) RebootAnswer(com.cloud.agent.api.RebootAnswer) RevertToVMSnapshotAnswer(com.cloud.agent.api.RevertToVMSnapshotAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) PrepareForMigrationAnswer(com.cloud.agent.api.PrepareForMigrationAnswer) MigrateAnswer(com.cloud.agent.api.MigrateAnswer) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) ScaleVmAnswer(com.cloud.agent.api.ScaleVmAnswer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) SecurityGroupRuleAnswer(com.cloud.agent.api.SecurityGroupRuleAnswer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) MockSecurityRulesVO(com.cloud.simulator.MockSecurityRulesVO) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

MockVMVO (com.cloud.simulator.MockVMVO)21 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)10 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)10 ConfigurationException (javax.naming.ConfigurationException)10 MockHost (com.cloud.simulator.MockHost)6 HashMap (java.util.HashMap)6 MockVm (com.cloud.simulator.MockVm)5 Answer (com.cloud.agent.api.Answer)4 MockVolumeVO (com.cloud.simulator.MockVolumeVO)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 AttachVolumeAnswer (com.cloud.agent.api.AttachVolumeAnswer)3 BackupSnapshotAnswer (com.cloud.agent.api.BackupSnapshotAnswer)3 CreateVolumeFromSnapshotAnswer (com.cloud.agent.api.CreateVolumeFromSnapshotAnswer)3 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)3 ManageSnapshotAnswer (com.cloud.agent.api.ManageSnapshotAnswer)3 MigrateAnswer (com.cloud.agent.api.MigrateAnswer)3 ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)3 SecStorageSetupAnswer (com.cloud.agent.api.SecStorageSetupAnswer)3 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)2 GetHostStatsAnswer (com.cloud.agent.api.GetHostStatsAnswer)2