use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class InstanceModelWebSocket method startInstanceModelRefinement.
private void startInstanceModelRefinement(QName serviceTemplate) {
Thread thread = new Thread(() -> {
this.instanceModelRefiner = new InstanceModelRefinement(this);
DataToSend dataToSend = new DataToSend();
dataToSend.topologyTemplate = this.instanceModelRefiner.refine(new ServiceTemplateId(serviceTemplate));
try {
this.sendAsync(dataToSend);
this.onClose(this.session);
} catch (JsonProcessingException e) {
logger.error("Error while sending final topology template!", e);
} catch (IOException e) {
logger.error("Error while closing web socket!", e);
}
});
thread.start();
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class RefinementWebSocket method onMessage.
@Override
@OnMessage
public void onMessage(String message, Session session) throws IOException {
RefinementWebSocketApiData data = JacksonProvider.mapper.readValue(message, RefinementWebSocketApiData.class);
switch(data.task) {
case START:
if (!running) {
Thread thread = new Thread(() -> {
RefinementElementApiData element = new RefinementElementApiData();
element.serviceTemplateContainingRefinements = refinement.refineServiceTemplate(new ServiceTemplateId(data.serviceTemplate));
try {
this.sendAsync(element);
this.session.close();
this.session = null;
} catch (JsonProcessingException e) {
LOGGER.error("Error while sending refinement result", e);
} catch (IOException e) {
LOGGER.error("Error while closing the session", e);
}
running = false;
});
this.running = true;
thread.start();
}
break;
case REFINE_WITH:
this.future.complete(data.refineWith);
break;
case STOP:
this.future.complete(-1);
this.sendAsync(new RefinementElementApiData(null, this.refinementServiceTemplate, null));
this.onClose(this.session);
break;
}
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class EnhancementUtilsTestWithGitBackedRepository method getAvailableFeaturesWhereASpecificRequirementIsSatisfied.
@Test
void getAvailableFeaturesWhereASpecificRequirementIsSatisfied() throws Exception {
this.setRevisionTo("origin/plain");
TServiceTemplate serviceTemplate = RepositoryFactory.getRepository().getElement(new ServiceTemplateId(QName.valueOf("{http://opentosca.org/add/management/to/instances/servicetemplates}STWithBasicManagementOnly_w1-wip2")));
Map<String, Map<QName, String>> availableFeaturesForTopology = // As we do not want to filter the features based on the deployment technology, the second parameter is null.
EnhancementUtils.getAvailableFeaturesForTopology(serviceTemplate.getTopologyTemplate(), Collections.emptyList());
assertEquals(2, availableFeaturesForTopology.size());
assertEquals(2, availableFeaturesForTopology.get("MySQL-Database_w2").size());
assertEquals(2, availableFeaturesForTopology.get("Ubuntu_16.04-w1").size());
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class EnhancementUtilsTestWithGitBackedRepository method applyFeaturesToTopology.
@Test
void applyFeaturesToTopology() throws Exception {
this.setRevisionTo("origin/plain");
TTopologyTemplate topology = RepositoryFactory.getRepository().getElement(new ServiceTemplateId(QName.valueOf("{http://opentosca.org/add/management/to/instances/servicetemplates}STWithBasicManagementOnly_w1-wip1"))).getTopologyTemplate();
// As we do not want to filter the features based on the deployment technology, the second parameter is null.
EnhancementUtils.applyFeaturesForTopology(topology, EnhancementUtils.getAvailableFeaturesForTopology(topology, Collections.emptyList()));
String ubuntuNodeTemplateId = "Ubuntu_16.04-w1";
String mySqlNodeTemplateId = "MySQL-Database_w1";
assertEquals(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes" + EnhancementUtils.GENERATED_NS_SUFFIX + "}Ubuntu_16.04-w1-" + ubuntuNodeTemplateId + "-Testing-Freeze_and_Defrost" + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_VERSION_PREFIX + "1"), topology.getNodeTemplate(ubuntuNodeTemplateId).getType());
assertEquals(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes" + EnhancementUtils.GENERATED_NS_SUFFIX + "}MySQL-Database_w1-" + mySqlNodeTemplateId + "-Freeze_and_defrost" + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_VERSION_PREFIX + "1"), topology.getNodeTemplate(mySqlNodeTemplateId).getType());
assertNotNull(ModelUtilities.getPropertiesKV(topology.getNodeTemplate(ubuntuNodeTemplateId)));
assertEquals(9, ModelUtilities.getPropertiesKV(topology.getNodeTemplate(ubuntuNodeTemplateId)).size());
assertNotNull(ModelUtilities.getPropertiesKV(topology.getNodeTemplate(mySqlNodeTemplateId)));
assertEquals(3, ModelUtilities.getPropertiesKV(topology.getNodeTemplate(mySqlNodeTemplateId)).size());
}
use of org.eclipse.winery.model.ids.definitions.ServiceTemplateId in project winery by eclipse.
the class InstanceModelUtilsTest method executeErrorCommandTest.
@Test
void executeErrorCommandTest() throws Exception {
this.setRevisionTo("origin/plain");
TServiceTemplate serviceTemplate = this.repository.getElement(new ServiceTemplateId("http://opentosca.org/servicetemplates", "SshTest_w1-wip1", false));
sshd.setCommandFactory((channel, command) -> new SupportErrorCommand(command) {
@Override
public String getReturnValue() {
return "error";
}
});
Session session = getSession(serviceTemplate);
String pwd = InstanceModelUtils.executeCommand(session, "pwd");
assertNotNull(pwd);
assertTrue(pwd.isEmpty());
}
Aggregations