nchosts 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/nchosts.rb +1 -0
- data/lib/nchosts/collector.rb +32 -0
- data/lib/nchosts/command.rb +5 -13
- data/lib/nchosts/version.rb +1 -1
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65e3a7a605c74fdb654bf0cc87a00d5cb61e62a9
|
4
|
+
data.tar.gz: 79cc45ab6fffecd0c9520679800ce64c46b52491
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ba2d5f198803e79b7ca3fefe18320e3f192b7f77e2b2e2e4e04d68ecc7005bf3684be078173e428583f0b163ba70711c8889665c7a87bd715301940a815ae52
|
7
|
+
data.tar.gz: 318fde2d1be4e8ee7d0a12a7a12a12fb5c12f751425cff5eeaaa074709b451eac4bf1658574e27bdda7a0530118a5db1af454754ac77c651a8513d09b6cc3fdf
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -35,7 +35,7 @@
|
|
35
35
|
|
36
36
|
$ nchosts generate -i instances.json -f hosts >> /etc/hosts
|
37
37
|
$ nchosts generate -i instances.json -f ssh_config >> ~/.ssh/config
|
38
|
-
$ nchosts generate -i instances.json -f aliases >> ~/.
|
38
|
+
$ nchosts generate -i instances.json -f aliases >> ~/.bashrc
|
39
39
|
|
40
40
|
自分で書いた erubis 形式のテンプレートファイルを利用することもできます。
|
41
41
|
テンプレートの中では `instances` というローカル変数 (配列) でサーバー情報の一覧を参照できます。
|
data/lib/nchosts.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Nchosts
|
2
|
+
class Collector
|
3
|
+
ENDPOINTS = %w(
|
4
|
+
cp.cloud.nifty.com
|
5
|
+
uscp.cloud.nifty.com
|
6
|
+
)
|
7
|
+
attr_accessor :clients
|
8
|
+
|
9
|
+
def initialize(account)
|
10
|
+
@clients = []
|
11
|
+
ENDPOINTS.each do |endpoint|
|
12
|
+
@clients << AceClient::Niftycloud::Computing.build_client(
|
13
|
+
endpoint: endpoint,
|
14
|
+
path: '/api/',
|
15
|
+
access_key_id: account['access_key_id'],
|
16
|
+
secret_access_key: account['secret_access_key']
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def collect
|
22
|
+
@clients.each do |client|
|
23
|
+
client.regions.each do |region|
|
24
|
+
client.endpoint = region['regionEndpoint']
|
25
|
+
client.instances.each do |instance|
|
26
|
+
yield region, instance
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/nchosts/command.rb
CHANGED
@@ -12,19 +12,11 @@ module Nchosts
|
|
12
12
|
instances = []
|
13
13
|
json = JSON.parse File.read(options[:config])
|
14
14
|
json['accounts'].each do |account|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
)
|
21
|
-
client.regions.each do |region|
|
22
|
-
client.endpoint = region['regionEndpoint']
|
23
|
-
client.instances.each do |instance|
|
24
|
-
instance['region'] = region
|
25
|
-
instance['account'] = account
|
26
|
-
instances << instance
|
27
|
-
end
|
15
|
+
collector = Nchosts::Collector.new(account)
|
16
|
+
collector.collect do |region, instance|
|
17
|
+
instance['region'] = region
|
18
|
+
instance['account'] = account
|
19
|
+
instances << instance
|
28
20
|
end
|
29
21
|
end
|
30
22
|
File.write options[:output_path], instances.to_json
|
data/lib/nchosts/version.rb
CHANGED
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nchosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tily
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ace-client
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ace-client-ext
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: builder
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: json
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: erubis
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: command to collect hosts info
|
@@ -130,13 +130,14 @@ executables:
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
-
- .gitignore
|
133
|
+
- ".gitignore"
|
134
134
|
- Gemfile
|
135
135
|
- LICENSE.txt
|
136
136
|
- README.md
|
137
137
|
- Rakefile
|
138
138
|
- bin/nchosts
|
139
139
|
- lib/nchosts.rb
|
140
|
+
- lib/nchosts/collector.rb
|
140
141
|
- lib/nchosts/command.rb
|
141
142
|
- lib/nchosts/templates/aliases.erb
|
142
143
|
- lib/nchosts/templates/hosts.erb
|
@@ -153,18 +154,19 @@ require_paths:
|
|
153
154
|
- lib
|
154
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
156
|
requirements:
|
156
|
-
- -
|
157
|
+
- - ">="
|
157
158
|
- !ruby/object:Gem::Version
|
158
159
|
version: '0'
|
159
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
161
|
requirements:
|
161
|
-
- -
|
162
|
+
- - ">="
|
162
163
|
- !ruby/object:Gem::Version
|
163
164
|
version: '0'
|
164
165
|
requirements: []
|
165
166
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.2.2
|
167
168
|
signing_key:
|
168
169
|
specification_version: 4
|
169
170
|
summary: command to collect hosts info
|
170
171
|
test_files: []
|
172
|
+
has_rdoc:
|