Search in sources :

Example 56 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException 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 57 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(java.lang.String, java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public String assignIpAddressFromPool(String serverId, String pool) throws ZoneException {
    checkArg(serverId, "serverId");
    checkArg(pool, "pool");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVER, serverId);
    RequestState.put(RequestState.POOL, pool);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    Nova client = novaConnector.getClient();
    FloatingIpsExtension extension = client.floatingIps();
    if (extension == null) {
        throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_UNSUPPORTED_OPERATION, "getAvailableAddresses", context.getProvider().getName()));
    }
    try {
        String ip = reserveFreeFloatingIPAddress(pool);
        if (ip != null) {
            assignIpAddress(serverId, 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) FloatingIpsExtension(com.woorea.openstack.nova.api.extensions.FloatingIpsExtension) Nova(com.woorea.openstack.nova.Nova) NotSupportedException(com.att.cdp.exceptions.NotSupportedException)

Example 58 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException 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 59 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException 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 60 with OpenStackBaseException

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

the class OpenStackSnapshotService method destroySnapshot.

/**
 * This method can be called to destroy a snapshot.
 *
 * @param id
 *            The id of the snapshot to be destroyed.
 * @throws ZoneException
 *             - If the snapshot cannot be destroyed.
 * @see com.att.cdp.zones.SnapshotService#destroySnapshot(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public void destroySnapshot(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SNAPSHOT, id);
    RequestState.put(RequestState.SERVICE, "Volume");
    RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
    try {
        cinder.getClient().snapshots().delete(id).execute();
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

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