Commit 483fa864 authored by Spiros Koulouzis's avatar Spiros Koulouzis

removed status. It is now set as current state

parent 98c7bd7a
......@@ -155,6 +155,10 @@ node_types:
ssh_keys:
type: tosca.datatypes.ARTICONF.Credential
required: false
artifacts:
provisioned_files:
type: string
required: false
interfaces:
CloudsStorm:
type: tosca.interfaces.ARTICONF.CloudsStorm
......
......@@ -290,16 +290,6 @@ public class ToscaHelper {
return "vm_user";
}
public CloudsStormSubTopology.StatusEnum getVMTopologyTemplateStatus(NodeTemplateMap nodeTemplateMap) throws TypeExeption {
NodeTemplate nodeTemplate = nodeTemplateMap.getNodeTemplate();
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
String status = (String) nodeTemplate.getAttributes().get("status");
return CloudsStormSubTopology.StatusEnum.fromValue(status);
} else {
throw new TypeExeption("NodeTemplateMap is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType());
}
}
public NODE_STATES getNodeCurrentState(NodeTemplateMap node) {
return getNodeState(node, "current_state");
}
......
......@@ -420,25 +420,6 @@ public class ToscaHelperTest {
}
}
/**
* Test of getVMTopologyTemplateStatus method, of class ToscaHelper.
*/
@Test
public void testGetVMTopologyTemplateStatus() throws Exception {
if (serviceUp) {
System.out.println("getVMTopologyTemplateStatus");
toscaTemplateWithCredentials = null;
instance.uploadToscaTemplate(provisionedToscaTemplate);
List<NodeTemplateMap> vmTopologies = instance.getVMTopologyTemplates();
for (NodeTemplateMap vmTopology : vmTopologies) {
CloudsStormSubTopology.StatusEnum status = instance.getVMTopologyTemplateStatus(vmTopology);
assertEquals(CloudsStormSubTopology.StatusEnum.RUNNING, status);
}
}
}
/**
* Test of getKeyPairsFromVM method, of class ToscaHelper.
......
......@@ -160,7 +160,6 @@ public class DRIPService {
if (nodeNames == null || nodeNames.isEmpty()) {
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
for (NodeTemplateMap vmTopology : vmTopologies) {
CloudsStormSubTopology.StatusEnum status = helper.getVMTopologyTemplateStatus(vmTopology);
toscaTemplate = setDesieredSate(toscaTemplate, vmTopologies, NODE_STATES.DELETED);
}
return execute(toscaTemplate, provisionerQueueName);
......
......@@ -26,12 +26,8 @@ import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormInfrasCode;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.cloud.storm.CredentialInfo;
import nl.uva.sne.drip.model.cloud.storm.InfrasCode;
import nl.uva.sne.drip.model.cloud.storm.OpCode;
import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import static nl.uva.sne.drip.provisioner.CloudStormService.APP_FOLDER_NAME;
import static nl.uva.sne.drip.provisioner.CloudStormService.INFRASTUCTURE_CODE_FILE_NAME;
import static nl.uva.sne.drip.provisioner.CloudStormService.INFS_FOLDER_NAME;
......@@ -41,6 +37,7 @@ import static nl.uva.sne.drip.provisioner.CloudStormService.TOP_TOPOLOGY_FILE_NA
import static nl.uva.sne.drip.provisioner.CloudStormService.UC_FOLDER_NAME;
import static nl.uva.sne.drip.provisioner.CloudStormService.UD_FOLDER_NAME;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.apache.commons.io.FilenameUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
......@@ -93,106 +90,90 @@ public class CloudStormServiceTest {
public void tearDown() {
}
// /**
// * Test of execute method, of class CloudStormService.
// */
private void initPaths() throws FileNotFoundException {
tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
topologyTempInputDirPath = tempInputDirPath + TOPOLOGY_RELATIVE_PATH;
topologyTempInputDir = new File(topologyTempInputDirPath);
if (!(topologyTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
credentialsTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UC_FOLDER_NAME;
File credentialsTempInputDir = new File(credentialsTempInputDirPath);
if (!(credentialsTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + credentialsTempInputDir.getAbsolutePath());
}
providersDBTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UD_FOLDER_NAME;
File providersDBTempInputDir = new File(providersDBTempInputDirPath);
if (!(providersDBTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + providersDBTempInputDir.getAbsolutePath());
}
infrasCodeTempInputDirPath = tempInputDirPath + File.separator + APP_FOLDER_NAME;
File infrasCodeTempInputDir = new File(infrasCodeTempInputDirPath);
if (!(infrasCodeTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
}
private CloudStormService getService(String messagefilePath) throws IOException, JsonProcessingException, ApiException {
Message message = objectMapper.readValue(new File(messagefilePath), Message.class);
return new CloudStormService(RPCServer.getProp(), message.getToscaTemplate());
}
/**
* Test of execute method, of class CloudStormService.
*/
// @Test
// public void testExecute() throws Exception {
// if (ToscaHelper.isServiceUp(sureToscaBasePath)) {
// System.out.println("execute");
// CloudStormService instance = null;
// ToscaTemplate expResult = null;
// ToscaTemplate result = instance.execute();
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// CloudStormService instance = getService(messageExampleProvisioneRequestFilePath);
// instance.execute();
// }
//
// /**
// * Test of writeCloudStormTopologyFiles method, of class CloudStormService.
// */
// @Test
// public void testWriteCloudStormTopologyFiles() throws Exception {
// System.out.println("writeCloudStormTopologyFiles");
// Map<String, Object> result = instance.writeCloudStormTopologyFiles(tempInputDirPath);
// assertNull(result);
// }
//
// /**
// * Test of buildSSHKeyPair method, of class CloudStormService.
// */
// @Test
// public void testBuildSSHKeyPair() throws Exception {
// System.out.println("buildSSHKeyPair");
// String result = instance.buildSSHKeyPair(tempInputDirPath, null);
// assertNotNull(result);
// String userPublicKeyName = "id_rsa.pub";
// String userPrivateName = FilenameUtils.removeExtension(userPublicKeyName);
// assertTrue(new File(tempInputDirPath + File.separator + userPrivateName).exists());
// assertTrue(new File(tempInputDirPath + File.separator + userPublicKeyName).exists());
//
// }
//
// /**
// * Test of getCloudsStormSubTopologiesAndVMs method, of class
// * CloudStormService.
// */
// @Test
// public void testGetCloudsStormSubTopologiesAndVMs() throws Exception {
// System.out.println("getCloudsStormSubTopologiesAndVMs");
// String tempInputDirPath = "";
// CloudStormService instance = null;
// Map<String, Object> expResult = null;
// Map<String, Object> result = instance.getCloudsStormSubTopologiesAndVMs(tempInputDirPath);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
//
// /**
// * Test of getBestMatchingCloudStormVM method, of class CloudStormService.
// */
// @Test
// public void testGetBestMatchingCloudStormVM() throws Exception {
// System.out.println("getBestMatchingCloudStormVM");
// NodeTemplateMap vmMap = null;
// String provider = "";
// CloudStormService instance = null;
// CloudsStormVM expResult = null;
// CloudsStormVM result = instance.getBestMatchingCloudStormVM(vmMap, provider);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
//
// /**
// * Test of writeCloudStormCredentialsFiles method, of class
// * CloudStormService.
// */
// @Test
// public void testWriteCloudStormCredentialsFiles() throws Exception {
// System.out.println("writeCloudStormCredentialsFiles");
// String credentialsTempInputDirPath = "";
// CloudStormService instance = null;
// instance.writeCloudStormCredentialsFiles(credentialsTempInputDirPath);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
//
// /**
// * Test of getCloudStormCredentialInfo method, of class CloudStormService.
// */
// @Test
// public void testGetCloudStormCredentialInfo() throws Exception {
// System.out.println("getCloudStormCredentialInfo");
// Credential toscaCredentials = null;
// String tmpPath = "";
// CloudStormService instance = null;
// CredentialInfo expResult = null;
// CredentialInfo result = instance.getCloudStormCredentialInfo(toscaCredentials, tmpPath);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
/**
* Test of writeCloudStormTopologyFiles method, of class CloudStormService.
*/
@Test
public void testWriteCloudStormTopologyFiles() throws Exception {
System.out.println("writeCloudStormTopologyFiles");
CloudStormService instance = getService(messageExampleProvisioneRequestFilePath);
Map<String, Object> result = instance.writeCloudStormTopologyFiles(tempInputDirPath);
assertNull(result);
}
/**
* Test of buildSSHKeyPair method, of class CloudStormService.
*/
@Test
public void testBuildSSHKeyPair() throws Exception {
System.out.println("buildSSHKeyPair");
CloudStormService instance = getService(messageExampleProvisioneRequestFilePath);
String result = instance.buildSSHKeyPair(tempInputDirPath, null);
assertNotNull(result);
String userPublicKeyName = "id_rsa.pub";
String userPrivateName = FilenameUtils.removeExtension(userPublicKeyName);
assertTrue(new File(tempInputDirPath + File.separator + userPrivateName).exists());
assertTrue(new File(tempInputDirPath + File.separator + userPublicKeyName).exists());
instance = getService(messageExampleDeleteRequestFilePath);
result = instance.buildSSHKeyPair(tempInputDirPath, null);
assertNotNull(result);
userPublicKeyName = "id_rsa.pub";
userPrivateName = FilenameUtils.removeExtension(userPublicKeyName);
assertTrue(new File(tempInputDirPath + File.separator + userPrivateName).exists());
assertTrue(new File(tempInputDirPath + File.separator + userPublicKeyName).exists());
}
/**
* Test of writeCloudStormInfrasCodeFiles method, of class
* CloudStormService.
......@@ -227,42 +208,7 @@ public class CloudStormServiceTest {
}
private void initPaths() throws FileNotFoundException {
tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
topologyTempInputDirPath = tempInputDirPath + TOPOLOGY_RELATIVE_PATH;
topologyTempInputDir = new File(topologyTempInputDirPath);
if (!(topologyTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
credentialsTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UC_FOLDER_NAME;
File credentialsTempInputDir = new File(credentialsTempInputDirPath);
if (!(credentialsTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + credentialsTempInputDir.getAbsolutePath());
}
providersDBTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UD_FOLDER_NAME;
File providersDBTempInputDir = new File(providersDBTempInputDirPath);
if (!(providersDBTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + providersDBTempInputDir.getAbsolutePath());
}
infrasCodeTempInputDirPath = tempInputDirPath + File.separator + APP_FOLDER_NAME;
File infrasCodeTempInputDir = new File(infrasCodeTempInputDirPath);
if (!(infrasCodeTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
}
private CloudStormService getService(String messagefilePath) throws IOException, JsonProcessingException, ApiException {
Message message = objectMapper.readValue(new File(messagefilePath), Message.class);
return new CloudStormService(RPCServer.getProp(), message.getToscaTemplate());
}
private void testWriteCloudStormInfrasFiles(String path, CloudsStormSubTopology.StatusEnum status, OpCode.OperationEnum opCode) throws IOException, JsonProcessingException, ApiException, Exception {
CloudStormService instance = getService(path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment