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.
- checksums.yaml +4 -4
- data/.gitignore +19 -19
- data/.travis.yml +20 -20
- data/CHANGELOG.md +19 -19
- data/CONTRIBUTING.md +31 -31
- data/CONTRIBUTORS.md +2 -2
- data/Gemfile +4 -4
- data/LICENSE.txt +72 -72
- data/README.md +83 -83
- data/Rakefile +37 -37
- data/docs/cla-corporate.md +133 -133
- data/docs/cla-individual.md +84 -84
- data/examples/datacenter.md +94 -94
- data/examples/flavor.md +58 -58
- data/examples/global_ip.md +22 -22
- data/examples/image.md +34 -34
- data/examples/key_pair.md +56 -56
- data/examples/server.md +82 -82
- data/examples/vlan.md +85 -85
- data/knife-softlayer.gemspec +39 -39
- data/lib/chef/knife/flavor/base.rb +52 -52
- data/lib/chef/knife/softlayer.rb +14 -14
- data/lib/chef/knife/softlayer_base.rb +112 -112
- data/lib/chef/knife/softlayer_datacenter_list.rb +28 -28
- data/lib/chef/knife/softlayer_datacenter_show.rb +45 -45
- data/lib/chef/knife/softlayer_delete.rb +6 -6
- data/lib/chef/knife/softlayer_flavor_list.rb +53 -53
- data/lib/chef/knife/softlayer_global_ip_list.rb +34 -34
- data/lib/chef/knife/softlayer_image_list.rb +26 -26
- data/lib/chef/knife/softlayer_key_pair_create.rb +37 -37
- data/lib/chef/knife/softlayer_key_pair_list.rb +28 -28
- data/lib/chef/knife/softlayer_list.rb +6 -6
- data/lib/chef/knife/softlayer_server_create.rb +462 -458
- data/lib/chef/knife/softlayer_server_destroy.rb +146 -146
- data/lib/chef/knife/softlayer_server_list.rb +27 -27
- data/lib/chef/knife/softlayer_server_relaunch.rb +208 -208
- data/lib/chef/knife/softlayer_vlan_create.rb +37 -37
- data/lib/chef/knife/softlayer_vlan_list.rb +28 -28
- data/lib/chef/knife/softlayer_vlan_show.rb +40 -40
- data/lib/knife-softlayer/version.rb +12 -12
- data/spec/spec_helper.rb +21 -21
- data/spec/unit/softlayer_base_spec.rb +26 -26
- data/spec/unit/softlayer_server_create_spec.rb +105 -105
- data/spec/unit/softlayer_server_destroy_spec.rb +47 -47
- metadata +27 -27
data/lib/chef/knife/softlayer.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
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 "knife-softlayer/version"
|
9
|
-
|
10
|
-
module Knife
|
11
|
-
module Softlayer
|
12
|
-
# Your code goes here...
|
13
|
-
end
|
14
|
-
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 "knife-softlayer/version"
|
9
|
+
|
10
|
+
module Knife
|
11
|
+
module Softlayer
|
12
|
+
# Your code goes here...
|
13
|
+
end
|
14
|
+
end
|
@@ -1,112 +1,112 @@
|
|
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/bootstrap'
|
9
|
-
require 'knife-softlayer/version'
|
10
|
-
|
11
|
-
class Chef
|
12
|
-
class Knife
|
13
|
-
module SoftlayerBase
|
14
|
-
|
15
|
-
USER_AGENT = "Chef Knife Softlayer Plugin #{::Knife::Softlayer::VERSION}" unless defined? USER_AGENT
|
16
|
-
|
17
|
-
# :nodoc:
|
18
|
-
def self.included(includer)
|
19
|
-
includer.class_eval do
|
20
|
-
|
21
|
-
deps do
|
22
|
-
require 'fog/softlayer'
|
23
|
-
require 'net/ssh'
|
24
|
-
require 'net/ssh/multi'
|
25
|
-
require 'chef/monkey_patches/net-ssh-multi'
|
26
|
-
require 'readline'
|
27
|
-
require 'chef/exceptions'
|
28
|
-
require 'chef/search/query'
|
29
|
-
require 'chef/mixin/command'
|
30
|
-
require 'chef/mixin/shell_out'
|
31
|
-
require 'mixlib/shellout'
|
32
|
-
require 'chef/json_compat'
|
33
|
-
end
|
34
|
-
|
35
|
-
# Make the base bootstrap options available on topo bootstrap
|
36
|
-
self.options = (Chef::Knife::Bootstrap.options).merge(self.options)
|
37
|
-
|
38
|
-
option :softlayer_credential_file,
|
39
|
-
:long => "--softlayer-credential-file FILE",
|
40
|
-
:description => "File containing SoftLayer credentials as used by `softlayer_api` Ruby gem.",
|
41
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:softlayer_credential_file] = key }
|
42
|
-
|
43
|
-
option :softlayer_username,
|
44
|
-
:short => "-U USERNAME",
|
45
|
-
:long => "--softlayer-username KEY",
|
46
|
-
:description => "Your SoftLayer Username",
|
47
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:softlayer_access_key_id] = key }
|
48
|
-
|
49
|
-
option :softlayer_api_key,
|
50
|
-
:short => "-K SECRET",
|
51
|
-
:long => "--softlayer-api-key SECRET",
|
52
|
-
:description => "Your SoftLayer API Key",
|
53
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:softlayer_secret_access_key] = key }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
##
|
58
|
-
# Returns a connection to a SoftLayer API Service Endpoint.
|
59
|
-
# @param [Symbol] service
|
60
|
-
# @return [SoftLayer::Service]
|
61
|
-
def connection(service=:compute)
|
62
|
-
self.send(service)
|
63
|
-
end
|
64
|
-
|
65
|
-
def compute
|
66
|
-
@compute_connection ||= Fog::Compute.new(
|
67
|
-
:provider => :softlayer,
|
68
|
-
:softlayer_username => Chef::Config[:knife][:softlayer_username],
|
69
|
-
:softlayer_api_key => Chef::Config[:knife][:softlayer_api_key],
|
70
|
-
:softlayer_default_datacenter => Chef::Config[:knife][:softlayer_default_datacenter],
|
71
|
-
:softlayer_default_domain => Chef::Config[:knife][:softlayer_default_domain],
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
def network
|
76
|
-
@network_connection ||= Fog::Network.new(
|
77
|
-
:provider => :softlayer,
|
78
|
-
:softlayer_username => Chef::Config[:knife][:softlayer_username],
|
79
|
-
:softlayer_api_key => Chef::Config[:knife][:softlayer_api_key],
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
|
-
##
|
84
|
-
# Locates a config value.
|
85
|
-
# @param [String] key
|
86
|
-
# @return [String]
|
87
|
-
def locate_config_value(key)
|
88
|
-
key = key.to_sym
|
89
|
-
config[key] || Chef::Config[:knife][key]
|
90
|
-
end
|
91
|
-
|
92
|
-
##
|
93
|
-
# A CLI output formatting wrapper.
|
94
|
-
# @param [String] label
|
95
|
-
# @param [String] value
|
96
|
-
# @param [Symbol] color
|
97
|
-
# @return [String]
|
98
|
-
def msg_pair(label, value, color=:cyan)
|
99
|
-
if value && !value.to_s.empty?
|
100
|
-
puts "#{ui.color(label, color)}: #{value}"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
module OS
|
109
|
-
def OS.windows?
|
110
|
-
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
111
|
-
end
|
112
|
-
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/bootstrap'
|
9
|
+
require 'knife-softlayer/version'
|
10
|
+
|
11
|
+
class Chef
|
12
|
+
class Knife
|
13
|
+
module SoftlayerBase
|
14
|
+
|
15
|
+
USER_AGENT = "Chef Knife Softlayer Plugin #{::Knife::Softlayer::VERSION}" unless defined? USER_AGENT
|
16
|
+
|
17
|
+
# :nodoc:
|
18
|
+
def self.included(includer)
|
19
|
+
includer.class_eval do
|
20
|
+
|
21
|
+
deps do
|
22
|
+
require 'fog/softlayer'
|
23
|
+
require 'net/ssh'
|
24
|
+
require 'net/ssh/multi'
|
25
|
+
require 'chef/monkey_patches/net-ssh-multi'
|
26
|
+
require 'readline'
|
27
|
+
require 'chef/exceptions'
|
28
|
+
require 'chef/search/query'
|
29
|
+
require 'chef/mixin/command'
|
30
|
+
require 'chef/mixin/shell_out'
|
31
|
+
require 'mixlib/shellout'
|
32
|
+
require 'chef/json_compat'
|
33
|
+
end
|
34
|
+
|
35
|
+
# Make the base bootstrap options available on topo bootstrap
|
36
|
+
self.options = (Chef::Knife::Bootstrap.options).merge(self.options)
|
37
|
+
|
38
|
+
option :softlayer_credential_file,
|
39
|
+
:long => "--softlayer-credential-file FILE",
|
40
|
+
:description => "File containing SoftLayer credentials as used by `softlayer_api` Ruby gem.",
|
41
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:softlayer_credential_file] = key }
|
42
|
+
|
43
|
+
option :softlayer_username,
|
44
|
+
:short => "-U USERNAME",
|
45
|
+
:long => "--softlayer-username KEY",
|
46
|
+
:description => "Your SoftLayer Username",
|
47
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:softlayer_access_key_id] = key }
|
48
|
+
|
49
|
+
option :softlayer_api_key,
|
50
|
+
:short => "-K SECRET",
|
51
|
+
:long => "--softlayer-api-key SECRET",
|
52
|
+
:description => "Your SoftLayer API Key",
|
53
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:softlayer_secret_access_key] = key }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Returns a connection to a SoftLayer API Service Endpoint.
|
59
|
+
# @param [Symbol] service
|
60
|
+
# @return [SoftLayer::Service]
|
61
|
+
def connection(service=:compute)
|
62
|
+
self.send(service)
|
63
|
+
end
|
64
|
+
|
65
|
+
def compute
|
66
|
+
@compute_connection ||= Fog::Compute.new(
|
67
|
+
:provider => :softlayer,
|
68
|
+
:softlayer_username => Chef::Config[:knife][:softlayer_username],
|
69
|
+
:softlayer_api_key => Chef::Config[:knife][:softlayer_api_key],
|
70
|
+
:softlayer_default_datacenter => Chef::Config[:knife][:softlayer_default_datacenter],
|
71
|
+
:softlayer_default_domain => Chef::Config[:knife][:softlayer_default_domain],
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def network
|
76
|
+
@network_connection ||= Fog::Network.new(
|
77
|
+
:provider => :softlayer,
|
78
|
+
:softlayer_username => Chef::Config[:knife][:softlayer_username],
|
79
|
+
:softlayer_api_key => Chef::Config[:knife][:softlayer_api_key],
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Locates a config value.
|
85
|
+
# @param [String] key
|
86
|
+
# @return [String]
|
87
|
+
def locate_config_value(key)
|
88
|
+
key = key.to_sym
|
89
|
+
config[key] || Chef::Config[:knife][key]
|
90
|
+
end
|
91
|
+
|
92
|
+
##
|
93
|
+
# A CLI output formatting wrapper.
|
94
|
+
# @param [String] label
|
95
|
+
# @param [String] value
|
96
|
+
# @param [Symbol] color
|
97
|
+
# @return [String]
|
98
|
+
def msg_pair(label, value, color=:cyan)
|
99
|
+
if value && !value.to_s.empty?
|
100
|
+
puts "#{ui.color(label, color)}: #{value}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
module OS
|
109
|
+
def OS.windows?
|
110
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
111
|
+
end
|
112
|
+
end
|
@@ -1,28 +1,28 @@
|
|
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/softlayer_base'
|
9
|
-
|
10
|
-
class Chef
|
11
|
-
class Knife
|
12
|
-
class SoftlayerDatacenterList < Knife
|
13
|
-
|
14
|
-
include Knife::SoftlayerBase
|
15
|
-
|
16
|
-
banner 'knife softlayer datacenter list (options)'
|
17
|
-
|
18
|
-
def run
|
19
|
-
$stdout.sync = true
|
20
|
-
table_data = connection(:network).datacenters.map do |dc|
|
21
|
-
{:name => dc.name, :long_name => dc.long_name }
|
22
|
-
end
|
23
|
-
puts Formatador.display_table(table_data, [:name, :long_name])
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
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/softlayer_base'
|
9
|
+
|
10
|
+
class Chef
|
11
|
+
class Knife
|
12
|
+
class SoftlayerDatacenterList < Knife
|
13
|
+
|
14
|
+
include Knife::SoftlayerBase
|
15
|
+
|
16
|
+
banner 'knife softlayer datacenter list (options)'
|
17
|
+
|
18
|
+
def run
|
19
|
+
$stdout.sync = true
|
20
|
+
table_data = connection(:network).datacenters.map do |dc|
|
21
|
+
{:name => dc.name, :long_name => dc.long_name }
|
22
|
+
end
|
23
|
+
puts Formatador.display_table(table_data, [:name, :long_name])
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,45 +1,45 @@
|
|
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/softlayer_base'
|
9
|
-
|
10
|
-
class Chef
|
11
|
-
class Knife
|
12
|
-
class SoftlayerDatacenterShow < Knife
|
13
|
-
|
14
|
-
include Knife::SoftlayerBase
|
15
|
-
|
16
|
-
banner 'knife softlayer datacenter show DATACENTER'
|
17
|
-
|
18
|
-
option :dc,
|
19
|
-
:short => "-a",
|
20
|
-
:long => "--all",
|
21
|
-
:description => "Display all available configuration options for launching an instance.",
|
22
|
-
:default => false
|
23
|
-
|
24
|
-
|
25
|
-
def run
|
26
|
-
unless name_args.size == 1
|
27
|
-
puts ui.color("Specify exactly one datacenter to show.", :red)
|
28
|
-
show_usage
|
29
|
-
exit 1
|
30
|
-
end
|
31
|
-
|
32
|
-
$stdout.sync = true
|
33
|
-
dc = connection(:network).datacenters.by_name(name_args[0])
|
34
|
-
|
35
|
-
puts "#{ui.color("Long Name:", :green)} #{dc.long_name}"
|
36
|
-
puts "#{ui.color("Name:", :green)} #{dc.name}"
|
37
|
-
|
38
|
-
puts "#{ui.color("Routers:", :green)}"
|
39
|
-
puts Formatador.display_table(dc.routers)
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
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/softlayer_base'
|
9
|
+
|
10
|
+
class Chef
|
11
|
+
class Knife
|
12
|
+
class SoftlayerDatacenterShow < Knife
|
13
|
+
|
14
|
+
include Knife::SoftlayerBase
|
15
|
+
|
16
|
+
banner 'knife softlayer datacenter show DATACENTER'
|
17
|
+
|
18
|
+
option :dc,
|
19
|
+
:short => "-a",
|
20
|
+
:long => "--all",
|
21
|
+
:description => "Display all available configuration options for launching an instance.",
|
22
|
+
:default => false
|
23
|
+
|
24
|
+
|
25
|
+
def run
|
26
|
+
unless name_args.size == 1
|
27
|
+
puts ui.color("Specify exactly one datacenter to show.", :red)
|
28
|
+
show_usage
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
|
32
|
+
$stdout.sync = true
|
33
|
+
dc = connection(:network).datacenters.by_name(name_args[0])
|
34
|
+
|
35
|
+
puts "#{ui.color("Long Name:", :green)} #{dc.long_name}"
|
36
|
+
puts "#{ui.color("Name:", :green)} #{dc.name}"
|
37
|
+
|
38
|
+
puts "#{ui.color("Routers:", :green)}"
|
39
|
+
puts Formatador.display_table(dc.routers)
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,6 +1,6 @@
|
|
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
|
-
#
|
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
|
+
#
|
@@ -1,53 +1,53 @@
|
|
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/softlayer_base'
|
9
|
-
require 'chef/knife/flavor/base'
|
10
|
-
|
11
|
-
class Chef
|
12
|
-
class Knife
|
13
|
-
class SoftlayerFlavorList < Knife
|
14
|
-
|
15
|
-
include Knife::SoftlayerBase
|
16
|
-
include Knife::SoftlayerFlavorBase
|
17
|
-
|
18
|
-
banner 'knife softlayer flavor list (options)'
|
19
|
-
|
20
|
-
option :all,
|
21
|
-
:short => "-a",
|
22
|
-
:long => "--all",
|
23
|
-
:description => "Display all available configuration options for launching an instance.",
|
24
|
-
:default => false
|
25
|
-
|
26
|
-
##
|
27
|
-
# Run the procedure to list softlayer VM flavors or display all available options.
|
28
|
-
# @return [nil]
|
29
|
-
def run
|
30
|
-
$stdout.sync = true
|
31
|
-
if config[:all]
|
32
|
-
|
33
|
-
if OS.windows?
|
34
|
-
puts ui.list(options_table, :uneven_columns_across, 6)
|
35
|
-
else
|
36
|
-
IO.popen('less', 'w') do |pipe|
|
37
|
-
pipe.puts ui.list(options_table, :uneven_columns_across, 6)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
msg = "These options can be used in place of 'flavors'; See `knife softlayer server create --help` for details.\n"
|
42
|
-
else
|
43
|
-
puts connection.flavors.table([:id, :cpu, :ram, :disk,])
|
44
|
-
msg = "'flavors' provided here for convenience; SoftLayer allows you to choose a configuration a la carte.\nFor a full list of available instance options use --all with the `knife softlayer flavor list` subcommand."
|
45
|
-
end
|
46
|
-
puts ui.color("\nNOTICE: ", :yellow)
|
47
|
-
puts ui.color(msg)
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
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/softlayer_base'
|
9
|
+
require 'chef/knife/flavor/base'
|
10
|
+
|
11
|
+
class Chef
|
12
|
+
class Knife
|
13
|
+
class SoftlayerFlavorList < Knife
|
14
|
+
|
15
|
+
include Knife::SoftlayerBase
|
16
|
+
include Knife::SoftlayerFlavorBase
|
17
|
+
|
18
|
+
banner 'knife softlayer flavor list (options)'
|
19
|
+
|
20
|
+
option :all,
|
21
|
+
:short => "-a",
|
22
|
+
:long => "--all",
|
23
|
+
:description => "Display all available configuration options for launching an instance.",
|
24
|
+
:default => false
|
25
|
+
|
26
|
+
##
|
27
|
+
# Run the procedure to list softlayer VM flavors or display all available options.
|
28
|
+
# @return [nil]
|
29
|
+
def run
|
30
|
+
$stdout.sync = true
|
31
|
+
if config[:all]
|
32
|
+
|
33
|
+
if OS.windows?
|
34
|
+
puts ui.list(options_table, :uneven_columns_across, 6)
|
35
|
+
else
|
36
|
+
IO.popen('less', 'w') do |pipe|
|
37
|
+
pipe.puts ui.list(options_table, :uneven_columns_across, 6)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
msg = "These options can be used in place of 'flavors'; See `knife softlayer server create --help` for details.\n"
|
42
|
+
else
|
43
|
+
puts connection.flavors.table([:id, :cpu, :ram, :disk,])
|
44
|
+
msg = "'flavors' provided here for convenience; SoftLayer allows you to choose a configuration a la carte.\nFor a full list of available instance options use --all with the `knife softlayer flavor list` subcommand."
|
45
|
+
end
|
46
|
+
puts ui.color("\nNOTICE: ", :yellow)
|
47
|
+
puts ui.color(msg)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|