use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ApiTestVcenter method addVcenterAcls.
private void addVcenterAcls(BalancedWebResource user, URI vCenterId, List<URI> tenantIds, int expectedStatus) {
ACLAssignmentChanges param = new ACLAssignmentChanges();
if (CollectionUtils.isEmpty(tenantIds)) {
Assert.assertTrue(false);
}
Iterator<URI> tenantsIterator = tenantIds.iterator();
while (tenantsIterator.hasNext()) {
URI tenantId = tenantsIterator.next();
ACLEntry aclEntry = new ACLEntry();
aclEntry.getAces().add(ACL.USE.name());
aclEntry.setTenant(tenantId.toString());
param.getAdd().add(aclEntry);
}
ClientResponse clientResponse = user.path(getVcenterAclApi(vCenterId)).put(ClientResponse.class, param);
Assert.assertEquals(expectedStatus, clientResponse.getStatus());
if (expectedStatus == HttpStatus.SC_OK && expectedStatus != HttpStatus.SC_ACCEPTED) {
TaskResourceRep taskResourceRep = clientResponse.getEntity(TaskResourceRep.class);
Assert.assertEquals(vCenterId, taskResourceRep.getResource().getId());
clientResponse = user.path(getVcenterAclApi(vCenterId)).get(ClientResponse.class);
Assert.assertEquals(HttpStatus.SC_OK, clientResponse.getStatus());
ACLAssignments aclAssignments = clientResponse.getEntity(ACLAssignments.class);
Assert.assertNotNull(aclAssignments);
List<ACLEntry> aclEntries = aclAssignments.getAssignments();
Assert.assertFalse(CollectionUtils.isEmpty(aclEntries));
Assert.assertTrue(getTenantsFromAcls(aclEntries).containsAll(tenantIds));
while (taskResourceRep.getState().equalsIgnoreCase(TASK_STATUS_PENDING)) {
clientResponse = user.path(getVdcTaskApi() + "/" + taskResourceRep.getId().toString()).get(ClientResponse.class);
Assert.assertEquals(HttpStatus.SC_OK, clientResponse.getStatus());
taskResourceRep = clientResponse.getEntity(TaskResourceRep.class);
Assert.assertNotNull(taskResourceRep.getResource().getId());
}
}
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ApiTestVcenter method removeVcenterAcl.
private void removeVcenterAcl(BalancedWebResource user, URI vCenterId, List<URI> tenantIds, int expectedStatus) {
if (CollectionUtils.isEmpty(tenantIds)) {
return;
}
ACLAssignmentChanges param = new ACLAssignmentChanges();
while (tenantIds.iterator().hasNext()) {
URI tenantId = tenantIds.iterator().next();
ACLEntry aclEntry = new ACLEntry();
aclEntry.getAces().add(ACL.USE.name());
aclEntry.setTenant(tenantId.toString());
param.getRemove().add(aclEntry);
}
ClientResponse clientResponse = user.path(getVcenterAclApi(vCenterId)).queryParam("discover_vcenter", "false").put(ClientResponse.class, param);
Assert.assertEquals(expectedStatus, clientResponse.getStatus());
if (expectedStatus == HttpStatus.SC_OK && expectedStatus != HttpStatus.SC_ACCEPTED) {
TaskResourceRep taskResourceRep = clientResponse.getEntity(TaskResourceRep.class);
Assert.assertEquals(vCenterId, taskResourceRep.getResource().getId());
clientResponse = user.path(getVcenterAclApi(vCenterId)).get(ClientResponse.class);
Assert.assertEquals(HttpStatus.SC_OK, clientResponse.getStatus());
ACLAssignments aclAssignments = clientResponse.getEntity(ACLAssignments.class);
Assert.assertNotNull(aclAssignments);
List<ACLEntry> aclEntries = aclAssignments.getAssignments();
Assert.assertFalse(getTenantsFromAcls(aclEntries).containsAll(tenantIds));
while (taskResourceRep.getState().equalsIgnoreCase(TASK_STATUS_PENDING)) {
clientResponse = user.path(getVdcTaskApi() + "/" + taskResourceRep.getId().toString()).get(ClientResponse.class);
Assert.assertEquals(HttpStatus.SC_OK, clientResponse.getStatus());
taskResourceRep = clientResponse.getEntity(TaskResourceRep.class);
Assert.assertNotNull(taskResourceRep.getResource().getId());
}
}
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ComputeSystemServiceApiTest method deactivateComputeSystem.
private Boolean deactivateComputeSystem(ComputeSystemRestRep cs) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InterruptedException {
if (cs == null) {
System.out.println("Unable to run the test as there's no Compute System to run the test against");
return false;
}
System.out.println("De-activating compute element: " + BeanUtils.describe(cs));
TaskResourceRep deactivateTask = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + cs.getId() + DEACTIVATE_RELATIVE_PATH).post(TaskResourceRep.class);
System.out.println("Waiting for compute element deactivation: ");
Thread.sleep(60000 / 8);
cs = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + cs.getId()).get(ComputeSystemRestRep.class);
if (cs.getInactive().booleanValue() == false) {
return false;
}
System.out.println("Compute System should be deleted from the system! Safe to run the test over...");
return true;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ComputeSystemServiceApiTest method testCreateComputeSystem.
@Test(groups = "runByDefault", timeOut = 100000)
public void testCreateComputeSystem() throws Exception {
TaskResourceRep taskCreateComputeSystem = createAndDiscoverComputeSystem(EnvConfig.get("sanity", "ucsm.host"), EnvConfig.get("sanity", "ucsm.host.username"), EnvConfig.get("sanity", "ucsm.host.password"), "api-test-compute-system", 80);
Assert.assertNotNull(taskCreateComputeSystem, "Compute System Task should not be null");
Assert.assertNotNull(taskCreateComputeSystem.getOpId(), "Compute System Task Id should not be null");
Assert.assertNotNull(taskCreateComputeSystem.getResource(), "Task related resource should not be null");
computeSystem = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + taskCreateComputeSystem.getResource().getId()).get(ComputeSystemRestRep.class);
Assert.assertNotNull(computeSystem, "Created Compute System should not be null!");
System.out.println("Created Compute System has id: " + computeSystem.getId());
// Wait long enough for the Compute System to get discovered...
while (computeSystem.getDiscoveryJobStatus().equals(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.name())) {
computeSystem = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + taskCreateComputeSystem.getResource().getId()).get(ComputeSystemRestRep.class);
Thread.sleep(1000);
}
// Refresh the compute system!
computeSystem = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + taskCreateComputeSystem.getResource().getId()).get(ComputeSystemRestRep.class);
Assert.assertEquals(computeSystem.getDiscoveryJobStatus(), DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.name());
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ComputeSystemServiceApiTest method testInvalidAddressCreateComputeSystem.
@Test(groups = "runByDefault", timeOut = 100000)
public void testInvalidAddressCreateComputeSystem() throws Exception {
TaskResourceRep taskCreateComputeSystem = createAndDiscoverComputeSystem(EnvConfig.get("sanity", "ucsm.invalidAddress.host"), EnvConfig.get("sanity", "ucsm.invalidAddress.username"), EnvConfig.get("sanity", "ucsm.invalidAddress.password"), "bad-address-api-test-compute-system", 80);
Assert.assertNotNull(taskCreateComputeSystem, "Compute System Task should not be null");
Assert.assertNotNull(taskCreateComputeSystem.getOpId(), "Compute System Task Id should not be null");
Assert.assertNotNull(taskCreateComputeSystem.getResource(), "Task related resource should not be null");
invalidAddressComputeSystem = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + taskCreateComputeSystem.getResource().getId()).get(ComputeSystemRestRep.class);
Assert.assertNotNull(invalidAddressComputeSystem, "Created Compute System should not be null!");
System.out.println("Created Compute System has id: " + invalidAddressComputeSystem.getId());
// Wait long enough for the Compute System to get discovered...
while (invalidAddressComputeSystem.getDiscoveryJobStatus().equals(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.name())) {
invalidAddressComputeSystem = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + taskCreateComputeSystem.getResource().getId()).get(ComputeSystemRestRep.class);
Thread.sleep(1000);
}
// Refresh the compute system!
invalidAddressComputeSystem = rSys.path(COMPUTE_SYSTEM_RESOURCE + "/" + taskCreateComputeSystem.getResource().getId()).get(ComputeSystemRestRep.class);
Assert.assertEquals(invalidAddressComputeSystem.getDiscoveryJobStatus(), DiscoveredDataObject.DataCollectionJobStatus.ERROR.name());
}
Aggregations