Search in sources :

Example 51 with CloudSite

use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.

the class CloudConfigTest method testGetCloudSite.

/**
 * This method implements a test for the getCloudSite method.
 */
@Test
public final void testGetCloudSite() {
    CloudSite site1 = con.getCloudSite("MTN13").get();
    assertEquals("mtn13", site1.getRegionId());
    assertEquals("mtn13", site1.getIdentityServiceId());
    assertEquals("MDT13", site1.getClli());
    assertEquals("3.0", site1.getCloudVersion());
}
Also used : CloudSite(org.onap.so.db.catalog.beans.CloudSite) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 52 with CloudSite

use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.

the class MsoTenantUtilsFactoryTest method getTenantUtils_shouldReturnNull_forInvalidServerType.

@Test
public void getTenantUtils_shouldReturnNull_forInvalidServerType() throws MsoCloudSiteNotFound {
    // GIVEN
    String cloudSiteId = "CloudSiteId";
    CloudSite cloudSite = mock(CloudSite.class, RETURNS_DEEP_STUBS);
    given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.of(cloudSite));
    // WHEN
    MsoTenantUtils tenantUtils = msoTenantUtilsFactory.getTenantUtils(cloudSiteId);
    // THEN
    assertThat(tenantUtils).isNull();
}
Also used : CloudSite(org.onap.so.db.catalog.beans.CloudSite) Test(org.junit.Test)

Example 53 with CloudSite

use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.

the class MsoTenantUtilsFactoryTest method shouldReturnAppropriateUtilsInstanceForGivenServerType.

private <T extends MsoTenantUtils> void shouldReturnAppropriateUtilsInstanceForGivenServerType(ServerType serverType, T expectedInstance) throws MsoCloudSiteNotFound {
    // GIVEN
    String cloudSiteId = "CloudSiteId";
    CloudSite cloudSite = mock(CloudSite.class, RETURNS_DEEP_STUBS);
    given(cloudSite.getIdentityService().getIdentityServerType()).willReturn(serverType);
    given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.of(cloudSite));
    // WHEN
    MsoTenantUtils tenantUtils = msoTenantUtilsFactory.getTenantUtils(cloudSiteId);
    // THEN
    assertThat(tenantUtils).isEqualTo(expectedInstance);
}
Also used : CloudSite(org.onap.so.db.catalog.beans.CloudSite)

Example 54 with CloudSite

use of org.onap.so.db.catalog.beans.CloudSite 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);
    }
}
Also used : CloudSite(org.onap.so.db.catalog.beans.CloudSite) CatalogDbClient(org.onap.so.db.catalog.client.CatalogDbClient)

Aggregations

CloudSite (org.onap.so.db.catalog.beans.CloudSite)54 Test (org.junit.Test)25 MsoCloudSiteNotFound (org.onap.so.openstack.exceptions.MsoCloudSiteNotFound)13 CloudIdentity (org.onap.so.db.catalog.beans.CloudIdentity)12 MsoException (org.onap.so.openstack.exceptions.MsoException)12 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)9 StackInfo (org.onap.so.openstack.beans.StackInfo)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 BaseTest (org.onap.so.BaseTest)7 CatalogDbAdapterBaseTest (org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)6 Keystone (com.woorea.openstack.keystone.Keystone)5 Quantum (com.woorea.openstack.quantum.Quantum)5 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)5 OpenStackRequest (com.woorea.openstack.base.client.OpenStackRequest)4 Heat (com.woorea.openstack.heat.Heat)4 Tenant (com.woorea.openstack.keystone.model.Tenant)4 Network (com.woorea.openstack.quantum.model.Network)4 MsoTenant (org.onap.so.openstack.beans.MsoTenant)4 JsonParseException (com.fasterxml.jackson.core.JsonParseException)3