use of com.cloud.network.vpc.NetworkACLVO in project cloudstack by apache.
the class ServerDBSyncImpl method syncNetworkPolicy.
/*
* Network Policy Synchronization methods
*/
@SuppressWarnings({ "unchecked" })
public boolean syncNetworkPolicy() throws Exception {
final ApiConnector api = _manager.getApiConnector();
try {
List<NetworkACLVO> dbAcls = _manager.findManagedACLs();
if (dbAcls == null) {
dbAcls = new ArrayList<NetworkACLVO>();
}
List<NetworkPolicy> pList = (List<NetworkPolicy>) api.list(NetworkPolicy.class, null);
List<NetworkPolicy> vncList = new ArrayList<NetworkPolicy>();
for (NetworkPolicy policy : pList) {
if (!_manager.isSystemDefaultNetworkPolicy(policy)) {
vncList.add(policy);
}
}
s_logger.debug("sync Network Policy - DB size: " + dbAcls.size() + " VNC Size: " + vncList.size());
return _dbSync.syncGeneric(NetworkPolicy.class, dbAcls, vncList);
} catch (Exception ex) {
s_logger.warn("sync network-policys", ex);
throw ex;
}
}
use of com.cloud.network.vpc.NetworkACLVO in project cloudstack by apache.
the class ContrailManagerImpl method findManagedACLs.
@Override
public List<NetworkACLVO> findManagedACLs() {
List<VpcVO> vpcs = findManagedVpcs();
if (vpcs == null || vpcs.isEmpty()) {
return null;
}
List<Long> vpcIds = new ArrayList<Long>();
/* default-allow, default-deny ACLs will be under vpcId '0', so include it*/
vpcIds.add((long) 0);
for (VpcVO vpc : vpcs) {
vpcIds.add(vpc.getId());
}
SearchBuilder<NetworkACLVO> searchBuilder = _networkAclDao.createSearchBuilder();
searchBuilder.and("vpcId", searchBuilder.entity().getVpcId(), Op.IN);
SearchCriteria<NetworkACLVO> sc = searchBuilder.create();
sc.setParameters("vpcId", vpcIds.toArray());
List<NetworkACLVO> acls = _networkAclDao.search(sc, null);
if (acls == null || acls.size() == 0) {
s_logger.debug("no acls found");
return null;
}
/* only return if acl is associated to any network */
List<NetworkACLVO> jnprAcls = new ArrayList<NetworkACLVO>();
for (NetworkACLVO acl : acls) {
List<NetworkVO> nets = _networksDao.listByAclId(acl.getId());
if (nets == null || nets.isEmpty()) {
continue;
}
jnprAcls.add(acl);
}
return jnprAcls;
}
Aggregations