use of org.onap.so.db.catalog.client.CatalogDbClient in project so by onap.
the class OofInfraUtils method getHomingInstance.
/**
* This method gets a HomingInstance in catalog database.
*
* @param serviceInstanceId
*
* @return HomingInstance
*/
public HomingInstance getHomingInstance(String serviceInstanceId, DelegateExecution execution) {
String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
CatalogDbClient client = new CatalogDbClient(endpoint, auth);
try {
return client.getHomingInstance(serviceInstanceId, endpoint + "/homingInstance/");
} catch (Exception exception) {
logger.debug("Could not get HomingInstance for serviceInstanceId : {}", serviceInstanceId);
logger.debug("Get HomingInstance Error: {}", exception);
}
return null;
}
use of org.onap.so.db.catalog.client.CatalogDbClient in project so by onap.
the class OofInfraUtils method createHomingInstance.
/**
* This method creates a HomingInstance in catalog database.
*
* @param homingInstance
*
* @return void
*/
public void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
CatalogDbClient client = new CatalogDbClient(endpoint, auth);
try {
client.postHomingInstance(homingInstance);
} catch (Exception exception) {
logger.debug("Could not create HomingInstance : {}", homingInstance.getServiceInstanceId());
logger.debug("HomingInstance Creation Error: {}", exception);
}
}
use of org.onap.so.db.catalog.client.CatalogDbClient in project so by onap.
the class OofInfraUtils method createCloudSite.
/**
* This method creates a cloudsite in catalog database.
*
* @param cloudSite
*
* @return void
*/
public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
try {
CloudSite getCloudsite;
CatalogDbClient client = new CatalogDbClient(endpoint, auth);
getCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")).orElse(new CloudSite());
if (!cloudSite.getId().equals(getCloudsite.getId())) {
client.postOofHomingCloudSite(cloudSite);
logger.debug("Did not findd cloudsite : {}", cloudSite.getId());
logger.debug("Will create cloudSite: {}", cloudSite.toString());
} else {
logger.debug("Found cloudsite : {}", cloudSite.getId());
logger.debug("Will not create cloudSite: {}", cloudSite.toString());
}
} catch (Exception e) {
logger.debug("Error looking up or creating cloudsite : {}", cloudSite.getId());
logger.debug("CloudSite Lookup/Creation Error: " + e);
}
}
Aggregations