use of org.platformlayer.service.network.model.NetworkConnection in project platformlayer by platformlayer.
the class NetworkConnectionController method addChildren.
@Override
protected void addChildren() throws OpsException {
NetworkConnection model = ops.getInstance(NetworkConnection.class);
Protocol protocol = null;
if (model.protocol != null) {
protocol = EnumUtils.valueOfCaseInsensitive(Protocol.class, model.protocol);
}
Transport transport = null;
// if (model.transport != null) {
// protocol = EnumUtils.valueOfCaseInsensitive(Transport.class, model.transport);
// }
List<Integer> ports = Lists.newArrayList();
if (model.port != 0) {
ports.add(model.port);
if (model.protocol == null) {
protocol = Protocol.Tcp;
}
} else {
ItemBase destItem = platformLayer.getItem(model.destItem);
HasPorts hasPorts = providers.toInterface(destItem, HasPorts.class);
ports.addAll(hasPorts.getPorts());
if (model.protocol == null) {
// TODO: Support UDP?
protocol = Protocol.Tcp;
}
}
UUID uniqueId = platformLayer.getOrCreateUuid(model);
for (int port : ports) {
PlatformLayerFirewallEntry net = injected(PlatformLayerFirewallEntry.class);
net.destItem = model.destItem;
net.port = port;
net.sourceItemKey = model.sourceItem;
net.sourceCidr = model.sourceCidr;
net.protocol = protocol;
net.transport = transport;
net.uniqueId = port + "-" + uniqueId.toString();
addChild(net);
}
}
Aggregations