Search in sources :

Example 1 with NetworkBuilder

use of org.openstack4j.model.network.builder.NetworkBuilder in project camel by apache.

the class NetworkProducer method messageToNetwork.

private Network messageToNetwork(Message message) {
    Network network = message.getBody(Network.class);
    if (network == null) {
        Map headers = message.getHeaders();
        NetworkBuilder builder = Builders.network();
        ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
        builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
        if (headers.containsKey(NeutronConstants.ADMIN_STATE_UP)) {
            builder.adminStateUp(message.getHeader(NeutronConstants.ADMIN_STATE_UP, Boolean.class));
        }
        if (headers.containsKey(NeutronConstants.NETWORK_TYPE)) {
            builder.networkType(message.getHeader(NeutronConstants.NETWORK_TYPE, NetworkType.class));
        }
        if (headers.containsKey(NeutronConstants.IS_SHARED)) {
            builder.isShared(message.getHeader(NeutronConstants.IS_SHARED, Boolean.class));
        }
        if (headers.containsKey(NeutronConstants.IS_ROUTER_EXTERNAL)) {
            builder.isRouterExternal(message.getHeader(NeutronConstants.IS_ROUTER_EXTERNAL, Boolean.class));
        }
        if (headers.containsKey(NeutronConstants.TENANT_ID)) {
            builder.tenantId(message.getHeader(NeutronConstants.TENANT_ID, String.class));
        }
        if (headers.containsKey(NeutronConstants.PHYSICAL_NETWORK)) {
            builder.physicalNetwork(message.getHeader(NeutronConstants.PHYSICAL_NETWORK, String.class));
        }
        if (headers.containsKey(NeutronConstants.SEGMENT_ID)) {
            builder.segmentId(message.getHeader(NeutronConstants.SEGMENT_ID, String.class));
        }
        network = builder.build();
    }
    return network;
}
Also used : NetworkBuilder(org.openstack4j.model.network.builder.NetworkBuilder) NetworkType(org.openstack4j.model.network.NetworkType) Network(org.openstack4j.model.network.Network) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 Network (org.openstack4j.model.network.Network)1 NetworkType (org.openstack4j.model.network.NetworkType)1 NetworkBuilder (org.openstack4j.model.network.builder.NetworkBuilder)1