Search in sources :

Example 86 with OpenStackBaseException

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

the class OpenStackComputeService method getExtendedNetworks.

/**
 * This method returns a list of OS extended network attributes for the supplied tenant.
 * <p>
 * This lists networks that are available to the tenant. The information in the network list includes extended
 * network attributes.
 * </p>
 *
 * @return A list of networks and their extended attributes
 * @throws ZoneException
 *             If the networks and extended attributes cannot be listed
 * @see com.att.cdp.zones.ComputeService#getExtendedNetworks()
 */
@Override
public List<Network> getExtendedNetworks() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    List<Network> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Networks extendedNetworks = nova.getClient().networks().listExtended().execute();
        for (com.woorea.openstack.nova.model.Network en : extendedNetworks.getList()) {
            Network network = new OpenStackNetwork(context, en);
            list.add(network);
        }
    } 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) Network(com.att.cdp.zones.model.Network) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) ArrayList(java.util.ArrayList) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork)

Example 87 with OpenStackBaseException

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

the class OpenStackComputeService method migrateServer.

/**
 * @see com.att.cdp.zones.ComputeService#migrateServer(java.lang.String)
 */
@Override
public void migrateServer(String serverId) throws ZoneException {
    checkArg(serverId, "serverId");
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVER, serverId);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        OpenStackResponse response = nova.getClient().servers().migrate(serverId).request();
        if (response == null || response.getStatus() != Status.ACCEPTED.getStatusCode()) {
            throw new ZoneException(response.getEntity(String.class));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : OpenStackResponse(com.woorea.openstack.base.client.OpenStackResponse) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Example 88 with OpenStackBaseException

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

the class OpenStackNetworkService method deleteLoadBalancerHealthMonitor.

/**
 * @see com.att.cdp.zones.NetworkService#deleteLoadBalancerHealthMonitor(com.att.cdp.zones.model.LoadBalancerHealthMonitor)
 */
@SuppressWarnings("nls")
@Override
public void deleteLoadBalancerHealthMonitor(LoadBalancerHealthMonitor loadBalancerHealthMonitor) throws ZoneException {
    checkArg(loadBalancerHealthMonitor, "loadBalancerHealthMonitor");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.LOADBALANCERHEALTHMONITOR, loadBalancerHealthMonitor.getId());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        client.lbaas().HealthMonitor().delete(loadBalancerHealthMonitor.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 89 with OpenStackBaseException

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

the class OpenStackNetworkService method getNetworkExtensions.

/**
 * @return List of extensions
 * @throws ZoneException
 *             If the context cannot be used to obtain the list of extensions
 * @see com.att.cdp.zones.NetworkService#getNetworks()
 */
@SuppressWarnings("nls")
public List<Extension> getNetworkExtensions() throws ZoneException {
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    ArrayList<Extension> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        ExtensionsResource res = new ExtensionsResource(client);
        for (com.woorea.openstack.nova.model.Extension ext : res.list(false).execute()) {
            list.add(ext);
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Extension(com.woorea.openstack.nova.model.Extension) FloatingIpsExtension(com.woorea.openstack.nova.api.extensions.FloatingIpsExtension) Quantum(com.woorea.openstack.quantum.Quantum) Extension(com.woorea.openstack.nova.model.Extension) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) ExtensionsResource(com.woorea.openstack.nova.api.ExtensionsResource)

Example 90 with OpenStackBaseException

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

the class OpenStackNetworkService method createLoadBalancerMember.

/**
 * @see com.att.cdp.zones.NetworkService#createLoadBalancerMember(com.att.cdp.zones.model.LoadBalancerMember)
 */
@Override
public LoadBalancerMember createLoadBalancerMember(LoadBalancerMember loadBalancerMember) 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.LoadBalancerMember loadBalancerMemberToCreate = new com.woorea.openstack.quantum.model.LoadBalancerMember();
        loadBalancerMemberToCreate.setAddress(loadBalancerMember.getAddress());
        loadBalancerMemberToCreate.setPort(loadBalancerMember.getProtocolPort());
        loadBalancerMemberToCreate.setPoolId(loadBalancerMember.getPoolId());
        loadBalancerMemberToCreate.setWeight(loadBalancerMember.getWeight());
        com.woorea.openstack.quantum.model.LoadBalancerMember openstackLbMember = client.lbaas().Member().create(loadBalancerMemberToCreate).execute();
        return new OpenStackLoadBalancerMember(context, openstackLbMember);
    } 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) OpenStackLoadBalancerMember(com.att.cdp.openstack.model.OpenStackLoadBalancerMember) LoadBalancerMember(com.att.cdp.zones.model.LoadBalancerMember) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackLoadBalancerMember(com.att.cdp.openstack.model.OpenStackLoadBalancerMember)

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