Class: VCAP::Quota::RepQuota
Instance Attribute Summary collapse
-
#filesystem ⇒ Object
Returns the value of attribute filesystem.
-
#ids_only ⇒ Object
Returns the value of attribute ids_only.
-
#report_groups ⇒ Object
Returns the value of attribute report_groups.
-
#report_users ⇒ Object
Returns the value of attribute report_users.
Instance Method Summary collapse
- #build_command ⇒ Object
-
#initialize ⇒ RepQuota
constructor
A new instance of RepQuota.
- #parse_result(result) ⇒ Object
- #validate ⇒ Object
Methods inherited from Command
Constructor Details
#initialize ⇒ RepQuota
Returns a new instance of RepQuota.
96 97 98 |
# File 'lib/vcap/quota.rb', line 96 def initialize @report_users = true end |
Instance Attribute Details
#filesystem ⇒ Object
Returns the value of attribute filesystem.
94 95 96 |
# File 'lib/vcap/quota.rb', line 94 def filesystem @filesystem end |
#ids_only ⇒ Object
Returns the value of attribute ids_only.
93 94 95 |
# File 'lib/vcap/quota.rb', line 93 def ids_only @ids_only end |
#report_groups ⇒ Object
Returns the value of attribute report_groups.
91 92 93 |
# File 'lib/vcap/quota.rb', line 91 def report_groups @report_groups end |
#report_users ⇒ Object
Returns the value of attribute report_users.
92 93 94 |
# File 'lib/vcap/quota.rb', line 92 def report_users @report_users end |
Instance Method Details
#build_command ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/vcap/quota.rb', line 105 def build_command cmd = ['repquota', '-p'] # -p reports grace as 0 when unset cmd << '-u' if self.report_users cmd << '-g' if self.report_groups cmd << '-n' if self.ids_only cmd << self.filesystem cmd = cmd.flatten.join(' ') cmd end |
#parse_result(result) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/vcap/quota.rb', line 115 def parse_result(result) if result[0] == 0 quota_info = {} result[1].lines.each do |line| next unless line.match(/[^\s]+\s+[+-]+\s+\d+/) fields = line.split(/\s+/) if self.ids_only match = fields[0].match(/^#(\d+)$/) uid = match[1].to_i else uid = fields[0] end quota_info[uid] = { :usage => { :block => fields[2].to_i, :inode => fields[6].to_i }, :quotas => { :block => { :soft => fields[3].to_i, :hard => fields[4].to_i, }, :inode => { :soft => fields[7].to_i, :hard => fields[8].to_i, }, } } end [true, quota_info] else [false, result] end end |
#validate ⇒ Object
100 101 102 103 |
# File 'lib/vcap/quota.rb', line 100 def validate assert_at_least_one_of(:report_groups, :report_users) assert_at_least_one_of(:filesystem) end |