Search in sources :

Example 11 with NetworkACLItemVO

use of com.cloud.network.vpc.NetworkACLItemVO in project cloudstack by apache.

the class NetworkACLServiceTest method setUp.

@Override
@Before
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    Account account = new AccountVO("testaccount", 1, "testdomain", (short) 0, UUID.randomUUID().toString());
    UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
    CallContext.register(user, account);
    createACLItemCmd = new CreateNetworkACLCmd() {

        @Override
        public Long getACLId() {
            return 3L;
        }

        @Override
        public Integer getNumber() {
            return 1;
        }

        @Override
        public String getProtocol() {
            return "TCP";
        }
    };
    acl = new NetworkACLVO() {

        @Override
        public Long getVpcId() {
            return 1L;
        }

        @Override
        public long getId() {
            return 1L;
        }
    };
    aclItem = new NetworkACLItemVO() {

        @Override
        public long getAclId() {
            return 4L;
        }
    };
}
Also used : Account(com.cloud.user.Account) NetworkACLVO(com.cloud.network.vpc.NetworkACLVO) UserVO(com.cloud.user.UserVO) CreateNetworkACLCmd(org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd) AccountVO(com.cloud.user.AccountVO) NetworkACLItemVO(com.cloud.network.vpc.NetworkACLItemVO) Before(org.junit.Before)

Example 12 with NetworkACLItemVO

use of com.cloud.network.vpc.NetworkACLItemVO in project cloudstack by apache.

the class OvsTunnelManagerImpl method prepareVpcRoutingPolicyUpdate.

private OvsVpcRoutingPolicyConfigCommand prepareVpcRoutingPolicyUpdate(long vpcId) {
    List<OvsVpcRoutingPolicyConfigCommand.Acl> acls = new ArrayList<>();
    List<OvsVpcRoutingPolicyConfigCommand.Tier> tiers = new ArrayList<>();
    VpcVO vpc = _vpcDao.findById(vpcId);
    List<? extends Network> vpcNetworks = _vpcMgr.getVpcNetworks(vpcId);
    assert (vpc != null && (vpcNetworks != null && !vpcNetworks.isEmpty())) : "invalid vpc id";
    for (Network network : vpcNetworks) {
        Long networkAclId = network.getNetworkACLId();
        if (networkAclId == null)
            continue;
        NetworkACLVO networkAcl = _networkACLDao.findById(networkAclId);
        List<OvsVpcRoutingPolicyConfigCommand.AclItem> aclItems = new ArrayList<>();
        List<NetworkACLItemVO> aclItemVos = _networkACLItemDao.listByACL(networkAclId);
        for (NetworkACLItemVO aclItem : aclItemVos) {
            String[] sourceCidrs = aclItem.getSourceCidrList().toArray(new String[aclItem.getSourceCidrList().size()]);
            aclItems.add(new OvsVpcRoutingPolicyConfigCommand.AclItem(aclItem.getNumber(), aclItem.getUuid(), aclItem.getAction().name(), aclItem.getTrafficType().name(), ((aclItem.getSourcePortStart() != null) ? aclItem.getSourcePortStart().toString() : null), ((aclItem.getSourcePortEnd() != null) ? aclItem.getSourcePortEnd().toString() : null), aclItem.getProtocol(), sourceCidrs));
        }
        OvsVpcRoutingPolicyConfigCommand.Acl acl = new OvsVpcRoutingPolicyConfigCommand.Acl(networkAcl.getUuid(), aclItems.toArray(new OvsVpcRoutingPolicyConfigCommand.AclItem[aclItems.size()]));
        acls.add(acl);
        OvsVpcRoutingPolicyConfigCommand.Tier tier = new OvsVpcRoutingPolicyConfigCommand.Tier(network.getUuid(), network.getCidr(), networkAcl.getUuid());
        tiers.add(tier);
    }
    OvsVpcRoutingPolicyConfigCommand cmd = new OvsVpcRoutingPolicyConfigCommand(vpc.getUuid(), vpc.getCidr(), acls.toArray(new OvsVpcRoutingPolicyConfigCommand.Acl[acls.size()]), tiers.toArray(new OvsVpcRoutingPolicyConfigCommand.Tier[tiers.size()]));
    return cmd;
}
Also used : ArrayList(java.util.ArrayList) NetworkACLItemVO(com.cloud.network.vpc.NetworkACLItemVO) OvsVpcRoutingPolicyConfigCommand(com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand) NetworkACLVO(com.cloud.network.vpc.NetworkACLVO) VpcVO(com.cloud.network.vpc.VpcVO) Network(com.cloud.network.Network)

Example 13 with NetworkACLItemVO

use of com.cloud.network.vpc.NetworkACLItemVO in project cloudstack by apache.

the class NetworkACLItemDaoImpl method findByAclAndNumber.

@Override
public NetworkACLItemVO findByAclAndNumber(long aclId, int number) {
    SearchCriteria<NetworkACLItemVO> sc = AllFieldsSearch.create();
    sc.setParameters("aclId", aclId);
    sc.setParameters("number", number);
    NetworkACLItemVO vo = findOneBy(sc);
    if (vo != null) {
        loadCidrs(vo);
    }
    return vo;
}
Also used : NetworkACLItemVO(com.cloud.network.vpc.NetworkACLItemVO)

Example 14 with NetworkACLItemVO

use of com.cloud.network.vpc.NetworkACLItemVO in project cloudstack by apache.

the class NetworkACLItemDaoImpl method listByACL.

@Override
public List<NetworkACLItemVO> listByACL(Long aclId) {
    if (aclId == null)
        return Lists.newArrayList();
    SearchCriteria<NetworkACLItemVO> sc = AllFieldsSearch.create();
    sc.setParameters("aclId", aclId);
    List<NetworkACLItemVO> list = listBy(sc);
    for (NetworkACLItemVO item : list) {
        loadCidrs(item);
    }
    return list;
}
Also used : NetworkACLItemVO(com.cloud.network.vpc.NetworkACLItemVO)

Aggregations

NetworkACLItemVO (com.cloud.network.vpc.NetworkACLItemVO)14 VpcVO (com.cloud.network.vpc.VpcVO)6 Network (com.cloud.network.Network)4 ArrayList (java.util.ArrayList)4 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 NetworkACLVO (com.cloud.network.vpc.NetworkACLVO)2 Vpc (com.cloud.network.vpc.Vpc)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 DomainRouterVO (com.cloud.vm.DomainRouterVO)2 IOException (java.io.IOException)2 NetworkPolicyModel (org.apache.cloudstack.network.contrail.model.NetworkPolicyModel)2 Test (org.junit.Test)2 Command (com.cloud.agent.api.Command)1 NetworkUsageCommand (com.cloud.agent.api.NetworkUsageCommand)1 OvsVpcRoutingPolicyConfigCommand (com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand)1 PlugNicCommand (com.cloud.agent.api.PlugNicCommand)1 SetupGuestNetworkCommand (com.cloud.agent.api.SetupGuestNetworkCommand)1