Skip to content

Commit

Permalink
VNF_Catalogue Codebase
Browse files Browse the repository at this point in the history
Catalogue of Open Source VNFs consist in helping the end users to get
information of the VNF we can deploy on top of an OPNFV solution

[Deepak]: Removed all swp files.

Change-Id: Ib2ea7330e964f1b684f32aedf631accd580df968
Signed-off-by: Kumar Rishabh <[email protected]>
Signed-off-by: Deepak S <[email protected]>
  • Loading branch information
KumarRishabh42 authored and sdeepak2 committed Jul 21, 2017
1 parent b835128 commit 1f6b18a
Show file tree
Hide file tree
Showing 100 changed files with 29,045 additions and 0 deletions.
2 changes: 2 additions & 0 deletions VNF_Catalogue/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
44 changes: 44 additions & 0 deletions VNF_Catalogue/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#############################################
# Docker container for VNF_Catalogue WebApp
#############################################
# Purpose: Don't run it from here! Use docker-compose(See README.md)
#
# Maintained by Kumar Rishabh :: penguinRaider
##
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#

FROM node:boron
MAINTAINER KumarRishabh::penguinRaider <[email protected]>
LABEL version="v0.0.1" description="Open Source VNF_Catalogue for OPNFV"

ENV DB_HOST mysql
ENV DB_USER vnf_user
ENV DB_PASSWORD vnf_password
ENV DB_DATABASE vnf_catalogue
ENV MINIO_ACCESS_KEY vnf_minio
ENV MINIO_SECRET_KEY vnf_minio
ENV MINIO_HOST minio

RUN apt-get update
RUN apt-get install vim -y

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app/

# RUN npm config set proxy http://10.4.20.103:8080
# RUN npm config set https-proxy http://10.4.20.103:8080

RUN npm install

COPY . /usr/src/app

EXPOSE 3000

# We wait for mysql service to come up before starting the server using a 3rd_party script.
CMD [ "./migration/3rd_party/wait-for-it/wait-for-it.sh", "mysql:3306", "-t", "0", "--", "./migration/3rd_party/wait-for-it/wait-for-it.sh", "minio:9000", "-t", "0", "--", "npm", "start" ]
18 changes: 18 additions & 0 deletions VNF_Catalogue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#VNF_Catalogue Nodejs + Jade + MySql server


## Quickstart

First install docker and docker-compose. This multicontainer app uses
docker-compose to organize the vnf_catalogue web_app

The use
```docker-compose up```

set time zone(optional)
Set same timezone in both nodejs server and mysql server. Something
similar to below can be used:
``` SET GLOBAL time_zone = '+00:00'; ```


The server would be accessible at ```ip_address:3000```
110 changes: 110 additions & 0 deletions VNF_Catalogue/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*******************************************************************************
* Copyright (c) 2017 Kumar Rishabh and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution, and is available at
* http://www.apache.org/licenses/LICENSE-2.0
*******************************************************************************/

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var validator = require('express-validator');

var routes = require('./routes/index');
var search_projects = require('./routes/search_projects');
var search_projects_results = require('./routes/search_projects_results');
var search_max = require('./routes/search_max');
var project_profile = require('./routes/project_profile');
var add_project = require('./routes/add_project');
var add_tag = require('./routes/add_tag');
var search_tag = require('./routes/search_tag');
var search_vnf = require('./routes/search_vnf');
var vnf_tag_association = require('./routes/vnf_tag_association');
//var project_profile = require('./routes/project_profile');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

db_pool = require('./database').pool;
minio_client = require('./minio').minio_client;
// Database
//var db = require('mysql2');

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(validator());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

// create minio bucket if it does not exist
minio_client.makeBucket('opnfv-vnfcatalogue', 'us-east-1', function(err) {
if (err) {
return console.log(err);
} else {
console.log('Bucket created successfully in "us-east-1".');
}
});

// Make our db accessible to our router
app.use(function(req,res,next){
//db_pool size 50 default
req.db_pool = db_pool;
req.minio = minio_client;
next();
});

app.use('/', routes);
app.use('/search_projects', search_projects);
app.use('/search_projects_results', search_projects_results);
app.use('/project_profile', project_profile);
app.use('/add_project', add_project);
app.use('/add_tag', add_tag);
app.use('/search_tag', search_tag);
app.use('/search_vnf', search_vnf);
app.use('/vnf_tag_association', vnf_tag_association);
app.use('/search_max', search_max);
//app.use('/', project_profile);
// Some Error handling for now #TODO Remove

/// catch 404 and forwarding to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});


// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});

module.exports = app;
9 changes: 9 additions & 0 deletions VNF_Catalogue/bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node
var debug = require('debug')('my-application');
var app = require('../app');

app.set('port', process.env.PORT || 3000);

var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
20 changes: 20 additions & 0 deletions VNF_Catalogue/cronjob/3rd_party/wait-for-it/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2016 Giles Hall

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
75 changes: 75 additions & 0 deletions VNF_Catalogue/cronjob/3rd_party/wait-for-it/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# HELP NEEDED

### March 13, 2017 update

Since I posted this request for help, I've had a dozen or so responses which I am now sorting through. Applicants need to fill out [this](https://goo.gl/forms/GKCBFxaloaU47aky1) survey by March 17th. I will select, notify and announce the new volunteer(s) on March 19th. Once this is done, me and my team will work through the backlog of issues amd pull requests. Thanks for your paitence.

### Old request follows:

Hi there! I wrote `wait-for-it` in order to help me orchestrate containers I operate at my day job. I thought it was a neat little script, so I published it. I assumed I would be its only user, but that's not what happened! `wait-for-it` has received more stars then all of my other public repositories put together. I had no idea this tool would solicit such an audience, and I was equally unprepared to carve out the time required to address my user's issues and patches. I would like to solicit a volunteer from the community who would be willing to be a co-maintainer of this repository. If this is something you might be interested in, please email me at `[email protected]`. Thanks!

## wait-for-it

`wait-for-it.sh` is a pure bash script that will wait on the availability of a host and TCP port. It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers. Since it is a pure bash script, it does not have any external dependencies.

## Usage

```
wait-for-it.sh host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST Host or IP under test
-p PORT | --port=PORT TCP port under test
Alternatively, you specify the host and port as host:port
-s | --strict Only execute subcommand if the test succeeds
-q | --quiet Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
```

## Examples

For example, let's test to see if we can access port 80 on www.google.com, and if it is available, echo the message `google is up`.

```
$ ./wait-for-it.sh www.google.com:80 -- echo "google is up"
wait-for-it.sh: waiting 15 seconds for www.google.com:80
wait-for-it.sh: www.google.com:80 is available after 0 seconds
google is up
```

You can set your own timeout with the `-t` or `--timeout=` option. Setting the timeout value to 0 will disable the timeout:

```
$ ./wait-for-it.sh -t 0 www.google.com:80 -- echo "google is up"
wait-for-it.sh: waiting for www.google.com:80 without a timeout
wait-for-it.sh: www.google.com:80 is available after 0 seconds
google is up
```

The subcommand will be executed regardless if the service is up or not. If you wish to execute the subcommand only if the service is up, add the `--strict` argument. In this example, we will test port 81 on www.google.com which will fail:

```
$ ./wait-for-it.sh www.google.com:81 --timeout=1 --strict -- echo "google is up"
wait-for-it.sh: waiting 1 seconds for www.google.com:81
wait-for-it.sh: timeout occurred after waiting 1 seconds for www.google.com:81
wait-for-it.sh: strict mode, refusing to execute subprocess
```

If you don't want to execute a subcommand, leave off the `--` argument. This way, you can test the exit condition of `wait-for-it.sh` in your own scripts, and determine how to proceed:

```
$ ./wait-for-it.sh www.google.com:80
wait-for-it.sh: waiting 15 seconds for www.google.com:80
wait-for-it.sh: www.google.com:80 is available after 0 seconds
$ echo $?
0
$ ./wait-for-it.sh www.google.com:81
wait-for-it.sh: waiting 15 seconds for www.google.com:81
wait-for-it.sh: timeout occurred after waiting 15 seconds for www.google.com:81
$ echo $?
124
```

## Thanks

I wrote this script for my employer, [Ginkgo Bioworks](http://www.ginkgobioworks.com/), who was kind enough to let me release it as an open source tool. We are always looking to [hire](https://jobs.lever.co/ginkgobioworks) talented folks who are interested in working in the field of synthetic biology.
Loading

0 comments on commit 1f6b18a

Please sign in to comment.