Search in sources :

Example 91 with TaskResourceRep

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());
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI)

Example 92 with TaskResourceRep

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());
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI)

Example 93 with TaskResourceRep

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;
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 94 with TaskResourceRep

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());
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) Test(org.testng.annotations.Test)

Example 95 with TaskResourceRep

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());
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) Test(org.testng.annotations.Test)

Aggregations

TaskResourceRep (com.emc.storageos.model.TaskResourceRep)160 URI (java.net.URI)85 TaskList (com.emc.storageos.model.TaskList)82 Operation (com.emc.storageos.db.client.model.Operation)68 Produces (javax.ws.rs.Produces)59 ArrayList (java.util.ArrayList)56 Volume (com.emc.storageos.db.client.model.Volume)55 Path (javax.ws.rs.Path)54 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)53 POST (javax.ws.rs.POST)50 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)49 Consumes (javax.ws.rs.Consumes)36 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)35 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 NamedURI (com.emc.storageos.db.client.model.NamedURI)30 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)23 Project (com.emc.storageos.db.client.model.Project)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)18 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)17 Copy (com.emc.storageos.model.block.Copy)17