Search in sources :

Example 6 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoMulticloudUtils method deleteVdu.

/**
 * VduPlugin interface for delete function.
 */
@Override
public VduInstance deleteVdu(CloudInfo cloudInfo, String instanceId, int timeoutMinutes) throws VduException {
    String cloudSiteId = cloudInfo.getCloudSiteId();
    String cloudOwner = cloudInfo.getCloudOwner();
    String tenantId = cloudInfo.getTenantId();
    try {
        // Delete the Multicloud stack
        StackInfo stackInfo = deleteStack(cloudSiteId, cloudOwner, tenantId, instanceId);
        // Populate a VduInstance based on the deleted Cloudify Deployment object
        VduInstance vduInstance = stackInfoToVduInstance(stackInfo);
        // Override return state to DELETED (MulticloudUtils sets to NOTFOUND)
        vduInstance.getStatus().setState(VduStateType.DELETED);
        return vduInstance;
    } catch (Exception e) {
        throw new VduException("Delete VDU Exception", e);
    }
}
Also used : VduInstance(org.onap.so.adapters.vdu.VduInstance) StackInfo(org.onap.so.openstack.beans.StackInfo) MsoAdapterException(org.onap.so.openstack.exceptions.MsoAdapterException) VduException(org.onap.so.adapters.vdu.VduException) MsoOpenstackException(org.onap.so.openstack.exceptions.MsoOpenstackException) MalformedURLException(java.net.MalformedURLException) UriBuilderException(javax.ws.rs.core.UriBuilderException) MsoException(org.onap.so.openstack.exceptions.MsoException) VduException(org.onap.so.adapters.vdu.VduException)

Example 7 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoMulticloudUtils method queryVdu.

/**
 * VduPlugin interface for query function.
 */
@Override
public VduInstance queryVdu(CloudInfo cloudInfo, String instanceId) throws VduException {
    String cloudSiteId = cloudInfo.getCloudSiteId();
    String cloudOwner = cloudInfo.getCloudOwner();
    String tenantId = cloudInfo.getTenantId();
    try {
        // Query the Cloudify Deployment object and populate a VduInstance
        StackInfo stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
        return stackInfoToVduInstance(stackInfo);
    } catch (Exception e) {
        throw new VduException("MsoMulticloudUtils (queryVdu): queryStack Exception ", e);
    }
}
Also used : StackInfo(org.onap.so.openstack.beans.StackInfo) MsoAdapterException(org.onap.so.openstack.exceptions.MsoAdapterException) VduException(org.onap.so.adapters.vdu.VduException) MsoOpenstackException(org.onap.so.openstack.exceptions.MsoOpenstackException) MalformedURLException(java.net.MalformedURLException) UriBuilderException(javax.ws.rs.core.UriBuilderException) MsoException(org.onap.so.openstack.exceptions.MsoException) VduException(org.onap.so.adapters.vdu.VduException)

Example 8 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoHeatUtilsWithUpdateTest method updateStackWithEnvironmentTest.

@Test
public void updateStackWithEnvironmentTest() throws JsonParseException, JsonMappingException, IOException, MsoException {
    String environmentString = "environmentString";
    CloudSite cloudSite = new CloudSite();
    Heat heatClient = new Heat("endpoint");
    Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
    Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
    StackInfo expectedStackInfo = new StackInfo("stackName", HeatStatus.UPDATED, "stackStatusReason", null);
    expectedStackInfo.setCanonicalName("stackName/id");
    doReturn(heatClient).when(heatUtils).getHeatClient(isA(String.class), isA(String.class));
    doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(isA(OpenStackRequest.class));
    doReturn("0").when(environment).getProperty(isA(String.class), isA(String.class));
    doReturn(updateStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
    StackInfo actualStackInfo = heatUtils.updateStack(cloudSiteId, cloudOwner, tenantId, stackName, heatTemplate, stackInputs, pollForCompletion, timeoutMinutes, environmentString);
    assertThat(actualStackInfo, sameBeanAs(expectedStackInfo));
}
Also used : Heat(com.woorea.openstack.heat.Heat) CloudSite(org.onap.so.db.catalog.beans.CloudSite) OpenStackRequest(com.woorea.openstack.base.client.OpenStackRequest) File(java.io.File) StackInfo(org.onap.so.openstack.beans.StackInfo) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 9 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoMulticloudUtilsTest method createStackSuccess.

@Test
public void createStackSuccess() throws MsoException, IOException {
    wireMockServer.stubFor(post(urlEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_CREATED)).willSetStateTo("CREATING"));
    wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE").whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("MulticloudGetCreateResponse.json").withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH)).inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED)).willSetStateTo("UPDATING"));
    wireMockServer.stubFor(get(urlEqualTo(MULTICLOUD_GET_PATH)).inScenario("CREATE").whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("MulticloudGetUpdateResponse.json").withStatus(HttpStatus.SC_OK)));
    StackInfo result = multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), true, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false, false);
    wireMockServer.resetScenarios();
    assertNotNull(result);
    assertEquals("TEST-stack", result.getName());
}
Also used : VduModelInfo(org.onap.so.adapters.vdu.VduModelInfo) StackInfo(org.onap.so.openstack.beans.StackInfo) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 10 with StackInfo

use of org.onap.so.openstack.beans.StackInfo in project so by onap.

the class MsoHeatUtilsITTest method createStackSuccessTest.

@Test
public final void createStackSuccessTest() throws MsoException, IOException {
    CloudSite cloudSite = getCloudSite(getCloudIdentity());
    StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
    StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
    StubOpenStack.mockOpenStackGet(wireMockServer, "TEST-stack/stackId");
    StackInfo stackInfo = heatUtils.createStack(cloudSite.getId(), "CloudOwner", "tenantId", "TEST-stack", null, "TEST-heat", new HashMap<>(), false, 1, "TEST-env", new HashMap<>(), new HashMap<>(), false, false);
    assertNotNull(stackInfo);
}
Also used : CloudSite(org.onap.so.db.catalog.beans.CloudSite) StackInfo(org.onap.so.openstack.beans.StackInfo) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Aggregations

StackInfo (org.onap.so.openstack.beans.StackInfo)38 MsoException (org.onap.so.openstack.exceptions.MsoException)17 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 Stack (com.woorea.openstack.heat.model.Stack)9 CloudSite (org.onap.so.db.catalog.beans.CloudSite)8 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)8 VduException (org.onap.so.adapters.vdu.VduException)7 BaseTest (org.onap.so.BaseTest)6 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)6 Heat (com.woorea.openstack.heat.Heat)4 MalformedURLException (java.net.MalformedURLException)4 Response (javax.ws.rs.core.Response)4 UriBuilderException (javax.ws.rs.core.UriBuilderException)4 RestClient (org.onap.so.client.RestClient)4 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)4 StackInfoMapper (org.onap.so.openstack.mappers.StackInfoMapper)4 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)3 OpenStackRequest (com.woorea.openstack.base.client.OpenStackRequest)3 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)3