use of com.emc.storageos.model.vdc.VirtualDataCenterList in project coprhd-controller by CoprHD.
the class InternalVdcService method listVdc.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public VirtualDataCenterList listVdc() {
VirtualDataCenterList vdcList = new VirtualDataCenterList();
List<URI> ids = _dbClient.queryByType(VirtualDataCenter.class, true);
Iterator<VirtualDataCenter> iter = _dbClient.queryIterativeObjects(VirtualDataCenter.class, ids);
while (iter.hasNext()) {
vdcList.getVirtualDataCenters().add(toNamedRelatedResource(iter.next()));
}
return vdcList;
}
use of com.emc.storageos.model.vdc.VirtualDataCenterList in project coprhd-controller by CoprHD.
the class InternalVdcApiTest method testSetInUse.
@Test
public void testSetInUse() throws Exception {
VirtualDataCenterList vdcResp = rSys.path("/vdc").get(VirtualDataCenterList.class);
List<NamedRelatedResourceRep> vdcList = vdcResp.getVirtualDataCenters();
Assert.assertTrue(!vdcList.isEmpty());
URI vdcId = vdcList.get(0).getId();
ClientResponse resp = internalVdcClient.setVdcInUse(vdcId, true);
Assert.assertEquals(resp.getClientResponseStatus(), ClientResponse.Status.OK);
resp = internalVdcClient.setVdcInUse(vdcId, false);
Assert.assertEquals(resp.getClientResponseStatus(), ClientResponse.Status.OK);
}
use of com.emc.storageos.model.vdc.VirtualDataCenterList in project coprhd-controller by CoprHD.
the class InternalVdcApiTest method testListVdc.
@Test
public void testListVdc() throws Exception {
VirtualDataCenterList vdcResp = rSys.path("/vdc").get(VirtualDataCenterList.class);
List<NamedRelatedResourceRep> vdcList = vdcResp.getVirtualDataCenters();
VirtualDataCenterList vdcListFromInternalApi = internalVdcClient.listVdc();
Assert.assertTrue(vdcListFromInternalApi != null);
Assert.assertEquals(vdcList.size(), vdcListFromInternalApi.getVirtualDataCenters().size());
Assert.assertTrue(!vdcList.isEmpty());
URI vdcId = vdcList.get(0).getId();
URI vdcIdFromInternalApi = vdcListFromInternalApi.getVirtualDataCenters().get(0).getId();
Assert.assertEquals(vdcId, vdcIdFromInternalApi);
}
use of com.emc.storageos.model.vdc.VirtualDataCenterList in project coprhd-controller by CoprHD.
the class InternalVdcApiTest method testGetVdc.
@Test
public void testGetVdc() throws Exception {
VirtualDataCenterList vdcResp = rSys.path("/vdc").get(VirtualDataCenterList.class);
List<NamedRelatedResourceRep> vdcList = vdcResp.getVirtualDataCenters();
Assert.assertTrue(!vdcList.isEmpty());
URI vdcId = vdcList.get(0).getId();
VirtualDataCenterRestRep vdcFromInternalApi = internalVdcClient.getVdc(vdcId);
Assert.assertTrue(vdcFromInternalApi != null);
Assert.assertEquals(vdcId, vdcFromInternalApi.getId());
Assert.assertEquals("vdc1", vdcFromInternalApi.getShortId());
}
use of com.emc.storageos.model.vdc.VirtualDataCenterList 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