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,63 +1,63 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerDelete < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server delete SERVER_ID [SERVER_ID] (options)'
9
-
10
- option :keep_ips,
11
- long: '--keep-ips',
12
- description: 'Keep server IPs after deleting the server.'
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
- name_args.each do |server_id|
25
- server = OneAndOne::Server.new
26
-
27
- begin
28
- server.get(server_id: server_id)
29
- rescue StandardError => e
30
- if e.message.include? 'NOT_FOUND'
31
- ui.error("Server ID #{server_id} not found. Skipping.")
32
- else
33
- ui.error(e.message)
34
- end
35
- next
36
- end
37
-
38
- server_name = server.specs['name']
39
-
40
- confirm("Do you really want to delete server '#{server_name}'")
41
-
42
- server.delete(keep_ips: config[:keep_ips])
43
-
44
- if config[:wait]
45
- begin
46
- puts ui.color('Deleting, wait for the operation to complete...', :cyan).to_s
47
- server.wait_for
48
- puts "Server '#{server_name}' is #{ui.color('deleted', :bold)}"
49
- rescue StandardError => e
50
- if e.message.include? 'NOT_FOUND'
51
- puts "Server '#{server_name}' is #{ui.color('deleted', :bold)}"
52
- else
53
- ui.error(e.message)
54
- end
55
- end
56
- else
57
- puts "Server '#{server_name}' is #{ui.color('being deleted', :bold)}"
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerDelete < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server delete SERVER_ID [SERVER_ID] (options)'
9
+
10
+ option :keep_ips,
11
+ long: '--keep-ips',
12
+ description: 'Keep server IPs after deleting the server.'
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
+ name_args.each do |server_id|
25
+ server = OneAndOne::Server.new
26
+
27
+ begin
28
+ server.get(server_id: server_id)
29
+ rescue StandardError => e
30
+ if e.message.include? 'NOT_FOUND'
31
+ ui.error("Server ID #{server_id} not found. Skipping.")
32
+ else
33
+ ui.error(e.message)
34
+ end
35
+ next
36
+ end
37
+
38
+ server_name = server.specs['name']
39
+
40
+ confirm("Do you really want to delete server '#{server_name}'")
41
+
42
+ server.delete(keep_ips: config[:keep_ips])
43
+
44
+ if config[:wait]
45
+ begin
46
+ puts ui.color('Deleting, wait for the operation to complete...', :cyan).to_s
47
+ server.wait_for
48
+ puts "Server '#{server_name}' is #{ui.color('deleted', :bold)}"
49
+ rescue StandardError => e
50
+ if e.message.include? 'NOT_FOUND'
51
+ puts "Server '#{server_name}' is #{ui.color('deleted', :bold)}"
52
+ else
53
+ ui.error(e.message)
54
+ end
55
+ end
56
+ else
57
+ puts "Server '#{server_name}' is #{ui.color('being deleted', :bold)}"
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,60 +1,60 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerHddAdd < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server hdd add HDD_SIZE [HDD_SIZE] (options)'
9
-
10
- option :id,
11
- short: '-I ID',
12
- long: '--server-id ID',
13
- description: 'Server ID'
14
-
15
- option :wait,
16
- short: '-W',
17
- long: '--wait',
18
- description: 'Wait for the operation to complete.'
19
-
20
- def run
21
- $stdout.sync = true
22
-
23
- init_client
24
-
25
- server = OneAndOne::Server.new
26
-
27
- begin
28
- server.get(server_id: config[:id])
29
- rescue StandardError => e
30
- if e.message.include? 'NOT_FOUND'
31
- ui.error("Server ID #{config[:id]} not found")
32
- else
33
- ui.error(e.message)
34
- end
35
- exit 1
36
- end
37
-
38
- hdds = []
39
-
40
- name_args.each do |size|
41
- hdds << { 'size' => size, 'is_main' => false }
42
- end
43
-
44
- if hdds.empty?
45
- ui.error('At least one value for HDD size must be specified.')
46
- else
47
- server.add_hdds(hdds: hdds)
48
-
49
- if config[:wait]
50
- puts ui.color('Adding, wait for the operation to complete...', :cyan).to_s
51
- server.wait_for
52
- puts "New HDD(s) is/are #{ui.color('added', :bold)}"
53
- else
54
- puts "New HDD(s) is/are #{ui.color('being added', :bold)}"
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerHddAdd < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server hdd add HDD_SIZE [HDD_SIZE] (options)'
9
+
10
+ option :id,
11
+ short: '-I ID',
12
+ long: '--server-id ID',
13
+ description: 'Server ID'
14
+
15
+ option :wait,
16
+ short: '-W',
17
+ long: '--wait',
18
+ description: 'Wait for the operation to complete.'
19
+
20
+ def run
21
+ $stdout.sync = true
22
+
23
+ init_client
24
+
25
+ server = OneAndOne::Server.new
26
+
27
+ begin
28
+ server.get(server_id: config[:id])
29
+ rescue StandardError => e
30
+ if e.message.include? 'NOT_FOUND'
31
+ ui.error("Server ID #{config[:id]} not found")
32
+ else
33
+ ui.error(e.message)
34
+ end
35
+ exit 1
36
+ end
37
+
38
+ hdds = []
39
+
40
+ name_args.each do |size|
41
+ hdds << { 'size' => size, 'is_main' => false }
42
+ end
43
+
44
+ if hdds.empty?
45
+ ui.error('At least one value for HDD size must be specified.')
46
+ else
47
+ server.add_hdds(hdds: hdds)
48
+
49
+ if config[:wait]
50
+ puts ui.color('Adding, wait for the operation to complete...', :cyan).to_s
51
+ server.wait_for
52
+ puts "New HDD(s) is/are #{ui.color('added', :bold)}"
53
+ else
54
+ puts "New HDD(s) is/are #{ui.color('being added', :bold)}"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -1,55 +1,55 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerHddDelete < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server hdd delete (options)'
9
-
10
- option :disk_id,
11
- short: '-D DISK_ID',
12
- long: '--disk-id DISK_ID',
13
- description: 'Disk ID'
14
-
15
- option :server_id,
16
- short: '-S SERVER_ID',
17
- long: '--server-id SERVER_ID',
18
- description: 'Server ID'
19
-
20
- option :wait,
21
- short: '-W',
22
- long: '--wait',
23
- description: 'Wait for the operation to complete.'
24
-
25
- def run
26
- $stdout.sync = true
27
-
28
- init_client
29
-
30
- server = OneAndOne::Server.new
31
-
32
- begin
33
- server.get(server_id: config[:server_id])
34
- rescue StandardError => e
35
- if e.message.include? 'NOT_FOUND'
36
- ui.error("Server ID #{config[:server_id]} not found")
37
- else
38
- ui.error(e.message)
39
- end
40
- exit 1
41
- end
42
-
43
- server.delete_hdd(server_id: config[:server_id], hdd_id: config[:disk_id])
44
-
45
- if config[:wait]
46
- puts ui.color('Deleting, wait for the operation to complete...', :cyan).to_s
47
- server.wait_for
48
- puts "HDD #{config[:disk_id]} is #{ui.color('deleted', :bold)}"
49
- else
50
- puts "HDD #{config[:disk_id]} is #{ui.color('being deleted', :bold)}"
51
- end
52
- end
53
- end
54
- end
55
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerHddDelete < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server hdd delete (options)'
9
+
10
+ option :disk_id,
11
+ short: '-D DISK_ID',
12
+ long: '--disk-id DISK_ID',
13
+ description: 'Disk ID'
14
+
15
+ option :server_id,
16
+ short: '-S SERVER_ID',
17
+ long: '--server-id SERVER_ID',
18
+ description: 'Server ID'
19
+
20
+ option :wait,
21
+ short: '-W',
22
+ long: '--wait',
23
+ description: 'Wait for the operation to complete.'
24
+
25
+ def run
26
+ $stdout.sync = true
27
+
28
+ init_client
29
+
30
+ server = OneAndOne::Server.new
31
+
32
+ begin
33
+ server.get(server_id: config[:server_id])
34
+ rescue StandardError => e
35
+ if e.message.include? 'NOT_FOUND'
36
+ ui.error("Server ID #{config[:server_id]} not found")
37
+ else
38
+ ui.error(e.message)
39
+ end
40
+ exit 1
41
+ end
42
+
43
+ server.delete_hdd(server_id: config[:server_id], hdd_id: config[:disk_id])
44
+
45
+ if config[:wait]
46
+ puts ui.color('Deleting, wait for the operation to complete...', :cyan).to_s
47
+ server.wait_for
48
+ puts "HDD #{config[:disk_id]} is #{ui.color('deleted', :bold)}"
49
+ else
50
+ puts "HDD #{config[:disk_id]} is #{ui.color('being deleted', :bold)}"
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,44 +1,44 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerHddList < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server hdd list SERVER_ID [SERVER_ID]'
9
-
10
- def run
11
- $stdout.sync = true
12
-
13
- server_id = ''
14
-
15
- if name_args.empty?
16
- ui.error('Server ID must be provided.')
17
- exit 1
18
- else
19
- server_id = name_args[0]
20
- end
21
-
22
- init_client
23
-
24
- server = OneAndOne::Server.new
25
-
26
- response = server.hdds(server_id: server_id)
27
- formated_output(response, true)
28
-
29
- hdds = [
30
- ui.color('ID', :bold),
31
- ui.color('Size (GB)', :bold),
32
- ui.color('Main', :bold)
33
- ]
34
- response.each do |disk|
35
- hdds << disk['id']
36
- hdds << disk['size'].to_s
37
- hdds << disk['is_main'].to_s
38
- end
39
-
40
- puts ui.list(hdds, :uneven_columns_across, 3)
41
- end
42
- end
43
- end
44
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerHddList < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server hdd list SERVER_ID [SERVER_ID]'
9
+
10
+ def run
11
+ $stdout.sync = true
12
+
13
+ server_id = ''
14
+
15
+ if name_args.empty?
16
+ ui.error('Server ID must be provided.')
17
+ exit 1
18
+ else
19
+ server_id = name_args[0]
20
+ end
21
+
22
+ init_client
23
+
24
+ server = OneAndOne::Server.new
25
+
26
+ response = server.hdds(server_id: server_id)
27
+ formated_output(response, true)
28
+
29
+ hdds = [
30
+ ui.color('ID', :bold),
31
+ ui.color('Size (GB)', :bold),
32
+ ui.color('Main', :bold)
33
+ ]
34
+ response.each do |disk|
35
+ hdds << disk['id']
36
+ hdds << disk['size'].to_s
37
+ hdds << disk['is_main'].to_s
38
+ end
39
+
40
+ puts ui.list(hdds, :uneven_columns_across, 3)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,59 +1,59 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerHddResize < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server hdd resize (options)'
9
-
10
- option :disk_id,
11
- short: '-D DISK_ID',
12
- long: '--disk-id DISK_ID',
13
- description: 'Disk ID'
14
-
15
- option :disk_size,
16
- long: '--disk-size DISK_SIZE',
17
- description: 'Disk size'
18
-
19
- option :server_id,
20
- short: '-S SERVER_ID',
21
- long: '--server-id SERVER_ID',
22
- description: 'Server ID'
23
-
24
- option :wait,
25
- short: '-W',
26
- long: '--wait',
27
- description: 'Wait for the operation to complete.'
28
-
29
- def run
30
- $stdout.sync = true
31
-
32
- init_client
33
-
34
- server = OneAndOne::Server.new
35
-
36
- begin
37
- server.get(server_id: config[:server_id])
38
- rescue StandardError => e
39
- if e.message.include? 'NOT_FOUND'
40
- ui.error("Server ID #{config[:server_id]} not found")
41
- else
42
- ui.error(e.message)
43
- end
44
- exit 1
45
- end
46
-
47
- server.modify_hdd(server_id: config[:server_id], hdd_id: config[:disk_id], size: config[:disk_size])
48
-
49
- if config[:wait]
50
- puts ui.color('Resizing, wait for the operation to complete...', :cyan).to_s
51
- server.wait_for
52
- puts "HDD #{config[:disk_id]} is #{ui.color('resized', :bold)}"
53
- else
54
- puts "HDD #{config[:disk_id]} is #{ui.color('resizing', :bold)}"
55
- end
56
- end
57
- end
58
- end
59
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerHddResize < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server hdd resize (options)'
9
+
10
+ option :disk_id,
11
+ short: '-D DISK_ID',
12
+ long: '--disk-id DISK_ID',
13
+ description: 'Disk ID'
14
+
15
+ option :disk_size,
16
+ long: '--disk-size DISK_SIZE',
17
+ description: 'Disk size'
18
+
19
+ option :server_id,
20
+ short: '-S SERVER_ID',
21
+ long: '--server-id SERVER_ID',
22
+ description: 'Server ID'
23
+
24
+ option :wait,
25
+ short: '-W',
26
+ long: '--wait',
27
+ description: 'Wait for the operation to complete.'
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ init_client
33
+
34
+ server = OneAndOne::Server.new
35
+
36
+ begin
37
+ server.get(server_id: config[:server_id])
38
+ rescue StandardError => e
39
+ if e.message.include? 'NOT_FOUND'
40
+ ui.error("Server ID #{config[:server_id]} not found")
41
+ else
42
+ ui.error(e.message)
43
+ end
44
+ exit 1
45
+ end
46
+
47
+ server.modify_hdd(server_id: config[:server_id], hdd_id: config[:disk_id], size: config[:disk_size])
48
+
49
+ if config[:wait]
50
+ puts ui.color('Resizing, wait for the operation to complete...', :cyan).to_s
51
+ server.wait_for
52
+ puts "HDD #{config[:disk_id]} is #{ui.color('resized', :bold)}"
53
+ else
54
+ puts "HDD #{config[:disk_id]} is #{ui.color('resizing', :bold)}"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end