Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lucarin91 committed Apr 20, 2017
1 parent 118a8f9 commit 9a9b46a
Show file tree
Hide file tree
Showing 16 changed files with 337 additions and 64 deletions.
64 changes: 37 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tosKer
[Slides](http://slideck.io/github.com/di-unipi-socc/tosKer/doc/slide.md)
# TosKer
Orchestrate TOSCA applications on top of Docker.

## Intallation
**Requirements**
Expand All @@ -10,42 +10,52 @@
sudo pip install tosker
```

Usage:
### Install from source
```
tosker <file> (create|start|stop|delete)... [<inputs>...]
tosker <file> (create|start|stop|delete)... -q|--quiet [<inputs>...]
tosker <file> (create|start|stop|delete)... --debug [<inputs>...]
tosker -h|--help
git clone https://github.com/di-unipi-socc/tosKer/tree/master
cd tosKer
sudo python setup.py install
```

Options:
Run the tests:
```
-h --help Show this help.
-q --quiet Active quiet mode.
--debug Active debugging mode.
python setup.py test
```

Examples:
## Usage
```
tosker tosker/test/TOSCA/wordpress.yaml create --name mario
tosker tosker/test/TOSCA/wordpress.yaml start -q
tosker tosker/test/TOSCA/wordpress.yaml stop --debuug
tosker tosker/test/TOSCA/wordpress.yaml delete
tosker FILE [COMPONENTS...] COMMANDS... [OPTIONS] [INPUTS]
tosker -h|--help
tosker -v|--version
```
Where
- `FILE` is a TOSCA YAML file or CSAR file

tosker tosker/test/TOSCA/wordpress.yaml create start --name mario
tosker tosker/test/TOSCA/wordpress.yaml stop delete -q
- `COMMANDS` are a list of the following commands:
- `create` Create application components
- `start` Start applications components
- `stop` Stop application components
- `delete` Delete application components (except volume)

```
- `COMPONENTS` is a list of components to deploy

- `OPTIONS`
- `-h --help` Print usage
- `-q --quiet` Enable quiet mode
- `--debug` Enable debugging mode (override quiet mode)
- `-v --version` Print version

### Install from source
```
git clone https://github.com/di-unipi-socc/tosKer/tree/master
cd tosKer
sudo python setup.py install
```
- `INPUTS` provide TOSCA inputs _(syntax: `--NAME VALUE`)_

Run the tests:
Examples:
```
python setup.py test
tosker hello.yaml create --name mario
tosker hello.yaml start -q
tosker hello.yaml stop --debuug
tosker hello.yaml delete
tosker hello.yaml create start --name mario
tosker hello.yaml stop delete -q
tosker hello.yaml database api create start
```
66 changes: 40 additions & 26 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tosKer
TosKer
======

`Slides <http://slideck.io/github.com/di-unipi-socc/tosKer/doc/slide.md>`__
Orchestrate TOSCA applications on top of Docker.

Intallation
-----------
Expand All @@ -12,46 +12,60 @@ Intallation

sudo pip install tosker

Usage:
Install from source
~~~~~~~~~~~~~~~~~~~

::

tosker <file> (create|start|stop|delete)... [<inputs>...]
tosker <file> (create|start|stop|delete)... -q|--quiet [<inputs>...]
tosker <file> (create|start|stop|delete)... --debug [<inputs>...]
tosker -h|--help
git clone https://github.com/di-unipi-socc/tosKer/tree/master
cd tosKer
sudo python setup.py install

Options:
Run the tests:

::

-h --help Show this help.
-q --quiet Active quiet mode.
--debug Active debugging mode.
python setup.py test

Examples:
Usage
-----

::

tosker tosker/test/TOSCA/wordpress.yaml create --name mario
tosker tosker/test/TOSCA/wordpress.yaml start -q
tosker tosker/test/TOSCA/wordpress.yaml stop --debuug
tosker tosker/test/TOSCA/wordpress.yaml delete
tosker FILE [COMPONENTS...] COMMANDS... [OPTIONS] [INPUTS]
tosker -h|--help
tosker -v|--version

tosker tosker/test/TOSCA/wordpress.yaml create start --name mario
tosker tosker/test/TOSCA/wordpress.yaml stop delete -q
Where - ``FILE`` is a TOSCA YAML file or CSAR file

Install from source
~~~~~~~~~~~~~~~~~~~
- ``COMMANDS`` are a list of the following commands:

::
- ``create`` Create application components
- ``start`` Start applications components
- ``stop`` Stop application components
- ``delete`` Delete application components (except volume)

git clone https://github.com/di-unipi-socc/tosKer/tree/master
cd tosKer
sudo python setup.py install
- ``COMPONENTS`` is a list of components to deploy

Run the tests:
- ``OPTIONS``

- ``-h --help`` Print usage
- ``-q --quiet`` Enable quiet mode
- ``--debug`` Enable debugging mode (override quiet mode)
- ``-v --version`` Print version

- ``INPUTS`` provide TOSCA inputs *(syntax: ``--NAME VALUE``)*

Examples:

::

python setup.py test
tosker hello.yaml create --name mario
tosker hello.yaml start -q
tosker hello.yaml stop --debuug
tosker hello.yaml delete

tosker hello.yaml create start --name mario
tosker hello.yaml stop delete -q

tosker hello.yaml database api create start
13 changes: 9 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# To use a consistent encoding
from codecs import open
from os import path
from os import walk

here = path.abspath(path.dirname(__file__))

Expand All @@ -24,7 +25,7 @@
long_description=long_description,

# The project's main homepage.
url='https://github.com/di-unipi-socc/tosKer',
url='https://github.com/di-unipi-socc/TosKer',

# Author details
author='lucarin91',
Expand Down Expand Up @@ -87,9 +88,13 @@
# need to place data files outside of your packages. See:
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
# data_files=[
# ('/etc/tosker', ['tosker/tosker-types.yaml'])
# ],
data_files=[
('/etc/tosker', ['tosker/tosker-types.yaml']),
('/etc/tosker/examples',
['tosker/tests/TOSCA/thoughts-app/thoughts.csar',
'tosker/tests/TOSCA/node-mongo-csar/node-mongo.csar'])

],

# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
Expand Down
2 changes: 2 additions & 0 deletions tosker/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def _usage():
tosker hello.yaml create start --name mario
tosker hello.yaml stop delete -q
tosker hello.yaml database api create start
'''


Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TOSCA-Meta-File-Version: 1.0
CSAR-Version: 1.1
Created-By: lucarin91
Entry-Definitions: node-mongo.yaml
Content-Type: application/vnd.oasis.tosca.definitions.yaml
56 changes: 56 additions & 0 deletions tosker/tests/TOSCA/node-mongo-csar/node-mongo/app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* jslint node: true */
"use strict";
var express = require('express');
var mongoose = require('mongoose');

(function connect_to_mongo() {
mongoose.connect('mongodb://db/data1', function(err) {
if (err) connect_to_mongo();
else console.log('connection successful');
});
})();

var Schema = mongoose.Schema;
var PeopleSchema = mongoose.model('People',
new Schema({
name: String,
surname: String
})
);
new PeopleSchema({
name: 'Mario',
surname: 'Rossi'
}).save();
new PeopleSchema({
name: 'Mario',
surname: 'Verdi'
}).save();
new PeopleSchema({
name: 'John',
surname: 'Foo'
}).save();
new PeopleSchema({
name: 'John',
surname: 'Bar'
}).save();
new PeopleSchema({
name: 'Mario',
surname: 'FooBar'
}).save();

var app = express();

app.get('/', function(req, res) {
PeopleSchema.find(function(err, people) {
var html = '<h3>People:</h3>';
html += '<ul>';
people.forEach(p => html += '<li>' + p.name + ' ' + p.surname + '</li>');
html += '</ul>';
res.send(html);
});
});

var port = process.env.PORT || 80;
app.listen(port, function() {
console.log('server listen on port ' + port);
});
11 changes: 11 additions & 0 deletions tosker/tests/TOSCA/node-mongo-csar/node-mongo/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "node-mongo-example",
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.14.0",
"mongoose": "^4.6.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories:

imports:
# - tosker: https://di-unipi-socc.github.io/tosker-types/0.0.6/tosker.yaml
- tosker: ../../../tosker-types.yaml
- tosker: tosker-types.yaml

topology_template:
node_templates:
Expand All @@ -23,12 +23,12 @@ topology_template:
interfaces:
Standard:
create:
implementation: app/install.sh
implementation: scripts/app/install.sh
inputs:
package: { get_artifact: [ SELF, package ] }
main: { get_artifact: [ SELF, code ] }
start:
implementation: app/start.sh
implementation: scripts/app/start.sh
inputs:
port: 80

Expand All @@ -39,9 +39,9 @@ topology_template:
interfaces:
Standard:
create:
implementation: mongo/install.sh
implementation: scripts/mongo/install.sh
start:
implementation: mongo/start.sh
implementation: scripts/mongo/start.sh

node:
type: tosker.nodes.Software
Expand All @@ -50,7 +50,7 @@ topology_template:
interfaces:
Standard:
create:
implementation: install_node.sh
implementation: scripts/install_node.sh

server1:
type: tosker.nodes.Container
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cp $INPUT_PACKAGE $INPUT_MAIN .
npm install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
export PORT=$INPUT_PORT
node main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
apt-get update
apt-get install nodejs npm -y
apt-get clean
ln -s /usr/bin/nodejs /usr/bin/node
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" > /etc/apt/sources.list.d/mongodb-org-3.2.list
apt-get update
apt-get install -y mongodb-org
apt-get clean

mkdir -p /db
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
mongod --dbpath /db > /db/DEBUG_LOG
Loading

0 comments on commit 9a9b46a

Please sign in to comment.