use of com.att.cdp.zones.ComputeService 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.zones.ComputeService in project AJSC by att.
the class TestSecurityGroups method testAll.
@Test
@Ignore
public void testAll() throws ZoneException {
Context context = connect();
ComputeService service = context.getComputeService();
String aclName = "Unit Test ACL";
try {
ACL template = new ACL();
template.setName(aclName);
template.setDescription(aclName);
ACL acl = service.createAccessControlList(template);
assertNotNull(acl);
assertTrue(acl.getRules().isEmpty());
Rule rule1 = new Rule(Rule.PROTOCOL.TCP, 80, 80, "0.0.0.0/0");
Rule rule2 = new Rule(Rule.PROTOCOL.UDP, 60000, 60010, "0.0.0.0/0");
rule1 = service.addACLRule(acl.getId(), rule1);
assertNotNull(rule1.getId());
rule2 = service.addACLRule(acl.getId(), rule2);
assertNotNull(rule2.getId());
acl = service.getAccessControlList(acl.getId());
assertEquals(2, acl.getRules().size());
assertEquals(Rule.PROTOCOL.TCP, acl.getRules().get(0).getProtocol());
assertEquals(Rule.PROTOCOL.UDP, acl.getRules().get(1).getProtocol());
service.deleteACLRule(rule1);
acl = service.getAccessControlList(acl.getId());
assertEquals(1, acl.getRules().size());
assertEquals(Rule.PROTOCOL.UDP, acl.getRules().get(0).getProtocol());
service.deleteACLRule(rule2);
acl = service.getAccessControlList(acl.getId());
assertTrue(acl.getRules().isEmpty());
service.deleteAccessControlList(acl.getId());
try {
service.getAccessControlList(acl.getId());
fail("Failed to delete the ACL");
} catch (ZoneException ze) {
// Successfully deleted the ACL
}
} catch (ZoneException ze) {
ze.printStackTrace();
fail();
}
}
use of com.att.cdp.zones.ComputeService in project AJSC by att.
the class OpenStackServer method loadHypervisorAttachment.
/**
* This method is called to load the hypervisor attachment, if it has not already been loaded. If it has been
* loaded, then the call is ignored.
*
* @param context
* The context that represents the connection we are servicing
* @throws ZoneException
* If the attachments cannot be obtained, or if a hypervisor cannot be listed, or a hypervisor does not
* exist
*/
private void loadHypervisorAttachment(Context context) throws ZoneException {
if (hypervisorAttachmentProcessed.compareAndSet(false, true)) {
ComputeService computeService = context.getComputeService();
List<Hypervisor> hypervisors = computeService.getHypervisors();
if (this.novaModel.getHypervisorHostname() != null && !this.novaModel.getHypervisorHostname().isEmpty()) {
String hypervisorName = this.novaModel.getHypervisorHostname();
for (Hypervisor h : hypervisors) {
if (h.getHostName().equals(hypervisorName)) {
this.setHypervisor(h);
return;
}
}
}
}
}
use of com.att.cdp.zones.ComputeService in project AJSC by att.
the class ConnectedServer method getPorts.
/**
* Override the API class to actually get and return the list of ports from the service provider and to cache them
* once obtained.
*
* @see com.att.cdp.zones.model.Server#getPorts()
*/
@Override
public List<Port> getPorts() throws ZoneException {
Context context = getContext();
ComputeService service = context.getComputeService();
List<Port> ports = service.getPorts(this);
if (ports == null) {
ports = new ArrayList<Port>();
}
return ports;
}
use of com.att.cdp.zones.ComputeService in project AJSC by att.
the class ConnectedServer method detachPort.
/**
* @see com.att.cdp.zones.model.Server#detachPort(com.att.cdp.zones.model.Port)
*/
@Override
public void detachPort(Port port) throws ZoneException {
Context context = getContext();
ComputeService service = context.getComputeService();
service.detachPort(this, port);
}
Aggregations