getCspSLAs(String id) {
- UUID uid = UUID.fromString(id);
- Csp csp = cspIdMap.get(uid);
- return csp.getSlas();
- }
-
- public Mcsla getMcsla(String id) {
- UUID uid = UUID.fromString(id);
- Mcsla mcsla = mcslaIdMap.get(uid);
- return mcsla;
- }
-
- public Mcsla updateMcsla(Mcsla mcsla) {
- UUID uid = mcsla.getmCSLA_id();
- if (uid == null)
- return null;
- System.out.println("McslaService:updateMcsla:id:" + uid);
- mcslaIdMap.put(uid, mcsla);
-
- // Push to repository
- try {
- GitControl gc = new GitControl();
- gc.pushMcslaToRepo(mcsla);
- } catch (IOException | GitAPIException e) {
- // TODO Auto-generated catch block
- System.out.println("McslaService:updateMcsla:FAILED");
- e.printStackTrace();
- return null;
- }
- System.out.println("McslaService:updateMcsla:--Done--");
- return mcsla;
-
- }
-
- public ProjectConfig getProjectConfig() {
-
- ConfigFileService configService = getConfigService();
- ProjectConfig projectConfig = new ProjectConfig(configService.getGitremotepath(),
- configService.getGitusername());
- return projectConfig;
- }
-
- // operation on GET MCSLAfrom repo
- public Mcsla getMcsla() {
- Mcsla mcsla;
- // Get from repository
- try {
- GitControl gc = new GitControl();
- mcsla = gc.getMcslaFromRepo();
- } catch (IOException | GitAPIException e) {
- // TODO Auto-generated catch block
- System.out.println("McslaService:getMcsla:FAILED");
- e.printStackTrace();
- return null;
- }
- System.out.println("McslaService:getMcsla:--Done--");
- return mcsla;
- }
-
-}
diff --git a/MCSLA/MCSLAService/src/main/resources/application.properties b/MCSLA/MCSLAService/src/main/resources/application.properties
deleted file mode 100644
index 3a5d92dff8a5c58311f76cac58dc33fe78ece973..0000000000000000000000000000000000000000
--- a/MCSLA/MCSLAService/src/main/resources/application.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-logging.level.com.concretepage= INFO
-decide.app.git.remote-path= https://gitlab.fokus.fraunhofer.de/tja/test.git
-decide.app.git.user-name= test
-decide.app.git.user-password= testpassword
-# this is just for test the srv with JerseyClient.java
-# decide.mcsla.srv=http://localhost:8080/decide.mcsla.srv
\ No newline at end of file
diff --git a/MCSLA/MCSLAService/src/main/webapp/WEB-INF/springrest-servlet.xml b/MCSLA/MCSLAService/src/main/webapp/WEB-INF/springrest-servlet.xml
deleted file mode 100644
index 196b41073904e16cf1e8155fe553ae98762b7c17..0000000000000000000000000000000000000000
--- a/MCSLA/MCSLAService/src/main/webapp/WEB-INF/springrest-servlet.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/MCSLA/MCSLAService/src/main/webapp/WEB-INF/web.xml b/MCSLA/MCSLAService/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 12c49881c8876d6f35095748c0a45dbdb65adf1a..0000000000000000000000000000000000000000
--- a/MCSLA/MCSLAService/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Archetype Created Web Application
-
- springrest
-
- org.springframework.web.servlet.DispatcherServlet
-
- 1
-
-
-
- springrest
- /
-
-
diff --git a/MCSLA/MCSLAService/src/main/webapp/index.jsp b/MCSLA/MCSLAService/src/main/webapp/index.jsp
deleted file mode 100644
index 700676689f817f6ae81bfaf5a116ffa722f9cda0..0000000000000000000000000000000000000000
--- a/MCSLA/MCSLAService/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- DECIDE MCSLA Service (v2)
-
- Get method All mcslas
-
-
- Get method mcsla
-
-
- Get method All csps
-
-
- Get method config
-
-
-
\ No newline at end of file
diff --git a/MCSLA/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/JerseyClient.java b/MCSLA/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/JerseyClient.java
deleted file mode 100644
index 40218e649a97ad5dc2209b9f43f9c204c9d1262c..0000000000000000000000000000000000000000
--- a/MCSLA/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/JerseyClient.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package eu.DECIDEh2020.mcsla.service.tests;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-import eu.DECIDEh2020.mcsla.beans.Csp;
-import eu.DECIDEh2020.mcsla.beans.Mcsla;
-import eu.DECIDEh2020.mcsla.beans.Metric;
-import eu.DECIDEh2020.mcsla.beans.MicroserviceSLA;
-import eu.DECIDEh2020.mcsla.beans.MicroserviceSLO;
-import eu.DECIDEh2020.mcsla.beans.MicroserviceSQO;
-import eu.DECIDEh2020.mcsla.beans.Remedy;
-import eu.DECIDEh2020.mcsla.beans.UnderlyingMetricRef;
-import eu.DECIDEh2020.mcsla.beans.ViolationTriggerRule;
-import eu.DECIDEh2020.mcsla.service.configuration.ProjectConfig;
-
-public class JerseyClient {
- private static final String SRV_MCSLAS = "http://localhost:8080/decide.mcsla.srv/mcslas";
- private static final String SRV_CSPS = "http://localhost:8080/decide.mcsla.srv/csps";
- private static final String SRV_CONFIG = "http://localhost:8080/decide.mcsla.srv/config";
- private static final String SRV_AGGREGATE = "http://localhost:8080/decide.mcsla.srv/aggregate";
-
- public static void main(String[] args) {
-
- System.out.println("####################TEST MAIN START####################");
- JerseyClient jerseyClient = new JerseyClient();
- ProjectConfig config = jerseyClient.getProjectConfig();
- System.out.println(
- "Main:got ProjectConfig user:" + config.getGitusername() + " path:" + config.getGitremotepath());
- // jerseyClient.getMcslaDetails();
- // get currently used CSPs returns CSP SLAs
- MicroserviceSLA[] slas = jerseyClient.getCspSLAs();
- System.out.println("Main:got CSP SLAs:" + slas.length);
- // Prepare SLOs to send to MCSLA Aggregator
- MicroserviceSLO[] slos = buildSLOs(slas);
- System.out.println("Main:got list SLOs:" + slos.length);
- // Return aggregated SLO
- MicroserviceSLO aggregatedSLO = jerseyClient.applyAggregationRules(slos);
- if (aggregatedSLO != null)
- System.out.println("Main:got aggregated SLO:" + aggregatedSLO.termName);
- else
- System.out.println("Main:got aggregated SLO is NULL :-(");
- // if (true)
- // return;
- Mcsla mcsla = createMCSLAexample(aggregatedSLO);
- jerseyClient.addMcsla(mcsla);
- System.out.println("Main:addMcsla done.");
-
- DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- Date date = new Date();
- mcsla.setDescription("this is MCSLA UPDATED at:" + dateFormat.format(date) + " description line.");
- mcsla = jerseyClient.updateMcsla(mcsla);
- if (mcsla == null) {
- System.out.println("Main:got updated mcsla is NULL :-(");
- return;
- } else
- System.out.println("Main:updateMcsla done.");
-
- mcsla = jerseyClient.getMcslaById(mcsla.mCSLA_id.toString());
- System.out.println("Main:getMcslaById:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription());
- // jerseyClient.deleteMcsla(mcsla.getmCSLA_id());
- System.out.println("####################TEST MAIN DONE####################");
-
- }
-
- private ProjectConfig getProjectConfig() {
- RestTemplate restTemplate = new RestTemplate();
- ProjectConfig pconfig = restTemplate.getForObject(SRV_CONFIG, ProjectConfig.class);
- System.out.println("JerseyClient:getAppConfig:" + pconfig.getGitusername() + ", " + pconfig.getGitremotepath());
- return pconfig;
- }
-
- @SuppressWarnings("unused")
- private static MicroserviceSLA addSQOs(MicroserviceSLA sla) {
- UUID uuid = UUID.randomUUID();
-
- List sqos = new ArrayList<>();
- MicroserviceSQO sqo = new MicroserviceSQO();
- sqo.setMicroservice_SQO_id(uuid.toString());
- sqo.set__comment("CPU Uitlization will not be less then 85% of the time Over a Day");
- sqo.setTermName("CPU-utilization");
- sqo.setMonitoringResult("result");
- sqo.setValue("95");
- sqo.setUnit("percentage");
- sqo.setCalculationFormula("CPU-utilization LT 85");
- List vtrs = new ArrayList<>();
- ViolationTriggerRule vtr = new ViolationTriggerRule();
- vtr.setBreaches_count(2);
- vtr.setViointerval(30);
- vtrs.add(vtr);
- sqo.setViolationTriggerRule(vtrs);
- Remedy remedy = new Remedy();
- remedy.setType("discount");
- remedy.setUnit("%");
- remedy.setValidity("P1D");
- remedy.setValue(5);
- sqo.setRemedy(remedy);
-
- List metrics = new ArrayList<>();
- Metric metric = new Metric();
- metric.setMetric_id("CSA_002");
- metric.setDescriptor("CloudServiceAvailability");
- UnderlyingMetricRef underlyingMetricRef = new UnderlyingMetricRef();
- underlyingMetricRef.setRefid("TQD_001");
- metric.setUnderlyingMetricRef(underlyingMetricRef);
- metrics.add(metric);
- sqo.setMetrics(metrics);
- sqos.add(sqo);
- sla.setMicroservice_SQOs(sqos);
- return sla;
- }
-
- private static MicroserviceSLO[] buildSLOs(MicroserviceSLA[] slas) {
- List sloslist = new ArrayList<>();
- for (MicroserviceSLA sla : slas) {
- if (sla.getMicroservice_SLOs() != null)
- sloslist.addAll(sla.getMicroservice_SLOs());
- }
- MicroserviceSLO[] slos = new MicroserviceSLO[sloslist.size()];
- slos = sloslist.toArray(slos);
- return slos;
- }
-
- private static Mcsla createMCSLAexample(MicroserviceSLO slo) {
-
- UUID uid = UUID.randomUUID();
- String randomUUIDString = uid.toString();
- Mcsla mcsla = new Mcsla();
- mcsla.setmCSLA_id(uid);
- mcsla.setDescription("this is MCSLA dummy description line created from createMCSLAexample method.");
- mcsla.setVisibility("public");
- mcsla.setValidityPeriod("this is Validity Period line.");
- List slas = new ArrayList<>();
-
- UUID uuid = UUID.randomUUID();
- MicroserviceSLA sla = new MicroserviceSLA();
- sla.setMicroservice_SLA_id(uuid.toString());
- sla.set__comment(slo.__comment);
- uuid = UUID.randomUUID();
- randomUUIDString = uuid.toString();
- // TODO fix this need valid CSP
- sla.setCsp_id(randomUUIDString);
- // TODO fix this need valid setValidityPeriod
- sla.setValidityPeriod(Integer.toString(5));
- sla.setVisibility("public");
- uuid = UUID.randomUUID();
- randomUUIDString = uuid.toString();
- sla.setMicroservice_id(randomUUIDString);
- List slos = new ArrayList<>();
-
- slos.add(slo);
- sla.setMicroservice_SLOs(slos);
- slas.add(sla);
- mcsla.setMicroservice_SLAs(slas);
-
- return mcsla;
-
- }
-
- public void addMcsla(Mcsla mcsla) {
- // It is used to create new resource. Method POST
- RestTemplate restTemplate = new RestTemplate();
- HttpEntity request = new HttpEntity<>(mcsla);
- Mcsla resMcsla = restTemplate.postForObject(SRV_MCSLAS, request, Mcsla.class);
- if (resMcsla == null)
- System.out.println("JerseyClient:addMcsla:FAILED");
- else
- System.out.println("JerseyClient:addMcsla:" + resMcsla.getmCSLA_id() + ", " + resMcsla.getDescription());
- }
-
- private MicroserviceSLO applyAggregationRules(MicroserviceSLO[] slos) {
- System.out.printf("JerseyClient:applyAggregationRules to %s SLOs %n", slos.length);
- RestTemplate restTemplate = new RestTemplate();
- HttpEntity requestEntity = new HttpEntity(slos);
- HttpEntity response = restTemplate.exchange(SRV_AGGREGATE, HttpMethod.POST, requestEntity,
- MicroserviceSLO.class);
- MicroserviceSLO resSLO = response.getBody();
- System.out.println(
- "JerseyClient:applyAggregationRules:" + resSLO.getMicroservice_SLO_id() + ", " + resSLO.getTermName());
- return resSLO;
- }
-
- public void deleteMcsla(UUID uid) {
- RestTemplate restTemplate = new RestTemplate();
- String entityUrl = SRV_MCSLAS + "/" + uid.toString();
- restTemplate.delete(entityUrl);
- }
-
- public MicroserviceSLA[] getCspSLAs() {
- RestTemplate restTemplate = new RestTemplate();
- ResponseEntity responseEntity = restTemplate.getForEntity(SRV_CSPS, Csp[].class);
- Csp[] csplist = responseEntity.getBody();
-
- List slaslist = new ArrayList<>();
- // for each CSP get SLAs
- for (int index = 0; index < csplist.length; index++) {
- ResponseEntity responseEntitylist = restTemplate.getForEntity(SRV_CSPS + "/{id}",
- MicroserviceSLA[].class, csplist[index].getmCSP_id());
- MicroserviceSLA[] slas = responseEntitylist.getBody();
- List cspslas = new ArrayList(Arrays.asList(slas));
- slaslist.addAll(cspslas);
- }
-
- System.out.println("JerseyClient:getCspSLAs:" + slaslist.size());
- return slaslist.toArray(new MicroserviceSLA[slaslist.size()]);
- }
-
- public Mcsla getMcslaById(String id) {
- RestTemplate restTemplate = new RestTemplate();
- Mcsla mcsla = restTemplate.getForObject(SRV_MCSLAS + "/{id}", Mcsla.class, id);
- System.out.println("JerseyClient:getMcslaById:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription());
- return mcsla;
- }
-
- public void getMcslaDetails() {
- RestTemplate restTemplate = new RestTemplate();
- ResponseEntity responseEntity = restTemplate.getForEntity(SRV_MCSLAS, Mcsla[].class);
- Mcsla[] list = responseEntity.getBody();
- // HttpStatus statusCode = responseEntity.getStatusCode();
- // System.out.println("HttpStatus:getMcslaDetails:" +
- // statusCode.value());
-
- for (int index = 0; index < list.length; index++) {
- System.out.println(list[index].getmCSLA_id() + ", " + list[index].getDescription());
- }
- }
-
- public Mcsla updateMcsla(Mcsla mcsla) {
- // It is generally used to update resource, METHOD PUT
- System.out.println("JerseyClient:updateMcsla:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription());
- RestTemplate restTemplate = new RestTemplate();
- HttpEntity requestEntity = new HttpEntity(mcsla);
- HttpEntity response = restTemplate.exchange(SRV_MCSLAS, HttpMethod.PUT, requestEntity, Mcsla.class);
- Mcsla resMcsla = response.getBody();
- if (resMcsla == null)
- System.out.println("JerseyClient:updateMcsla:FAILED");
- return resMcsla;
- }
-}
diff --git a/MCSLA/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/TestGit.java b/MCSLA/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/TestGit.java
deleted file mode 100644
index f2a068022cf0fe18ef959bcd98d5403ed34c4c2d..0000000000000000000000000000000000000000
--- a/MCSLA/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/TestGit.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package eu.DECIDEh2020.mcsla.service.tests;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.UUID;
-
-import org.eclipse.jgit.api.errors.CanceledException;
-import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
-import org.eclipse.jgit.api.errors.DetachedHeadException;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.api.errors.InvalidConfigurationException;
-import org.eclipse.jgit.api.errors.InvalidRemoteException;
-import org.eclipse.jgit.api.errors.NoFilepatternException;
-import org.eclipse.jgit.api.errors.NoHeadException;
-import org.eclipse.jgit.api.errors.NoMessageException;
-import org.eclipse.jgit.api.errors.RefNotFoundException;
-import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
-
-import eu.DECIDEh2020.mcsla.beans.Mcsla;
-import eu.DECIDEh2020.mcsla.service.git.GitControl;
-
-public class TestGit {
-
- public static void main(String[] args) throws IOException, GitAPIException {
-
- Mcsla mcsla = new Mcsla(UUID.randomUUID(), "this is MCSLA3 description line.", "public",
- "this is MCSLA3 setValidityPeriod line.");
- pushToRepo(mcsla);
-
- getFromRepo();
-
- }
-
- private static void getFromRepo()
- throws IOException, NoFilepatternException, GitAPIException, FileNotFoundException, NoHeadException,
- NoMessageException, ConcurrentRefUpdateException, WrongRepositoryStateException, InvalidRemoteException,
- InvalidConfigurationException, DetachedHeadException, CanceledException, RefNotFoundException {
-
- GitControl gc = new GitControl();
- // Push to repository
- Mcsla mcsla = gc.getMcslaFromRepo();
- System.out.println("TestGit:getFromRepo:" + mcsla.getmCSLA_id());
- }
-
- private static void pushToRepo(Mcsla mcsla)
- throws IOException, NoFilepatternException, GitAPIException, FileNotFoundException, NoHeadException,
- NoMessageException, ConcurrentRefUpdateException, WrongRepositoryStateException, InvalidRemoteException,
- InvalidConfigurationException, DetachedHeadException, CanceledException, RefNotFoundException {
-
- GitControl gc = new GitControl();
- // Push to repository
- gc.pushMcslaToRepo(mcsla);
- }
-
- @SuppressWarnings("unused")
- private static String getProperty(String key) {
- Properties prop = new Properties();
- InputStream input = null;
- String value = null;
- try {
-
- String propertiesfilename = "application.properties";
- input = TestGit.class.getClassLoader().getResourceAsStream(propertiesfilename);
- if (input == null) {
- System.out.println("Sorry, unable to find properties file:" + propertiesfilename);
- return null;
- }
-
- prop.load(input);
-
- value = prop.getProperty(key);
-
- } catch (IOException ex) {
- ex.printStackTrace();
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return value;
- }
-
-}
\ No newline at end of file
diff --git a/MCSLA/mcsla-core b/MCSLA/mcsla-core
deleted file mode 160000
index 87c3c3f7687905656f81034b72b5e809c1bc133e..0000000000000000000000000000000000000000
--- a/MCSLA/mcsla-core
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 87c3c3f7687905656f81034b72b5e809c1bc133e