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;
}
};
}
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;
}
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;
}
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;
}
Aggregations