diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index dfb6e35546c792eb2acfc9236ba9469c0c763ca4..9c1fc9243318db2d781901e8852d392dfaa47a39 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -13,7 +13,8 @@ <module name="AvoidStarImport"> <property name="excludes" value="java.io,java.util,java.util.concurrent,com.google.common.graph, org.apache.bcel.classfile,org.mongodb.morphia.annotations,de.ugoe.cs.comfort.data.models, - org.apache.bcel.generic,org.jacoco.core.data,com.github.javaparser.ast.stmt" /> + org.apache.bcel.generic,org.jacoco.core.data,com.github.javaparser.ast.stmt, + org.eclipse.cmf.occi.core"/> </module> <module name="ConstantName"/> <module name="EmptyBlock"> @@ -41,12 +42,14 @@ <module name="LeftCurly"/> <module name="RightCurly"> <property name="id" value="RightCurlySame"/> - <property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/> + <property name="tokens" + value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/> </module> <module name="RightCurly"> <property name="id" value="RightCurlyAlone"/> <property name="option" value="alone"/> - <property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/> + <property name="tokens" + value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/> </module> <module name="OneStatementPerLine"/> diff --git a/de.ugoe.cs.rwm.mocci.connector/build.gradle b/de.ugoe.cs.rwm.mocci.connector/build.gradle index 1baa0e885575d196aba9fab2139d72aa0f3e4c04..39f14e686fe00b40e8f736fc45786dba9be57fc2 100644 --- a/de.ugoe.cs.rwm.mocci.connector/build.gradle +++ b/de.ugoe.cs.rwm.mocci.connector/build.gradle @@ -6,9 +6,9 @@ dependencies { compile group: 'org.modmacao.occi', name: 'platform', version: '1.0.0' compile group: 'org.modmacao', name: 'cm', version: '1.0.0' compile group: 'org.modmacao', name: 'core', version: '1.0.0' - compile group: 'org.modmacao.core', name: 'connector', version : '1.0.0' + compile group: 'org.modmacao.core', name: 'connector', version: '1.0.0' compile group: 'commons-io', name: 'commons-io', version: '2.6' - + //maven compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore', version: '2.15.0' @@ -21,31 +21,32 @@ sourceSets { main { java { srcDir 'src-gen' - } - //output.classesDir = "$workDir/client/program" } + //output.classesDir = "$workDir/client/program" } - +} + processResources { - from("."){ - include("plugin.xml") - } + from(".") { + include("plugin.xml") + include("mocci.properties") + } } - - + + uploadArchives { repositories { - mavenDeployer { - repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") { - authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD')) + mavenDeployer { + repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") { + authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD')) } - if (System.getenv('VERSION') != null) { - pom.version = System.getenv('VERSION') - println "Version is set to: " + System.getenv('VERSION') - } - pom.version = "SNAPSHOT" - pom.artifactId = "connector" - pom.groupId = "de.ugoe.cs.rwm.mocci" - } + if (System.getenv('VERSION') != null) { + pom.version = System.getenv('VERSION') + println "Version is set to: " + System.getenv('VERSION') + } + pom.version = "SNAPSHOT" + pom.artifactId = "connector" + pom.groupId = "de.ugoe.cs.rwm.mocci" + } } } diff --git a/de.ugoe.cs.rwm.mocci.connector/mocci.properties b/de.ugoe.cs.rwm.mocci.connector/mocci.properties new file mode 100644 index 0000000000000000000000000000000000000000..a165cd72248c47cd4b1de98d0e3b874125ae74bc --- /dev/null +++ b/de.ugoe.cs.rwm.mocci.connector/mocci.properties @@ -0,0 +1 @@ +default_endpoint=172.19.0.1:8080 \ No newline at end of file diff --git a/de.ugoe.cs.rwm.mocci.connector/src-gen/de/ugoe/cs/rwm/mocci/connector/ResultproviderConnector.java b/de.ugoe.cs.rwm.mocci.connector/src-gen/de/ugoe/cs/rwm/mocci/connector/ResultproviderConnector.java index a3f6c7ebf744700f7be876c98ced0c289e2a3aca..ffaba2605155658584118d2a1ace8ee6cd2fd912 100644 --- a/de.ugoe.cs.rwm.mocci.connector/src-gen/de/ugoe/cs/rwm/mocci/connector/ResultproviderConnector.java +++ b/de.ugoe.cs.rwm.mocci.connector/src-gen/de/ugoe/cs/rwm/mocci/connector/ResultproviderConnector.java @@ -19,14 +19,12 @@ import java.util.LinkedList; import java.util.List; import java.util.NoSuchElementException; -import org.eclipse.cmf.occi.core.AttributeState; -import org.eclipse.cmf.occi.core.Link; -import org.eclipse.cmf.occi.core.MixinBase; -import org.eclipse.cmf.occi.core.Resource; +import org.eclipse.cmf.occi.core.*; import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import de.ugoe.cs.rwm.mocci.connector.util.PropertiesHelper; import monitoring.Monitorableproperty; import monitoring.Occiresultprovider; import monitoring.Sensor; @@ -70,6 +68,14 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl @Override public void occiCreate() { LOGGER.debug("occiCreate() called on " + this); + + // check for default provider endpoint + if (rspIsDefined() == false) { + MixinBase mixB = getMartMixin(); + Occiresultprovider orp = (Occiresultprovider) mixB; + orp.setResultProviderEndpoint(getDefaultEndpoint()); + getEndpointAttribute(orp).setValue(getDefaultEndpoint()); + } // TODO: Implement this callback or remove this method. } // End of user code @@ -238,6 +244,52 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl workaround.add(monObjectAttr); } + private AttributeState getEndpointAttribute(Occiresultprovider orp) { + for (AttributeState as : orp.getAttributes()) { + if (as.getName().equals("result.provider.endpoint")) { + return as; + } + } + AttributeState as = OCCIFactory.eINSTANCE.createAttributeState(); + as.setName("result.provider.endpoint"); + orp.getAttributes().add(as); + return as; + } + + private boolean rspIsDefined() { + MixinBase mixB = getMartMixin(); + if (mixB != null) { + Occiresultprovider orp = (Occiresultprovider) mixB; + if (orp.getResultProviderEndpoint() == null || orp.getResultProviderEndpoint().equals("")) { + return false; + } + for (AttributeState as : this.getAttributes()) { + if (as.getName().equals("occi.result.provider.endpoint")) { + if (as.getValue() == null || as.getValue().equals("")) { + return false; + } + } + } + for (AttributeState as : orp.getAttributes()) { + if (as.getName().equals("occi.result.provider.endpoint")) { + if (as.getValue() == null || as.getValue().equals("")) { + return false; + } + } + } + } + return true; + } + + private String getDefaultEndpoint() { + String defaultEndpoint = new PropertiesHelper().getProperties().getProperty("default_endpoint"); + if (defaultEndpoint == null || defaultEndpoint.equals("")) { + return "localhost"; + } + System.out.println("Using default endpoint: " + defaultEndpoint); + return defaultEndpoint; + } + private Sensor getSensor() { for (Link link : this.getRlinks()) { if (link.getSource() instanceof Sensor) {