knife-softlayer 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +19 -19
  3. data/.travis.yml +20 -20
  4. data/CHANGELOG.md +19 -19
  5. data/CONTRIBUTING.md +31 -31
  6. data/CONTRIBUTORS.md +2 -2
  7. data/Gemfile +4 -4
  8. data/LICENSE.txt +72 -72
  9. data/README.md +83 -83
  10. data/Rakefile +37 -37
  11. data/docs/cla-corporate.md +133 -133
  12. data/docs/cla-individual.md +84 -84
  13. data/examples/datacenter.md +94 -94
  14. data/examples/flavor.md +58 -58
  15. data/examples/global_ip.md +22 -22
  16. data/examples/image.md +34 -34
  17. data/examples/key_pair.md +56 -56
  18. data/examples/server.md +82 -82
  19. data/examples/vlan.md +85 -85
  20. data/knife-softlayer.gemspec +39 -39
  21. data/lib/chef/knife/flavor/base.rb +52 -52
  22. data/lib/chef/knife/softlayer.rb +14 -14
  23. data/lib/chef/knife/softlayer_base.rb +112 -112
  24. data/lib/chef/knife/softlayer_datacenter_list.rb +28 -28
  25. data/lib/chef/knife/softlayer_datacenter_show.rb +45 -45
  26. data/lib/chef/knife/softlayer_delete.rb +6 -6
  27. data/lib/chef/knife/softlayer_flavor_list.rb +53 -53
  28. data/lib/chef/knife/softlayer_global_ip_list.rb +34 -34
  29. data/lib/chef/knife/softlayer_image_list.rb +26 -26
  30. data/lib/chef/knife/softlayer_key_pair_create.rb +37 -37
  31. data/lib/chef/knife/softlayer_key_pair_list.rb +28 -28
  32. data/lib/chef/knife/softlayer_list.rb +6 -6
  33. data/lib/chef/knife/softlayer_server_create.rb +462 -458
  34. data/lib/chef/knife/softlayer_server_destroy.rb +146 -146
  35. data/lib/chef/knife/softlayer_server_list.rb +27 -27
  36. data/lib/chef/knife/softlayer_server_relaunch.rb +208 -208
  37. data/lib/chef/knife/softlayer_vlan_create.rb +37 -37
  38. data/lib/chef/knife/softlayer_vlan_list.rb +28 -28
  39. data/lib/chef/knife/softlayer_vlan_show.rb +40 -40
  40. data/lib/knife-softlayer/version.rb +12 -12
  41. data/spec/spec_helper.rb +21 -21
  42. data/spec/unit/softlayer_base_spec.rb +26 -26
  43. data/spec/unit/softlayer_server_create_spec.rb +105 -105
  44. data/spec/unit/softlayer_server_destroy_spec.rb +47 -47
  45. metadata +27 -27
data/examples/server.md CHANGED
@@ -1,82 +1,82 @@
1
- ### Server Examples
2
-
3
- These examples all assume you have set your SoftLayer username and api key in `~/.chef/knife.rb` like this:
4
-
5
- ```ruby
6
- knife[:softlayer_username] = 'example_user'
7
- knife[:softlayer_api_key] = '1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a'
8
- ```
9
-
10
- #### Create server and bootstrap as a chef node
11
-
12
- Create a server using an image, a flavor, assign an existing global ip address, and inject two ssh keys.
13
-
14
- ```sh
15
- user@localhost> knife softlayer server create --image-id 23f7f05f-3657-4330-8772-329ed2e816bc --assign-global-ip 108.168.254.41 --ssh-keys 12345 23456 --hostname web --domain ibm.com --flavor m1.tiny --run-list 'recipe[redis],recipe[rbenv],recipe[apt]' -i /Users/user/.ssh/my_private_key_rsa
16
- ```
17
-
18
- Create a server, provision a new global ip address and assign it to the server, tag both the chef node and the SoftLayer server with the passed tags.
19
-
20
- ```sh
21
- user@localhost> knife softlayer server create --new-global-ip v4 --tags job=task,private=true --hostname web --domain ibm.com --flavor m1.tiny --run-list 'recipe[redis],recipe[rbenv],recipe[apt]' --ssh-keys 12345 -i /Users/user/.ssh/my_private_key_rsa
22
- ```
23
-
24
- Create a server located in specific public and private VLANS.
25
-
26
- ```sh
27
- user@localhost> knife softlayer server create --vlan 12345 --private-vlan 23456 --hostname web --domain ibm.com --flavor m1.tiny --run-list 'recipe[redis],recipe[rbenv],recipe[apt]' --ssh-keys 12345 -i /Users/user/.ssh/my_private_key_rsa --new-global-ip v4 --tags job=task,private=true
28
- ```
29
-
30
- Create a server specifying options from a JSON file.
31
-
32
- ```sh
33
- user@localhost> cat /Users/user/bootstrap.json
34
- {
35
- "hostname": "web",
36
- "domain": "ibm.com",
37
- "flavor": "m1.xlarge",
38
- "run-list": "recipe[redis],recipe[rbenv],recipe[apt]",
39
- "ssh-keys": "73148",
40
- "identity-file": "/Users/user/.ssh/my_softlayer_key_rsa",
41
- "image-id": "23f7f05f-3657-4330-8772-329ed2e816bc",
42
- "user_data": "first_boot=disabled"
43
- }
44
-
45
- user@localhost> knife softlayer server create --from-file /Users/user/bootstrap.json
46
-
47
- # options file + additional arguments
48
- user@localhost> knife softlayer server create --from-file /Users/user/bootstrap.json --tags job=task,private=true
49
- ```
50
-
51
- Other options.
52
-
53
- ```sh
54
- user@localhost> knife softlayer server create --help
55
- # There are a lot...
56
- ```
57
-
58
- #### Destroy a server and its chef node and client
59
-
60
- Use the node name as an identifier.
61
-
62
- ```sh
63
- user@localhost> knife softlayer server destroy --node-name some-node-name
64
- Decommissioning SoftLayer VM, this may take a few minutes.
65
- WARNING: Deleted node some-node-name
66
- Chef node successfully deleted.
67
- WARNING: Deleted client some-node-name
68
- Chef client successfully deleted.
69
- SoftLayer VM successfully deleted. You are no longer being billed for this instance.
70
- ```
71
-
72
- Use the public ip address as an identifier
73
-
74
- ```sh
75
- user@localhost> knife softlayer server destroy --ip-address 33.33.33.33
76
- Decommissioning SoftLayer VM, this may take a few minutes.
77
- WARNING: Deleted node 5849421
78
- Chef node successfully deleted.
79
- WARNING: Deleted client 5849421
80
- Chef client successfully deleted.
81
- SoftLayer VM successfully deleted. You are no longer being billed for this instance.
82
- ```
1
+ ### Server Examples
2
+
3
+ These examples all assume you have set your SoftLayer username and api key in `~/.chef/knife.rb` like this:
4
+
5
+ ```ruby
6
+ knife[:softlayer_username] = 'example_user'
7
+ knife[:softlayer_api_key] = '1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a'
8
+ ```
9
+
10
+ #### Create server and bootstrap as a chef node
11
+
12
+ Create a server using an image, a flavor, assign an existing global ip address, and inject two ssh keys.
13
+
14
+ ```sh
15
+ user@localhost> knife softlayer server create --image-id 23f7f05f-3657-4330-8772-329ed2e816bc --assign-global-ip 108.168.254.41 --ssh-keys 12345 23456 --hostname web --domain ibm.com --flavor m1.tiny --run-list 'recipe[redis],recipe[rbenv],recipe[apt]' -i /Users/user/.ssh/my_private_key_rsa
16
+ ```
17
+
18
+ Create a server, provision a new global ip address and assign it to the server, tag both the chef node and the SoftLayer server with the passed tags.
19
+
20
+ ```sh
21
+ user@localhost> knife softlayer server create --new-global-ip v4 --tags job=task,private=true --hostname web --domain ibm.com --flavor m1.tiny --run-list 'recipe[redis],recipe[rbenv],recipe[apt]' --ssh-keys 12345 -i /Users/user/.ssh/my_private_key_rsa
22
+ ```
23
+
24
+ Create a server located in specific public and private VLANS.
25
+
26
+ ```sh
27
+ user@localhost> knife softlayer server create --vlan 12345 --private-vlan 23456 --hostname web --domain ibm.com --flavor m1.tiny --run-list 'recipe[redis],recipe[rbenv],recipe[apt]' --ssh-keys 12345 -i /Users/user/.ssh/my_private_key_rsa --new-global-ip v4 --tags job=task,private=true
28
+ ```
29
+
30
+ Create a server specifying options from a JSON file.
31
+
32
+ ```sh
33
+ user@localhost> cat /Users/user/bootstrap.json
34
+ {
35
+ "hostname": "web",
36
+ "domain": "ibm.com",
37
+ "flavor": "m1.xlarge",
38
+ "run-list": "recipe[redis],recipe[rbenv],recipe[apt]",
39
+ "ssh-keys": "73148",
40
+ "identity-file": "/Users/user/.ssh/my_softlayer_key_rsa",
41
+ "image-id": "23f7f05f-3657-4330-8772-329ed2e816bc",
42
+ "user_data": "first_boot=disabled"
43
+ }
44
+
45
+ user@localhost> knife softlayer server create --from-file /Users/user/bootstrap.json
46
+
47
+ # options file + additional arguments
48
+ user@localhost> knife softlayer server create --from-file /Users/user/bootstrap.json --tags job=task,private=true
49
+ ```
50
+
51
+ Other options.
52
+
53
+ ```sh
54
+ user@localhost> knife softlayer server create --help
55
+ # There are a lot...
56
+ ```
57
+
58
+ #### Destroy a server and its chef node and client
59
+
60
+ Use the node name as an identifier.
61
+
62
+ ```sh
63
+ user@localhost> knife softlayer server destroy --node-name some-node-name
64
+ Decommissioning SoftLayer VM, this may take a few minutes.
65
+ WARNING: Deleted node some-node-name
66
+ Chef node successfully deleted.
67
+ WARNING: Deleted client some-node-name
68
+ Chef client successfully deleted.
69
+ SoftLayer VM successfully deleted. You are no longer being billed for this instance.
70
+ ```
71
+
72
+ Use the public ip address as an identifier
73
+
74
+ ```sh
75
+ user@localhost> knife softlayer server destroy --ip-address 33.33.33.33
76
+ Decommissioning SoftLayer VM, this may take a few minutes.
77
+ WARNING: Deleted node 5849421
78
+ Chef node successfully deleted.
79
+ WARNING: Deleted client 5849421
80
+ Chef client successfully deleted.
81
+ SoftLayer VM successfully deleted. You are no longer being billed for this instance.
82
+ ```
data/examples/vlan.md CHANGED
@@ -1,85 +1,85 @@
1
- ### VLAN examples
2
-
3
- These examples all assume you have set your SoftLayer username and api key in `~/.chef/knife.rb` like this:
4
-
5
- ```ruby
6
- knife[:softlayer_username] = 'example_user'
7
- knife[:softlayer_api_key] = '1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a'
8
- ```
9
-
10
- #### Create a new VLAN
11
-
12
- ```sh
13
- user@localhost> knife softlayer vlan create
14
- Enter a vlan name:
15
- ```
16
-
17
- ```sh
18
- user@localhost> knife softlayer vlan create
19
- Enter a vlan name: my-new-vlan
20
- Enter a datacenter name:
21
- ```
22
-
23
- ```sh
24
- user@localhost> knife softlayer vlan create
25
- Enter a vlan name: my-new-vlan
26
- Enter a datacenter name: wdc01
27
- Enter a router hostname:
28
- ```
29
-
30
- ```sh
31
- user@localhost> knife softlayer vlan create
32
- Enter a vlan name: my-new-vlan
33
- Enter a datacenter name: wdc01
34
- Enter a router hostname: bcr05a.wdc01
35
- Enter a network space:[PUBLIC]
36
- ```
37
-
38
- ```sh
39
- user@localhost> knife softlayer vlan create
40
- Enter a vlan name: my-new-vlan
41
- Enter a datacenter name: wdc01
42
- Enter a router hostname: bcr05a.wdc01
43
- Enter a network space:[PUBLIC] PRIVATE # routers that start with bcr are for private VLANS; fcr are for public VLANS
44
- VLAN successfully created. Provisioning may take a few minutes to complete.
45
- ```
46
-
47
- #### List VLANS
48
-
49
- ```sh
50
- user@localhost> knife softlayer vlan list
51
- +--------+----------------------+--------------+---------------+--------------+
52
- | id | name | datacenter | network_space | router |
53
- +--------+----------------------+--------------+---------------+--------------+
54
- | 379384 | [none] | Washington 1 | PUBLIC | fcr02.wdc01 |
55
- +--------+----------------------+--------------+---------------+--------------+
56
- | 379386 | [none] | Washington 1 | PRIVATE | bcr02.wdc01 |
57
- +--------+----------------------+--------------+---------------+--------------+
58
- | 563298 | my-new-vlan | Washington 1 | PRIVATE | bcr02.wdc01 |
59
- +--------+----------------------+--------------+---------------+--------------+
60
- | 339652 | [none] | San Jose 1 | PUBLIC | fcr01a.sjc01 |
61
- +--------+----------------------+--------------+---------------+--------------+
62
- | 339654 | [none] | San Jose 1 | PRIVATE | bcr01a.sjc01 |
63
- +--------+----------------------+--------------+---------------+--------------+
64
- | 557984 | [none] | Dallas 5 | PUBLIC | fcr02a.dal05 |
65
- +--------+----------------------+--------------+---------------+--------------+
66
- | 557986 | [none] | Dallas 5 | PRIVATE | bcr02a.dal05 |
67
- +--------+----------------------+--------------+---------------+--------------+
68
- ```
69
-
70
- #### Show a particular VLAN
71
-
72
- ```sh
73
- user@localhost> knife softlayer vlan show 563298
74
- ID: 563298
75
- Name: my-new-vlan
76
- Datacenter: wdc01
77
- Network Space: PRIVATE
78
- Router: bcr02.wdc01
79
- Subnets:
80
- +--------+------+---------------+---------------+---------------+---------+------------+------------+
81
- | id | cidr | gateway_ip | network_id | broadcast | type | datacenter | ip_version |
82
- +--------+------+---------------+---------------+---------------+---------+------------+------------+
83
- | 572522 | 30 | 10.32.181.241 | 10.32.181.240 | 10.32.181.243 | PRIMARY | wdc01 | 4 |
84
- +--------+------+---------------+---------------+---------------+---------+------------+------------+
85
- ```
1
+ ### VLAN examples
2
+
3
+ These examples all assume you have set your SoftLayer username and api key in `~/.chef/knife.rb` like this:
4
+
5
+ ```ruby
6
+ knife[:softlayer_username] = 'example_user'
7
+ knife[:softlayer_api_key] = '1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a'
8
+ ```
9
+
10
+ #### Create a new VLAN
11
+
12
+ ```sh
13
+ user@localhost> knife softlayer vlan create
14
+ Enter a vlan name:
15
+ ```
16
+
17
+ ```sh
18
+ user@localhost> knife softlayer vlan create
19
+ Enter a vlan name: my-new-vlan
20
+ Enter a datacenter name:
21
+ ```
22
+
23
+ ```sh
24
+ user@localhost> knife softlayer vlan create
25
+ Enter a vlan name: my-new-vlan
26
+ Enter a datacenter name: wdc01
27
+ Enter a router hostname:
28
+ ```
29
+
30
+ ```sh
31
+ user@localhost> knife softlayer vlan create
32
+ Enter a vlan name: my-new-vlan
33
+ Enter a datacenter name: wdc01
34
+ Enter a router hostname: bcr05a.wdc01
35
+ Enter a network space:[PUBLIC]
36
+ ```
37
+
38
+ ```sh
39
+ user@localhost> knife softlayer vlan create
40
+ Enter a vlan name: my-new-vlan
41
+ Enter a datacenter name: wdc01
42
+ Enter a router hostname: bcr05a.wdc01
43
+ Enter a network space:[PUBLIC] PRIVATE # routers that start with bcr are for private VLANS; fcr are for public VLANS
44
+ VLAN successfully created. Provisioning may take a few minutes to complete.
45
+ ```
46
+
47
+ #### List VLANS
48
+
49
+ ```sh
50
+ user@localhost> knife softlayer vlan list
51
+ +--------+----------------------+--------------+---------------+--------------+
52
+ | id | name | datacenter | network_space | router |
53
+ +--------+----------------------+--------------+---------------+--------------+
54
+ | 379384 | [none] | Washington 1 | PUBLIC | fcr02.wdc01 |
55
+ +--------+----------------------+--------------+---------------+--------------+
56
+ | 379386 | [none] | Washington 1 | PRIVATE | bcr02.wdc01 |
57
+ +--------+----------------------+--------------+---------------+--------------+
58
+ | 563298 | my-new-vlan | Washington 1 | PRIVATE | bcr02.wdc01 |
59
+ +--------+----------------------+--------------+---------------+--------------+
60
+ | 339652 | [none] | San Jose 1 | PUBLIC | fcr01a.sjc01 |
61
+ +--------+----------------------+--------------+---------------+--------------+
62
+ | 339654 | [none] | San Jose 1 | PRIVATE | bcr01a.sjc01 |
63
+ +--------+----------------------+--------------+---------------+--------------+
64
+ | 557984 | [none] | Dallas 5 | PUBLIC | fcr02a.dal05 |
65
+ +--------+----------------------+--------------+---------------+--------------+
66
+ | 557986 | [none] | Dallas 5 | PRIVATE | bcr02a.dal05 |
67
+ +--------+----------------------+--------------+---------------+--------------+
68
+ ```
69
+
70
+ #### Show a particular VLAN
71
+
72
+ ```sh
73
+ user@localhost> knife softlayer vlan show 563298
74
+ ID: 563298
75
+ Name: my-new-vlan
76
+ Datacenter: wdc01
77
+ Network Space: PRIVATE
78
+ Router: bcr02.wdc01
79
+ Subnets:
80
+ +--------+------+---------------+---------------+---------------+---------+------------+------------+
81
+ | id | cidr | gateway_ip | network_id | broadcast | type | datacenter | ip_version |
82
+ +--------+------+---------------+---------------+---------------+---------+------------+------------+
83
+ | 572522 | 30 | 10.32.181.241 | 10.32.181.240 | 10.32.181.243 | PRIMARY | wdc01 | 4 |
84
+ +--------+------+---------------+---------------+---------------+---------+------------+------------+
85
+ ```
@@ -1,39 +1,39 @@
1
- #
2
- # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
- # © Copyright IBM Corporation 2014.
4
- #
5
- # LICENSE: Apache 2.0 (http://www.apache.org/licenses/)
6
- #
7
-
8
- # coding: utf-8
9
- lib = File.expand_path('../lib', __FILE__)
10
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
11
- require 'knife-softlayer/version'
12
-
13
- Gem::Specification.new do |spec|
14
- spec.name = "knife-softlayer"
15
- spec.version = Knife::Softlayer::VERSION
16
- spec.authors = ["Matt Eldridge"]
17
- spec.email = ["matt.eldridge@us.ibm.com"]
18
- spec.summary = %q{SoftLayer VM support for Chef's knife utility.}
19
- spec.description = %q{A knife plugin for launching and bootstrapping instances in the IBM SoftLayer cloud.}
20
- spec.homepage = "https://github.com/SoftLayer/knife-softlayer"
21
- spec.license = "Apache 2.0"
22
-
23
- spec.files = `git ls-files -z`.split("\x0")
24
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
- spec.test_files = spec.files.grep(%r{^(spec|spec|features)/})
26
- spec.require_paths = ["lib"]
27
-
28
- spec.add_dependency "fog-softlayer", "~> 1.1.4"
29
- spec.add_dependency "knife-windows", "> 0.5.12"
30
- spec.add_dependency "net-ssh", "> 2.8.0"
31
-
32
- spec.add_development_dependency "mixlib-config", "~>2.0"
33
- spec.add_development_dependency "chef", ">=0.10.10"
34
- spec.add_development_dependency "rspec", "~>2.14"
35
- spec.add_development_dependency "rake", "~>10.1"
36
- spec.add_development_dependency "sdoc", "~>0.3"
37
- spec.add_development_dependency "bundler", "~>1.5"
38
- spec.add_development_dependency "osrcry"
39
- end
1
+ #
2
+ # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
+ # © Copyright IBM Corporation 2014.
4
+ #
5
+ # LICENSE: Apache 2.0 (http://www.apache.org/licenses/)
6
+ #
7
+
8
+ # coding: utf-8
9
+ lib = File.expand_path('../lib', __FILE__)
10
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
11
+ require 'knife-softlayer/version'
12
+
13
+ Gem::Specification.new do |spec|
14
+ spec.name = "knife-softlayer"
15
+ spec.version = Knife::Softlayer::VERSION
16
+ spec.authors = ["Matt Eldridge"]
17
+ spec.email = ["matt.eldridge@us.ibm.com"]
18
+ spec.summary = %q{SoftLayer VM support for Chef's knife utility.}
19
+ spec.description = %q{A knife plugin for launching and bootstrapping instances in the IBM SoftLayer cloud.}
20
+ spec.homepage = "https://github.com/SoftLayer/knife-softlayer"
21
+ spec.license = "Apache 2.0"
22
+
23
+ spec.files = `git ls-files -z`.split("\x0")
24
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
+ spec.test_files = spec.files.grep(%r{^(spec|spec|features)/})
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "fog-softlayer", "~> 1.1.4"
29
+ spec.add_dependency "knife-windows", "> 0.5.12"
30
+ spec.add_dependency "net-ssh", "> 2.8.0"
31
+
32
+ spec.add_development_dependency "mixlib-config", "~>2.0"
33
+ spec.add_development_dependency "chef", ">=0.10.10"
34
+ spec.add_development_dependency "rspec", "~>2.14"
35
+ spec.add_development_dependency "rake", "~>10.1"
36
+ spec.add_development_dependency "sdoc", "~>0.3"
37
+ spec.add_development_dependency "bundler", "~>1.5"
38
+ spec.add_development_dependency "osrcry"
39
+ end
@@ -1,52 +1,52 @@
1
- #
2
- # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
- # © Copyright IBM Corporation 2014.
4
- #
5
- # LICENSE: Apache 2.0 (http://www.apache.org/licenses/)
6
- #
7
-
8
- require 'chef/knife'
9
-
10
- class Chef
11
- class Knife
12
- module SoftlayerFlavorBase
13
-
14
- ##
15
- # Build table of all VM configuration options.
16
- # @return [Hash]
17
- def options_table
18
- columns = [
19
- "| CORES",
20
- "| RAM",
21
- "| DISK",
22
- "| OS",
23
- "| NETWORK [MBS]",
24
- "| DATACENTER",
25
- ]
26
-
27
- 6.times { columns << '| ========== ' }
28
-
29
- opts = connection.request(:virtual_guest, :get_create_object_options).body
30
- cpu = opts['processors']
31
- ram = opts['memory']
32
- disk = opts['blockDevices'].sort_by{|d| d['itemPrice']['item']['description'] unless d['itemPrice'].nil? }
33
- os = opts['operatingSystems']
34
- net = opts['networkComponents']
35
- datacenter = opts['datacenters']
36
-
37
- i = 0
38
- until i >= opts.keys.map{|key| opts[key].count }.sort.last do
39
- columns << (cpu[i].nil? ? '| ' : '| ' + cpu[i]['itemPrice']['item']['description'])
40
- columns << (ram[i].nil? ? '| ' : '| ' + ram[i]['template']['maxMemory'].to_s + " [#{ram[i]['itemPrice']['item']['description']}]")
41
- columns << (disk[i].nil? ? '| ' : '| ' + disk[i]['itemPrice']['item']['description'])
42
- columns << (os[i].nil? ? '| ' : '| ' + os[i]['template']['operatingSystemReferenceCode'])
43
- columns << (net[i].nil? ? '| ' : '| ' + net[i]['template']['networkComponents'].first['maxSpeed'].to_s)
44
- columns << (datacenter[i].nil? ? '| ' : '| ' + datacenter[i]['template']['datacenter']['name'])
45
- i+=1
46
- end
47
- columns
48
- end
49
-
50
- end
51
- end
52
- end
1
+ #
2
+ # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
+ # © Copyright IBM Corporation 2014.
4
+ #
5
+ # LICENSE: Apache 2.0 (http://www.apache.org/licenses/)
6
+ #
7
+
8
+ require 'chef/knife'
9
+
10
+ class Chef
11
+ class Knife
12
+ module SoftlayerFlavorBase
13
+
14
+ ##
15
+ # Build table of all VM configuration options.
16
+ # @return [Hash]
17
+ def options_table
18
+ columns = [
19
+ "| CORES",
20
+ "| RAM",
21
+ "| DISK",
22
+ "| OS",
23
+ "| NETWORK [MBS]",
24
+ "| DATACENTER",
25
+ ]
26
+
27
+ 6.times { columns << '| ========== ' }
28
+
29
+ opts = connection.request(:virtual_guest, :get_create_object_options).body
30
+ cpu = opts['processors']
31
+ ram = opts['memory']
32
+ disk = opts['blockDevices'].sort_by{|d| d['itemPrice']['item']['description'] unless d['itemPrice'].nil? }
33
+ os = opts['operatingSystems']
34
+ net = opts['networkComponents']
35
+ datacenter = opts['datacenters']
36
+
37
+ i = 0
38
+ until i >= opts.keys.map{|key| opts[key].count }.sort.last do
39
+ columns << (cpu[i].nil? ? '| ' : '| ' + cpu[i]['itemPrice']['item']['description'])
40
+ columns << (ram[i].nil? ? '| ' : '| ' + ram[i]['template']['maxMemory'].to_s + " [#{ram[i]['itemPrice']['item']['description']}]")
41
+ columns << (disk[i].nil? ? '| ' : '| ' + disk[i]['itemPrice']['item']['description'])
42
+ columns << (os[i].nil? ? '| ' : '| ' + os[i]['template']['operatingSystemReferenceCode'])
43
+ columns << (net[i].nil? ? '| ' : '| ' + net[i]['template']['networkComponents'].first['maxSpeed'].to_s)
44
+ columns << (datacenter[i].nil? ? '| ' : '| ' + datacenter[i]['template']['datacenter']['name'])
45
+ i+=1
46
+ end
47
+ columns
48
+ end
49
+
50
+ end
51
+ end
52
+ end