use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.
the class OpenStackNetworkService method releaseIpAddress.
/**
* @see com.att.cdp.zones.NetworkService#releaseIpAddress(java.lang.String, java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public void releaseIpAddress(String serverId, String assignedAddress) throws ZoneException {
checkArg(serverId, "serverId");
checkArg(assignedAddress, "assignedAddress");
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVER, serverId);
RequestState.put(RequestState.IPADDRESS, assignedAddress);
RequestState.put(RequestState.SERVICE, "Compute");
RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
ComputeService compute = context.getComputeService();
compute.releaseIpAddress(serverId, assignedAddress);
((OpenStackContext) context).deallocateFloatingIP(assignedAddress);
}
use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.
the class OpenStackComputeService 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();
OpenStackContext osContext = (OpenStackContext) getContext();
nova = osContext.getNovaConnector();
osContext.refreshIfStale(nova);
}
use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.
the class TestComputeService method testOpenstackMigrate.
@Ignore
@Test
public void testOpenstackMigrate() throws ZoneException {
// For testing the migrate functionality
Properties properties = new Properties();
String vmId = "75dce20c-97f9-454d-abcc-aa904a33df5a";
properties.put(ContextFactory.PROPERTY_IDENTITY_URL, "http://135.25.246.131:5000");
properties.put(ContextFactory.PROPERTY_TENANT, "Play");
// String vmId = "af51c8b9-3df4-4770-846a-457666367b23";
// properties.put(ContextFactory.PROPERTY_IDENTITY_URL, "http://135.25.69.195:5000");
// properties.put(ContextFactory.PROPERTY_TENANT, "Trinity");
OpenStackContext context = (OpenStackContext) ContextFactory.getContext("OpenStackProvider", properties);
context.login("AppC", "AppC");
ComputeService computeService = context.getComputeService();
Server testVNF = computeService.getServer(vmId);
long t1, t2, t3, t4;
t1 = System.currentTimeMillis() / 1000;
computeService.migrateServer(testVNF.getId());
testVNF.waitForStateChange(1, 600, Status.PENDING);
t2 = System.currentTimeMillis() / 1000;
System.out.println("Migrate accepted and calculating prep work");
try {
computeService.migrateServer(testVNF.getId());
fail("Should not be able to migrate a server that is in PENDING");
} catch (Exception e) {
// Good
}
try {
computeService.processResize(testVNF);
fail("Should not be able to confirm a resize on a server that is in PENDING");
} catch (Exception e) {
// Good
}
testVNF.waitForStateChange(5, 600, Status.READY);
t3 = System.currentTimeMillis() / 1000;
System.out.println("Migrate calculations does. Send resizeConfirm to apply");
computeService.processResize(testVNF);
testVNF.waitForStateChange(1, 600, Status.RUNNING);
t4 = System.currentTimeMillis() / 1000;
// System.out.println("Migrate Complete. Time to: 1) Start checking after migrate() call, 2) Finish checking, 3) Commit migrate");
// System.out.println(String.format("1) %3ds\n2) %3ds (%03ds)\n3) %3ds (%3ds)", t2 - t1, t3 - t2, t3 - t1,
// t4 - t3, t4 - t1));
}
use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.
the class OpenStackSnapshotService method connect.
/**
* This is a helper method used to construct the Cinder service object and setup the environment to access the
* OpenStack compute service (Cinder).
*
* @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;
cinder = osContext.getCinderConnector();
((OpenStackContext) context).refreshIfStale(cinder);
}
use of com.att.cdp.openstack.OpenStackContext in project AJSC by att.
the class AbstractTestCase method login.
/**
* A helper method to allow test cases that need an active, actual logged in connection to a provider
*
* @return The context
* @throws ZoneException
* If the login fails
*/
protected OpenStackContext login() throws ZoneException {
OpenStackContext context = (OpenStackContext) ContextFactory.getContext("OpenStackProvider", getProperties());
assertFalse(context.isLoggedIn());
context.login(getProperties().getProperty(ContextFactory.PROPERTY_USERID), getProperties().getProperty(ContextFactory.PROPERTY_PASSWORD));
assertTrue(context.isLoggedIn());
return context;
}
Aggregations