Skip to content
README.md 7.06 KiB
Newer Older
MATHONAT Romain's avatar
MATHONAT Romain committed
[![Build Status](https://travis-ci.org/occiware/OCCInterface.svg?branch=master)](https://travis-ci.org/occiware/OCCInterface)
romathonat's avatar
romathonat committed
============
romathonat's avatar
romathonat committed
OCCInterface
============


MATHONAT Romain's avatar
MATHONAT Romain committed
OCCInterface is a generic application which let you explore and modify the resources of an OCCI server.
MATHONAT Romain's avatar
MATHONAT Romain committed
Its aims are multiple:
MATHONAT Romain's avatar
MATHONAT Romain committed
- give a productivity tool to developers calling the OCCI API
- manage and explore resources of an OCCI server easily
- vulgarize, explain OCCI to newcomers, diffuse the OCCI way of thinking
Marc Dutoo's avatar
Marc Dutoo committed
- be an (executable) reference documentation of capabilities of an OCCI implementation or of an integration of OCCI clouds, thanks to [executable REST samples](https://github.com/occiware/OCCInterface/blob/master/src/readings/GettingStarted.md).
MATHONAT Romain's avatar
MATHONAT Romain committed

MATHONAT Romain's avatar
MATHONAT Romain committed
A demo is avalaible here : http://occinterface.herokuapp.com/
![./assets/screenOccinterface.png](./assets/screenOccinterface.png)
romathonat's avatar
romathonat committed

romathonat's avatar
romathonat committed
## How to use it
MATHONAT Romain's avatar
MATHONAT Romain committed

### Through a docker image

If you have Docker installed (if not, you can find how to do so [here](https://docs.docker.com/engine/installation/)), and don't want to mess with your pre-existing dev environment, you may prefer this to the next section ("How to build and run it locally").

``` bash
git clone https://github.com/occiware/occiware-ozwillo.git
cd occiware-ozwillo/docker/occinterface
sudo docker build -t occinterface .
sudo docker run -p 3000:3000 occinterface
```

### Or build and run it locally

MATHONAT Romain's avatar
MATHONAT Romain committed
Requirement :
romathonat's avatar
romathonat committed
(some versions bellow should work too but have not been tested)
- nodeJS: >=6
MATHONAT Romain's avatar
MATHONAT Romain committed
- npm: >=3.8.9

Marc Dutoo's avatar
Marc Dutoo committed
NB. an easy way to install both, whatever the version of node you already have, is to install [nvm](https://github.com/creationix/nvm) :
``` bash
sudo apt-get update
sudo apt-get install build-essential libssl-dev
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
nvm install v6.2.0
```

Build and run :
MATHONAT Romain's avatar
MATHONAT Romain committed

``` bash
git clone https://github.com/occiware/OCCInterface.git
```

``` bash
npm install
```

``` bash
romathonat's avatar
romathonat committed
npm run dev
MATHONAT Romain's avatar
MATHONAT Romain committed
```

MATHONAT Romain's avatar
MATHONAT Romain committed
You can go to [http://localhost:3000/](http://localhost:3000/).
MATHONAT Romain's avatar
MATHONAT Romain committed
Then, you need to enter the URL of the OCCI server on the input at the top of the page (without "/" at the end)
MATHONAT Romain's avatar
MATHONAT Romain committed

## How to integrate it in your own OCCI implementation
TODO
romathonat's avatar
romathonat committed
## FAQ
MATHONAT Romain's avatar
MATHONAT Romain committed

Marc Dutoo's avatar
Marc Dutoo committed
- How to know the exact requests (and responses) sent by OCCInterface to the Cloud backend ?  
Simple : use an in-browser Javascript debug tool. If your browser is Firefox for instance, you can install Firebug, start it and then go in its Console (or Network) tab, where you can right-click on requests and see everything - and even "copy for curl".

Marc Dutoo's avatar
Marc Dutoo committed
- What is the syntax of executable REST samples ?  
Short answer : see examples in [src/readings](https://github.com/occiware/OCCInterface/blob/master/src/readings) such as [GettingStarted.md](https://github.com/occiware/OCCInterface/blob/master/src/readings/GettingStarted.md). Long answer : read below.

MATHONAT Romain's avatar
MATHONAT Romain committed
- What is a **playground link** and how to create it ?  
MATHONAT Romain's avatar
MATHONAT Romain committed
A playground link is a clickable link that make a GET request on the API and displays its content in the codeview.
To do so, create a classic link in markdown, and make your URL begin with "/"  
MATHONAT Romain's avatar
MATHONAT Romain committed
example:  
MATHONAT Romain's avatar
MATHONAT Romain committed
```
[/resources/compute](/resources/compute)
```
MATHONAT Romain's avatar
MATHONAT Romain committed

- What is a **sample link** and how to create it ?  
MATHONAT Romain's avatar
MATHONAT Romain committed
A sample link is a link that post datas onto the current server when clicking on it. The formating is as follow (in markdown):

``` JSON
text before %{
  "text": "sampleLink",
MATHONAT Romain's avatar
MATHONAT Romain committed
  "post": {
Marc Dutoo's avatar
Marc Dutoo committed
    "address": "/compute",
MATHONAT Romain's avatar
MATHONAT Romain committed
    "datas": {
Marc Dutoo's avatar
Marc Dutoo committed
      "kind":"http://schemas.ogf.org/occi/infrastructure#compute",
MATHONAT Romain's avatar
MATHONAT Romain committed
      "attributes": {
        "occi.compute.hostname" : "test",
        "occi.compute.state" : "inactive"
      },
      "id": "6df690d2-3158-40c4-88fb-d1c41584d6e5"
    }
  }
}% text after
```

Marc Dutoo's avatar
Marc Dutoo committed
It will result into a clickable link, which will post or put datas on click:
MATHONAT Romain's avatar
MATHONAT Romain committed

``` HTML
<p>text before <a>sampleLink</a> text after</p>
```
Marc Dutoo's avatar
Marc Dutoo committed

MATHONAT Romain's avatar
MATHONAT Romain committed
You can post an array instead of an object (in the "datas" attribute).
Marc Dutoo's avatar
Marc Dutoo committed
It can be put instead of posted, by using the "put" key instead of the "post" one.

MATHONAT Romain's avatar
MATHONAT Romain committed
If you want your sample link to post to different categories, just put an array instead of an object inside the "post" attribute. Example :

``` JSON
%{
  "text": "sampleLink",
MATHONAT Romain's avatar
MATHONAT Romain committed
  "post": [
    {
Marc Dutoo's avatar
Marc Dutoo committed
        "address": "/compute",
        "kind":"http://schemas.ogf.org/occi/infrastructure#compute",
MATHONAT Romain's avatar
MATHONAT Romain committed
        "datas": {
          "attributes": {
            "occi.compute.hostname" : "test",
            "occi.compute.state" : "inactive"
          },
          "id": "6df690d2-3158-40c4-88fb-d1c41584d6e5"
        }
    },
    {
Marc Dutoo's avatar
Marc Dutoo committed
        "address": "/storage",
MATHONAT Romain's avatar
MATHONAT Romain committed
        "datas": [
            {
Marc Dutoo's avatar
Marc Dutoo committed
              "kind":"http://schemas.ogf.org/occi/infrastructure#storage",
MATHONAT Romain's avatar
MATHONAT Romain committed
              "attributes": {
                "occi.storage.size" : 1000
              },
              "id": "6df690d2-3158-40c4-88fb-d1c41584d6e6"
            },
            {
Marc Dutoo's avatar
Marc Dutoo committed
              "kind":"http://schemas.ogf.org/occi/infrastructure#storage",
MATHONAT Romain's avatar
MATHONAT Romain committed
              "attributes": {
                "occi.storage.size" : 500
              },
              "id": "6df690d2-3158-40c4-88fb-d1c41584d689"
MATHONAT Romain's avatar
MATHONAT Romain committed
            }
MATHONAT Romain's avatar
MATHONAT Romain committed
        ]
    }
  ]
romathonat's avatar
romathonat committed
}%
MATHONAT Romain's avatar
MATHONAT Romain committed
```
- Can I delete datas with a sample link ?  
Yes, you can, with the following format :
MATHONAT Romain's avatar
MATHONAT Romain committed

  "text": "my sample link",
  "del": "/6df690d2-3158-40c4-88fb-d1c41584d6e7"
}%
```
MATHONAT Romain's avatar
MATHONAT Romain committed

Marc Dutoo's avatar
Marc Dutoo committed
- can I execute an OCCI action with a sample link ?
Yes, you can, with the following format :

``` JSON
text before %{
  "text": "my sample action link",
  "post": {
    "address": "/compute/6df690d2-3158-40c4-88fb-d1c41584d6e5?action=stop",
    "datas": {
      "action":"http://schemas.ogf.org/occi/infrastructure/compute/action#stop",
      "attributes": {
        "method": "graceful"
      }
    }
  }
}% text after
```

MATHONAT Romain's avatar
MATHONAT Romain committed
- How to deploy on Heroku ?  

romathonat's avatar
romathonat committed
``` bash
#need to be done once
heroku git:remote -a herokiRepo
```
MATHONAT Romain's avatar
MATHONAT Romain committed
``` bash
npm run build
```
``` bash
git commit -am "deployment message"
```
``` bash
git push heroku master
```
romathonat's avatar
romathonat committed
- I have an issue "(mixed active content)", how to fix it ?
MATHONAT Romain's avatar
MATHONAT Romain committed
You need to have the same domain policy between your OCCI server and your OCCInterface server. For instance http with http, or https with https.
MATHONAT Romain's avatar
MATHONAT Romain committed

MATHONAT Romain's avatar
MATHONAT Romain committed

Marc Dutoo's avatar
Marc Dutoo committed
## OCCInterface with the MART server

Follow the instructions of the [MART server](https://github.com/cgourdin/MartServer/blob/master/doc/server.md) : check it out, then do

```
mvn initialize
mvn clean install
mvn exec:java
```

Beware, there are [several differences between MART and erocci](https://github.com/occiware/OCCInterface/issues/13), though OCCInterface does its best to work with both.

## OCCInterface with the erocci server

**How to configure your Erocci Server :**

Follow the instructions of [erocci](https://github.com/erocci/erocci/blob/master/doc/README.md)

Then, you need to edit the config/sys.config file.
romathonat's avatar
romathonat committed
Find the "backend" section, and modify it that way :

``` erlang
{backends,
    [
     {root, erocci_backend_mnesia,
      [{schema, "/path/to/config.xml"}],
      <<"/">>}
    ]
   }
```

Copy locally and use [this file](https://github.com/occiware/occi-schemas/blob/master/schemas/http%253A%252F%252Fschemas.ogf.org%252Focci%252Finfrastructure%2523.xml) as the config.xml file.

romathonat's avatar
romathonat committed
Then, you can start the server with