This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tuwiendsg/pull-request-tosca-example
Pull request tosca example
- Loading branch information
Showing
7 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Run software-define sensor in TOSCA-based deployment tool (SALSA) | ||
|
||
This example includes 3 TOSCA files which can be deployed by [SALSA](http://tuwiendsg.github.io/SALSA/). The TOSCA files define the sensor runtime in 3 cases: plain machine, via Docker, and via Vagrant. | ||
|
||
The steps to run these examples are: | ||
|
||
1. Build the sensor source code. | ||
2. Install and run SALSA. | ||
3. Copy and pack following files into a single package: sensor-artifacts.tar.gz | ||
1. src/sdsensor/target/sdsensor-0.0.1-SNAPSHOT-jar-with-dependencies.jar | ||
2. src/sdcommon/target/sdcommon-0.0.1-SNAPSHOT.jar | ||
3. src/sdcloudconnectivity/target/cloud-connectivity-0.0.1-SNAPSHOT-jar-with-dependencies.jar | ||
4. src/sdsensor/conf/mqttcloud.json (must be edited to match with your MQTT broker) | ||
5. src/sdsensor/datasample/data.csv (optional: replace with your data file) | ||
4. Copy execution file: runsensor.sh | ||
5. Copy Dockerfile or Vagrantfile in the corresponding case. | ||
4. Edit the path in ```ArtifactReference``` in TOSCA files to match with above artifacts. | ||
5. Submit the TOSCA file to SALSA and wait for the provisioning completed. | ||
|
||
You can view the data being pushed to the MQTT broker with settings as in mqttcloud.json | ||
|
||
Note: In this example, we pack multiple artifacts for a better deliver. |
64 changes: 64 additions & 0 deletions
64
java/genericsdsensor/examples/sensors/tosca/sensors-docker.tosca.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<ns2:Definitions id="IoTSensors" name="IoTSensors" xmlns:ns2="http://docs.oasis-open.org/tosca/ns/2011/12"> | ||
<ns2:ServiceTemplate id="SensorTopology"> | ||
<ns2:TopologyTemplate> | ||
<ns2:RelationshipTemplate id="dockerOnVM" type="HOSTON"> | ||
<ns2:SourceElement ref="sensorDocker"/> | ||
<ns2:TargetElement ref="PersonalMachine"/> | ||
</ns2:RelationshipTemplate> | ||
<ns2:NodeTemplate minInstances="1" maxInstances="2147483647" id="PersonalMachine" type="os"> | ||
<ns2:Properties> | ||
<MappingProperties> | ||
<MappingProperty type="os"> | ||
<property name="provider">localhost</property> | ||
<property name="instanceType"/> | ||
<property name="baseImage"/> | ||
<property name="packages"></property> | ||
</MappingProperty> | ||
</MappingProperties> | ||
</ns2:Properties> | ||
<ns2:Requirements/> | ||
<ns2:Capabilities/> | ||
<ns2:Policies/> | ||
</ns2:NodeTemplate> | ||
<ns2:NodeTemplate minInstances="1" maxInstances="50" id="sensorDocker" type="docker"> | ||
<ns2:Properties> | ||
<MappingProperties> | ||
<MappingProperty type="os"> | ||
<property name="provider">localhost</property> | ||
<property name="instanceType">000000512</property> | ||
<property name="baseImage">a82e054f-4f01-49f9-bc4c-77a98045739c</property> | ||
<property name="packages"></property> | ||
</MappingProperty> | ||
</MappingProperties> | ||
</ns2:Properties> | ||
<ns2:Requirements/> | ||
<ns2:Capabilities/> | ||
<ns2:Policies/> | ||
<ns2:DeploymentArtifacts> | ||
<ns2:DeploymentArtifact name="Artifact_17be547e-74ce-4918-aee1-01b93a366ef5" artifactType="salsa:misc" artifactRef="Artifact_17be547e-74ce-4918-aee1-01b93a366ef5" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
<ns2:DeploymentArtifact name="dockerFileArtifact" artifactType="salsa:dockerfile" artifactRef="dockerFileArtifact" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
<ns2:DeploymentArtifact name="Artifact_ff4be584-8ade-4c4d-ad46-7400a6f7a1e4" artifactType="salsa:misc" artifactRef="Artifact_ff4be584-8ade-4c4d-ad46-7400a6f7a1e4" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
</ns2:DeploymentArtifacts> | ||
</ns2:NodeTemplate> | ||
</ns2:TopologyTemplate> | ||
</ns2:ServiceTemplate> | ||
<ns2:ArtifactTemplate id="Artifact_17be547e-74ce-4918-aee1-01b93a366ef5" type="misc"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/sensor-artifacts.tar.gz"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
<ns2:ArtifactTemplate id="dockerFileArtifact" type="dockerfile"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/Dockerfile"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
<ns2:ArtifactTemplate id="Artifact_ff4be584-8ade-4c4d-ad46-7400a6f7a1e4" type="misc"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/runsensor.sh"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
</ns2:Definitions> |
51 changes: 51 additions & 0 deletions
51
java/genericsdsensor/examples/sensors/tosca/sensors-plain-machine.tosca.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<ns2:Definitions id="IoTSensors" name="IoTSensors" xmlns:ns2="http://docs.oasis-open.org/tosca/ns/2011/12"> | ||
<ns2:ServiceTemplate id="SensorTopology"> | ||
<ns2:TopologyTemplate> | ||
<ns2:RelationshipTemplate id="sensorOnMachine" type="HOSTON"> | ||
<ns2:SourceElement ref="sensor"/> | ||
<ns2:TargetElement ref="PersonalMachine"/> | ||
</ns2:RelationshipTemplate> | ||
<ns2:NodeTemplate minInstances="1" maxInstances="2147483647" id="PersonalMachine" type="os"> | ||
<ns2:Properties> | ||
<MappingProperties> | ||
<MappingProperty type="os"> | ||
<property name="provider">localhost</property> | ||
<property name="instanceType"/> | ||
<property name="baseImage"/> | ||
<property name="packages"></property> | ||
</MappingProperty> | ||
</MappingProperties> | ||
</ns2:Properties> | ||
<ns2:Requirements/> | ||
<ns2:Capabilities/> | ||
<ns2:Policies/> | ||
</ns2:NodeTemplate> | ||
<ns2:NodeTemplate minInstances="1" maxInstances="50" id="sensor" type="software"> | ||
<ns2:Properties> | ||
<MappingProperties/> | ||
</ns2:Properties> | ||
<ns2:Requirements/> | ||
<ns2:Capabilities/> | ||
<ns2:Policies/> | ||
<ns2:DeploymentArtifacts> | ||
<ns2:DeploymentArtifact name="Artifact_9d7fa492-08ef-4536-acf9-55b31c774790" artifactType="salsa:misc" artifactRef="Artifact_9d7fa492-08ef-4536-acf9-55b31c774790" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
<ns2:DeploymentArtifact name="Artifact_271e6855-84bc-447b-a659-4e07c54003b2" artifactType="salsa:shcont" artifactRef="Artifact_271e6855-84bc-447b-a659-4e07c54003b2" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
</ns2:DeploymentArtifacts> | ||
</ns2:NodeTemplate> | ||
</ns2:TopologyTemplate> | ||
</ns2:ServiceTemplate> | ||
<ns2:ArtifactTemplate id="Artifact_9d7fa492-08ef-4536-acf9-55b31c774790" type="misc"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/sensor-artifacts.tar.gz"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
<ns2:ArtifactTemplate id="Artifact_271e6855-84bc-447b-a659-4e07c54003b2" type="shcont"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/runsensor.sh"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
</ns2:Definitions> | ||
|
62 changes: 62 additions & 0 deletions
62
java/genericsdsensor/examples/sensors/tosca/sensors-vagrant-virtualbox.tosca.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<ns2:Definitions id="IoTSensors" name="IoTSensors" xmlns:ns2="http://docs.oasis-open.org/tosca/ns/2011/12"> | ||
<ns2:ServiceTemplate id="SensorTopology"> | ||
<ns2:TopologyTemplate> | ||
<ns2:RelationshipTemplate id="sensorOnMachine" type="HOSTON"> | ||
<ns2:SourceElement ref="vagrant"/> | ||
<ns2:TargetElement ref="PersonalMachine"/> | ||
</ns2:RelationshipTemplate> | ||
<ns2:NodeTemplate minInstances="1" maxInstances="2147483647" id="PersonalMachine" type="os"> | ||
<ns2:Properties> | ||
<MappingProperties> | ||
<MappingProperty type="os"> | ||
<property name="provider">localhost</property> | ||
<property name="instanceType"/> | ||
<property name="baseImage"/> | ||
<property name="packages"></property> | ||
</MappingProperty> | ||
</MappingProperties> | ||
</ns2:Properties> | ||
<ns2:Requirements/> | ||
<ns2:Capabilities/> | ||
<ns2:Policies/> | ||
</ns2:NodeTemplate> | ||
<ns2:NodeTemplate minInstances="1" maxInstances="50" id="vagrant" type="software"> | ||
<ns2:Properties> | ||
<MappingProperties> | ||
<MappingProperty type="action"> | ||
<property name="undeploy">/usr/bin/vagrant destroy</property> | ||
<property name="deploy">/usr/bin/vagrant up</property> | ||
</MappingProperty> | ||
</MappingProperties> | ||
</ns2:Properties> | ||
<ns2:Requirements/> | ||
<ns2:Capabilities/> | ||
<ns2:Policies/> | ||
<ns2:DeploymentArtifacts> | ||
<ns2:DeploymentArtifact name="Artifact_e9ced96f-f847-48e5-bb39-404df01b2068" artifactType="salsa:misc" artifactRef="Artifact_e9ced96f-f847-48e5-bb39-404df01b2068" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
<ns2:DeploymentArtifact name="Artifact_d4096a96-b866-4476-baf7-8b90efeaaa1d" artifactType="salsa:misc" artifactRef="Artifact_d4096a96-b866-4476-baf7-8b90efeaaa1d" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
<ns2:DeploymentArtifact name="Artifact_d0d67cb5-cd99-4e3f-9816-b2e5856afb90" artifactType="salsa:misc" artifactRef="Artifact_d0d67cb5-cd99-4e3f-9816-b2e5856afb90" xmlns:salsa="https://github.com/tuwiendsg/SALSA"/> | ||
</ns2:DeploymentArtifacts> | ||
</ns2:NodeTemplate> | ||
</ns2:TopologyTemplate> | ||
</ns2:ServiceTemplate> | ||
<ns2:ArtifactTemplate id="Artifact_e9ced96f-f847-48e5-bb39-404df01b2068" type="misc"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/sensor-artifacts.tar.gz"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
<ns2:ArtifactTemplate id="Artifact_d4096a96-b866-4476-baf7-8b90efeaaa1d" type="misc"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/runsensor.sh"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
<ns2:ArtifactTemplate id="Artifact_d0d67cb5-cd99-4e3f-9816-b2e5856afb90" type="misc"> | ||
<ns2:Properties/> | ||
<ns2:ArtifactReferences> | ||
<ns2:ArtifactReference reference="file:///path/to/your/artifacts/Vagrantfile"/> | ||
</ns2:ArtifactReferences> | ||
</ns2:ArtifactTemplate> | ||
</ns2:Definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## Run software-define sensor via Vagrant | ||
|
||
Vagrant enables to deploy sensor on top of different providers. This example contains two Vagrant files: for VirtualBox and for docker. VirtualBox is the default environment. | ||
|
||
To use the Vagrant, following steps need to be done: | ||
|
||
1. Install Vagrant by following [the documentation](https://www.vagrantup.com/docs/installation/). | ||
2. Build the sensor source code. | ||
3. Copy the all following sensor artifacts into the same folder with the Vagrant file: | ||
1. src/sdsensor/target/sdsensor-0.0.1-SNAPSHOT-jar-with-dependencies.jar | ||
2. src/sdcommon/target/sdcommon-0.0.1-SNAPSHOT.jar | ||
3. src/sdcloudconnectivity/target/cloud-connectivity-0.0.1-SNAPSHOT-jar-with-dependencies.jar | ||
4. src/sdsensor/conf/mqttcloud.json (must be edited to match with your MQTT broker) | ||
5. src/sdsensor/datasample/data.csv (optional: replace with your data file) | ||
4. Based on which environment to run: | ||
1. Vagrant + Virtualbox: change `Vagrantfile.virtualbox` to `Vagrantfile` | ||
2. Vagrant + Docker: change `Vagrantfile.docker` to `Vagrantfile`, and copy the Dockerfile from docker example to this folder | ||
3. Run following command: | ||
``` | ||
vagrant up | ||
``` | ||
4. You can view the data being pushed to the MQTT broker with settings as in mqttcloud.json | ||
|
||
Note: | ||
|
||
* In the case of Vagrant + Virtualbox, you need virtuabox installed localy. The image to be used in this case is Ubuntu 12.04, which has no Java. Thus, Vagrant will install JRE 1.7 during the provisioning. | ||
* In the case of Vagrant + Docker, the result is similar to Docker example with Vagrant API to control the Docker container. |
10 changes: 10 additions & 0 deletions
10
java/genericsdsensor/examples/sensors/vagrant/Vagrantfile.docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.configure("2") do |config| | ||
|
||
config.vm.provider "docker" do |d| | ||
d.build_dir = "." | ||
end | ||
|
||
end |
95 changes: 95 additions & 0 deletions
95
java/genericsdsensor/examples/sensors/vagrant/Vagrantfile.virtualbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# All Vagrant configuration is done below. The "2" in Vagrant.configure | ||
# configures the configuration version (we support older styles for | ||
# backwards compatibility). Please don't change it unless you know what | ||
# you're doing. | ||
Vagrant.configure("2") do |config| | ||
# The most common configuration options are documented and commented below. | ||
# For a complete reference, please see the online documentation at | ||
# https://docs.vagrantup.com. | ||
|
||
# Every Vagrant development environment requires a box. You can search for | ||
# boxes at https://atlas.hashicorp.com/search. | ||
config.vm.box = "hashicorp/precise64" | ||
|
||
# Disable automatic box update checking. If you disable this, then | ||
# boxes will only be checked for updates when the user runs | ||
# `vagrant box outdated`. This is not recommended. | ||
# config.vm.box_check_update = false | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine. In the example below, | ||
# accessing "localhost:8080" will access port 80 on the guest machine. | ||
# config.vm.network "forwarded_port", guest: 80, host: 8080 | ||
|
||
# Create a private network, which allows host-only access to the machine | ||
# using a specific IP. | ||
# config.vm.network "private_network", ip: "192.168.33.10" | ||
|
||
# Create a public network, which generally matched to bridged network. | ||
# Bridged networks make the machine appear as another physical device on | ||
# your network. | ||
# config.vm.network "public_network" | ||
|
||
# Share an additional folder to the guest VM. The first argument is | ||
# the path on the host to the actual folder. The second argument is | ||
# the path on the guest to mount the folder. And the optional third | ||
# argument is a set of non-required options. | ||
# config.vm.synced_folder "../data", "/vagrant_data" | ||
|
||
# Provider-specific configuration so you can fine-tune various | ||
# backing providers for Vagrant. These expose provider-specific options. | ||
# Example for VirtualBox: | ||
# | ||
# config.vm.provider "virtualbox" do |vb| | ||
# # Display the VirtualBox GUI when booting the machine | ||
# vb.gui = true | ||
# | ||
# # Customize the amount of memory on the VM: | ||
# vb.memory = "1024" | ||
# end | ||
# | ||
# View the documentation for the provider you are using for more | ||
# information on available options. | ||
|
||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies | ||
# such as FTP and Heroku are also available. See the documentation at | ||
# https://docs.vagrantup.com/v2/push/atlas.html for more information. | ||
# config.push.define "atlas" do |push| | ||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" | ||
# end | ||
|
||
# Enable provisioning with a shell script. Additional provisioners such as | ||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
|
||
# Different providers, use | ||
# Docker provider, run by: vagrant up --provider=docker | ||
#config.vm.provider "docker" do |d| | ||
# d.image = "leduchung/ubuntu:14.04-jre8" | ||
#end | ||
|
||
# VirtualBox provider, run by: vagrant up --provider | ||
|
||
# Create a folder for sensor artifacts | ||
config.vm.provision "shell", inline: <<-SHELL | ||
mkdir -p /tmp/sensor | ||
chmod 777 /tmp/sensor | ||
apt-get update | ||
apt-get install -y openjdk-7-jre-headless | ||
SHELL | ||
|
||
config.vm.provision "file", source: "./cloud-connectivity-0.0.1-SNAPSHOT-jar-with-dependencies.jar", destination: "/tmp/sensor/cloud-connectivity-0.0.1-SNAPSHOT-jar-with-dependencies.jar" | ||
config.vm.provision "file", source: "./sdsensor-0.0.1-SNAPSHOT-jar-with-dependencies.jar", destination: "/tmp/sensor/sdsensor-0.0.1-SNAPSHOT-jar-with-dependencies.jar" | ||
config.vm.provision "file", source: "./sdcommon-0.0.1-SNAPSHOT.jar", destination: "/tmp/sensor/sdcommon-0.0.1-SNAPSHOT.jar" | ||
config.vm.provision "file", source: "./mqttcloud.json", destination: "/tmp/sensor/mqttcloud.json" | ||
config.vm.provision "file", source: "./data.csv", destination: "/tmp/sensor/data.csv" | ||
config.vm.provision "file", source: "./runsensor.sh", destination: "/tmp/sensor/runsensor.sh" | ||
|
||
config.vm.provision "shell", inline: <<-SHELL | ||
cd /tmp/sensor | ||
/bin/bash runsensor.sh | ||
SHELL | ||
end |