Module: Chef::Knife::SoftlayerFlavorBase
- Included in:
- SoftlayerFlavorList
- Defined in:
- lib/chef/knife/flavor/base.rb
Instance Method Summary collapse
-
#options_table ⇒ Hash
Build table of all VM configuration options.
Instance Method Details
#options_table ⇒ Hash
Build table of all VM configuration options.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chef/knife/flavor/base.rb', line 17 def columns = [ "| CORES", "| RAM", "| DISK", "| OS", "| NETWORK [MBS]", "| DATACENTER", ] 6.times { columns << '| ========== ' } opts = connection.request(:virtual_guest, :get_create_object_options).body cpu = opts['processors'] ram = opts['memory'] disk = opts['blockDevices'].sort_by{|d| d['itemPrice']['item']['description'] unless d['itemPrice'].nil? } os = opts['operatingSystems'] net = opts['networkComponents'] datacenter = opts['datacenters'] i = 0 until i >= opts.keys.map{|key| opts[key].count }.sort.last do columns << (cpu[i].nil? ? '| ' : '| ' + cpu[i]['itemPrice']['item']['description']) columns << (ram[i].nil? ? '| ' : '| ' + ram[i]['template']['maxMemory'].to_s + " [#{ram[i]['itemPrice']['item']['description']}]") columns << (disk[i].nil? ? '| ' : '| ' + disk[i]['itemPrice']['item']['description']) columns << (os[i].nil? ? '| ' : '| ' + os[i]['template']['operatingSystemReferenceCode']) columns << (net[i].nil? ? '| ' : '| ' + net[i]['template']['networkComponents'].first['maxSpeed'].to_s) columns << (datacenter[i].nil? ? '| ' : '| ' + datacenter[i]['template']['datacenter']['name']) i+=1 end columns end |