Search in sources :

Example 1 with Extension

use of com.woorea.openstack.nova.model.Extension in project AJSC by att.

the class OpenStackNetworkService method getMetadata.

/**
 * @see com.att.cdp.zones.NetworkService#getMetadata()
 */
@Override
public NetworkMetadata getMetadata() throws ZoneException {
    OpenStackNetworkMetadata metadata = new OpenStackNetworkMetadata();
    // get the extensions
    List<Extension> extensions = getNetworkExtensions();
    for (Extension extension : extensions) {
        String alias = extension.getAlias();
        String description = extension.getDescription();
        // should never happen but to be safe
        if (alias == null) {
            continue;
        }
        // check alias extension and fill out metadata appropriately
        switch(alias) {
            case LOAD_BALANCER_EXTENSION:
                metadata.setLoadBalancerSupported(true);
                metadata.setLoadBalancerDescription(description);
                break;
            case SECURITY_GROUP_EXTENSION:
                metadata.setSecurityGroupSupported(true);
                metadata.setSecurityGroupDescription(description);
                break;
            case ROUTER_EXTENSION:
                metadata.setRouterSupported(true);
                metadata.setRouterDescription(description);
                break;
            case FIREWALL_EXTENSION:
                metadata.setFirewallSupported(true);
                metadata.setFirewallDescription(description);
                break;
            case QUOTA_EXTENSION:
                metadata.setQuotaSupported(true);
                metadata.setQuotaDescription(description);
                break;
            case VPN_EXTENSION:
                metadata.setVpnSupported(true);
                metadata.setVpnDescription(description);
                break;
            default:
                break;
        }
    }
    return metadata;
}
Also used : Extension(com.woorea.openstack.nova.model.Extension) FloatingIpsExtension(com.woorea.openstack.nova.api.extensions.FloatingIpsExtension)

Example 2 with Extension

use of com.woorea.openstack.nova.model.Extension in project AJSC by att.

the class OpenStackComputeService method getExtensions.

/**
 * Returns the set of extensions loaded, if any
 *
 * @return The list of extensions installed, if any
 * @throws ZoneException
 *             If anything fails
 */
public List<String> getExtensions() throws ZoneException {
    connect();
    Context context = getContext();
    ArrayList<String> extensions = new ArrayList<>();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        for (Extension extension : nova.getClient().extensions().list(true).execute()) {
            extensions.add(extension.getName());
        }
    } catch (OpenStackBaseException e) {
        if (e instanceof OpenStackResponseException) {
            OpenStackResponseException osre = (OpenStackResponseException) e;
            if (osre.getStatus() != 404) {
                ExceptionMapper.mapException(e);
            }
        } else {
            ExceptionMapper.mapException(e);
        }
    }
    return extensions;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Extension(com.woorea.openstack.nova.model.Extension) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 3 with Extension

use of com.woorea.openstack.nova.model.Extension in project AJSC by att.

the class OpenStackComputeService method getExtensions.

/**
 * Returns the set of extensions loaded, if any
 *
 * @return The list of extensions installed, if any
 * @throws ZoneException
 *             If anything fails
 */
public List<String> getExtensions() throws ZoneException {
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<String> extensions = new ArrayList<>();
    try {
        for (Extension extension : nova.getClient().extensions().list(true).execute()) {
            extensions.add(extension.getName());
        }
    } catch (OpenStackBaseException ex) {
        if (ex instanceof OpenStackResponseException) {
            OpenStackResponseException osre = (OpenStackResponseException) ex;
            if (osre.getStatus() != 404) {
                ExceptionMapper.mapException(ex);
            }
        } else {
            ExceptionMapper.mapException(ex);
        }
    }
    return extensions;
}
Also used : Extension(com.woorea.openstack.nova.model.Extension) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 4 with Extension

use of com.woorea.openstack.nova.model.Extension 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)

Aggregations

Extension (com.woorea.openstack.nova.model.Extension)4 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)3 ArrayList (java.util.ArrayList)3 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)2 FloatingIpsExtension (com.woorea.openstack.nova.api.extensions.FloatingIpsExtension)2 OpenStackContext (com.att.cdp.openstack.OpenStackContext)1 Context (com.att.cdp.zones.Context)1 ExtensionsResource (com.woorea.openstack.nova.api.ExtensionsResource)1 Quantum (com.woorea.openstack.quantum.Quantum)1