Search in sources :

Example 16 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class TestNovaConnector method testGlanceConnector.

@Test
@Ignore
public void testGlanceConnector() throws ZoneException {
    OpenStackContext context = login();
    NovaConnector connector = context.getNovaConnector();
    assertNotNull(connector);
    Access access = connector.getAccess();
    assertNotNull(access);
    Nova client = connector.getClient();
    assertNotNull(client);
    logout(context);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Access(com.woorea.openstack.keystone.model.Access) Nova(com.woorea.openstack.nova.Nova) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class TestQuantumConnector method testGlanceConnector.

@Test
@Ignore
public void testGlanceConnector() throws ZoneException {
    OpenStackContext context = login();
    QuantumConnector connector = context.getQuantumConnector();
    assertNotNull(connector);
    Access access = connector.getAccess();
    assertNotNull(access);
    Quantum client = connector.getClient();
    assertNotNull(client);
    logout(context);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) Access(com.woorea.openstack.keystone.model.Access) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class TestOpenStackACL method testCtorACL.

@Test
@Ignore
public void testCtorACL() throws ZoneException {
    OpenStackContext context = login();
    SecurityGroup group = new SecurityGroup();
    logout(context);
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) SecurityGroup(com.woorea.openstack.nova.model.SecurityGroup) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class OpenStackNetworkService method connect.

/**
 * This is a helper method used to construct the Nova service object and setup the environment to access the
 * OpenStack compute service (Nova).
 *
 * @throws NotLoggedInException
 *             If the user is not logged in
 * @throws ContextClosedException
 *             If the user attempts an operation after the context is closed
 */
private void connect() throws NotLoggedInException, ContextClosedException {
    checkLogin();
    checkOpen();
    Context context = getContext();
    OpenStackContext osContext = (OpenStackContext) context;
    quantumConnector = osContext.getQuantumConnector();
    novaConnector = osContext.getNovaConnector();
    ((OpenStackContext) context).refreshIfStale(quantumConnector);
    ((OpenStackContext) context).refreshIfStale(novaConnector);
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackContext(com.att.cdp.openstack.OpenStackContext)

Example 20 with OpenStackContext

use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.

the class OpenStackNetworkService method reserveFreeFloatingIPAddress.

/**
 * This method is used o determine which IP addresses in the floating ip address pool specified are free, and to
 * reserve the first one
 *
 * @param pool
 *            The name of the pool to be searched, or null if we are searching all pools available to the tenant
 * @return The reserved IP address (or null if there are none available in the pool)
 * @throws OpenStackResponseException
 * @throws OpenStackConnectException
 */
@SuppressWarnings("nls")
private String reserveFreeFloatingIPAddress(String pool) throws OpenStackConnectException, OpenStackResponseException {
    Nova client = novaConnector.getClient();
    HashSet<String> available = new HashSet<>();
    Context context = getContext();
    FloatingIps ips = client.floatingIps().list().execute();
    for (FloatingIp ip : ips.getList()) {
        if (pool == null || pool.equalsIgnoreCase(ip.getPool())) {
            available.add(ip.getIp());
        }
    }
    Servers servers = client.servers().list(true).execute();
    for (com.woorea.openstack.nova.model.Server server : servers.getList()) {
        Addresses allocatedAddresses = server.getAddresses();
        Map<String, List<Address>> addressMap = allocatedAddresses.getAddresses();
        for (Map.Entry<String, List<Address>> entry : addressMap.entrySet()) {
            List<Address> addressList = entry.getValue();
            for (Address address : addressList) {
                if (address.getType().equalsIgnoreCase("floating")) {
                    available.remove(address.getAddr());
                }
            }
        }
    }
    if (!available.isEmpty()) {
        Iterator<String> it = available.iterator();
        while (it.hasNext()) {
            String ip = it.next();
            if (((OpenStackContext) context).allocateFloatingIP(ip)) {
                return ip;
            }
        }
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Address(com.woorea.openstack.nova.model.Server.Addresses.Address) FloatingIps(com.woorea.openstack.nova.model.FloatingIps) Nova(com.woorea.openstack.nova.Nova) Servers(com.woorea.openstack.nova.model.Servers) FloatingIp(com.woorea.openstack.nova.model.FloatingIp) Addresses(com.woorea.openstack.nova.model.Server.Addresses) OpenStackContext(com.att.cdp.openstack.OpenStackContext) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)28 Context (com.att.cdp.zones.Context)17 ContextConnectionException (com.att.cdp.exceptions.ContextConnectionException)7 ZoneException (com.att.cdp.exceptions.ZoneException)7 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)7 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)7 Ignore (org.junit.Ignore)7 Test (org.junit.Test)7 Access (com.woorea.openstack.keystone.model.Access)5 NovaConnector (com.att.cdp.openstack.connectors.NovaConnector)4 OpenStackKeyPair (com.att.cdp.openstack.model.OpenStackKeyPair)3 OpenStackTenant (com.att.cdp.openstack.model.OpenStackTenant)3 Keystone (com.woorea.openstack.keystone.Keystone)3 Tenants (com.woorea.openstack.keystone.model.Tenants)3 ComputeService (com.att.cdp.zones.ComputeService)2 Nova (com.woorea.openstack.nova.Nova)2 KeyPairs (com.woorea.openstack.nova.model.KeyPairs)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2