Code Monkey home page Code Monkey logo

cloudsim-portal's Introduction

Cloudsim Portal

cloudsim-portal is part of the cloudsim project. You can find

Codeship Status for osrf/cloudsim-portal

Dependency Status

Coverage Status

This is the cloud interface micro service for Cloudsim

What is this repository for?

  • A web app that manages simulators on the cloud
  • Has different types of users (to create, share and start machines on the cloud)
  • Launches new AWS instances with simulators or field computers
  • Must be run from an AWS instance when using SSL certificates

Prerequisite

AWS Setup

You will need AWS credentials to launch instances on AWS.

Get the AWS keys (AWSAccessKeyId and AWSSecretKey) from the AWS console.

IMAGE

An important configuration is to upload or create a "Key Pair" in each region where you want to launch simulator machines. That key must be called cloudsim.

IMAGE

AWS will put the public key in the simulator machine you launched so that you can ssh into the machine by doing:

ssh -i cloudsim.pem ubuntu@ip_address

Add two security groups (names are important):

  • cloudsim-portal

    Inbound rules:

    HTTPS / TCP / 443 / Anywhere SSH / TCP / 22 / Anywhere All ICMP / ICMP / 0-65535 / Anywhere Custom TCP Rule / TCP / 5050 / Anywhere

  • cloudsim-sim

    Inbound rules:

    HTTPS / TCP / 443 / Anywhere SSH / TCP / 22 / Anywhere All ICMP / ICMP / 0-65535 / Anywhere Custom UDP Rule / UDP / 1194 / Anywhere

Launch an instance on the AWS server for the cloudsim portal

There are different ways to start an AWS instance to host the cloudsim portal

Option 1)

You can do it manually using the AWS EC2 console. Make sure to assign the right security group (cloudsim-portal) and choose the key pair (cloudsim) you created.

Option 2)

This package contains a script to launch an AWS instance from the command line with the cloudsim-portal security group and the cloudsim key.

To use this script, you will need to first setup the AWS environment variables, see Environment variable setup section below.

Use the launch_portal.js script to launch a new AWS instance.

node launch_portal.js cloudsim empty.bash

You should see the ip address printed when the machine is launched.

Configure cloudsim portal instance

Once the new aws instance is up and running, ssh into the machine:

ssh -i cloudsim.pem ubuntu@ip_address

Change the hostname to portal

sudo su
echo "portal" > /etc/hostname
echo "127.0.1.1 portal" >>  /etc/hosts

Setup the iptable to redirect port 443 (HTTPS) to 4000 (cloudsim portal server). This won't survive a reboot unless you put this in /etc/rc.local

iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 443 -j REDIRECT --to-port 4000

Installation

Dependencies

nodejs

You need the following: nodejs (version 4 and up)

If you are running Ubuntu Trusty or older distributions, you should install using nodesource:

curl https://deb.nodesource.com/setup_4.x | sudo -E bash -

Otherwise, install using apt-get:

sudo apt-get install -y nodejs nodejs-legacy npm redis-server mercurial

Setup the portal

From the root directory

npm install

Environment variable setup

In order for the portal to launch a simulator machine, valid AWS access keys are needed. Create a .env file and add the follwing but replace the XXX with your AWS keys:

AWS_ACCESS_KEY_ID=XXXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXXXXX

These environment variables must be loaded in the shell that runs the portal web app (the keys are used to launch simulation machines)

For security purposes, all sockets and REST API's are protected. Set up the public key needed to decode json web tokens. Edit and .env file and add the following variable. Replace XXX with the actual public key.

CLOUDSIM_AUTH_PUB_KEY=XXXXXXXX

Run the portal

From the command line:

npm start

This starts the portal http server and you should be able to access it by going to:

https://ip_address:4000 (if port 4000 is open)

https://ip_address (if the port 4000 is redirected to 443)

MongoDB

Set up mongo with an admin user:

$ mongo

> show dbs
> use cloudsim-portal
> db.users.insert({"username": "admin"})

other useful mongo commands for retrieving data from collections:

> db.users.find().pretty()
> db.simulators.find().pretty()
> db.simulations.find().pretty()
> db.simulators.remove({})

Testing

How to run tests

npm test

This sets the NODE_ENV environment variable to test and uses fake cloud services. No AWS instances will be launched.

AWS dry-run

AWS cloud services supports dry runs. Declare a CLOUDSIM_DRY_RUN variable in the .env file and set it to true. All AWS cloud services will be called with DryRun enabled.

Fake cloud services

The difference between fake cloud services and AWS dry-run is that the fake cloud services does not actually make any services calls to the AWS provider. Instead, fake cloud service calls return immediately as if machines were successfully launched.

To use fake cloud services, comment out the AWS_ACCESS_KEY_ID environment variable.in the .env file.

Deployment instructions

Refer to these instructions on how to deploy to AWS Elastic Beanstalk using Codeship.

cloudsim-portal's People

Contributors

chapulina avatar german-e-mas avatar iche033 avatar patricioreyna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.