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();
}
}
Aggregations