Search in sources :

Example 11 with Network

use of com.woorea.openstack.quantum.model.Network in project so by onap.

the class MsoNeutronUtils method findNetworkById.

/*
     * Find a network (or query its existence) by its Id.
     *
     * @param neutronClient an authenticated Quantum object
     * 
     * @param networkId the network ID to query
     * 
     * @return a Network object or null if not found
     */
private Network findNetworkById(Quantum neutronClient, String networkId) {
    if (networkId == null) {
        return null;
    }
    try {
        OpenStackRequest<Network> request = neutronClient.networks().show(networkId);
        Network network = executeAndRecordOpenstackRequest(request);
        return network;
    } catch (OpenStackResponseException e) {
        if (e.getStatus() == 404) {
            return null;
        } else {
            logger.error("{} {} Openstack Error, GET Network By ID ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), networkId, e);
            throw e;
        }
    }
}
Also used : OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) Network(com.woorea.openstack.quantum.model.Network)

Aggregations

Network (com.woorea.openstack.quantum.model.Network)11 Test (org.junit.Test)5 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)4 Quantum (com.woorea.openstack.quantum.Quantum)4 CloudSite (org.onap.so.db.catalog.beans.CloudSite)4 NetworkInfo (org.onap.so.openstack.beans.NetworkInfo)4 MsoCloudSiteNotFound (org.onap.so.openstack.exceptions.MsoCloudSiteNotFound)4 MsoException (org.onap.so.openstack.exceptions.MsoException)4 NetworkInfoMapper (org.onap.so.openstack.mappers.NetworkInfoMapper)3 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)2 Segment (com.woorea.openstack.quantum.model.Segment)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Networks (com.woorea.openstack.quantum.model.Networks)1 MsoNetworkAlreadyExists (org.onap.so.openstack.exceptions.MsoNetworkAlreadyExists)1 MsoNetworkNotFound (org.onap.so.openstack.exceptions.MsoNetworkNotFound)1