knife-oneandone 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -12
  3. data/.rspec +2 -2
  4. data/.rubocop.yml +29 -26
  5. data/.travis.yml +5 -5
  6. data/Gemfile +4 -4
  7. data/LICENSE +201 -201
  8. data/README.md +358 -278
  9. data/Rakefile +6 -6
  10. data/knife-oneandone.gemspec +30 -31
  11. data/lib/1and1/helpers.rb +29 -29
  12. data/lib/chef/knife/oneandone_appliance_list.rb +39 -39
  13. data/lib/chef/knife/oneandone_base.rb +32 -32
  14. data/lib/chef/knife/oneandone_block_storage_attach.rb +33 -0
  15. data/lib/chef/knife/oneandone_block_storage_create.rb +64 -0
  16. data/lib/chef/knife/oneandone_block_storage_delete.rb +59 -0
  17. data/lib/chef/knife/oneandone_block_storage_detach.rb +28 -0
  18. data/lib/chef/knife/oneandone_block_storage_list.rb +42 -0
  19. data/lib/chef/knife/oneandone_block_storage_rename.rb +38 -0
  20. data/lib/chef/knife/oneandone_datacenter_list.rb +33 -33
  21. data/lib/chef/knife/oneandone_firewall_create.rb +97 -97
  22. data/lib/chef/knife/oneandone_firewall_delete.rb +59 -59
  23. data/lib/chef/knife/oneandone_firewall_list.rb +33 -33
  24. data/lib/chef/knife/oneandone_ip_list.rb +39 -39
  25. data/lib/chef/knife/oneandone_loadbalancer_create.rb +147 -147
  26. data/lib/chef/knife/oneandone_loadbalancer_delete.rb +59 -59
  27. data/lib/chef/knife/oneandone_loadbalancer_list.rb +39 -39
  28. data/lib/chef/knife/oneandone_mp_list.rb +37 -37
  29. data/lib/chef/knife/oneandone_server_baremetal_model_list.rb +31 -0
  30. data/lib/chef/knife/oneandone_server_create.rb +193 -163
  31. data/lib/chef/knife/oneandone_server_delete.rb +63 -63
  32. data/lib/chef/knife/oneandone_server_hdd_add.rb +60 -60
  33. data/lib/chef/knife/oneandone_server_hdd_delete.rb +55 -55
  34. data/lib/chef/knife/oneandone_server_hdd_list.rb +44 -44
  35. data/lib/chef/knife/oneandone_server_hdd_resize.rb +59 -59
  36. data/lib/chef/knife/oneandone_server_list.rb +35 -35
  37. data/lib/chef/knife/oneandone_server_modify.rb +80 -80
  38. data/lib/chef/knife/oneandone_server_reboot.rb +41 -41
  39. data/lib/chef/knife/oneandone_server_rename.rb +37 -37
  40. data/lib/chef/knife/oneandone_server_size_list.rb +39 -39
  41. data/lib/chef/knife/oneandone_server_start.rb +35 -35
  42. data/lib/chef/knife/oneandone_server_stop.rb +41 -41
  43. data/lib/chef/knife/oneandone_ssh_key_create.rb +54 -0
  44. data/lib/chef/knife/oneandone_ssh_key_delete.rb +59 -0
  45. data/lib/chef/knife/oneandone_ssh_key_list.rb +44 -0
  46. data/lib/chef/knife/oneandone_ssh_key_rename.rb +37 -0
  47. data/lib/knife-oneandone/version.rb +5 -5
  48. metadata +24 -13
@@ -1,35 +1,35 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerStart < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server start SERVER_ID [SERVER_ID] (options)'
9
-
10
- option :wait,
11
- short: '-W',
12
- long: '--wait',
13
- description: 'Wait for the operation to complete.'
14
-
15
- def run
16
- $stdout.sync = true
17
-
18
- init_client
19
-
20
- name_args.each do |server_id|
21
- server = OneAndOne::Server.new
22
- response = server.change_status(server_id: server_id, action: 'POWER_ON')
23
-
24
- if config[:wait]
25
- puts ui.color('Starting, wait for the operation to complete...', :cyan).to_s
26
- server.wait_for
27
- puts "Server '#{server.specs['name']}' is #{ui.color('started', :bold)}"
28
- else
29
- puts "Server '#{response['name']}' is #{ui.color('starting', :bold)}"
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerStart < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server start SERVER_ID [SERVER_ID] (options)'
9
+
10
+ option :wait,
11
+ short: '-W',
12
+ long: '--wait',
13
+ description: 'Wait for the operation to complete.'
14
+
15
+ def run
16
+ $stdout.sync = true
17
+
18
+ init_client
19
+
20
+ name_args.each do |server_id|
21
+ server = OneAndOne::Server.new
22
+ response = server.change_status(server_id: server_id, action: 'POWER_ON')
23
+
24
+ if config[:wait]
25
+ puts ui.color('Starting, wait for the operation to complete...', :cyan).to_s
26
+ server.wait_for
27
+ puts "Server '#{server.specs['name']}' is #{ui.color('started', :bold)}"
28
+ else
29
+ puts "Server '#{response['name']}' is #{ui.color('starting', :bold)}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,41 +1,41 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerStop < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server stop SERVER_ID [SERVER_ID] (options)'
9
-
10
- option :force,
11
- long: '--force',
12
- description: 'Force hardware shutdown.'
13
-
14
- option :wait,
15
- short: '-W',
16
- long: '--wait',
17
- description: 'Wait for the operation to complete.'
18
-
19
- def run
20
- $stdout.sync = true
21
-
22
- init_client
23
-
24
- method = config[:force] ? 'HARDWARE' : 'SOFTWARE'
25
-
26
- name_args.each do |server_id|
27
- server = OneAndOne::Server.new
28
- response = server.change_status(server_id: server_id, action: 'POWER_OFF', method: method)
29
-
30
- if config[:wait]
31
- puts ui.color('Stopping, wait for the operation to complete...', :cyan).to_s
32
- server.wait_for
33
- puts "Server '#{server.specs['name']}' is #{ui.color('stopped', :bold)}"
34
- else
35
- puts "Server '#{response['name']}' is #{ui.color('stopping', :bold)}"
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerStop < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server stop SERVER_ID [SERVER_ID] (options)'
9
+
10
+ option :force,
11
+ long: '--force',
12
+ description: 'Force hardware shutdown.'
13
+
14
+ option :wait,
15
+ short: '-W',
16
+ long: '--wait',
17
+ description: 'Wait for the operation to complete.'
18
+
19
+ def run
20
+ $stdout.sync = true
21
+
22
+ init_client
23
+
24
+ method = config[:force] ? 'HARDWARE' : 'SOFTWARE'
25
+
26
+ name_args.each do |server_id|
27
+ server = OneAndOne::Server.new
28
+ response = server.change_status(server_id: server_id, action: 'POWER_OFF', method: method)
29
+
30
+ if config[:wait]
31
+ puts ui.color('Stopping, wait for the operation to complete...', :cyan).to_s
32
+ server.wait_for
33
+ puts "Server '#{server.specs['name']}' is #{ui.color('stopped', :bold)}"
34
+ else
35
+ puts "Server '#{response['name']}' is #{ui.color('stopping', :bold)}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,54 @@
1
+ require 'chef/knife/oneandone_base'
2
+ require '1and1/helpers'
3
+
4
+ class Chef
5
+ class Knife
6
+ class OneandoneSshKeyCreate < Knife
7
+ include Knife::OneandoneBase
8
+ include Oneandone::Helpers
9
+
10
+ banner 'knife oneandone ssh key create (options)'
11
+
12
+ option :name,
13
+ short: '-n NAME',
14
+ long: '--name NAME',
15
+ description: 'SSH Key name (required)'
16
+
17
+ option :description,
18
+ long: '--description DESCRIPTION',
19
+ description: 'SSH Key description'
20
+
21
+ option :public_key,
22
+ short: '-p PUBLIC_KEY',
23
+ long: '--public-key PUBLIC_KEY',
24
+ description: 'Public key to import. If not given, new SSH key pair will be created'\
25
+ ' and the private key is returned in the response.'
26
+
27
+ option :wait,
28
+ short: '-W',
29
+ long: '--wait',
30
+ description: 'Wait for the operation to complete.'
31
+
32
+ def run
33
+ $stdout.sync = true
34
+
35
+ validate(config[:name], '-n NAME')
36
+
37
+ init_client
38
+
39
+ ssh_key = OneAndOne::SshKey.new
40
+ response = ssh_key.create(name: config[:name], description: config[:description],
41
+ public_key: config[:public_key])
42
+
43
+ if config[:wait]
44
+ ssh_key.wait_for
45
+ formated_output(ssh_key.get, true)
46
+ puts "SSH Key #{response['id']} is #{ui.color('created', :bold)}"
47
+ else
48
+ formated_output(response, true)
49
+ puts "SSH Key #{response['id']} is #{ui.color('being created', :bold)}"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,59 @@
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneSshKeyDelete < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone ssh key delete SSH_KEY_ID [SSH_KEY_ID] (options)'
9
+
10
+ option :wait,
11
+ short: '-W',
12
+ long: '--wait',
13
+ description: 'Wait for the operation to complete.'
14
+
15
+ def run
16
+ $stdout.sync = true
17
+
18
+ init_client
19
+
20
+ name_args.each do |ssh_key_id|
21
+ ssh_key = OneAndOne::SshKey.new
22
+
23
+ begin
24
+ ssh_key.get(ssh_key_id: ssh_key_id)
25
+ rescue StandardError => e
26
+ if e.message.include? 'NOT_FOUND'
27
+ ui.error("SSH key ID #{ssh_key_id} not found. Skipping.")
28
+ else
29
+ ui.error(e.message)
30
+ end
31
+ next
32
+ end
33
+
34
+ ssh_key_name = ssh_key.specs['name']
35
+
36
+ confirm("Do you really want to delete SSH key '#{ssh_key_name}'")
37
+
38
+ ssh_key.delete
39
+
40
+ if config[:wait]
41
+ begin
42
+ puts ui.color('Deleting, wait for the operation to complete...', :cyan).to_s
43
+ ssh_key.wait_for
44
+ puts "SSH key '#{ssh_key_name}' is #{ui.color('deleted', :bold)}"
45
+ rescue StandardError => e
46
+ if e.message.include? 'NOT_FOUND'
47
+ puts "SSH key '#{ssh_key_name}' is #{ui.color('deleted', :bold)}"
48
+ else
49
+ ui.error(e.message)
50
+ end
51
+ end
52
+ else
53
+ puts "SSH key '#{ssh_key_name}' is #{ui.color('being deleted', :bold)}"
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,44 @@
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneSshKeyList < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone ssh key list'
9
+
10
+ def run
11
+ $stdout.sync = true
12
+
13
+ init_client
14
+
15
+ response = OneAndOne::SshKey.new.list
16
+ formated_output(response, true)
17
+
18
+ ssh_keys = [
19
+ ui.color('ID', :bold),
20
+ ui.color('Name', :bold),
21
+ ui.color('Description', :bold),
22
+ ui.color('State', :bold),
23
+ ui.color('Servers', :bold),
24
+ ui.color('Md5', :bold),
25
+ ui.color('Public Key', :bold),
26
+ ui.color('Creation Date', :bold)
27
+ ]
28
+
29
+ response.each do |ssh|
30
+ ssh_keys << ssh['id']
31
+ ssh_keys << ssh['name']
32
+ ssh_keys << (ssh['description'].nil? ? '' : ssh['description'])
33
+ ssh_keys << ssh['state']
34
+ ssh_keys << ssh['servers'].to_s
35
+ ssh_keys << ssh['md5']
36
+ ssh_keys << ssh['public_key']
37
+ ssh_keys << ssh['creation_date']
38
+ end
39
+
40
+ puts ui.list(ssh_keys, :uneven_columns_across, 8)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,37 @@
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneSshKeyRename < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone ssh key rename (options)'
9
+
10
+ option :name,
11
+ short: '-n NAME',
12
+ long: '--name NAME',
13
+ description: 'SSH Key name'
14
+
15
+ option :description,
16
+ long: '--description DESCRIPTION',
17
+ description: 'SSH Key description'
18
+
19
+ option :id,
20
+ short: '-I ID',
21
+ long: '--id ID',
22
+ description: 'SSH Key ID'
23
+
24
+ def run
25
+ $stdout.sync = true
26
+
27
+ init_client
28
+
29
+ ssh_key = OneAndOne::SshKey.new
30
+ response = ssh_key.modify(ssh_key_id: config[:id], name: config[:name], description: config[:description])
31
+
32
+ formated_output(response, true)
33
+ puts "SSH Key updated #{ui.color('updated', :bold)}"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
- module Knife
2
- module Oneandone
3
- VERSION = '1.0.0'.freeze
4
- end
5
- end
1
+ module Knife
2
+ module Oneandone
3
+ VERSION = '1.2.0'.freeze
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-oneandone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nurfet Becirevic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-06 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: 1and1
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.1'
26
+ version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +86,42 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.39'
89
+ version: '0.58'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.39'
96
+ version: '0.58'
97
97
  - !ruby/object:Gem::Dependency
98
- name: webmock
98
+ name: vcr
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.24'
103
+ version: '3.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.24'
110
+ version: '3.0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: vcr
112
+ name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.0'
117
+ version: '1.24'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.0'
124
+ version: '1.24'
125
125
  description: Official Chef Knife plugin for managing 1&1 Cloud servers
126
126
  email:
127
127
  - nurfet@stackpointcloud.com
@@ -141,6 +141,12 @@ files:
141
141
  - lib/1and1/helpers.rb
142
142
  - lib/chef/knife/oneandone_appliance_list.rb
143
143
  - lib/chef/knife/oneandone_base.rb
144
+ - lib/chef/knife/oneandone_block_storage_attach.rb
145
+ - lib/chef/knife/oneandone_block_storage_create.rb
146
+ - lib/chef/knife/oneandone_block_storage_delete.rb
147
+ - lib/chef/knife/oneandone_block_storage_detach.rb
148
+ - lib/chef/knife/oneandone_block_storage_list.rb
149
+ - lib/chef/knife/oneandone_block_storage_rename.rb
144
150
  - lib/chef/knife/oneandone_datacenter_list.rb
145
151
  - lib/chef/knife/oneandone_firewall_create.rb
146
152
  - lib/chef/knife/oneandone_firewall_delete.rb
@@ -150,6 +156,7 @@ files:
150
156
  - lib/chef/knife/oneandone_loadbalancer_delete.rb
151
157
  - lib/chef/knife/oneandone_loadbalancer_list.rb
152
158
  - lib/chef/knife/oneandone_mp_list.rb
159
+ - lib/chef/knife/oneandone_server_baremetal_model_list.rb
153
160
  - lib/chef/knife/oneandone_server_create.rb
154
161
  - lib/chef/knife/oneandone_server_delete.rb
155
162
  - lib/chef/knife/oneandone_server_hdd_add.rb
@@ -163,6 +170,10 @@ files:
163
170
  - lib/chef/knife/oneandone_server_size_list.rb
164
171
  - lib/chef/knife/oneandone_server_start.rb
165
172
  - lib/chef/knife/oneandone_server_stop.rb
173
+ - lib/chef/knife/oneandone_ssh_key_create.rb
174
+ - lib/chef/knife/oneandone_ssh_key_delete.rb
175
+ - lib/chef/knife/oneandone_ssh_key_list.rb
176
+ - lib/chef/knife/oneandone_ssh_key_rename.rb
166
177
  - lib/knife-oneandone/version.rb
167
178
  homepage: https://github.com/1and1/oneandone-cloudserver-chef
168
179
  licenses:
@@ -184,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
195
  version: '0'
185
196
  requirements: []
186
197
  rubyforge_project:
187
- rubygems_version: 2.6.4
198
+ rubygems_version: 2.6.13
188
199
  signing_key:
189
200
  specification_version: 4
190
201
  summary: Chef Knife plugin for 1&1 Cloud server