use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ApiTestVcenter method createDefaultVcenterNoCleanUpRegister.
private URI createDefaultVcenterNoCleanUpRegister(BalancedWebResource user, int expectedStatus, boolean discoverVcenter, boolean cascadeTenancy) {
VcenterCreateParam param = new VcenterCreateParam();
param.setName(getDefaultVcenterName());
param.setIpAddress(getDefaultVcenterIp());
param.setUserName(getDefaultVcenterUser());
param.setPassword(getDefaultVcenterPassword());
param.setUseSsl(true);
param.setPortNumber(VCENTER_PORT);
param.setCascadeTenancy(cascadeTenancy);
ClientResponse clientResponse = user.path(getVcenterApi()).queryParam(getDiscoverVcenterQueryParam(), new Boolean(discoverVcenter).toString()).post(ClientResponse.class, param);
Assert.assertEquals(expectedStatus, clientResponse.getStatus());
if (expectedStatus != HttpStatus.SC_OK && expectedStatus != HttpStatus.SC_ACCEPTED) {
return NullColumnValueGetter.getNullURI();
}
TaskResourceRep taskResourceRep = clientResponse.getEntity(TaskResourceRep.class);
Assert.assertNotNull(taskResourceRep.getResource().getId());
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());
}
return taskResourceRep.getResource().getId();
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ComputeSystemServiceApiTest method createAndDiscoverComputeSystem.
private TaskResourceRep createAndDiscoverComputeSystem(String ip, String username, String password, String name, int portname) throws Exception {
TaskResourceRep taskCreateComputeSystem = null;
ComputeSystemCreate computeSystemCreate = new ComputeSystemCreate();
computeSystemCreate.setIpAddress(ip);
computeSystemCreate.setName(name);
computeSystemCreate.setPassword(password);
computeSystemCreate.setUserName(username);
computeSystemCreate.setPortNumber(portname);
computeSystemCreate.setSystemType(ComputeSystem.Type.ucs.name());
return taskCreateComputeSystem = rSys.path(COMPUTE_SYSTEM_RESOURCE).post(TaskResourceRep.class, computeSystemCreate);
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ApiTest method checkFSCreate.
private void checkFSCreate(BalancedWebResource user, boolean good, boolean dup) throws Exception {
FileSystemParam fsparam = new FileSystemParam();
fsparam.setVpool(_cosFile.getId());
fsparam.setLabel("test-fs-" + System.currentTimeMillis());
fsparam.setVarray(_nh);
fsparam.setSize("20480000");
if (good) {
TaskResourceRep resp = user.path("/file/filesystems/").queryParam("project", _testProject.toString()).post(TaskResourceRep.class, fsparam);
Assert.assertNotNull(resp.getOpId());
Assert.assertNotNull(resp.getResource());
_fs = resp.getResource().getId();
String fsId = _fs.toString();
String opId = resp.getOpId();
int checkCount = 1200;
String status;
do {
// wait upto ~2 minute for fs creation
Thread.sleep(100);
resp = user.path(String.format("/file/filesystems/%s/tasks/%s", fsId, opId)).get(TaskResourceRep.class);
status = resp.getState();
} while (status.equals("pending") && checkCount-- > 0);
if (!status.equals("ready")) {
Assert.assertTrue("Fileshare create timed out", false);
}
if (dup) {
ClientResponse response = user.path("/file/filesystems").queryParam("project", _testProject.toString()).post(ClientResponse.class, fsparam);
Assert.assertEquals(400, response.getStatus());
}
} else {
ClientResponse resp = user.path("/file/filesystems").queryParam("project", _testProject.toString()).post(ClientResponse.class, fsparam);
Assert.assertEquals(403, resp.getStatus());
}
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ApiTest method checkSnapCreate.
private void checkSnapCreate(BalancedWebResource user, boolean good) {
FileSystemSnapshotParam param = new FileSystemSnapshotParam();
param.setLabel("test-fs-snap-" + System.currentTimeMillis());
String snapCreateURL = String.format("/file/filesystems/%s/snapshots", _fs);
if (good) {
TaskResourceRep resp = user.path(snapCreateURL).post(TaskResourceRep.class, param);
Assert.assertNotNull(resp.getOpId());
Assert.assertNotNull(resp.getResource());
} else {
ClientResponse resp = user.path(snapCreateURL).post(ClientResponse.class, param);
Assert.assertEquals(403, resp.getStatus());
}
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ApiTest method testVDCs.
// TODO: to be moved in another test suite
public void testVDCs() {
// TODO: once devkit gets switched to 1+0 appliance, we should enable it again.
if (System.getenv("APP_HOST_NAMES").equals("localhost")) {
return;
}
VirtualDataCenterAddParam addParam = new VirtualDataCenterAddParam();
addParam.setApiEndpoint("http://apitest");
addParam.setSecretKey("apitestSecret");
addParam.setCertificateChain("apitestCertchain");
addParam.setName("apitestName" + System.currentTimeMillis());
// TODO: enhance to track task progress
// root should NOT do this.
ClientResponse rsp = rSys.path("/vdc").post(ClientResponse.class, addParam);
Assert.assertEquals(403, rsp.getStatus());
// use super admin with geo securityAdmin role to do post vdc
// assign geo securityadmin to superuser.
RoleAssignmentChanges changes = new RoleAssignmentChanges();
changes.setAdd(new ArrayList<RoleAssignmentEntry>());
RoleAssignmentEntry entry1 = new RoleAssignmentEntry();
entry1.setSubjectId(SUPERUSER);
entry1.getRoles().add("SECURITY_ADMIN");
changes.getAdd().add(entry1);
ClientResponse rsp1 = rSys.path("/vdc/role-assignments").put(ClientResponse.class, changes);
Assert.assertEquals(200, rsp1.getStatus());
// then do post VDC using superuser. should pass.
TaskResourceRep taskRep = rZAdminGr.path("/vdc").post(TaskResourceRep.class, addParam);
Assert.assertNotNull("vdc create task should not be null", taskRep);
VirtualDataCenterList vdcList = rSys.path("/vdc").get(VirtualDataCenterList.class);
Assert.assertNotNull("vdcList should not be null", vdcList);
Assert.assertNotNull("vdcList.getVirtualDataCenters should not be null", vdcList.getVirtualDataCenters());
// boolean found = false;
// for (NamedRelatedResourceRep vdcResource : vdcList.getVirtualDataCenters()) {
// if (vdcResource.getName().equals(addParam.getName())) {
// found = true;
// }
// }
// Assert.assertTrue("newly created vdc could not be found in vdc list", found);
VirtualDataCenterRestRep vdc = rZAdminGr.path("/vdc/" + taskRep.getResource().getId()).get(VirtualDataCenterRestRep.class);
Assert.assertNotNull("created vdc object can't be retrieved", vdc);
Assert.assertTrue("vdc name does not match", vdc.getName().equals(addParam.getName()));
// TODO: enhance to track task progress
ClientResponse response = rZAdminGr.path("/vdc/" + vdc.getId() + "/disconnect").post(ClientResponse.class);
Assert.assertEquals(405, response.getStatus());
// TODO: enhance to track task progress
response = rZAdminGr.path("/vdc/" + vdc.getId() + "/reconnect").post(ClientResponse.class);
Assert.assertEquals(405, response.getStatus());
// TODO: enhance to track task progress
taskRep = rZAdminGr.path("/vdc/" + vdc.getId()).delete(TaskResourceRep.class);
Assert.assertNotNull("vdc delete task should not be null", taskRep);
}
Aggregations