Skip to content
Snippets Groups Projects
Commit cca36094 authored by erbel's avatar erbel
Browse files

Added CreateElements example

parent ecbc7981
No related branches found
No related tags found
No related merge requests found
Pipeline #86330 passed
# Project Title
[![build status](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/badges/master/pipeline.svg)](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/commits/master)
Mocci is a toolchain using the Open Cloud Computing Interface (OCCI) to enable a model-driven cloud orchestration of cloud deployments and its monitoring instruments.
Moreover, a runtime model manager is provided that grants access to gathered monitoring data.
......
......@@ -18,7 +18,7 @@
<b><a href="../updatesite.zip">Download Eclipse Plugin Archive</a></b>
</div>
<h1>WOCCI Model Report</h1>
<h1>MOCCI Model Report</h1>
<p>
This is a small report navigation page for the Mocci model project.
......
package de.ugoe.cs.rwm.mocci;
import static org.junit.Assert.assertTrue;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.eclipse.cmf.occi.core.Configuration;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.Mixin;
import org.eclipse.cmf.occi.core.MixinBase;
import org.eclipse.cmf.occi.core.OCCIFactory;
import org.eclipse.cmf.occi.core.OCCIPackage;
import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl;
import org.eclipse.cmf.occi.core.util.OcciRegistry;
import org.eclipse.cmf.occi.infrastructure.Compute;
import org.eclipse.cmf.occi.infrastructure.InfrastructureFactory;
import org.eclipse.cmf.occi.infrastructure.impl.InfrastructureFactoryImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.epsilon.emc.emf.CachedResourceSet;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import de.ugoe.cs.rwm.docci.MartDeployer;
import de.ugoe.cs.rwm.docci.ModelUtility;
import de.ugoe.cs.rwm.mocci.TestUtility;
import de.ugoe.cs.rwm.docci.connector.Connector;
import de.ugoe.cs.rwm.docci.connector.LocalhostConnector;
import de.ugoe.cs.rwm.tocci.Transformator;
import de.ugoe.cs.rwm.tocci.TransformatorFactory;
import de.ugoe.cs.rwm.tocci.occi2openstack.OCCI2OPENSTACKTransformator;
import monitoring.MonitoringFactory;
import monitoring.MonitoringPackage;
import monitoring.MonitoringProperty;
import monitoring.MonitoringPropertyArray;
import monitoring.Monitoringproperties;
import monitoring.Sensor;
import monitoring.impl.MonitoringFactoryImpl;
public class CreateElementsTest {
@BeforeClass
public static void OCCIRegistrySetup() {
TestUtility.loggerSetup();
TestUtility.extensionRegistrySetup();
}
@Test
public void createModel() {
//Factories to create OCCI elements
OCCIFactory cFact = new OCCIFactoryImpl();
InfrastructureFactory iFact = new InfrastructureFactoryImpl();
MonitoringFactory mFact = new MonitoringFactoryImpl();
//Top level element
Configuration config = cFact.createConfiguration();
//Resources
Sensor sensor = mFact.createSensor();
Compute comp = iFact.createCompute();
//MixinBase
Monitoringproperties monProps = mFact.createMonitoringproperties();
MonitoringPropertyArray monArr = mFact.createMonitoringPropertyArray();
MonitoringProperty monProp = mFact.createMonitoringProperty();
monProp.setName("CPU");
monProp.setValue("Critical");
monProp.setId("123452");
monArr.getMonitoringpropertyarrayValues().add(monProp);
monProps.setMonitoringProperties(monArr);
comp.getParts().add(monProps);
config.getResources().add(sensor);
config.getResources().add(comp);
System.out.println(config);
for(org.eclipse.cmf.occi.core.Resource res : config.getResources()) {
System.out.println(res);
for(MixinBase mixBase: res.getParts()) {
System.out.println(mixBase);
if(mixBase instanceof Monitoringproperties) {
System.out.println(((Monitoringproperties) mixBase).getMonitoringProperties().getMonitoringpropertyarrayValues());
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment