sakurraform 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88126f4ae6bc4935c5b39fecf16f266a36def3b4
4
- data.tar.gz: 500102637b8e8c2ab46d66acc0572d35887741d2
3
+ metadata.gz: b5f5a476b605ae713423742cd27a16feff996a83
4
+ data.tar.gz: f72a7080d717c38cccda7ce83ad71e6b99d92a29
5
5
  SHA512:
6
- metadata.gz: eddd0b20f908bd1ddabfc9d19dbde30258ce8df06ae12e54d99d0173c70d3806f3a1190713fe145c4e8cb3e0c6456bd0976bb958be4ab5a39796684c1cd7b0f2
7
- data.tar.gz: af21a3f41402c7e5dc9deaabe9c527649965155c7187187e80897f7308d395bfebf8513625fbeb5bafb0271dc30fb0a1d31a32c82a8c5972adc6bd8f33943236
6
+ metadata.gz: 88a1afc61c100fc9334d4872381becb8e675749c233e3d0777ba7c60dc8c891f1e11cbcce49a6a374ff63493d0e2ec27e227a043a1af50a515fd16ab7e830286
7
+ data.tar.gz: af48f595e7aa87d27a25559bf4bca71d817687ba3bba173a9d1d86ba031de5be429cd52ba544c6c4673b251c69b7c835c03b23e53a47cd15de3b3ede95fbf202
data/CHANGELOG.md CHANGED
@@ -0,0 +1,15 @@
1
+ # CHANGELOG of sakurraform
2
+
3
+ ## v0.0.2
4
+
5
+ - Fix: Change cli name to sakurraform
6
+ - Change name from sakura_name to sakurraform_name of table.
7
+ - Feature: sakurraform map
8
+ - Feature: Base storage command
9
+ - Add aws-sdk to depends.
10
+
11
+ ## v0.0.1
12
+
13
+ - Inital release.
14
+ - create network and servers from yaml
15
+ - show resources
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # Sakurraform
2
2
 
3
- [WIP]
3
+ [![Gem Version](https://badge.fury.io/rb/sakurraform.svg)](http://badge.fury.io/rb/sakurraform)
4
+
5
+ Manage Infrastructure from Code with Sakura no Cloud and Base Storage.
6
+
7
+ ## TODO
8
+
9
+ - delete resources.
10
+ - update resources if detect diff.
4
11
 
5
- Manage Infrastructure from Code with Sakura no Cloud
6
12
 
7
13
  ## Installation
8
14
 
@@ -23,28 +29,121 @@ Or install it yourself as:
23
29
  ## Usage
24
30
 
25
31
  ```
26
- $ ./bin/sakkuraform
32
+ $ ./bin/sakurraform
27
33
  Commands:
28
- sakkuraform help [COMMAND] # Describe available commands or one specific command
29
- sakkuraform init # initiaize .sakuracloud/credentials
30
- sakkuraform plan SUBCOMMAND #
31
- sakkuraform status # show status
32
- sakkuraform version # show version
34
+ sakurraform bs SUBCOMMAND # Manage Sakura no Base Storage
35
+ sakurraform help [COMMAND] # Describe available commands or one specific command
36
+ sakurraform init # initiaize .sakuracloud/credentials
37
+ sakurraform map # open sakura cloud map!
38
+ sakurraform plan SUBCOMMAND # Manage plan
39
+ sakurraform status # show status
40
+ sakurraform version # show version
41
+
33
42
  ```
34
43
 
35
44
  ### sakurraform init
36
45
 
37
46
  Create credential file
38
47
 
39
- ### sakkuraform plan SUBCOMMAND
48
+ ### sakurraform plan SUBCOMMAND
40
49
 
41
- #### sakkuraform plan generate
50
+ #### sakurraform plan generate
42
51
 
43
52
  Create plan template.
44
53
 
45
- #### sakkuraform plan apply
54
+ #### sakurraform plan apply
55
+
56
+ Create resources from yaml and save state to file.
57
+
58
+ ```
59
+ ## Example 2 networks and 2 servers.
60
+
61
+ $ ./bin/sakurraform plan apply
62
+ Create new network defaultrouter
63
+ [fog][WARNING] Create Router with public subnet
64
+ [fog][WARNING] Waiting available new router...
65
+ ...... create state/network/defaultrouter-dbfd50c0-2a2c-0132-62c2-38e8563c85ec.yml
66
+ Create new network defaultrouter2
67
+ [fog][WARNING] Create Router with public subnet
68
+ [fog][WARNING] Waiting available new router...
69
+ ...... create state/network/defaultrouter2-e5ea21c0-2a2c-0132-62c2-38e8563c85ec.yml
70
+ Create new server server1
71
+ [fog][WARNING] Create Server
72
+ [fog][WARNING] Create Volume
73
+ [fog][WARNING] Waiting disk until available
74
+ .[fog][WARNING] Modifing disk
75
+ Associate 133.242.242.242 to server1
76
+ create state/server/server1-efc00f30-2a2c-0132-62c2-38e8563c85ec.yml
77
+ Create new server server2
78
+ [fog][WARNING] Create Server
79
+ [fog][WARNING] Create Volume
80
+ [fog][WARNING] Waiting disk until available
81
+ .[fog][WARNING] Modifing disk
82
+ Associate 133.242.242.243 to server2
83
+ create state/server/server2-21a3a320-2a2d-0132-62c2-38e8563c85ec.yml
84
+ ```
85
+
86
+ create once.
87
+
88
+ ```
89
+ $ ./bin/sakurraform plan apply
90
+ defaultrouter already available as defaultrouter-dbfd50c0-2a2c-0132-62c2-38e8563c85ec
91
+ defaultrouter2 already available as defaultrouter2-e5ea21c0-2a2c-0132-62c2-38e8563c85ec
92
+ server1 already available as server1-efc00f30-2a2c-0132-62c2-38e8563c85ec
93
+ server2 already available as server2-21a3a320-2a2d-0132-62c2-38e8563c85ec
94
+ ```
95
+
96
+ #### sakurraform status
97
+
98
+ Show status of resources.
46
99
 
47
- Create resources from yaml.
100
+ ```
101
+ $ ./bin/sakurraform status
102
+ Nework resources
103
+ +----------------+-----------------------------------------------------+--------------+--------------------+-----------------+
104
+ | name | sakurraform_name | sakura_id | subnet | gateway |
105
+ +----------------+-----------------------------------------------------+--------------+--------------------+-----------------+
106
+ | defaultrouter | defaultrouter-d9805cd0-295c-0132-62c1-38e8563c85ec | 112600778154 | 133.242.242.192/28 | 133.242.242.193 |
107
+ +----------------+-----------------------------------------------------+--------------+--------------------+-----------------+
108
+ | defaultrouter2 | defaultrouter2-e2368190-295c-0132-62c1-38e8563c85ec | 112600778157 | 133.242.242.208/28 | 133.242.242.209 |
109
+ +----------------+-----------------------------------------------------+--------------+--------------------+-----------------+
110
+
111
+ Server resources
112
+ +---------+----------------------------------------------+--------------+-----------------+--------+---------------------------+
113
+ | name | sakurraform_name | sakura_id | ipaddress | status | last_state_changed |
114
+ +---------+----------------------------------------------+--------------+-----------------+--------+---------------------------+
115
+ | server1 | server1-ed6ea720-295c-0132-62c1-38e8563c85ec | 112600778159 | 133.242.242.194 | up | 2014-09-29T01:47:57+09:00 |
116
+ +---------+----------------------------------------------+--------------+-----------------+--------+---------------------------+
117
+ | server2 | server2-1f9f9b40-295d-0132-62c1-38e8563c85ec | 112600778162 | 133.242.242.195 | up | 2014-09-29T01:49:22+09:00 |
118
+ +---------+----------------------------------------------+--------------+-----------------+--------+---------------------------+
119
+
120
+ ```
121
+
122
+ ### sakurraform map
123
+
124
+ open map page by bwowser...
125
+
126
+
127
+ ### sakurraform bs SUBCOMMAND
128
+
129
+ #### sakurraform bs create
130
+
131
+ Create bucket(..just open browser)
132
+
133
+ #### sakurraform bs ls
134
+
135
+ list object entries.
136
+
137
+ ```
138
+ $ ./bin/sakurraform bs ls
139
+ +----------+----------------+---------------------+---------------------------+-------------------------------------------------------+
140
+ | key | content_length | content_type | last_modified | public_url |
141
+ +----------+----------------+---------------------+---------------------------+-------------------------------------------------------+
142
+ | hogehoge | 0 | binary/octet-stream | 2014-09-30 02:14:27 +0900 | http://test-hogehgoe.b.storage.sakura.ad.jp/hogehoge |
143
+ +----------+----------------+---------------------+---------------------------+-------------------------------------------------------+
144
+ | mogemoge | 0 | binary/octet-stream | 2014-09-30 02:14:28 +0900 | http://test-hogehoge.b.storage.sakura.ad.jp/mogemoge |
145
+ +----------+----------------+---------------------+---------------------------+-------------------------------------------------------+
146
+ ```
48
147
 
49
148
 
50
149
  ## Contributing
File without changes
@@ -0,0 +1,38 @@
1
+ require 'aws-sdk'
2
+ module SakurraForm
3
+ class Bs < Thor
4
+ include Thor::Actions
5
+ include SakurraForm::Helper
6
+
7
+ def self.source_root
8
+ File.expand_path("../../", __FILE__)
9
+ end
10
+
11
+ desc 'create', 'Create bucket(..just open browser)'
12
+ def create
13
+ system('open https://secure.sakura.ad.jp/storage/#!/namespace/manage/')
14
+ end
15
+
16
+ desc 'ls', 'list object entries'
17
+ def ls
18
+ s3 = AWS::S3.new(
19
+ :access_key_id => Fog.credentials[:sakura_base_storage_bucket],
20
+ :secret_access_key => Fog.credentials[:sakura_base_storage_token] ,
21
+ :s3_endpoint => 'b.storage.sakura.ad.jp',
22
+ :use_ssl => false
23
+ )
24
+
25
+ bucket = s3.buckets[Fog.credentials[:sakura_base_storage_bucket]]
26
+ table = bucket.objects.entries.map do |ent|
27
+ {
28
+ :key => ent.key,
29
+ :content_type => ent.content_type,
30
+ :content_length => ent.content_length,
31
+ :last_modified => ent.last_modified,
32
+ :public_url => ent.public_url.to_s
33
+ }
34
+ end
35
+ Formatador.display_table(table, [:key, :content_length, :content_type, :last_modified, :public_url])
36
+ end
37
+ end
38
+ end
@@ -11,8 +11,10 @@ module SakurraForm
11
11
  desc 'init', 'initiaize .sakuracloud/credentials'
12
12
  def init
13
13
  empty_directory('.sakuracloud')
14
- @sakuracloud_api_token = ask("Sakuracloud_api_token ? ")
15
- @sakuracloud_api_token_secret = ask("Sakuracloud_api_token_secret ? ")
14
+ @sakuracloud_api_token = ask("Sakuracloud_api_token(required) ? ")
15
+ @sakuracloud_api_token_secret = ask("Sakuracloud_api_token_secret(required) ? ")
16
+ @sakura_base_storage_bucket = ask("Sakura Base Storage buket name(optional) ? ")
17
+ @sakura_base_storage_token = ask("Sakura Base Storage token(optional) ? ")
16
18
  template('templates/credentials.tt', ".sakuracloud/credentials")
17
19
  end
18
20
  end
@@ -0,0 +1,14 @@
1
+ module SakurraForm
2
+ class CLI < Thor
3
+ include Thor::Actions
4
+
5
+ def self.source_root
6
+ File.expand_path("../../", __FILE__)
7
+ end
8
+
9
+ desc 'map', 'open sakura cloud map!'
10
+ def map
11
+ system('open https://secure.sakura.ad.jp/cloud/#!/map/map/')
12
+ end
13
+ end
14
+ end
@@ -7,7 +7,7 @@ module SakurraForm
7
7
  File.expand_path("../../", __FILE__)
8
8
  end
9
9
 
10
- desc 'generate', ''
10
+ desc 'generate', 'Generate template'
11
11
  def generate
12
12
  empty_directory('state')
13
13
  empty_directory('state/network')
@@ -16,7 +16,7 @@ module SakurraForm
16
16
  copy_file('templates/server.tt', "plan/server.yml")
17
17
  end
18
18
 
19
- desc 'apply', ''
19
+ desc 'apply', 'Apply plan'
20
20
  def apply
21
21
  ## Prepare Network
22
22
  col_networks = SakurraForm::Collection.new('network')
@@ -13,14 +13,14 @@ module SakurraForm
13
13
  col_network = SakurraForm::Collection.new('network')
14
14
  col_network.collection_resources(true)
15
15
  Formatador.display_line('[green]Nework resources[/]')
16
- Formatador.display_table(build_state_network(col_network), [:name, :sakura_name, :sakura_id, :subnet, :gateway])
16
+ Formatador.display_table(build_state_network(col_network), [:name, :sakurraform_name, :sakura_id, :subnet, :gateway])
17
17
  say()
18
18
 
19
19
  ## Showdown Server
20
20
  col_server = SakurraForm::Collection.new('server')
21
21
  col_server.collection_resources(true)
22
22
  Formatador.display_line('[green]Server resources[/]')
23
- Formatador.display_table(build_state_server(col_server), [:name, :sakura_name, :sakura_id, :ipaddress, :status, :last_state_changed])
23
+ Formatador.display_table(build_state_server(col_server), [:name, :sakurraform_name, :sakura_id, :ipaddress, :status, :last_state_changed])
24
24
  end
25
25
 
26
26
  end
@@ -1,11 +1,20 @@
1
1
  require 'sakurraform/cli/version'
2
2
  require 'sakurraform/cli/init'
3
3
  require 'sakurraform/cli/plan'
4
+ require 'sakurraform/cli/bs'
4
5
  require 'sakurraform/cli/status'
6
+ require 'sakurraform/cli/map'
5
7
 
6
8
  module SakurraForm
7
9
  class CLI < Thor
8
- desc "plan SUBCOMMAND", ''
10
+ desc "plan SUBCOMMAND", 'Manage plan'
9
11
  subcommand "plan", SakurraForm::Plan
10
12
  end
11
13
  end
14
+
15
+ module SakurraForm
16
+ class CLI < Thor
17
+ desc "bs SUBCOMMAND", 'Manage Sakura no Base Storage'
18
+ subcommand "bs", SakurraForm::Bs
19
+ end
20
+ end
@@ -52,7 +52,7 @@ module SakurraForm
52
52
  table_datum = {}
53
53
  # pp resource
54
54
  table_datum[:name] = resource.name
55
- table_datum[:sakura_name] = resource.resource_id ? resource.resource_id : 'not created'
55
+ table_datum[:sakurraform_name] = resource.resource_id ? resource.resource_id : 'not created'
56
56
  table_datum[:sakura_id] = resource.remote_state ? resource.remote_state[:id] : 'not created'
57
57
  table_datum[:subnet] = resource.remote_state ? resource.remote_state[:subnets].first['NetworkAddress'] + '/' + resource.remote_state[:subnets].first['NetworkMaskLen'].to_s : 'not created'
58
58
  table_datum[:gateway] = resource.remote_state ? resource.remote_state[:subnets].first['DefaultRoute'] : 'not created'
@@ -68,7 +68,7 @@ module SakurraForm
68
68
  table_datum = {}
69
69
  # pp resource
70
70
  table_datum[:name] = resource.name
71
- table_datum[:sakura_name] = resource.resource_id ? resource.resource_id : 'not created'
71
+ table_datum[:sakurraform_name] = resource.resource_id ? resource.resource_id : 'not created'
72
72
  table_datum[:sakura_id] = resource.remote_state ? resource.remote_state[:id] : 'not created'
73
73
  table_datum[:status] = resource.remote_state ? resource.remote_state[:instance]['Status'] : 'not created'
74
74
  table_datum[:last_state_changed] = resource.remote_state ? resource.remote_state[:instance]['StatusChangedAt'] : 'not created'
@@ -1,3 +1,5 @@
1
1
  default:
2
2
  sakuracloud_api_token: <%= @sakuracloud_api_token %>
3
3
  sakuracloud_api_token_secret: <%= @sakuracloud_api_token_secret %>
4
+ sakura_base_storage_bucket: <%= @sakura_base_storage_bucket ? @sakura_base_storage_bucket : "null" %>
5
+ sakura_base_storage_token: <%= @sakura_base_storage_token ? @sakura_base_storage_token : "null" %>
@@ -1,3 +1,3 @@
1
1
  module SakurraForm
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/sakurraform.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "thor"
22
22
  spec.add_dependency "uuid"
23
+ spec.add_dependency "aws-sdk"
23
24
  spec.add_dependency "chamber"
24
25
  spec.add_dependency "fog-sakuracloud", "~> 0.1.0"
25
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakurraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawanoboly
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws-sdk
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: chamber
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +126,7 @@ description: Manage Infrastructure from Code with Sakura no Cloud
112
126
  email:
113
127
  - sawanoboriyu@higanworks.com
114
128
  executables:
115
- - sakkuraform
129
+ - sakurraform
116
130
  extensions: []
117
131
  extra_rdoc_files: []
118
132
  files:
@@ -122,10 +136,12 @@ files:
122
136
  - LICENSE.txt
123
137
  - README.md
124
138
  - Rakefile
125
- - bin/sakkuraform
139
+ - bin/sakurraform
126
140
  - lib/sakurraform.rb
127
141
  - lib/sakurraform/cli.rb
142
+ - lib/sakurraform/cli/bs.rb
128
143
  - lib/sakurraform/cli/init.rb
144
+ - lib/sakurraform/cli/map.rb
129
145
  - lib/sakurraform/cli/plan.rb
130
146
  - lib/sakurraform/cli/status.rb
131
147
  - lib/sakurraform/cli/version.rb