Search in sources :

Example 96 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackNetworkService method updateLoadBalancerHealthMonitor.

/**
 * @see com.att.cdp.zones.NetworkService#updateLoadBalancerHealthMonitor(com.att.cdp.zones.model.LoadBalancerHealthMonitor)
 */
@SuppressWarnings("nls")
@Override
public LoadBalancerHealthMonitor updateLoadBalancerHealthMonitor(LoadBalancerHealthMonitor loadBalancerHealthMonitor) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        com.woorea.openstack.quantum.model.LoadBalancerHealthMonitor loadBalancerHealthMonitorToCreate = new com.woorea.openstack.quantum.model.LoadBalancerHealthMonitor();
        if (loadBalancerHealthMonitor.getType() != null) {
            loadBalancerHealthMonitorToCreate.setType(loadBalancerHealthMonitor.getType().name());
        }
        loadBalancerHealthMonitorToCreate.setDelay(loadBalancerHealthMonitor.getDelay());
        loadBalancerHealthMonitorToCreate.setTimeout(loadBalancerHealthMonitor.getTimeout());
        loadBalancerHealthMonitorToCreate.setMaxRetries(loadBalancerHealthMonitor.getMaxRetries());
        loadBalancerHealthMonitorToCreate.setUrlPath(loadBalancerHealthMonitor.getUrlPath());
        loadBalancerHealthMonitorToCreate.setExpectedCodes(loadBalancerHealthMonitor.getExpectedCodes());
        com.woorea.openstack.quantum.model.LoadBalancerHealthMonitor openstackLbMonitor = client.lbaas().HealthMonitor().update(loadBalancerHealthMonitorToCreate).execute();
        return new OpenStackLoadBalancerHealthMonitor(context, openstackLbMonitor);
    } 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) OpenStackLoadBalancerHealthMonitor(com.att.cdp.openstack.model.OpenStackLoadBalancerHealthMonitor) LoadBalancerHealthMonitor(com.att.cdp.zones.model.LoadBalancerHealthMonitor) OpenStackLoadBalancerHealthMonitor(com.att.cdp.openstack.model.OpenStackLoadBalancerHealthMonitor)

Example 97 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackNetworkService method updateLoadBalancerPool.

/**
 * @see com.att.cdp.zones.NetworkService#updateLoadBalancerPool(com.att.cdp.zones.model.LoadBalancerPool)
 */
@Override
public LoadBalancerPool updateLoadBalancerPool(LoadBalancerPool loadBalancerPool) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.LOADBALANCERPOOL, loadBalancerPool.getName());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        com.woorea.openstack.quantum.model.LoadBalancerPool loadBalancerPoolToCreate = new com.woorea.openstack.quantum.model.LoadBalancerPool();
        loadBalancerPoolToCreate.setName(loadBalancerPool.getName());
        if (loadBalancerPool.getProtocol() != null) {
            loadBalancerPoolToCreate.setProtocol(loadBalancerPool.getProtocol().name());
        }
        loadBalancerPoolToCreate.setSubnetId(loadBalancerPool.getSubnetId());
        if (loadBalancerPool.getLbAlgorithm() != null) {
            loadBalancerPoolToCreate.setMethod(loadBalancerPool.getLbAlgorithm().name());
        }
        com.woorea.openstack.quantum.model.LoadBalancerPool openstackLbPool = client.lbaas().Pool().update(loadBalancerPoolToCreate).execute();
        return new OpenStackLoadBalancerPool(context, openstackLbPool);
    } 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) OpenStackLoadBalancerPool(com.att.cdp.openstack.model.OpenStackLoadBalancerPool) OpenStackLoadBalancerPool(com.att.cdp.openstack.model.OpenStackLoadBalancerPool) LoadBalancerPool(com.att.cdp.zones.model.LoadBalancerPool)

Example 98 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackNetworkService method deleteNetwork.

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

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackNetworkService method createPort.

/**
 * @see com.att.cdp.zones.NetworkService#createPort(com.att.cdp.zones.model.Subnet)
 */
@Override
public Port createPort(Subnet subnet) throws ZoneException {
    this.checkArg(subnet, "subnet");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.PORT, subnet.getName());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    com.woorea.openstack.quantum.model.Port port = new com.woorea.openstack.quantum.model.Port();
    try {
        Quantum client = quantumConnector.getClient();
        port.setNetworkId(subnet.getNetwork());
        // List<com.woorea.openstack.quantum.model.Port.Ip> ips = new ArrayList<>();
        // com.woorea.openstack.quantum.model.Port.Ip ip = new com.woorea.openstack.quantum.model.Port.Ip();
        // ip.setSubnetId(subnet.getId());
        // ips.add(ip);
        // port.setList(ips);
        port = client.ports().create(port).execute();
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return new OpenStackPort(context, port);
}
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) Port(com.att.cdp.zones.model.Port) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort)

Example 100 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackNetworkService method assignIpAddressFromPool.

/**
 * @see com.att.cdp.zones.NetworkService#assignIpAddressFromPool(com.att.cdp.zones.model.Server)
 */
@SuppressWarnings("nls")
@Override
public String assignIpAddressFromPool(Server server) throws ZoneException {
    checkArg(server, "server");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVER, server.getName());
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    String ip;
    try {
        ip = reserveFreeFloatingIPAddress(null);
        if (ip != null) {
            assignIpAddress(server, ip);
            return ip;
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_UNAVAILABLE, "Floating IP Address", context.getProvider().getName()));
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) NotSupportedException(com.att.cdp.exceptions.NotSupportedException)

Aggregations

OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)151 OpenStackContext (com.att.cdp.openstack.OpenStackContext)140 Context (com.att.cdp.zones.Context)140 ArrayList (java.util.ArrayList)54 Quantum (com.woorea.openstack.quantum.Quantum)36 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)18 ZoneException (com.att.cdp.exceptions.ZoneException)15 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)14 Server (com.att.cdp.zones.model.Server)11 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)11 HashMap (java.util.HashMap)11 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)10 Snapshot (com.att.cdp.zones.model.Snapshot)10 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)8 OpenStackImage (com.att.cdp.openstack.model.OpenStackImage)8 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)8 OpenStackVolume (com.att.cdp.openstack.model.OpenStackVolume)8 OpenStackNetwork (com.att.cdp.openstack.model.OpenStackNetwork)7 Network (com.att.cdp.zones.model.Network)7 Port (com.att.cdp.zones.model.Port)7