use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class CreateAAIInventory method heatbridge.
public void heatbridge(CloudInformation cloudInformation) throws HeatBridgeException, MsoCloudSiteNotFound {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()).orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
if (cloudSite.getOrchestrator() != null && MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.getOrchestrator())) {
logger.debug("Skipping Heatbridge as CloudSite orchestrator is: " + MULTICLOUD_MODE);
return;
}
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
String heatStackId = cloudInformation.getTemplateInstanceId().split("/")[1];
List<String> oobMgtNetNames = new ArrayList<>();
HeatBridgeApi heatBridgeClient = createClient(getAaiClient(), cloudSite, cloudIdentity, cloudInformation);
heatBridgeClient.authenticate();
List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId());
List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources);
heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), osNetworks);
List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources);
heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources);
List<Image> osImages = heatBridgeClient.extractOpenstackImagesFromServers(osServers);
List<Flavor> osFlavors = heatBridgeClient.extractOpenstackFlavorsFromServers(osServers);
logger.debug("Successfully queried heat stack{} for resources.", heatStackId);
// os images
if (osImages != null && !osImages.isEmpty()) {
heatBridgeClient.buildAddImagesToAaiAction(osImages);
logger.debug("Successfully built AAI actions to add images.");
} else {
logger.debug("No images to update to AAI.");
}
// flavors
if (osFlavors != null && !osFlavors.isEmpty()) {
heatBridgeClient.buildAddFlavorsToAaiAction(osFlavors);
logger.debug("Successfully built AAI actions to add flavors.");
} else {
logger.debug("No flavors to update to AAI.");
}
// compute resources
heatBridgeClient.buildAddVserversToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), osServers);
logger.debug("Successfully queried compute resources and built AAI vserver actions.");
// neutron resources
List<String> oobMgtNetIds = new ArrayList<>();
// if no network-id list is provided, however network-name list is
if (!CollectionUtils.isEmpty(oobMgtNetNames)) {
oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames);
}
heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, cloudInformation.getOwner());
logger.debug("Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers.");
heatBridgeClient.buildAddVolumes(stackResources);
// Update AAI
logger.debug("Current Dry Run Value: {}", env.getProperty("heatBridgeDryrun", Boolean.class, false));
heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false));
}
use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class CloudConfigTest method createCloudSiteRest_TEST.
@Test
@Transactional
public void createCloudSiteRest_TEST() {
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
CloudSite cloudSite = new CloudSite();
cloudSite.setId("MTN7");
cloudSite.setClli("TESTCLLI");
cloudSite.setRegionId("regionId");
cloudSite.setCloudVersion("VERSION");
cloudSite.setPlatform("PLATFORM");
CloudIdentity cloudIdentity = new CloudIdentity();
cloudIdentity.setId("RANDOMID-test");
cloudIdentity.setIdentityUrl("URL");
cloudIdentity.setMsoId("MSO_ID");
cloudIdentity.setMsoPass("MSO_PASS");
cloudIdentity.setAdminTenant("ADMIN_TENANT");
cloudIdentity.setMemberRole("ROLE");
cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
cloudSite.setIdentityService(cloudIdentity);
String uri = "/cloudSite";
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri);
HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers);
ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, request, String.class);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri + "/" + cloudSite.getId());
HttpEntity<String> entity = new HttpEntity<String>(null, headers);
ResponseEntity<CloudSite> actualCloudSite = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, CloudSite.class);
builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri);
ResponseEntity<String> cloudSiteString = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
System.out.println(cloudSiteString.getBody());
assertEquals(Response.Status.OK.getStatusCode(), actualCloudSite.getStatusCode().value());
assertThat(actualCloudSite.getBody(), sameBeanAs(cloudSite).ignoring("created").ignoring("updated").ignoring("identityService.created").ignoring("identityService.updated"));
}
use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class CatalogDbClientTest method testGetCloudSiteByClliAndAicVersionNotFound.
@Test
public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
assertNull(cloudSite);
}
use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class CatalogDbClientTest method testCloudSiteClient.
@Test
public void testCloudSiteClient() {
CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
CloudSite cloudSite = new CloudSite();
cloudSite.setId("MTN6");
cloudSite.setClli("TESTCLLI");
cloudSite.setRegionId("regionId");
cloudSite.setCloudVersion("VERSION");
cloudSite.setPlatform("PLATFORM");
CloudIdentity cloudIdentity = new CloudIdentity();
cloudIdentity.setId("RANDOMID");
cloudIdentity.setIdentityUrl("URL");
cloudIdentity.setMsoId("MSO_ID");
cloudIdentity.setMsoPass("MSO_PASS");
cloudIdentity.setAdminTenant("ADMIN_TENANT");
cloudIdentity.setMemberRole("ROLE");
cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
cloudSite.setIdentityService(cloudIdentity);
localClient.postCloudSite(cloudSite);
CloudSite getCloudSite = this.client.getCloudSite("MTN6");
assertNotNull(getCloudSite);
assertNotNull(getCloudSite.getIdentityService());
assertEquals("TESTCLLI", getCloudSite.getClli());
assertEquals("regionId", getCloudSite.getRegionId());
assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
getCloudSite.setClli("clli2");
getCloudSite.setRegionId("region2");
CloudSite updatedCloudSite = this.client.updateCloudSite(getCloudSite);
assertNotNull(updatedCloudSite);
assertNotNull(updatedCloudSite.getIdentityService());
assertEquals("clli2", updatedCloudSite.getClli());
assertEquals("region2", updatedCloudSite.getRegionId());
this.client.deleteCloudSite(getCloudSite.getId());
getCloudSite = this.client.getCloudSite("MTN6");
assertNull(getCloudSite);
}
use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class CatalogDbClientTest method testGetCloudSiteHappyPath.
@Test
public void testGetCloudSiteHappyPath() throws Exception {
CloudSite cloudSite = client.getCloudSite(MTN13);
assertNotNull(cloudSite);
assertNotNull(cloudSite.getIdentityService());
assertEquals("MDT13", cloudSite.getClli());
assertEquals("mtn13", cloudSite.getRegionId());
assertEquals("MTN13", cloudSite.getIdentityServiceId());
}
Aggregations