Search in sources :

Example 1 with OpenStackSubnet

use of com.att.cdp.openstack.model.OpenStackSubnet 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 OpenStackSubnet

use of com.att.cdp.openstack.model.OpenStackSubnet in project AJSC by att.

the class OpenStackNetworkService method createSubnet.

@Override
public Subnet createSubnet(Subnet subnet) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SUBNET, subnet.getName());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        com.woorea.openstack.quantum.model.Subnet subnetToCreate = new com.woorea.openstack.quantum.model.Subnet();
        subnetToCreate.setName(subnet.getName());
        subnetToCreate.setNetworkId(subnet.getNetwork());
        subnetToCreate.setCidr(subnet.getRouting());
        subnetToCreate.setGw(subnet.getGatewayIp());
        subnetToCreate.setEnableDHCP(subnet.isDhcp());
        subnetToCreate.setDnsNames(subnet.getDns());
        if (subnet.isIpv4()) {
            subnetToCreate.setIpversion(IpVersion.IPV4);
        } else {
            subnetToCreate.setIpversion(IpVersion.IPV6);
        }
        if (!subnet.getHostRoutes().isEmpty()) {
            List<com.woorea.openstack.quantum.model.Route> routesToCreate = new ArrayList<>();
            List<Route> routes = subnet.getHostRoutes();
            for (Route route : routes) {
                com.woorea.openstack.quantum.model.Route newRoute = new com.woorea.openstack.quantum.model.Route();
                newRoute.setDestination(route.getDestination());
                newRoute.setNexthop(route.getNexthop());
                routesToCreate.add(newRoute);
            }
            subnetToCreate.setHostRoutes(routesToCreate);
        }
        com.woorea.openstack.quantum.model.Subnet openstackSubnet = client.subnets().create(subnetToCreate).execute();
        return new OpenStackSubnet(context, openstackSubnet);
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) Subnet(com.att.cdp.zones.model.Subnet) Route(com.att.cdp.zones.model.Route)

Example 3 with OpenStackSubnet

use of com.att.cdp.openstack.model.OpenStackSubnet 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 4 with OpenStackSubnet

use of com.att.cdp.openstack.model.OpenStackSubnet 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)4 OpenStackSubnet (com.att.cdp.openstack.model.OpenStackSubnet)4 Context (com.att.cdp.zones.Context)4 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)4 Quantum (com.woorea.openstack.quantum.Quantum)4 Subnet (com.att.cdp.zones.model.Subnet)3 SubnetsResource (com.woorea.openstack.quantum.api.SubnetsResource)3 ArrayList (java.util.ArrayList)3 Route (com.att.cdp.zones.model.Route)1