GithubHelp home page GithubHelp logo

connectionmaster / online_kitchen Goto Github PK

View Code? Open in Web Editor NEW

This project forked from avgtechnologies/online_kitchen

0.0 0.0 0.0 176 KB

Simple service for easy virtual machine provisioning

License: Other

Ruby 99.87% Procfile 0.13%

online_kitchen's Introduction

Build Status Code Climate

Online Kitchen

Prerequisites

Setup

  1. copy and setup config files:

    cp config/database.yml.example config/database.yml cp config/online_kitchen.yml.example config/online_kitchen.yml cp config/templates.yml.example config/templates.yml

  2. install all dependant libraries and init db:

    bundle install rake db:setup

  3. in root of the repository

    vagrant box add --insecure 'ubuntu/trusty64' https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/14.04/providers/virtualbox.box vagrant up vagrant ssh cd /vagrant

  4. Follow Procfile (in production)

Development

Example of curl with proper params to be used in Linux terminal (Windows terminal does not allow the '' and you need to use double quotes everywhere + escape the quotes... inside quotes with triple quotes. For windows users - install Cygwin (mintty.exe) or install MSYS (rxvt.exe):

For following examples you can run server in devel by rackup.

  • Get list of Configuration (for user franta.lopata):

    curl -i -H 'UserName: franta.lopata'
    -H 'AUTHENTICATIONTOKEN: secret' -H "Accept: application/json"
    -H "Content-Type: application/json"
    http://localhost:4567/api/v1/configurations

  • Create new configuration:

    curl -i -X POST -H 'UserName: franta.lopata'
    -H 'AUTHENTICATIONTOKEN: secret' -H "Accept: application/json"
    -H "Content-Type: application/json"
    -d '{ "configuration": {"name": "configurationName", "folder_name": "_online_kitnech_test"}}' http://localhost:4567/api/v1/configurations

  • Update Configuration:

  • add machine:

    curl -i -X PUT -H 'UserName: franta.lopata'
    -H 'AUTHENTICATIONTOKEN: secret'
    -H "Accept: application/json"
    -H "Content-Type: application/json"
    -d '{ "configuration": { "machines_attributes": [{ "name": "MachineName1", "template": "travis_7x86"}] }}'
    http://localhost:4567/api/v1/configurations/44

  • destroy machine (switch machine to destroy_queued state and schedule destroying):

    curl -i -X PUT -H 'UserName: franta.lopata'
    -H 'AUTHENTICATIONTOKEN: secret'
    -H "Accept: application/json"
    -H "Content-Type: application/json"
    -d '{ "configuration": { "machines_attributes": [{ "id": 22, "_destroy": "1"}] }}'
    http://localhost:4567/api/v1/configurations/44

  • Destroy configuration (e.g. schedule destroy)

    curl -i -X DELETE -H "UserName: franta.lopata"
    -H "AUTHENTICATIONTOKEN: secret"
    -H "Accept: application/json"
    -H "Content-Type: application/json"
    http://localhost:4567/api/v1/configurations/1

Error Handling

Service raises following exceptions:

  • 400 JSON::ParserError (not implemented yet)
  • 404 Record not Found
  • 422 InvalidRecord and/or Validation Error
  • 500 Application error - this means error in code

Example of validation error response:

 {
   "status": "unprocessable_entity",
   "errors": {
     "name": "is too short (minimum is 3 characters)"
   }
 }

Setup IRB

 rails
 > OnlineKitchen.setup
 > # for FactoryGirl
 > require 'factory_girl'
 > require './spec/factories'

FAQ

  1. If you have problem with downloading vagrant box

    vagrant box add --insecure 'ubuntu/trusty64' https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/14.04/providers/virtualbox.box

  2. How to remove all scheduled jobs?

    require 'sidekiq/api' Sidekiq::Queue.new.clear

online_kitchen's People

Contributors

ireznice avatar petrschreiber avatar lksv avatar ondrej-hosak avatar h4rr0d avatar trawais avatar panjan 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.