Search in sources :

Example 1 with BlockConsistencyGroupCreate

use of com.emc.storageos.model.block.BlockConsistencyGroupCreate in project coprhd-controller by CoprHD.

the class ApiSystemTestUtil method createConsistencyGroup.

public URI createConsistencyGroup(String cgName, URI project) {
    BlockConsistencyGroupCreate input = new BlockConsistencyGroupCreate();
    input.setName(cgName);
    input.setProject(project);
    try {
        BlockConsistencyGroupRestRep rep = client.blockConsistencyGroups().create(input);
        return rep.getId();
    } catch (ServiceErrorException ex) {
        log.error("Exception creating consistency group: " + cgName, ex);
        throw ex;
    }
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) BlockConsistencyGroupCreate(com.emc.storageos.model.block.BlockConsistencyGroupCreate) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 2 with BlockConsistencyGroupCreate

use of com.emc.storageos.model.block.BlockConsistencyGroupCreate in project coprhd-controller by CoprHD.

the class ConsistencyGroups method save.

@FlashException(referrer = { "create", "edit" })
public static void save(ConsistencyGroupForm consistencyGroup) {
    flash.put(ACTIVE_PROJECT_ID, consistencyGroup.projectId);
    consistencyGroup.validate("consistencyGroup");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    // NOTE : Only Create is supported at this time
    if (consistencyGroup.isNew()) {
        BlockConsistencyGroupCreate createParam = new BlockConsistencyGroupCreate();
        createParam.setName(consistencyGroup.name);
        createParam.setProject(uri(consistencyGroup.projectId));
        createParam.setArrayConsistency(consistencyGroup.arrayConsistency);
        BlockConsistencyGroupUtils.create(createParam);
    }
    flash.success(MessagesUtils.get("consistencyGroups.saved", consistencyGroup.name));
    if (StringUtils.isNotBlank(consistencyGroup.referrerUrl)) {
        redirect(consistencyGroup.referrerUrl);
    } else {
        list();
    }
}
Also used : BlockConsistencyGroupCreate(com.emc.storageos.model.block.BlockConsistencyGroupCreate) FlashException(controllers.util.FlashException)

Example 3 with BlockConsistencyGroupCreate

use of com.emc.storageos.model.block.BlockConsistencyGroupCreate in project coprhd-controller by CoprHD.

the class ApiTest method checkCreateConsistencyGroup.

private void checkCreateConsistencyGroup(BalancedWebResource user, boolean good) throws InterruptedException {
    final BlockConsistencyGroupCreate param = new BlockConsistencyGroupCreate();
    param.setName("test_group_" + System.currentTimeMillis());
    param.setProject(_testProject);
    if (good) {
        TaskList resp = user.path("/block/consistency-groups").post(TaskList.class, param);
        Assert.assertTrue(resp.getTaskList().size() == 1);
        Assert.assertNotNull(resp.getTaskList().get(0).getOpId());
        Assert.assertNotNull(resp.getTaskList().get(0).getResource().getId());
        _group = resp.getTaskList().get(0).getResource().getId();
        String groupId = _group.toString();
        String opId = resp.getTaskList().get(0).getOpId();
        int checkCount = 1200;
        String status;
        do {
            // wait upto ~2 minute for group creation
            Thread.sleep(100);
            TaskResourceRep taskResp = user.path(String.format("/block/consistency-groups/%s/tasks/%s", groupId, opId)).get(TaskResourceRep.class);
            status = taskResp.getState();
        } while (status.equals("pending") && checkCount-- > 0);
        if (!status.equals("ready")) {
            Assert.assertTrue("ConsistencyGroup create timed out", false);
        }
    } else {
        ClientResponse resp = user.path("/block/consistency-groups").post(ClientResponse.class, param);
        Assert.assertEquals(403, resp.getStatus());
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) BlockConsistencyGroupCreate(com.emc.storageos.model.block.BlockConsistencyGroupCreate)

Aggregations

BlockConsistencyGroupCreate (com.emc.storageos.model.block.BlockConsistencyGroupCreate)3 TaskList (com.emc.storageos.model.TaskList)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 FlashException (controllers.util.FlashException)1