Search in sources :

Example 1 with FirewallRuleDetailVO

use of org.apache.cloudstack.resourcedetail.FirewallRuleDetailVO in project cloudstack by apache.

the class NetworkMigrationManagerImpl method copyFirewallRulesToNewNetwork.

private void copyFirewallRulesToNewNetwork(Network srcNetwork, long dstNetworkId) {
    List<FirewallRuleVO> firewallRules = _firewallDao.listByNetworkPurposeTrafficType(srcNetwork.getId(), FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Egress);
    firewallRules.addAll(_firewallDao.listByNetworkPurposeTrafficType(srcNetwork.getId(), FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Ingress));
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Copying firewall rules from network with id " + srcNetwork.getId() + " to network with id " + dstNetworkId);
    }
    // Copy all objects that are dependant on the firewall rules
    for (FirewallRuleVO originalFirewallRule : firewallRules) {
        FirewallRuleVO ruleVO = new FirewallRuleVO(originalFirewallRule.getXid(), originalFirewallRule.getSourceIpAddressId(), originalFirewallRule.getSourcePortStart(), originalFirewallRule.getSourcePortEnd(), originalFirewallRule.getProtocol(), dstNetworkId, srcNetwork.getAccountId(), srcNetwork.getDomainId(), originalFirewallRule.getPurpose(), originalFirewallRule.getSourceCidrList(), originalFirewallRule.getDestinationCidrList(), originalFirewallRule.getIcmpCode(), originalFirewallRule.getIcmpType(), originalFirewallRule.getRelated(), originalFirewallRule.getTrafficType(), originalFirewallRule.getType());
        ruleVO = _firewallDao.persist(ruleVO);
        // Firewall rule cidrs
        List<FirewallRulesCidrsVO> firewallRulesCidrsVOS = _firewallRulesCidrDao.listByFirewallRuleId(originalFirewallRule.getId());
        for (FirewallRulesCidrsVO firewallRulesCidrVO : firewallRulesCidrsVOS) {
            _firewallRulesCidrDao.persist(new FirewallRulesCidrsVO(ruleVO.getId(), firewallRulesCidrVO.getSourceCidrList()));
        }
        // Firewall rules details
        List<FirewallRuleDetailVO> originalFirewallRuleDetails = _firewallRuleDetailsDao.listDetails(originalFirewallRule.getId());
        for (FirewallRuleDetailVO originalFirewallRuleDetail : originalFirewallRuleDetails) {
            _firewallRuleDetailsDao.persist(new FirewallRuleDetailVO(ruleVO.getId(), originalFirewallRuleDetail.getName(), originalFirewallRuleDetail.getValue(), originalFirewallRuleDetail.isDisplay()));
        }
    }
}
Also used : FirewallRuleDetailVO(org.apache.cloudstack.resourcedetail.FirewallRuleDetailVO) FirewallRulesCidrsVO(com.cloud.network.dao.FirewallRulesCidrsVO) FirewallRuleVO(com.cloud.network.rules.FirewallRuleVO)

Aggregations

FirewallRulesCidrsVO (com.cloud.network.dao.FirewallRulesCidrsVO)1 FirewallRuleVO (com.cloud.network.rules.FirewallRuleVO)1 FirewallRuleDetailVO (org.apache.cloudstack.resourcedetail.FirewallRuleDetailVO)1