Search in sources :

Example 6 with CloudInfo

use of org.onap.so.adapters.vdu.CloudInfo in project so by onap.

the class MsoHeatUtilsITTest method instantiateVduTest.

@Test
public void instantiateVduTest() throws MsoException, IOException {
    VduInstance expected = new VduInstance();
    expected.setVduInstanceId("name/da886914-efb2-4917-b335-c8381528d90b");
    expected.setVduInstanceName("name");
    VduStatus status = new VduStatus();
    status.setState(VduStateType.INSTANTIATED);
    status.setLastAction((new PluginAction("create", "complete", null)));
    expected.setStatus(status);
    CloudInfo cloudInfo = new CloudInfo();
    cloudInfo.setCloudSiteId("MTN13");
    cloudInfo.setTenantId("tenantId");
    VduModelInfo vduModel = new VduModelInfo();
    vduModel.setModelCustomizationUUID("blueprintId");
    vduModel.setTimeoutMinutes(1);
    VduArtifact artifact = new VduArtifact();
    artifact.setName("name");
    artifact.setType(ArtifactType.MAIN_TEMPLATE);
    byte[] content = new byte[1];
    artifact.setContent(content);
    List<VduArtifact> artifacts = new ArrayList<>();
    artifacts.add(artifact);
    vduModel.setArtifacts(artifacts);
    Map<String, byte[]> blueprintFiles = new HashMap<>();
    blueprintFiles.put(artifact.getName(), artifact.getContent());
    String instanceName = "stackname";
    Map<String, Object> inputs = new HashMap<>();
    boolean rollbackOnFailure = true;
    StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
    StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
    wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/stackname/stackId")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
    VduInstance actual = heatUtils.instantiateVdu(cloudInfo, instanceName, inputs, vduModel, rollbackOnFailure);
    assertThat(actual, sameBeanAs(expected));
}
Also used : CloudInfo(org.onap.so.adapters.vdu.CloudInfo) HashMap(java.util.HashMap) VduInstance(org.onap.so.adapters.vdu.VduInstance) VduStatus(org.onap.so.adapters.vdu.VduStatus) ArrayList(java.util.ArrayList) VduModelInfo(org.onap.so.adapters.vdu.VduModelInfo) PluginAction(org.onap.so.adapters.vdu.PluginAction) VduArtifact(org.onap.so.adapters.vdu.VduArtifact) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 7 with CloudInfo

use of org.onap.so.adapters.vdu.CloudInfo in project so by onap.

the class MsoHeatUtilsITTest method deleteVduTest.

@Test
public void deleteVduTest() throws Exception {
    VduInstance expected = new VduInstance();
    expected.setVduInstanceId("name/stackId");
    expected.setVduInstanceName("instanceId");
    VduStatus status = new VduStatus();
    status.setState(VduStateType.DELETED);
    expected.setStatus(status);
    CloudInfo cloudInfo = new CloudInfo();
    cloudInfo.setCloudSiteId("mtn13");
    cloudInfo.setTenantId("tenantId");
    String instanceId = "instanceId";
    int timeoutInMinutes = 1;
    StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
    wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
    StubOpenStack.mockOpenStackDelete(wireMockServer, "name/da886914-efb2-4917-b335-c8381528d90b");
    wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/name/da886914-efb2-4917-b335-c8381528d90b")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_DeleteComplete.json").withStatus(HttpStatus.SC_OK)));
    VduInstance actual = heatUtils.deleteVdu(cloudInfo, instanceId, timeoutInMinutes);
    assertThat(actual, sameBeanAs(expected));
}
Also used : CloudInfo(org.onap.so.adapters.vdu.CloudInfo) VduInstance(org.onap.so.adapters.vdu.VduInstance) VduStatus(org.onap.so.adapters.vdu.VduStatus) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 8 with CloudInfo

use of org.onap.so.adapters.vdu.CloudInfo in project so by onap.

the class MsoMulticloudUtilsTest method deleteVdu.

@Test
public void deleteVdu() throws VduException {
    CloudInfo cloudInfo = new CloudInfo("cloudSiteId", "cloudOwner", "tenantId", "tenantName");
    VduInstance vduInstance = multicloudUtils.deleteVdu(cloudInfo, "instanceId", 3);
    assertNotNull(vduInstance);
    assertTrue(VduStateType.DELETED == vduInstance.getStatus().getState());
}
Also used : CloudInfo(org.onap.so.adapters.vdu.CloudInfo) VduInstance(org.onap.so.adapters.vdu.VduInstance) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Aggregations

CloudInfo (org.onap.so.adapters.vdu.CloudInfo)8 VduInstance (org.onap.so.adapters.vdu.VduInstance)8 Test (org.junit.Test)4 BaseTest (org.onap.so.BaseTest)4 VduException (org.onap.so.adapters.vdu.VduException)4 VduPlugin (org.onap.so.adapters.vdu.VduPlugin)4 VnfException (org.onap.so.adapters.vnf.exceptions.VnfException)4 VduStatus (org.onap.so.adapters.vdu.VduStatus)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PluginAction (org.onap.so.adapters.vdu.PluginAction)2 VduModelInfo (org.onap.so.adapters.vdu.VduModelInfo)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 VduArtifact (org.onap.so.adapters.vdu.VduArtifact)1 VduStateType (org.onap.so.adapters.vdu.VduStateType)1 VnfAlreadyExists (org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists)1 CloudSite (org.onap.so.db.catalog.beans.CloudSite)1 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)1 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)1 HeatTemplateParam (org.onap.so.db.catalog.beans.HeatTemplateParam)1