Search in sources :

Example 51 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method deleteSubnet.

/**
 * Delete the specified network using it's id.
 *
 * @param subnet
 *            The subnet to be deleted.
 * @throws ZoneException
 *             If the network does not exist or cannot be deleted for some reason.
 */
@SuppressWarnings("nls")
@Override
public void deleteSubnet(Subnet subnet) throws ZoneException {
    checkArg(subnet, "subnet");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SUBNET, subnet.getId());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        client.subnets().delete(subnet.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 52 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method getLoadBalancerHealthMonitors.

/**
 * @see com.att.cdp.zones.NetworkService#getLoadBalancerHealthMonitors()
 */
@Override
public List<LoadBalancerHealthMonitor> getLoadBalancerHealthMonitors() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    ArrayList<LoadBalancerHealthMonitor> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        LoadBalancerResource.HealthMonitor resource = client.lbaas().HealthMonitor();
        for (com.woorea.openstack.quantum.model.LoadBalancerHealthMonitor loadBalancerHealthMonitor : resource.list().execute()) {
            list.add(new OpenStackLoadBalancerHealthMonitor(context, loadBalancerHealthMonitor));
        }
    } 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) OpenStackLoadBalancerHealthMonitor(com.att.cdp.openstack.model.OpenStackLoadBalancerHealthMonitor) LoadBalancerHealthMonitor(com.att.cdp.zones.model.LoadBalancerHealthMonitor) LoadBalancerResource(com.woorea.openstack.quantum.api.LoadBalancerResource) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackLoadBalancerHealthMonitor(com.att.cdp.openstack.model.OpenStackLoadBalancerHealthMonitor)

Example 53 with Context

use of com.att.cdp.zones.Context 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 54 with Context

use of com.att.cdp.zones.Context in project AJSC by att.

the class OpenStackNetworkService method getLoadBalancerHealthMonitorById.

/**
 * @see com.att.cdp.zones.NetworkService#getLoadBalancerHealthMonitorById(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public LoadBalancerHealthMonitor getLoadBalancerHealthMonitorById(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.LOADBALANCERHEALTHMONITOR, id);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        com.woorea.openstack.quantum.model.LoadBalancerHealthMonitor n = quantumConnector.getClient().lbaas().HealthMonitor().show(id).execute();
        return new OpenStackLoadBalancerHealthMonitor(context, n);
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackLoadBalancerHealthMonitor(com.att.cdp.openstack.model.OpenStackLoadBalancerHealthMonitor)

Example 55 with Context

use of com.att.cdp.zones.Context 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)

Aggregations

Context (com.att.cdp.zones.Context)248 OpenStackContext (com.att.cdp.openstack.OpenStackContext)167 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)140 ArrayList (java.util.ArrayList)55 Ignore (org.junit.Ignore)50 Test (org.junit.Test)47 Quantum (com.woorea.openstack.quantum.Quantum)35 ZoneException (com.att.cdp.exceptions.ZoneException)30 NetworkService (com.att.cdp.zones.NetworkService)24 Server (com.att.cdp.zones.model.Server)22 ComputeService (com.att.cdp.zones.ComputeService)21 Network (com.att.cdp.zones.model.Network)19 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)18 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)18 Subnet (com.att.cdp.zones.model.Subnet)15 Port (com.att.cdp.zones.model.Port)14 Snapshot (com.att.cdp.zones.model.Snapshot)12 Volume (com.att.cdp.zones.model.Volume)11 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)11 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)10