Search in sources :

Example 11 with Quantum

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

the class OpenStackNetworkService method getRouters.

/**
 * @return List<Router>
 * @throws ZoneException
 *             If the context cannot be used to get the list or routers
 * @see com.att.cdp.zones.NetworkService#getRouters()
 */
@SuppressWarnings("nls")
@Override
public List<Router> getRouters() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    ArrayList<Router> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        RoutersResource resource = client.routers();
        for (com.woorea.openstack.quantum.model.Router openstackRouter : resource.list().execute().getList()) {
            Router r = new OpenStackRouter(context, openstackRouter);
            list.add(r);
        }
    } 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) ArrayList(java.util.ArrayList) OpenStackRouter(com.att.cdp.openstack.model.OpenStackRouter) Router(com.att.cdp.zones.model.Router) OpenStackRouter(com.att.cdp.openstack.model.OpenStackRouter) RoutersResource(com.woorea.openstack.quantum.api.RoutersResource)

Example 12 with Quantum

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

the class OpenStackNetworkService method getLoadBalancerPoolByName.

/**
 * @see com.att.cdp.zones.NetworkService#getLoadBalancerPoolByName(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public List<LoadBalancerPool> getLoadBalancerPoolByName(String name) throws ZoneException {
    checkArg(name, "name");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.LOADBALANCERPOOL, name);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    List<LoadBalancerPool> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        LoadBalancerResource.Pool resource = client.lbaas().Pool();
        for (com.woorea.openstack.quantum.model.LoadBalancerPool loadBalancerPool : resource.list().execute()) {
            if (loadBalancerPool.getName().equals(name)) {
                list.add(new OpenStackLoadBalancerPool(context, loadBalancerPool));
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
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) LoadBalancerResource(com.woorea.openstack.quantum.api.LoadBalancerResource) OpenStackLoadBalancerPool(com.att.cdp.openstack.model.OpenStackLoadBalancerPool) OpenStackLoadBalancerPool(com.att.cdp.openstack.model.OpenStackLoadBalancerPool) LoadBalancerPool(com.att.cdp.zones.model.LoadBalancerPool) Quantum(com.woorea.openstack.quantum.Quantum)

Example 13 with Quantum

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

the class OpenStackNetworkService method deleteLoadBalancerMember.

/**
 * @see com.att.cdp.zones.NetworkService#deleteLoadBalancerMember(com.att.cdp.zones.model.LoadBalancerMember)
 */
@SuppressWarnings("nls")
@Override
public void deleteLoadBalancerMember(LoadBalancerMember loadBalancerMember) throws ZoneException {
    checkArg(loadBalancerMember, "loadBalancerMember");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.LOADBALANCERMEMBER, loadBalancerMember.getId());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        client.lbaas().Member().delete(loadBalancerMember.getId()).execute();
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
}
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)

Example 14 with Quantum

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

the class OpenStackNetworkService method updateLoadBalancerListener.

/**
 * @see com.att.cdp.zones.NetworkService#updateLoadBalancerListener(com.att.cdp.zones.model.LoadBalancerListener)
 */
@Override
public LoadBalancerListener updateLoadBalancerListener(LoadBalancerListener loadBalancerVIP) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.LOADBALANCERLISTENER, loadBalancerVIP.getName());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        com.woorea.openstack.quantum.model.LoadBalancerVIP loadBalancerVIPToCreate = new com.woorea.openstack.quantum.model.LoadBalancerVIP();
        loadBalancerVIPToCreate.setName(loadBalancerVIP.getName());
        // TODO Description
        loadBalancerVIPToCreate.setSubnetId(loadBalancerVIP.getSubnetId());
        loadBalancerVIPToCreate.setAddress(loadBalancerVIP.getIpAddress());
        if (loadBalancerVIP.getProtocol() != null) {
            loadBalancerVIPToCreate.setProtocol(loadBalancerVIP.getProtocol().name());
        }
        loadBalancerVIPToCreate.setPort(loadBalancerVIP.getProtocolPort());
        loadBalancerVIPToCreate.setPoolId(loadBalancerVIP.getPoolId());
        // TODO session persistence
        loadBalancerVIPToCreate.setConnectionLimit(loadBalancerVIP.getConnectionLimit());
        loadBalancerVIPToCreate.setState(loadBalancerVIP.isAdminStateUp());
        com.woorea.openstack.quantum.model.LoadBalancerVIP openstackLbVip = client.lbaas().VIP().update(loadBalancerVIPToCreate).execute();
        return new OpenStackLoadBalancerVIP(context, openstackLbVip);
    } 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) OpenStackLoadBalancerVIP(com.att.cdp.openstack.model.OpenStackLoadBalancerVIP) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackLoadBalancerVIP(com.att.cdp.openstack.model.OpenStackLoadBalancerVIP)

Example 15 with Quantum

use of com.woorea.openstack.quantum.Quantum 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)

Aggregations

Quantum (com.woorea.openstack.quantum.Quantum)37 OpenStackContext (com.att.cdp.openstack.OpenStackContext)36 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)36 Context (com.att.cdp.zones.Context)35 ArrayList (java.util.ArrayList)15 LoadBalancerResource (com.woorea.openstack.quantum.api.LoadBalancerResource)7 OpenStackLoadBalancerPool (com.att.cdp.openstack.model.OpenStackLoadBalancerPool)5 LoadBalancerPool (com.att.cdp.zones.model.LoadBalancerPool)5 OpenStackLoadBalancerVIP (com.att.cdp.openstack.model.OpenStackLoadBalancerVIP)4 OpenStackNetwork (com.att.cdp.openstack.model.OpenStackNetwork)4 OpenStackSubnet (com.att.cdp.openstack.model.OpenStackSubnet)4 Network (com.att.cdp.zones.model.Network)4 AbstractNetwork (com.att.cdp.zones.spi.AbstractNetwork)4 OpenStackLoadBalancerHealthMonitor (com.att.cdp.openstack.model.OpenStackLoadBalancerHealthMonitor)3 OpenStackLoadBalancerMember (com.att.cdp.openstack.model.OpenStackLoadBalancerMember)3 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)3 LoadBalancerHealthMonitor (com.att.cdp.zones.model.LoadBalancerHealthMonitor)3 LoadBalancerMember (com.att.cdp.zones.model.LoadBalancerMember)3 Subnet (com.att.cdp.zones.model.Subnet)3 SubnetsResource (com.woorea.openstack.quantum.api.SubnetsResource)3