Search in sources :

Example 1 with PortsResource

use of com.woorea.openstack.quantum.api.PortsResource in project AJSC by att.

the class OpenStackNetworkService method getPort.

/**
 * @see com.att.cdp.zones.NetworkService#getPort(java.lang.String)
 */
@Override
public Port getPort(String id) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    RequestState.put(RequestState.PORT, id);
    com.woorea.openstack.quantum.model.Port p = null;
    try {
        Quantum client = quantumConnector.getClient();
        PortsResource resource = client.ports();
        p = resource.show(id).execute();
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return new OpenStackPort(context, p);
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) PortsResource(com.woorea.openstack.quantum.api.PortsResource)

Example 2 with PortsResource

use of com.woorea.openstack.quantum.api.PortsResource in project AJSC by att.

the class OpenStackNetworkService method getPorts.

/**
 * @see com.att.cdp.zones.NetworkService#getPorts()
 */
@SuppressWarnings("nls")
@Override
public List<com.att.cdp.zones.model.Port> getPorts() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    List<com.att.cdp.zones.model.Port> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        PortsResource resource = client.ports();
        for (com.woorea.openstack.quantum.model.Port p : resource.list().execute()) {
            list.add(new OpenStackPort(context, p));
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Port(com.att.cdp.zones.model.Port) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) ArrayList(java.util.ArrayList) Quantum(com.woorea.openstack.quantum.Quantum) PortsResource(com.woorea.openstack.quantum.api.PortsResource)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)2 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)2 Context (com.att.cdp.zones.Context)2 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)2 Quantum (com.woorea.openstack.quantum.Quantum)2 PortsResource (com.woorea.openstack.quantum.api.PortsResource)2 Port (com.att.cdp.zones.model.Port)1 ArrayList (java.util.ArrayList)1