Search in sources :

Example 1 with SubnetsResource

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

the class OpenStackNetworkService method getSubnetById.

/**
 * @see com.att.cdp.zones.NetworkService#getSubnetById(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Subnet getSubnetById(String id) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SUBNET, id);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        SubnetsResource resource = client.subnets();
        for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
            if (net.getId().equals(id)) {
                return new OpenStackSubnet(context, net);
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SubnetsResource(com.woorea.openstack.quantum.api.SubnetsResource) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet)

Example 2 with SubnetsResource

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

the class OpenStackNetworkService method getSubnetsByName.

/**
 * @see com.att.cdp.zones.NetworkService#getSubnetsByName(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public List<Subnet> getSubnetsByName(String name) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SUBNET, name);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    List<Subnet> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        SubnetsResource resource = client.subnets();
        for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
            if (net.getName().equals(name)) {
                list.add(new OpenStackSubnet(context, net));
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SubnetsResource(com.woorea.openstack.quantum.api.SubnetsResource) ArrayList(java.util.ArrayList) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) Subnet(com.att.cdp.zones.model.Subnet)

Example 3 with SubnetsResource

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

the class OpenStackNetworkService method getSubnets.

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

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)3 OpenStackSubnet (com.att.cdp.openstack.model.OpenStackSubnet)3 Context (com.att.cdp.zones.Context)3 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)3 Quantum (com.woorea.openstack.quantum.Quantum)3 SubnetsResource (com.woorea.openstack.quantum.api.SubnetsResource)3 Subnet (com.att.cdp.zones.model.Subnet)2 ArrayList (java.util.ArrayList)2