use of org.onap.so.heatbridge.HeatBridgeException in project so by onap.
the class MsoCloudClientFactoryImpl method getOpenstackClient.
@Override
public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass, @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion, String userDomainName, String projectDomainName) throws HeatBridgeException {
Objects.requireNonNull(url, "Null openstack url!");
Objects.requireNonNull(msoId, "Null openstack user id!");
Objects.requireNonNull(msoPass, "Null openstack password!");
Objects.requireNonNull(regionId, "Null regionId ID!");
Objects.requireNonNull(tenantId, "Null tenant ID!");
Objects.requireNonNull(keystoneVersion, "Null keystone version");
if (userDomainName == null) {
userDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME;
}
if (projectDomainName == null) {
projectDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME;
}
try {
final OpenstackAccess osAccess = // keystone URL
new OpenstackAccessBuilder().setBaseUrl(url).setUser(// keystone username
msoId).setPassword(// keystone decrypted password
CryptoUtils.decryptCloudConfigPassword(msoPass)).setRegion(// openstack region
regionId).setDomainName(userDomainName).setProjectName(projectDomainName).setTenantId(// tenantId
tenantId).build();
// Identify the Keystone version
if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V2_KEY)) {
return openstackClientFactory.createOpenstackV2Client(osAccess);
} else if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V3_KEY)) {
return openstackClientFactory.createOpenstackV3Client(osAccess);
}
throw new OpenstackClientException("Unsupported keystone version! " + keystoneVersion);
} catch (OpenstackClientException osClientEx) {
logger.error("Error creating OS Client", osClientEx);
throw new HeatBridgeException("Client error when authenticating with the Openstack", osClientEx);
}
}
use of org.onap.so.heatbridge.HeatBridgeException in project so by onap.
the class AaiHelper method createVnfRelationshiptoVserver.
public Relationship createVnfRelationshiptoVserver(String vserverName, String genericVnfId, String vfModuleId) throws HeatBridgeException {
AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId));
AAIResultWrapper vfModule = resourcesClient.get(vfModuleUri);
if (vfModule.hasRelationshipsTo(Types.VNFC)) {
List<AAIResourceUri> vnfcUris = vfModule.getRelationships().get().getRelatedUris(Types.VNFC);
Optional<AAIResourceUri> foundVnfcURI = vnfcUris.stream().filter(resourceUri -> resourceUri.getURIKeys().get("vnfc-name").startsWith(vserverName)).findFirst();
if (!foundVnfcURI.isPresent()) {
throw new HeatBridgeException("Cannot Find VNFC to create edge to VServer");
} else {
return buildRelationship(foundVnfcURI.get());
}
} else {
throw new HeatBridgeException("VF Module contains no relationships to VNFCS, cannot build edge to VServer");
}
}
Aggregations