use of org.openstack4j.openstack.networking.domain.NeutronPool in project camel by apache.
the class SubnetProducer method messageToSubnet.
private Subnet messageToSubnet(Message message) {
Subnet subnet = message.getBody(Subnet.class);
if (subnet == null) {
Map headers = message.getHeaders();
SubnetBuilder builder = Builders.subnet();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
ObjectHelper.notEmpty(message.getHeader(NeutronConstants.NETWORK_ID, String.class), "Network ID");
builder.networkId(message.getHeader(NeutronConstants.NETWORK_ID, String.class));
ObjectHelper.notNull(message.getHeader(NeutronConstants.IP_VERSION, IPVersionType.class), "IP version");
builder.ipVersion(message.getHeader(NeutronConstants.IP_VERSION, IPVersionType.class));
if (headers.containsKey(NeutronConstants.CIDR)) {
builder.cidr(message.getHeader(NeutronConstants.CIDR, String.class));
}
if (headers.containsKey(NeutronConstants.SUBNET_POOL)) {
final NeutronPool pool = message.getHeader(NeutronConstants.SUBNET_POOL, NeutronPool.class);
builder.addPool(pool.getStart(), pool.getEnd());
}
if (headers.containsKey(NeutronConstants.NETWORK_ID)) {
builder.networkId(message.getHeader(NeutronConstants.NETWORK_ID, String.class));
}
if (headers.containsKey(NeutronConstants.ENABLE_DHCP)) {
builder.enableDHCP(message.getHeader(NeutronConstants.ENABLE_DHCP, Boolean.class));
}
if (headers.containsKey(NeutronConstants.GATEWAY)) {
builder.gateway(message.getHeader(NeutronConstants.GATEWAY, String.class));
}
subnet = builder.build();
}
return subnet;
}
Aggregations