Search in sources :

Example 6 with NetworkACLTO

use of com.cloud.agent.api.to.NetworkACLTO in project cloudstack by apache.

the class VirtualRoutingResourceTest method generateSetNetworkACLCommand.

protected SetNetworkACLCommand generateSetNetworkACLCommand() {
    final List<NetworkACLTO> acls = new ArrayList<>();
    final List<String> cidrs = new ArrayList<>();
    cidrs.add("192.168.0.1/24");
    cidrs.add("192.168.0.2/24");
    acls.add(new NetworkACLTO(1, "64", "TCP", 20, 80, false, false, cidrs, 0, 0, TrafficType.Ingress, true, 1));
    acls.add(new NetworkACLTO(2, "64", "ICMP", 0, 0, false, false, cidrs, -1, -1, TrafficType.Ingress, false, 2));
    acls.add(new NetworkACLTO(3, "65", "ALL", 0, 0, false, false, cidrs, -1, -1, TrafficType.Egress, true, 3));
    final NicTO nic = new NicTO();
    nic.setMac("01:23:45:67:89:AB");
    nic.setIp("192.168.1.1");
    nic.setNetmask("255.255.255.0");
    final SetNetworkACLCommand cmd = new SetNetworkACLCommand(acls, nic);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    return cmd;
}
Also used : NetworkACLTO(com.cloud.agent.api.to.NetworkACLTO) ArrayList(java.util.ArrayList) SetNetworkACLCommand(com.cloud.agent.api.routing.SetNetworkACLCommand) NicTO(com.cloud.agent.api.to.NicTO)

Example 7 with NetworkACLTO

use of com.cloud.agent.api.to.NetworkACLTO in project cloudstack by apache.

the class CommandSetupHelper method createNetworkACLsCommands.

public void createNetworkACLsCommands(final List<? extends NetworkACLItem> rules, final VirtualRouter router, final Commands cmds, final long guestNetworkId, final boolean privateGateway) {
    final List<NetworkACLTO> rulesTO = new ArrayList<NetworkACLTO>();
    String guestVlan = null;
    final Network guestNtwk = _networkDao.findById(guestNetworkId);
    final URI uri = guestNtwk.getBroadcastUri();
    if (uri != null) {
        guestVlan = BroadcastDomainType.getValue(uri);
    }
    if (rules != null) {
        for (final NetworkACLItem rule : rules) {
            final NetworkACLTO ruleTO = new NetworkACLTO(rule, guestVlan, rule.getTrafficType());
            rulesTO.add(ruleTO);
        }
    }
    NicTO nicTO = _networkHelper.getNicTO(router, guestNetworkId, null);
    final SetNetworkACLCommand cmd = new SetNetworkACLCommand(rulesTO, nicTO);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId()));
    cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, guestVlan);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
    final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
    cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
    if (privateGateway) {
        cmd.setAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY, String.valueOf(VpcGateway.Type.Private));
    }
    cmds.addCommand(cmd);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkACLItem(com.cloud.network.vpc.NetworkACLItem) NetworkACLTO(com.cloud.agent.api.to.NetworkACLTO) Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) SetNetworkACLCommand(com.cloud.agent.api.routing.SetNetworkACLCommand) URI(java.net.URI) NicTO(com.cloud.agent.api.to.NicTO)

Aggregations

NetworkACLTO (com.cloud.agent.api.to.NetworkACLTO)7 SetNetworkACLCommand (com.cloud.agent.api.routing.SetNetworkACLCommand)3 NicTO (com.cloud.agent.api.to.NicTO)3 ArrayList (java.util.ArrayList)3 Network (com.cloud.network.Network)2 NetworkACLItem (com.cloud.network.vpc.NetworkACLItem)2 URI (java.net.URI)2 Test (org.junit.Test)2 Zone (com.cloud.db.model.Zone)1 DataCenterVO (com.cloud.dc.DataCenterVO)1