Class: OneDatastoreHelper
- Inherits:
-
OpenNebulaHelper::OneHelper
- Object
- OpenNebulaHelper::OneHelper
- OneDatastoreHelper
- Defined in:
- lib/one_helper/onedatastore_helper.rb
Overview
Helper class for Datastore commands
Constant Summary collapse
- DATASTORE =
{ :name => 'datastore', :short => '-d id|name', :large => '--datastore id|name', :description => 'Selects the datastore', :format => String, :proc => lambda {|o, | OpenNebulaHelper.rname_to_id(o, 'DATASTORE') } }
- FILE_DATASTORE =
{ :name => 'file_datastore', :large => '--file-datastore id|name', :description => 'Selects the file datastore', :format => String, :proc => lambda {|o, | OpenNebulaHelper.rname_to_id(o, 'DATASTORE') } }
Instance Attribute Summary
Attributes inherited from OpenNebulaHelper::OneHelper
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from OpenNebulaHelper::OneHelper
#backup_mode_valid?, #check_orphan, client, #create_resource, #filterflag_to_i, filterflag_to_i_desc, get_client, get_password, #group_name, #initialize, list_layout_help, #list_pool, #list_pool_format, #list_pool_table, #list_pool_top, #list_pool_xml, #list_to_id, list_to_id_desc, name_to_id, #perform_action, #perform_actions, #print_page, #retrieve_resource, #set_client, set_endpoint, set_password, set_user, #show_resource, #start_pager, #stop_pager, table_conf, template_input_help, #to_id, to_id_desc, #user_name
Constructor Details
This class inherits a constructor from OpenNebulaHelper::OneHelper
Class Method Details
.conf_file ⇒ Object
50 51 52 |
# File 'lib/one_helper/onedatastore_helper.rb', line 50 def self.conf_file 'onedatastore.yaml' end |
.rname ⇒ Object
46 47 48 |
# File 'lib/one_helper/onedatastore_helper.rb', line 46 def self.rname 'DATASTORE' end |
Instance Method Details
#format_pool(options) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/one_helper/onedatastore_helper.rb', line 54 def format_pool() config_file = self.class.table_conf CLIHelper::ShowTable.new(config_file, self) do column :ID, 'ONE identifier for the Datastore', :size=>4 do |d| d['ID'] end column :USER, 'Username of the Datastore owner', :left, :size=>10 do |d| helper.user_name(d, ) end column :GROUP, 'Group of the Datastore', :left, :size=>10 do |d| helper.group_name(d, ) end column :NAME, 'Name of the Datastore', :left, :size=>13 do |d| d['NAME'] end column :SIZE, 'Datastore total size', :size =>10 do |d| shared = d['TEMPLATE']['SHARED'] if !shared.nil? && shared.upcase == 'NO' '-' else OpenNebulaHelper.unit_to_str(d['TOTAL_MB'].to_i, {}, 'M') end end column :AVAIL, 'Datastore free size', :left, :size =>5 do |d| if d['TOTAL_MB'].to_i == 0 '-' else "#{((d['FREE_MB'].to_f/d['TOTAL_MB'].to_f) * 100).round}%" end end column :CLUSTERS, 'Cluster IDs', :left, :size=>12 do |d| OpenNebulaHelper.clusters_str(d['CLUSTERS']['ID']) end column :IMAGES, 'Number of Images', :size=>6 do |d| if d['IMAGES']['ID'].nil? '0' else [d['IMAGES']['ID']].flatten.size end end column :TYPE, 'Datastore type', :left, :size=>4 do |d| type = OpenNebula::Datastore::DATASTORE_TYPES[d['TYPE'].to_i] OpenNebula::Datastore::SHORT_DATASTORE_TYPES[type] end column :DS, 'Datastore driver', :left, :size=>7 do |d| d['DS_MAD'] end column :TM, 'Transfer driver', :left, :size=>7 do |d| d['TM_MAD'] end column :STAT, 'State of the Datastore', :left, :size=>3 do |d| state = OpenNebula::Datastore::DATASTORE_STATES[d['STATE'].to_i] OpenNebula::Datastore::SHORT_DATASTORE_STATES[state] end default :ID, :USER, :GROUP, :NAME, :SIZE, :AVAIL, :CLUSTERS, :IMAGES, :TYPE, :DS, :TM, :STAT end end |