knife-scaleway 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/scaleway_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class ScalewayServerSnapshot < Knife
18
+ include Knife::ScalewayBase
19
+
20
+ banner 'knife scaleway server snapshot (options)'
21
+
22
+ option :name,
23
+ short: '-N NAME',
24
+ long: '--snapshot-name NAME',
25
+ description: 'Name of snapshot'
26
+
27
+ option :id,
28
+ short: '-I ID',
29
+ long: '--server-id ID',
30
+ description: 'Droplet ID'
31
+
32
+ def run
33
+ $stdout.sync = true
34
+
35
+ validate!
36
+
37
+ unless locate_config_value(:name)
38
+ ui.error('Name cannot be empty. => -N <name>')
39
+ exit 1
40
+ end
41
+
42
+ unless locate_config_value(:id)
43
+ ui.error('ID cannot be empty. => -I <id>')
44
+ exit 1
45
+ end
46
+
47
+ result = client.server_actions.snapshot(server_id: locate_config_value(:id), name: locate_config_value(:name))
48
+
49
+ unless result.class == DropletKit::Action
50
+ ui.error JSON.parse(result)['message']
51
+ exit 1
52
+ end
53
+
54
+ wait_for_status(result, status: 'active')
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,42 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/scaleway_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class ScalewayImageDestroy < Knife
18
+ include Knife::ScalewayBase
19
+
20
+ banner 'knife scaleway image destroy (options)'
21
+
22
+ option :id,
23
+ short: '-I ID',
24
+ long: '--image-id ID',
25
+ description: 'The image ID'
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ validate!
31
+
32
+ unless locate_config_value(:id)
33
+ ui.error('Image ID cannot be empty. => -I <image-id>')
34
+ exit 1
35
+ end
36
+
37
+ result = client.images.delete(id: locate_config_value(:id))
38
+ ui.info 'OK' if result == true || ui.error(JSON.parse(result)['message'])
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,58 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/scaleway_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class ScalewayImageList < Knife
18
+ include Knife::ScalewayBase
19
+
20
+ banner 'knife scaleway image list (options)'
21
+
22
+ option :public_images,
23
+ short: '-P',
24
+ long: '--public',
25
+ description: 'Show public images'
26
+
27
+ def run
28
+ $stdout.sync = true
29
+
30
+ validate!
31
+
32
+ image_list = [
33
+ ui.color('ID', :bold),
34
+ ui.color('Distribution', :bold),
35
+ ui.color('Name', :bold),
36
+ ui.color('Slug', :bold)
37
+ ]
38
+
39
+ images = Scaleway::Image.all
40
+
41
+ if config[:public_images]
42
+ found_images = images.find_all { |i| i.public == true }
43
+ else
44
+ found_images = images.find_all { |i| i.public == false }
45
+ end
46
+
47
+ found_images.each do |image|
48
+ image_list << image.id.to_s
49
+ image_list << image.arch.to_s
50
+ image_list << image.name.to_s
51
+ image_list << image.public.to_s
52
+ end
53
+
54
+ puts ui.list(image_list, :uneven_columns_across, 4)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,46 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/scaleway_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class ScalewayIpList < Knife
18
+ include Knife::ScalewayBase
19
+
20
+ banner 'knife scaleway ip list (options)'
21
+
22
+ def run
23
+ $stdout.sync = true
24
+
25
+ validate!
26
+
27
+ ip_list = [
28
+ ui.color('ID', :bold),
29
+ ui.color('Address', :bold),
30
+ ui.color('Server', :bold),
31
+ ]
32
+
33
+ ips = Scaleway::Ip.all
34
+
35
+ ips.each do |ip|
36
+ server_name = ip.server ? ip.server.name : ''
37
+ ip_list << ip.id.to_s
38
+ ip_list << ip.address.to_s
39
+ ip_list << server_name
40
+ end
41
+
42
+ puts ui.list(ip_list, :uneven_columns_across, 3)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,43 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/scaleway_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class ScalewayRegionList < Knife
18
+ include Knife::ScalewayBase
19
+
20
+ banner 'knife scaleway region list (options)'
21
+
22
+ def run
23
+ $stdout.sync = true
24
+
25
+ validate!
26
+
27
+ region_list = [
28
+ ui.color('Name', :bold),
29
+ ui.color('Slug', :bold)
30
+ ]
31
+
32
+ regions = [OpenStruct.new(name: 'France 1', slug: 'fr-1')]
33
+
34
+ regions.sort_by(&:name).each do |region|
35
+ region_list << region.name
36
+ region_list << region.slug
37
+ end
38
+
39
+ puts ui.list(region_list, :uneven_columns_across, 2)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,41 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/scaleway_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class ScalewaySizeList < Knife
18
+ include Knife::ScalewayBase
19
+
20
+ banner 'knife scaleway size list (options)'
21
+
22
+ def run
23
+ $stdout.sync = true
24
+
25
+ validate!
26
+
27
+ size_list = [
28
+ ui.color('Slug', :bold)
29
+ ]
30
+
31
+ sizes = client.sizes.all
32
+
33
+ sizes.each do |size|
34
+ size_list << size.slug
35
+ end
36
+
37
+ puts ui.list(size_list, :uneven_columns_across, 1)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,48 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/scaleway_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class ScalewayVolumeList < Knife
18
+ include Knife::ScalewayBase
19
+
20
+ banner 'knife scaleway volume list (options)'
21
+
22
+ def run
23
+ $stdout.sync = true
24
+
25
+ validate!
26
+
27
+ image_list = [
28
+ ui.color('ID', :bold),
29
+ ui.color('Name', :bold),
30
+ ui.color('Server', :bold),
31
+ ui.color('Size', :bold)
32
+ ]
33
+
34
+ volumes = Scaleway::Volume.all
35
+
36
+ volumes.each do |volume|
37
+ server_name = volume.server ? volume.server.name : ''
38
+ image_list << volume.id.to_s
39
+ image_list << volume.name.to_s
40
+ image_list << server_name
41
+ image_list << "#{(volume.size.to_i / 1000 / 1000 / 1000)} GB"
42
+ end
43
+
44
+ puts ui.list(image_list, :uneven_columns_across, 4)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,8 @@
1
+ # rubocop:disable Style/FileName
2
+ require 'knife-scaleway/version'
3
+
4
+ module Knife
5
+ module Scaleway
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Knife
2
+ module Scaleway
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,269 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-scaleway
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lukas Diener
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '10.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '10.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.27'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.27'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: knife-solo
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: knife-zero
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.20'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.20'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.9'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.9'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.8'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.8'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '4.3'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '4.3'
153
+ - !ruby/object:Gem::Dependency
154
+ name: coveralls
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: countloc
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: simplecov-console
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description: A plugin for chef's knife to manage instances of Scaleway servers
210
+ email:
211
+ - lukas.diener@hotmail.com
212
+ executables: []
213
+ extensions: []
214
+ extra_rdoc_files: []
215
+ files:
216
+ - ".gitignore"
217
+ - ".rubocop.yml"
218
+ - Gemfile
219
+ - Guardfile
220
+ - LICENSE.txt
221
+ - README.md
222
+ - Rakefile
223
+ - knife-scaleway.gemspec
224
+ - lib/chef/knife/scaleway.rb
225
+ - lib/chef/knife/scaleway_account_info.rb
226
+ - lib/chef/knife/scaleway_base.rb
227
+ - lib/chef/knife/scaleway_droplet_create.rb
228
+ - lib/chef/knife/scaleway_droplet_destroy.rb
229
+ - lib/chef/knife/scaleway_droplet_list.rb
230
+ - lib/chef/knife/scaleway_droplet_power.rb
231
+ - lib/chef/knife/scaleway_droplet_powercycle.rb
232
+ - lib/chef/knife/scaleway_droplet_reboot.rb
233
+ - lib/chef/knife/scaleway_droplet_rebuild.rb
234
+ - lib/chef/knife/scaleway_droplet_rename.rb
235
+ - lib/chef/knife/scaleway_droplet_resize.rb
236
+ - lib/chef/knife/scaleway_droplet_snapshot.rb
237
+ - lib/chef/knife/scaleway_image_destroy.rb
238
+ - lib/chef/knife/scaleway_image_list.rb
239
+ - lib/chef/knife/scaleway_ip_list.rb
240
+ - lib/chef/knife/scaleway_region_list.rb
241
+ - lib/chef/knife/scaleway_size_list.rb
242
+ - lib/chef/knife/scaleway_volume_list.rb
243
+ - lib/knife-scaleway.rb
244
+ - lib/knife-scaleway/version.rb
245
+ homepage: https://github.com/LukasSkywalker/knife-scaleway
246
+ licenses:
247
+ - Apache 2.0
248
+ metadata: {}
249
+ post_install_message:
250
+ rdoc_options: []
251
+ require_paths:
252
+ - lib
253
+ required_ruby_version: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ required_rubygems_version: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - ">="
261
+ - !ruby/object:Gem::Version
262
+ version: '0'
263
+ requirements: []
264
+ rubyforge_project:
265
+ rubygems_version: 2.4.8
266
+ signing_key:
267
+ specification_version: 4
268
+ summary: A plugin for chef's knife to manage instances of Scaleway servers
269
+ test_files: []