# Magellan::Cli

TODO: Write a gem description

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'magellan-cli'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install magellan-cli


## generate reference pages

```
export DEVCENTER_DIR=/path/to/magellan-devcenter.github.io
LANG=en DEST=$DEVCENTER_DIR SUBDIR=reference/magellan-cli/$LANG bundle exec rake reference
LANG=ja DEST=$DEVCENTER_DIR SUBDIR=reference/magellan-cli/$LANG bundle exec rake reference
```

then 

```
cd /path/to/magellan-devcenter.github.io
bundle exec jekyll serve
```

open http://localhost:4000/reference/magellan-cli/en
open http://localhost:4000/reference/magellan-cli/ja

After check the pages, you can commit the .md files to magellan-devcenter.github.io repogitory.


## Usage

### All-in-one patterns

#### 1. [API Server terminal]  initialize Database

```
bundle exec rake db:drop db:create db:migrate db:seed
```


#### 2. [API Server terminal] start API server and delayed_job daemon

```
bundle exec bin/delayed_job start
bundle exec bin/delayed_job status
bundle exec rails s
```


#### 3. [cli terminal] Load Magellan.yml

```
magellan-cli project load 1 path/to/Magellan.yml
```

#### 4. [cli terminal] create and configure Host Instance

```
magellan-cli host_instance sample_launch_options > launch_options.json
magellan-cli host_instance create 1 gce magellan-gce-sandbox1 launch_options.json
magellan-cli stage configure 1
```

#### 5. [API Server terminal]

Modify Host Instance config, if you need.

#### 6. [cli terminal] confirm Host Instance data

```
magellan-cli host_instance show 1
```

#### 7. [cli terminal] start stage inculding VmInstances and ContainerInstances

```
magellan-cli stage start 1
```


#### 8. [cli terminal] wait for stage working

check status of stage, host_instance and container_instance

```
magellan-cli stage list
magellan-cli host_instance list
magellan-cli container_instance list
```


#### 9. [cli terminal] connection check

```
irb

require 'json'
host_ip = JSON.parse(`magellan-cli host_instance show 1`)["public_ip"]
require 'libmagellan'
lm = Libmagellan.new(host: host_ip, port: 80,
                     consumer_key: "groovenauts.app1",
                     consumer_secret: "test")
puts Libmagellan::VERSION
lm.request("/ping").body
# => "pong\n"
lm.request("/hello/index").body
# => "{\"hello\":\"world\"}"
```



## Contributing

1. Fork it ( https://github.com/[my-github-username]/magellan-cli/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request