Search in sources :

Example 6 with NetworkACLVO

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;
    }
}
Also used : NetworkACLVO(com.cloud.network.vpc.NetworkACLVO) NetworkPolicy(net.juniper.contrail.api.types.NetworkPolicy) ApiConnector(net.juniper.contrail.api.ApiConnector) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) InternalErrorException(com.cloud.exception.InternalErrorException) IOException(java.io.IOException)

Example 7 with NetworkACLVO

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;
}
Also used : NetworkACLVO(com.cloud.network.vpc.NetworkACLVO) VpcVO(com.cloud.network.vpc.VpcVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) ArrayList(java.util.ArrayList)

Aggregations

NetworkACLVO (com.cloud.network.vpc.NetworkACLVO)7 InternalErrorException (com.cloud.exception.InternalErrorException)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 NetworkPolicyModel (org.apache.cloudstack.network.contrail.model.NetworkPolicyModel)3 VirtualNetworkModel (org.apache.cloudstack.network.contrail.model.VirtualNetworkModel)3 NetworkACLItemVO (com.cloud.network.vpc.NetworkACLItemVO)2 VpcVO (com.cloud.network.vpc.VpcVO)2 OvsVpcRoutingPolicyConfigCommand (com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 Network (com.cloud.network.Network)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 Account (com.cloud.user.Account)1 AccountVO (com.cloud.user.AccountVO)1 UserVO (com.cloud.user.UserVO)1 List (java.util.List)1 ApiConnector (net.juniper.contrail.api.ApiConnector)1