Search in sources :

Example 11 with MsoException

use of org.onap.so.openstack.exceptions.MsoException in project so by onap.

the class NovaClientImpl method queryOSQuotaSet.

/**
 * Query OS Quota Set
 *
 * @param cloudSiteId the cloud site id
 * @param tenantId the tenant id
 * @param limit limits the number of records returned
 * @param marker the last viewed record
 * @return a host aggregate
 * @throws MsoCloudSiteNotFound the mso cloud site not found
 * @throws NeutronClientException if the client cannot be built this is thrown
 */
public QuotaSet queryOSQuotaSet(String cloudSiteId, String tenantId) throws MsoCloudSiteNotFound, NovaClientException {
    try {
        Nova novaClient = client.getNovaClient(cloudSiteId, tenantId);
        OpenStackRequest<QuotaSet> request = novaClient.quotaSets().showQuota(tenantId);
        return executeAndRecordOpenstackRequest(request, false);
    } catch (MsoException e) {
        logger.error("Error building Nova Client", e);
        throw new NovaClientException("Error building Nova Client", e);
    }
}
Also used : MsoException(org.onap.so.openstack.exceptions.MsoException) QuotaSet(com.woorea.openstack.nova.model.QuotaSet) Nova(com.woorea.openstack.nova.Nova)

Example 12 with MsoException

use of org.onap.so.openstack.exceptions.MsoException in project so by onap.

the class NovaClientImpl method deleteKeyPair.

/**
 * Deletes a keypair inside openstack
 *
 * @param cloudSiteId the cloud site id
 * @param tenantId the tenant id
 * @param keyPairName name of the keypair to be deleted
 * @throws MsoCloudSiteNotFound the mso cloud site not found
 * @throws NeutronClientException if the client cannot be built this is thrown
 */
public void deleteKeyPair(String cloudSiteId, String tenantId, String keyPairName) throws MsoCloudSiteNotFound, NovaClientException {
    try {
        Nova novaClient = client.getNovaClient(cloudSiteId, tenantId);
        OpenStackRequest<Void> request = novaClient.keyPairs().delete(keyPairName);
        executeAndRecordOpenstackRequest(request, false);
    } catch (MsoException e) {
        logger.error("Error building Nova Client", e);
        throw new NovaClientException("Error building Nova Client", e);
    }
}
Also used : MsoException(org.onap.so.openstack.exceptions.MsoException) Nova(com.woorea.openstack.nova.Nova)

Example 13 with MsoException

use of org.onap.so.openstack.exceptions.MsoException in project so by onap.

the class MsoCommonUtilsTest method testRuntimeExceptionToMsoException.

@Test
public final void testRuntimeExceptionToMsoException() {
    RuntimeException re = new RuntimeException("runtime");
    MsoException me = commonUtils.runtimeExceptionToMsoException(re, "ContextError");
    assertTrue(me instanceof MsoAdapterException);
    assertTrue("ContextError".equals(me.getContext()));
    assertTrue(MsoExceptionCategory.INTERNAL.equals(me.getCategory()));
}
Also used : MsoException(org.onap.so.openstack.exceptions.MsoException) MsoAdapterException(org.onap.so.openstack.exceptions.MsoAdapterException) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 14 with MsoException

use of org.onap.so.openstack.exceptions.MsoException in project so by onap.

the class MsoMulticloudUtilsTest method createStackMulticloudClientIsNull.

@Ignore
@Test
public void createStackMulticloudClientIsNull() {
    try {
        multicloudUtilsMock.cloudConfig = cloudConfigMock;
        CloudSite cloudSite = new CloudSite();
        cloudSite.setIdentityService(new CloudIdentity());
        when(cloudConfigMock.getCloudSite("MTN13")).thenReturn(Optional.of(cloudSite));
        multicloudUtilsMock.createStack("MNT14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false, false);
    } catch (MsoException e) {
        assertEquals("0 : Multicloud client could not be initialized", e.toString());
        return;
    }
    fail("MsoOpenstackException expected!");
}
Also used : MsoException(org.onap.so.openstack.exceptions.MsoException) CloudSite(org.onap.so.db.catalog.beans.CloudSite) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) VduModelInfo(org.onap.so.adapters.vdu.VduModelInfo) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 15 with MsoException

use of org.onap.so.openstack.exceptions.MsoException in project so by onap.

the class MsoMulticloudUtilsTest method createStackBadRequest.

@Test
public void createStackBadRequest() {
    try {
        wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_BAD_REQUEST)));
        multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false, false);
    } catch (MsoException e) {
        assertEquals("0 : Bad Request", e.toString());
        return;
    }
    fail("MsoOpenstackException expected!");
}
Also used : MsoException(org.onap.so.openstack.exceptions.MsoException) VduModelInfo(org.onap.so.adapters.vdu.VduModelInfo) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Aggregations

MsoException (org.onap.so.openstack.exceptions.MsoException)53 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)12 CloudSite (org.onap.so.db.catalog.beans.CloudSite)12 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)12 Nova (com.woorea.openstack.nova.Nova)10 StackInfo (org.onap.so.openstack.beans.StackInfo)10 Quantum (com.woorea.openstack.quantum.Quantum)9 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)9 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)8 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)8 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 BaseTest (org.onap.so.BaseTest)7 MsoIOException (org.onap.so.openstack.exceptions.MsoIOException)7 HashMap (java.util.HashMap)6 VnfException (org.onap.so.adapters.vnf.exceptions.VnfException)6 MsoCloudSiteNotFound (org.onap.so.openstack.exceptions.MsoCloudSiteNotFound)6 IOException (java.io.IOException)5 NetworkException (org.onap.so.adapters.network.exceptions.NetworkException)5 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)5