use of com.cloud.network.vpc.NetworkACLItemCidrsVO in project cloudstack by apache.
the class NetworkACLItemCidrsDaoImpl method persist.
/* (non-Javadoc)
* @see com.cloud.network.dao.NetworkAclItemCidrsDao#persist(long, java.util.List)
*/
@Override
public void persist(long networkACLItemId, List<String> cidrs) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
for (String cidr : cidrs) {
NetworkACLItemCidrsVO vo = new NetworkACLItemCidrsVO(networkACLItemId, cidr);
persist(vo);
}
txn.commit();
}
use of com.cloud.network.vpc.NetworkACLItemCidrsVO in project cloudstack by apache.
the class BigSwitchBcfUtils method listACLbyNetwork.
public List<AclData> listACLbyNetwork(Network network) {
List<AclData> aclList = new ArrayList<AclData>();
List<FirewallRuleVO> fwRules;
fwRules = _fwRulesDao.listByNetworkAndPurposeAndNotRevoked(network.getId(), Purpose.Firewall);
List<FirewallRulesCidrsVO> fwCidrList = null;
SubnetUtils utils;
for (FirewallRuleVO rule : fwRules) {
AclData acl = new AclData();
acl.setId(rule.getUuid());
// CloudStack Firewall interface does not have priority
acl.setPriority((int) rule.getId());
acl.setIpProto(rule.getProtocol());
String cidr = null;
Integer port = rule.getSourcePortStart();
fwCidrList = _fwCidrsDao.listByFirewallRuleId(rule.getId());
if (fwCidrList != null) {
if (fwCidrList.size() > 1 || !rule.getSourcePortEnd().equals(port)) {
continue;
} else {
cidr = fwCidrList.get(0).getCidr();
}
}
if (cidr == null || cidr.equalsIgnoreCase("0.0.0.0/0")) {
cidr = "";
} else {
utils = new SubnetUtils(cidr);
if (!utils.getInfo().getNetworkAddress().equals(utils.getInfo().getAddress())) {
continue;
}
}
acl.setSource(acl.new AclNetwork(cidr, port));
acl.setAction("permit");
aclList.add(acl);
}
List<NetworkACLItemVO> aclItems;
List<NetworkACLItemCidrsVO> aclCidrList;
if (network.getNetworkACLId() != null) {
aclItems = _aclItemDao.listByACL(network.getNetworkACLId());
for (NetworkACLItem item : aclItems) {
AclData acl = new AclData();
acl.setId(item.getUuid());
acl.setPriority(item.getNumber());
acl.setIpProto(item.getProtocol());
// currently BCF supports single cidr policy
String cidr = null;
// currently BCF supports single port policy
Integer port = item.getSourcePortStart();
aclCidrList = _aclItemCidrsDao.listByNetworkACLItemId(item.getId());
if (aclCidrList != null) {
if (aclCidrList.size() > 1 || !item.getSourcePortEnd().equals(port)) {
continue;
} else {
cidr = aclCidrList.get(0).getCidr();
}
}
if (cidr == null || cidr.equalsIgnoreCase("0.0.0.0/0")) {
cidr = "";
} else {
utils = new SubnetUtils(cidr);
if (!utils.getInfo().getNetworkAddress().equals(utils.getInfo().getAddress())) {
continue;
}
}
acl.setSource(acl.new AclNetwork(cidr, port));
acl.setAction(item.getAction().name());
aclList.add(acl);
}
}
return aclList;
}
use of com.cloud.network.vpc.NetworkACLItemCidrsVO in project cloudstack by apache.
the class NetworkACLItemCidrsDaoImpl method getCidrs.
/* (non-Javadoc)
* @see com.cloud.network.dao.NetworkAclItemCidrsDao#getCidrs(long)
*/
@Override
public List<String> getCidrs(long networkACLItemId) {
SearchCriteria<NetworkACLItemCidrsVO> sc = cidrsSearch.create();
sc.setParameters("networkAclItemId", networkACLItemId);
List<NetworkACLItemCidrsVO> results = search(sc, null);
List<String> cidrs = new ArrayList<String>(results.size());
for (NetworkACLItemCidrsVO result : results) {
cidrs.add(result.getCidr());
}
return cidrs;
}
Aggregations