use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method sDDCSoftwareDeleteOtherExample.
@Test
public void sDDCSoftwareDeleteOtherExample() throws Exception {
SDDCSoftwareConfig sddc = createSDDCSoftwareConfig(SoftwareType.OTHERS);
sddcRepository.save(sddc);
this.mockMvc.perform(delete("/v1/sddc/" + sddc.getId())).andExpect(status().isOk());
Optional<SDDCSoftwareConfig> sddcOptional = sddcRepository.findById(sddc.getId());
TestCase.assertEquals(false, sddcOptional.isPresent());
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method SDDCSoftwareQueryByTypeAndUserId.
@Test
public void SDDCSoftwareQueryByTypeAndUserId() throws Exception {
SDDCSoftwareConfig sddcCreate = createSDDCSoftwareConfig(SoftwareType.VCENTER);
sddcCreate.setType(SoftwareType.VCENTER);
sddcCreate.setName("flowgate");
sddcCreate.setDescription("flowgate cluster");
Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
sddcCreate.setPassword(EncryptionGuard.encode(sddcCreate.getPassword()));
sddcRepository.save(sddcCreate);
FieldDescriptor[] fieldpath = new FieldDescriptor[] { fieldWithPath("id").description("ID of FacilitySoftwareConfig, created by flowgate"), fieldWithPath("name").description("The facilitySoftware name."), fieldWithPath("description").description("The facilitySoftware description."), fieldWithPath("userName").description("An username used to obtain authorization"), fieldWithPath("password").description(" A password used to obtain authorization."), fieldWithPath("serverURL").description("The server's address, it can be an IP or FQDN."), fieldWithPath("type").description("A type for facilitySoftware,forExample Nlyte,PowerIQ,Device42,OtherDCIM or OtherCMDB").type(SoftwareType.class).optional(), fieldWithPath("userId").description("userId"), fieldWithPath("subCategory").description("subCategory"), fieldWithPath("verifyCert").description("Whether to verify the certificate when accessing the serverURL.").type(JsonFieldType.BOOLEAN), subsectionWithPath("integrationStatus").description("The status of integration.").optional() };
MvcResult result = this.mockMvc.perform(get("/v1/sddc/type/{type}", SoftwareType.VCENTER)).andExpect(status().isOk()).andDo(document("SDDCSoftware-queryByType-example", pathParameters(parameterWithName("type").description("The type of SDDCSoftwareConfig, Sample value: VRO/VCENTER")), responseFields(fieldWithPath("[]").description("An array of SDDCSoftwareConfig.")).andWithPrefix("[].", fieldpath))).andReturn();
ObjectMapper mapper = new ObjectMapper();
String res = result.getResponse().getContentAsString();
SDDCSoftwareConfig[] sddcs = mapper.readValue(res, SDDCSoftwareConfig[].class);
for (SDDCSoftwareConfig sddc : sddcs) {
if (sddc.getName().equals("flowgate")) {
TestCase.assertEquals("flowgate cluster", sddc.getDescription());
}
}
sddcRepository.deleteById(sddcCreate.getId());
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SystemSummaryTest method testSummaryRepo.
@Test
public void testSummaryRepo() throws IOException {
ValueOperations<String, String> valueOperations = Mockito.mock(ValueOperations.class);
Mockito.doReturn(valueOperations).when(template).opsForValue();
FacilitySoftwareConfig nlyte1 = createFacility();
nlyte1.setType(com.vmware.flowgate.common.model.FacilitySoftwareConfig.SoftwareType.Nlyte);
nlyte1 = facilityrepo.save(nlyte1);
FacilitySoftwareConfig powerIQ1 = createFacility();
powerIQ1.setType(com.vmware.flowgate.common.model.FacilitySoftwareConfig.SoftwareType.PowerIQ);
powerIQ1 = facilityrepo.save(powerIQ1);
Asset nlyteServer1 = createAsset();
nlyteServer1.setCategory(AssetCategory.Server);
nlyteServer1.setAssetSource(nlyte1.getId());
nlyteServer1 = assetrepo.save(nlyteServer1);
Asset nlyteServer2 = createAsset();
nlyteServer2.setCategory(AssetCategory.Server);
nlyteServer2.setAssetSource(nlyte1.getId());
nlyteServer2 = assetrepo.save(nlyteServer2);
Asset nlytePDU1 = createAsset();
nlytePDU1.setCategory(AssetCategory.PDU);
nlytePDU1.setAssetSource(nlyte1.getId());
nlytePDU1 = assetrepo.save(nlytePDU1);
Asset nlytePDU2 = createAsset();
nlytePDU2.setCategory(AssetCategory.PDU);
nlytePDU2.setAssetSource(nlyte1.getId());
nlytePDU2 = assetrepo.save(nlytePDU2);
Asset powerIQSensor1 = createAsset();
powerIQSensor1.setCategory(AssetCategory.Sensors);
powerIQSensor1.setSubCategory(AssetSubCategory.Humidity);
powerIQSensor1.setAssetSource(powerIQ1.getId());
powerIQSensor1 = assetrepo.save(powerIQSensor1);
Asset powerIQSensor2 = createAsset();
powerIQSensor2.setCategory(AssetCategory.Sensors);
powerIQSensor2.setSubCategory(AssetSubCategory.Humidity);
powerIQSensor2.setAssetSource(powerIQ1.getId());
powerIQSensor2 = assetrepo.save(powerIQSensor2);
Asset powerIQSensor3 = createAsset();
powerIQSensor3.setCategory(AssetCategory.Sensors);
powerIQSensor3.setSubCategory(AssetSubCategory.Temperature);
powerIQSensor3.setAssetSource(powerIQ1.getId());
powerIQSensor3 = assetrepo.save(powerIQSensor3);
Asset powerIQSensor4 = createAsset();
powerIQSensor4.setCategory(AssetCategory.Sensors);
powerIQSensor4.setSubCategory(AssetSubCategory.Temperature);
powerIQSensor4.setAssetSource(powerIQ1.getId());
powerIQSensor4 = assetrepo.save(powerIQSensor4);
SDDCSoftwareConfig vro1 = createSDDC();
vro1.setType(SoftwareType.VRO);
vro1 = sddcrepo.save(vro1);
SDDCSoftwareConfig vro2 = createSDDC();
vro2.setType(SoftwareType.VRO);
vro2 = sddcrepo.save(vro2);
SDDCSoftwareConfig vc1 = createSDDC();
vc1.setType(SoftwareType.VCENTER);
vc1 = sddcrepo.save(vc1);
SDDCSoftwareConfig vc2 = createSDDC();
vc2.setType(SoftwareType.VCENTER);
vc2 = sddcrepo.save(vc2);
ServerMapping server1 = createServerMapping();
server1.setVroID(vro1.getId());
server1 = mappingrepo.save(server1);
ServerMapping server2 = createServerMapping();
server2.setVroID(vro1.getId());
server2 = mappingrepo.save(server2);
ServerMapping server3 = createServerMapping();
server3.setVcID(vc1.getId());
server3 = mappingrepo.save(server3);
ServerMapping server4 = createServerMapping();
server4.setVcID(vc2.getId());
server4 = mappingrepo.save(server4);
ServerMapping server5 = createServerMapping();
server5.setVroID(vro2.getId());
server5 = mappingrepo.save(server5);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
SystemSummary data = summaryService.getSystemResult(false);
TestCase.assertEquals(8, data.getAssetsNum());
TestCase.assertEquals(2, data.getFacilitySystemNum());
TestCase.assertEquals(4, data.getSddcIntegrationNum());
TestCase.assertEquals(2, data.getHumiditySensorNum());
TestCase.assertEquals(2, data.getTemperatureSensorNum());
TestCase.assertEquals(4, data.getSensorNum());
TestCase.assertEquals(2, data.getPduNum());
TestCase.assertEquals(2, data.getServerNum());
TestCase.assertEquals(5, data.getSddcServerNum());
TestCase.assertEquals(2, data.getVroNum());
TestCase.assertEquals(2, data.getVcNum());
} finally {
facilityrepo.deleteById(nlyte1.getId());
facilityrepo.deleteById(powerIQ1.getId());
assetrepo.deleteById(nlyteServer1.getId());
assetrepo.deleteById(nlyteServer2.getId());
assetrepo.deleteById(nlytePDU1.getId());
assetrepo.deleteById(nlytePDU2.getId());
assetrepo.deleteById(powerIQSensor1.getId());
assetrepo.deleteById(powerIQSensor2.getId());
assetrepo.deleteById(powerIQSensor3.getId());
assetrepo.deleteById(powerIQSensor4.getId());
sddcrepo.deleteById(vc1.getId());
sddcrepo.deleteById(vc2.getId());
sddcrepo.deleteById(vro1.getId());
sddcrepo.deleteById(vro2.getId());
mappingrepo.deleteById(server1.getId());
mappingrepo.deleteById(server2.getId());
mappingrepo.deleteById(server3.getId());
mappingrepo.deleteById(server4.getId());
mappingrepo.deleteById(server5.getId());
}
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SummaryService method getVcSummaryList.
public List<VcSummary> getVcSummaryList() {
List<VcSummary> vcSummary = new ArrayList<>();
List<SDDCSoftwareConfig> sddcSoftwareConfigs = sddcrpeo.findAllByType(SoftwareType.VCENTER.name());
for (SDDCSoftwareConfig s : sddcSoftwareConfigs) {
VcSummary vc = new VcSummary();
vc.setName(s.getName());
vc.setUrl(s.getServerURL());
vc.setHostsNum(summaryRepository.countServerMappingByVC(s.getId()));
vcSummary.add(vc);
}
return vcSummary;
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareController method getServerConfig.
// get a server
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public SDDCSoftwareConfig getServerConfig(@PathVariable String id) {
Optional<SDDCSoftwareConfig> sddcOptional = sddcRepository.findById(id);
SDDCSoftwareConfig server = null;
if (sddcOptional.isPresent()) {
server = sddcOptional.get();
server.setPassword(null);
}
return server;
}
Aggregations