Search in sources :

Example 1 with MockSecurityRulesVO

use of com.cloud.simulator.MockSecurityRulesVO 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

Answer (com.cloud.agent.api.Answer)1 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)1 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)1 CreateVMSnapshotAnswer (com.cloud.agent.api.CreateVMSnapshotAnswer)1 DeleteVMSnapshotAnswer (com.cloud.agent.api.DeleteVMSnapshotAnswer)1 FenceAnswer (com.cloud.agent.api.FenceAnswer)1 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)1 GetVmStatsAnswer (com.cloud.agent.api.GetVmStatsAnswer)1 GetVncPortAnswer (com.cloud.agent.api.GetVncPortAnswer)1 MigrateAnswer (com.cloud.agent.api.MigrateAnswer)1 PrepareForMigrationAnswer (com.cloud.agent.api.PrepareForMigrationAnswer)1 RebootAnswer (com.cloud.agent.api.RebootAnswer)1 RevertToVMSnapshotAnswer (com.cloud.agent.api.RevertToVMSnapshotAnswer)1 ScaleVmAnswer (com.cloud.agent.api.ScaleVmAnswer)1 SecurityGroupRuleAnswer (com.cloud.agent.api.SecurityGroupRuleAnswer)1 StartAnswer (com.cloud.agent.api.StartAnswer)1 StopAnswer (com.cloud.agent.api.StopAnswer)1 CheckSshAnswer (com.cloud.agent.api.check.CheckSshAnswer)1 MockSecurityRulesVO (com.cloud.simulator.MockSecurityRulesVO)1 MockVMVO (com.cloud.simulator.MockVMVO)1