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 OneandoneServerList < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server list'
9
-
10
- def run
11
- $stdout.sync = true
12
-
13
- init_client
14
-
15
- response = OneAndOne::Server.new.list
16
- formated_output(response, true)
17
-
18
- server_list = [
19
- ui.color('ID', :bold),
20
- ui.color('Name', :bold),
21
- ui.color('State', :bold),
22
- ui.color('Data Center', :bold)
23
- ]
24
- response.each do |server|
25
- server_list << server['id']
26
- server_list << server['name']
27
- server_list << server['status']['state']
28
- server_list << server['datacenter']['country_code']
29
- end
30
-
31
- puts ui.list(server_list, :uneven_columns_across, 4)
32
- end
33
- end
34
- end
35
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerList < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server list'
9
+
10
+ def run
11
+ $stdout.sync = true
12
+
13
+ init_client
14
+
15
+ response = OneAndOne::Server.new.list
16
+ formated_output(response, true)
17
+
18
+ server_list = [
19
+ ui.color('ID', :bold),
20
+ ui.color('Name', :bold),
21
+ ui.color('State', :bold),
22
+ ui.color('Data Center', :bold)
23
+ ]
24
+ response.each do |server|
25
+ server_list << server['id']
26
+ server_list << server['name']
27
+ server_list << server['status']['state']
28
+ server_list << server['datacenter']['country_code']
29
+ end
30
+
31
+ puts ui.list(server_list, :uneven_columns_across, 4)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,80 +1,80 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerModify < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server modify SERVER_ID [SERVER_ID] (options)'
9
-
10
- option :fixed_size_id,
11
- short: '-S FIXED_SIZE_ID',
12
- long: '--fixed-size-id FIXED_SIZE_ID',
13
- description: 'ID of the fixed instance size'
14
-
15
- option :cpu,
16
- short: '-P PROCESSORS',
17
- long: '--cpu PROCESSORS',
18
- description: 'The number of processors'
19
-
20
- option :cores,
21
- short: '-C CORES',
22
- long: '--cores CORES',
23
- description: 'The number of cores per processor'
24
-
25
- option :ram,
26
- short: '-r RAM',
27
- long: '--ram RAM',
28
- description: 'The amount of RAM in GB'
29
-
30
- option :wait,
31
- short: '-W',
32
- long: '--wait',
33
- description: 'Wait for the operation to complete.'
34
-
35
- def run
36
- $stdout.sync = true
37
-
38
- init_client
39
-
40
- name_args.each do |server_id|
41
- server = OneAndOne::Server.new
42
-
43
- begin
44
- server.get(server_id: server_id)
45
- rescue StandardError => e
46
- if e.message.include? 'NOT_FOUND'
47
- ui.error("Server ID #{server_id} not found. Skipping.")
48
- else
49
- ui.error(e.message)
50
- end
51
- next
52
- end
53
-
54
- server.modify_hardware(
55
- fixed_instance_id: config[:fixed_size_id],
56
- vcore: config[:cpu],
57
- cores_per_processor: config[:cores],
58
- ram: config[:ram]
59
- )
60
-
61
- if config[:wait]
62
- puts ui.color('Reconfiguring, wait for the operation to complete...', :cyan).to_s
63
- server.wait_for
64
-
65
- puts "\t#{ui.color('ID', :cyan)}: #{server.id}"
66
- puts "\t#{ui.color('Name', :cyan)}: #{server.specs['name']}"
67
- puts "\t#{ui.color('Fixed Size ID', :cyan)}: #{server.specs['hardware']['fixed_instance_size_id']}"
68
- puts "\t#{ui.color('Processors', :cyan)}: #{server.specs['hardware']['vcore']}"
69
- puts "\t#{ui.color('Cores per Processor', :cyan)}: #{server.specs['hardware']['cores_per_processor']}"
70
- puts "\t#{ui.color('RAM (GB)', :cyan)}: #{server.specs['hardware']['ram']}\n"
71
-
72
- puts "Server's hardware is #{ui.color('modified', :bold)}"
73
- else
74
- puts "Server's hardware is #{ui.color('being modified', :bold)}"
75
- end
76
- end
77
- end
78
- end
79
- end
80
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerModify < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server modify SERVER_ID [SERVER_ID] (options)'
9
+
10
+ option :fixed_size_id,
11
+ short: '-S FIXED_SIZE_ID',
12
+ long: '--fixed-size-id FIXED_SIZE_ID',
13
+ description: 'ID of the fixed instance size'
14
+
15
+ option :cpu,
16
+ short: '-P PROCESSORS',
17
+ long: '--cpu PROCESSORS',
18
+ description: 'The number of processors'
19
+
20
+ option :cores,
21
+ short: '-C CORES',
22
+ long: '--cores CORES',
23
+ description: 'The number of cores per processor'
24
+
25
+ option :ram,
26
+ short: '-r RAM',
27
+ long: '--ram RAM',
28
+ description: 'The amount of RAM in GB'
29
+
30
+ option :wait,
31
+ short: '-W',
32
+ long: '--wait',
33
+ description: 'Wait for the operation to complete.'
34
+
35
+ def run
36
+ $stdout.sync = true
37
+
38
+ init_client
39
+
40
+ name_args.each do |server_id|
41
+ server = OneAndOne::Server.new
42
+
43
+ begin
44
+ server.get(server_id: server_id)
45
+ rescue StandardError => e
46
+ if e.message.include? 'NOT_FOUND'
47
+ ui.error("Server ID #{server_id} not found. Skipping.")
48
+ else
49
+ ui.error(e.message)
50
+ end
51
+ next
52
+ end
53
+
54
+ server.modify_hardware(
55
+ fixed_instance_id: config[:fixed_size_id],
56
+ vcore: config[:cpu],
57
+ cores_per_processor: config[:cores],
58
+ ram: config[:ram]
59
+ )
60
+
61
+ if config[:wait]
62
+ puts ui.color('Reconfiguring, wait for the operation to complete...', :cyan).to_s
63
+ server.wait_for
64
+
65
+ puts "\t#{ui.color('ID', :cyan)}: #{server.id}"
66
+ puts "\t#{ui.color('Name', :cyan)}: #{server.specs['name']}"
67
+ puts "\t#{ui.color('Fixed Size ID', :cyan)}: #{server.specs['hardware']['fixed_instance_size_id']}"
68
+ puts "\t#{ui.color('Processors', :cyan)}: #{server.specs['hardware']['vcore']}"
69
+ puts "\t#{ui.color('Cores per Processor', :cyan)}: #{server.specs['hardware']['cores_per_processor']}"
70
+ puts "\t#{ui.color('RAM (GB)', :cyan)}: #{server.specs['hardware']['ram']}\n"
71
+
72
+ puts "Server's hardware is #{ui.color('modified', :bold)}"
73
+ else
74
+ puts "Server's hardware is #{ui.color('being modified', :bold)}"
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,41 +1,41 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerReboot < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server reboot SERVER_ID [SERVER_ID] (options)'
9
-
10
- option :force,
11
- long: '--force',
12
- description: 'Force hardware restart.'
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: 'REBOOT', method: method)
29
-
30
- if config[:wait]
31
- puts ui.color('Rebooting, wait for the operation to complete...', :cyan).to_s
32
- server.wait_for
33
- puts "Server '#{server.specs['name']}' is #{ui.color('rebooted', :bold)}"
34
- else
35
- puts "Server '#{response['name']}' is #{ui.color('rebooting', :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 OneandoneServerReboot < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server reboot SERVER_ID [SERVER_ID] (options)'
9
+
10
+ option :force,
11
+ long: '--force',
12
+ description: 'Force hardware restart.'
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: 'REBOOT', method: method)
29
+
30
+ if config[:wait]
31
+ puts ui.color('Rebooting, wait for the operation to complete...', :cyan).to_s
32
+ server.wait_for
33
+ puts "Server '#{server.specs['name']}' is #{ui.color('rebooted', :bold)}"
34
+ else
35
+ puts "Server '#{response['name']}' is #{ui.color('rebooting', :bold)}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,37 +1,37 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerRename < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server rename (options)'
9
-
10
- option :name,
11
- short: '-n NAME',
12
- long: '--server-name NAME',
13
- description: 'Name of the server'
14
-
15
- option :description,
16
- long: '--server-desc DESCRIPTION',
17
- description: 'Description of the server'
18
-
19
- option :id,
20
- short: '-I ID',
21
- long: '--server-id ID',
22
- description: 'Server ID'
23
-
24
- def run
25
- $stdout.sync = true
26
-
27
- init_client
28
-
29
- server = OneAndOne::Server.new
30
- response = server.modify(server_id: config[:id], name: config[:name], description: config[:description])
31
-
32
- formated_output(response, true)
33
- puts "Server name and/or description #{ui.color('updated', :bold)}"
34
- end
35
- end
36
- end
37
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerRename < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server rename (options)'
9
+
10
+ option :name,
11
+ short: '-n NAME',
12
+ long: '--server-name NAME',
13
+ description: 'Name of the server'
14
+
15
+ option :description,
16
+ long: '--server-desc DESCRIPTION',
17
+ description: 'Description of the server'
18
+
19
+ option :id,
20
+ short: '-I ID',
21
+ long: '--server-id ID',
22
+ description: 'Server ID'
23
+
24
+ def run
25
+ $stdout.sync = true
26
+
27
+ init_client
28
+
29
+ server = OneAndOne::Server.new
30
+ response = server.modify(server_id: config[:id], name: config[:name], description: config[:description])
31
+
32
+ formated_output(response, true)
33
+ puts "Server name and/or description #{ui.color('updated', :bold)}"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,39 +1,39 @@
1
- require 'chef/knife/oneandone_base'
2
-
3
- class Chef
4
- class Knife
5
- class OneandoneServerSizeList < Knife
6
- include Knife::OneandoneBase
7
-
8
- banner 'knife oneandone server size list'
9
-
10
- def run
11
- $stdout.sync = true
12
-
13
- init_client
14
-
15
- response = OneAndOne::Server.new.list_fixed
16
- formated_output(response, true)
17
-
18
- sizes = [
19
- ui.color('ID', :bold),
20
- ui.color('Name', :bold),
21
- ui.color('RAM (GB)', :bold),
22
- ui.color('Processor No.', :bold),
23
- ui.color('Cores per Processor', :bold),
24
- ui.color('Disk Size (GB)', :bold)
25
- ]
26
- response.each do |fs|
27
- sizes << fs['id']
28
- sizes << fs['name']
29
- sizes << fs['hardware']['ram'].to_s
30
- sizes << fs['hardware']['vcore'].to_s
31
- sizes << fs['hardware']['cores_per_processor'].to_s
32
- sizes << fs['hardware']['hdds'][0]['size'].to_s
33
- end
34
-
35
- puts ui.list(sizes, :uneven_columns_across, 6)
36
- end
37
- end
38
- end
39
- end
1
+ require 'chef/knife/oneandone_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class OneandoneServerSizeList < Knife
6
+ include Knife::OneandoneBase
7
+
8
+ banner 'knife oneandone server size list'
9
+
10
+ def run
11
+ $stdout.sync = true
12
+
13
+ init_client
14
+
15
+ response = OneAndOne::Server.new.list_fixed
16
+ formated_output(response, true)
17
+
18
+ sizes = [
19
+ ui.color('ID', :bold),
20
+ ui.color('Name', :bold),
21
+ ui.color('RAM (GB)', :bold),
22
+ ui.color('Processor No.', :bold),
23
+ ui.color('Cores per Processor', :bold),
24
+ ui.color('Disk Size (GB)', :bold)
25
+ ]
26
+ response.each do |fs|
27
+ sizes << fs['id']
28
+ sizes << fs['name']
29
+ sizes << fs['hardware']['ram'].to_s
30
+ sizes << fs['hardware']['vcore'].to_s
31
+ sizes << fs['hardware']['cores_per_processor'].to_s
32
+ sizes << fs['hardware']['hdds'][0]['size'].to_s
33
+ end
34
+
35
+ puts ui.list(sizes, :uneven_columns_across, 6)
36
+ end
37
+ end
38
+ end
39
+ end