vagrant-node 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/vagrant-node/actions/boxadd.rb +29 -20
- data/lib/vagrant-node/actions/snapshot.rb +1 -26
- data/lib/vagrant-node/api.rb +17 -25
- data/lib/vagrant-node/clientcontroller.rb +180 -153
- data/lib/vagrant-node/dbmanager.rb +106 -28
- data/lib/vagrant-node/exceptions.rb +1 -2
- data/lib/vagrant-node/nodeservercommand.rb +19 -32
- data/lib/vagrant-node/nodeserverpasswd.rb +2 -21
- data/lib/vagrant-node/nodeserverstart.rb +3 -1
- data/lib/vagrant-node/server.rb +4 -0
- data/lib/vagrant-node/util/downloader.rb +13 -5
- data/lib/vagrant-node/util/hwfunctions.rb +73 -0
- data/lib/vagrant-node/version.rb +1 -1
- metadata +179 -175
- data/.gitignore +0 -5
@@ -10,8 +10,10 @@ module DB
|
|
10
10
|
class DBManager
|
11
11
|
|
12
12
|
DOWNLOAD_ERROR=-1
|
13
|
-
|
14
|
-
|
13
|
+
DOWNLOAD_STOP=0
|
14
|
+
DOWNLOAD_START=1
|
15
|
+
DOWNLOAD_SUCCESS=2
|
16
|
+
DOWNLOAD_UNCOMPRESS = 3
|
15
17
|
|
16
18
|
def initialize(data_dir)
|
17
19
|
@db=check_database(data_dir)
|
@@ -91,48 +93,79 @@ module DB
|
|
91
93
|
@db.query(sql)
|
92
94
|
end
|
93
95
|
|
96
|
+
def quote_string(s)
|
97
|
+
s.gsub(/\\/, '\&\&').gsub(/'/, "''") # ' (for ruby-mode)
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
UNESCAPES = {
|
102
|
+
'a' => "\x07", 'b' => "\x08", 't' => "\x09",
|
103
|
+
'n' => "\x0a", 'v' => "\x0b", 'f' => "\x0c",
|
104
|
+
'r' => "\x0d", 'e' => "\x1b", "\\\\" => "\x5c",
|
105
|
+
"\"" => "\x22", "'" => "\x27"
|
106
|
+
}
|
107
|
+
|
108
|
+
def unescape(str)
|
109
|
+
# Escape all the things
|
110
|
+
str.gsub(/\\(?:([#{UNESCAPES.keys.join}])|u([\da-fA-F]{4}))|\\0?x([\da-fA-F]{2})/) {
|
111
|
+
if $1
|
112
|
+
if $1 == '\\' then '\\' else UNESCAPES[$1] end
|
113
|
+
elsif $2 # escape \u0000 unicode
|
114
|
+
["#$2".hex].pack('U*')
|
115
|
+
elsif $3 # escape \0xff or \xff
|
116
|
+
[$3].pack('H2')
|
117
|
+
end
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
|
94
122
|
def set_queued_process_error(id,exception)
|
95
123
|
|
96
124
|
errlog = []
|
97
|
-
|
98
|
-
errcode=PROCESS_ERROR
|
99
125
|
|
100
|
-
# decoded=exception.message.to_s.tr("\n"," ")
|
101
|
-
# puts exception.message.to_s
|
102
|
-
# pp exception.message.to_s
|
103
|
-
# pp decoded
|
104
126
|
|
127
|
+
errcode=PROCESS_ERROR
|
105
128
|
|
106
|
-
|
129
|
+
#Code to avoid some annoying things related to special chars
|
130
|
+
error_msg=exception.message
|
131
|
+
error_msg=quote_string(error_msg).to_json
|
132
|
+
error_msg=error_msg[1,error_msg.size-2]
|
133
|
+
|
134
|
+
|
135
|
+
|
107
136
|
if (exception.class==VMActionException)
|
108
|
-
errlog << {"vmname" => exception.vmname,"provider"=>exception.provider,"status" =>
|
137
|
+
#errlog << {"vmname" => exception.vmname,"provider"=>exception.provider,"status" => @db.escape(error_msg)}
|
138
|
+
errlog << {"vmname" => exception.vmname,"provider"=>exception.provider,"status" => error_msg}
|
109
139
|
elsif (exception.class==RestException)
|
110
140
|
errcode=exception.code
|
111
|
-
errlog << {"status" =>
|
141
|
+
errlog << {"status" => error_msg}
|
112
142
|
else
|
113
|
-
errlog << {"status" => exception.message.to_s.tr("\'","\"")}
|
143
|
+
# errlog << {"status" => exception.message.to_s.tr("\'","\"")}
|
144
|
+
errlog << {"status" => error_msg}
|
114
145
|
end
|
146
|
+
|
147
|
+
#sql="UPDATE #{OPERATION_QUEUE_TABLE_NAME} SET #{OPERATION_STATUS_COLUMN} = #{errcode},#{OPERATION_RESULT_COLUMN} = '#{errlog.to_json}' WHERE #{OPERATION_ID_COLUMN}= #{id}"
|
115
148
|
|
116
149
|
|
150
|
+
sql="UPDATE #{OPERATION_QUEUE_TABLE_NAME} SET #{OPERATION_STATUS_COLUMN} = #{errcode},#{OPERATION_RESULT_COLUMN} = '#{errlog.to_json}' WHERE #{OPERATION_ID_COLUMN}= #{id}"
|
117
151
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
#errlog << {"vmname" => "TODO","status" => exception.message.to_s}
|
152
|
+
|
122
153
|
|
154
|
+
|
123
155
|
#@db.execute(sql,errcode,errlog.to_json,id)
|
124
156
|
@db.query(sql)
|
125
157
|
end
|
126
158
|
|
127
159
|
def get_queued_process_result(id)
|
128
160
|
check_operation_timeout
|
129
|
-
sql="SELECT #{OPERATION_STATUS_COLUMN}
|
161
|
+
#sql="SELECT #{OPERATION_STATUS_COLUMN},QUOTE(#{OPERATION_RESULT_COLUMN}) as operation_result FROM #{OPERATION_QUEUE_TABLE_NAME} WHERE #{OPERATION_ID_COLUMN}= #{id};"
|
162
|
+
sql="SELECT #{OPERATION_STATUS_COLUMN},#{OPERATION_RESULT_COLUMN} FROM #{OPERATION_QUEUE_TABLE_NAME} WHERE #{OPERATION_ID_COLUMN}= #{id};"
|
130
163
|
@db.query(sql)
|
131
164
|
end
|
132
165
|
|
133
166
|
def get_queued_last
|
134
167
|
check_operation_timeout
|
135
|
-
sql="SELECT #{OPERATION_STATUS_COLUMN},#{OPERATION_RESULT_COLUMN} FROM #{OPERATION_QUEUE_TABLE_NAME};"
|
168
|
+
sql="SELECT #{OPERATION_STATUS_COLUMN},#{OPERATION_RESULT_COLUMN} FROM #{OPERATION_QUEUE_TABLE_NAME};"
|
136
169
|
@db.query(sql)
|
137
170
|
end
|
138
171
|
|
@@ -141,14 +174,57 @@ module DB
|
|
141
174
|
sql="DELETE FROM #{OPERATION_QUEUE_TABLE_NAME}"
|
142
175
|
@db.query(sql)
|
143
176
|
end
|
177
|
+
|
178
|
+
def are_boxes_queued
|
179
|
+
result=@db.query("SELECT * FROM #{DOWNLOAD_BOX_TABLE} WHERE #{DOWNLOAD_STATUS_COLUMN} = #{DOWNLOAD_STOP}")
|
180
|
+
|
181
|
+
result.size!=0
|
182
|
+
|
183
|
+
end
|
144
184
|
|
145
|
-
def
|
146
|
-
|
185
|
+
def start_box_download
|
186
|
+
|
187
|
+
result=@db.query("SELECT * FROM #{DOWNLOAD_BOX_TABLE} WHERE #{DOWNLOAD_STATUS_COLUMN} = #{DOWNLOAD_STOP}")
|
188
|
+
|
189
|
+
|
190
|
+
id_next=result.first["id"]
|
191
|
+
|
192
|
+
|
193
|
+
sql="UPDATE #{DOWNLOAD_BOX_TABLE} SET
|
194
|
+
#{DOWNLOAD_PROGRESS_COLUMN}='0%',
|
195
|
+
#{DOWNLOAD_REMAINING_COLUMN}='--:--:--',
|
196
|
+
#{DOWNLOAD_STATUS_COLUMN}=#{DOWNLOAD_START}
|
197
|
+
WHERE #{DOWNLOAD_ID_COLUMN}=#{id_next}"
|
198
|
+
|
147
199
|
@db.query(sql)
|
200
|
+
|
201
|
+
id_next
|
202
|
+
end
|
203
|
+
|
204
|
+
def add_box_download_info(box_name,box_url)
|
205
|
+
sql="INSERT INTO #{DOWNLOAD_BOX_TABLE}(#{DOWNLOAD_BOX_COLUMN},#{DOWNLOAD_URL_COLUMN},#{DOWNLOAD_PROGRESS_COLUMN},#{DOWNLOAD_REMAINING_COLUMN},#{DOWNLOAD_STATUS_COLUMN}) VALUES ('#{box_name}','#{box_url}','WAITING','WAITING',#{DOWNLOAD_STOP})"
|
206
|
+
@db.query(sql)
|
207
|
+
|
148
208
|
last_id=@db.query("SELECT LAST_INSERT_ID() as last")
|
149
209
|
last_id.first["last"]
|
150
210
|
end
|
151
211
|
|
212
|
+
def is_box_downloading
|
213
|
+
result=@db.query("SELECT * FROM #{DOWNLOAD_BOX_TABLE} WHERE #{DOWNLOAD_STATUS_COLUMN} = #{DOWNLOAD_START}")
|
214
|
+
return false if result.size==0
|
215
|
+
return true
|
216
|
+
end
|
217
|
+
|
218
|
+
def get_box_to_download
|
219
|
+
result=@db.query("SELECT * FROM #{DOWNLOAD_BOX_TABLE} WHERE #{DOWNLOAD_STATUS_COLUMN} = #{DOWNLOAD_STOP}")
|
220
|
+
|
221
|
+
((result.size==0)?nil:result.first)
|
222
|
+
|
223
|
+
|
224
|
+
#id_next=result.first["id"]
|
225
|
+
#id_next
|
226
|
+
end
|
227
|
+
|
152
228
|
def get_box_download
|
153
229
|
sql="SELECT * FROM #{DOWNLOAD_BOX_TABLE}"
|
154
230
|
@db.query(sql)
|
@@ -165,7 +241,7 @@ module DB
|
|
165
241
|
end
|
166
242
|
|
167
243
|
def set_box_download_error(id)
|
168
|
-
sql="UPDATE #{DOWNLOAD_BOX_TABLE} SET #{DOWNLOAD_STATUS_COLUMN} = #{DOWNLOAD_ERROR}, #{DOWNLOAD_PROGRESS_COLUMN} = 'ERROR' WHERE #{DOWNLOAD_ID_COLUMN}=#{id}"
|
244
|
+
sql="UPDATE #{DOWNLOAD_BOX_TABLE} SET #{DOWNLOAD_STATUS_COLUMN} = #{DOWNLOAD_ERROR}, #{DOWNLOAD_PROGRESS_COLUMN} = 'ERROR',#{DOWNLOAD_REMAINING_COLUMN}='ERROR' WHERE #{DOWNLOAD_ID_COLUMN}=#{id}"
|
169
245
|
@db.query(sql)
|
170
246
|
end
|
171
247
|
|
@@ -175,13 +251,15 @@ module DB
|
|
175
251
|
@db.query(sql)
|
176
252
|
end
|
177
253
|
|
178
|
-
def add_box_uncompression(
|
179
|
-
|
254
|
+
def add_box_uncompression(id)
|
255
|
+
|
256
|
+
sql="UPDATE #{DOWNLOAD_BOX_TABLE} SET #{DOWNLOAD_PROGRESS_COLUMN}='Uncompressing',#{DOWNLOAD_REMAINING_COLUMN}='Uncompressing',#{DOWNLOAD_STATUS_COLUMN}=#{DOWNLOAD_UNCOMPRESS} WHERE #{DOWNLOAD_ID_COLUMN}=#{id}"
|
257
|
+
#sql="INSERT INTO #{DOWNLOAD_BOX_TABLE}(#{DOWNLOAD_BOX_COLUMN},#{DOWNLOAD_URL_COLUMN},#{DOWNLOAD_PROGRESS_COLUMN},#{DOWNLOAD_REMAINING_COLUMN},#{DOWNLOAD_STATUS_COLUMN}) VALUES ('#{box_name}','#{box_url}','Uncompressing','Uncompressing',#{DOWNLOAD_STOP})"
|
180
258
|
#@db.execute(sql,box_name,box_url,DOWNLOAD_PROCESS)
|
181
259
|
@db.query(sql)
|
182
260
|
|
183
|
-
last_id=@db.query("SELECT LAST_INSERT_ID() as last")
|
184
|
-
last_id.first["last"]
|
261
|
+
# last_id=@db.query("SELECT LAST_INSERT_ID() as last")
|
262
|
+
# last_id.first["last"]
|
185
263
|
end
|
186
264
|
|
187
265
|
def set_box_uncompression_error(id)
|
@@ -191,7 +269,7 @@ module DB
|
|
191
269
|
end
|
192
270
|
|
193
271
|
def clear_box_uncompression(id)
|
194
|
-
sql="DELETE FROM #{DOWNLOAD_BOX_TABLE} WHERE #{
|
272
|
+
sql="DELETE FROM #{DOWNLOAD_BOX_TABLE} WHERE #{DOWNLOAD_ID_COLUMN}=#{id}"
|
195
273
|
@db.query(sql)
|
196
274
|
end
|
197
275
|
|
@@ -262,7 +340,7 @@ module DB
|
|
262
340
|
DOWNLOAD_ID_COLUMN = 'id'
|
263
341
|
DOWNLOAD_BOX_COLUMN = 'box_name'
|
264
342
|
DOWNLOAD_URL_COLUMN = 'box_url'
|
265
|
-
DOWNLOAD_STATUS_COLUMN = 'download_status'
|
343
|
+
DOWNLOAD_STATUS_COLUMN = 'download_status'
|
266
344
|
DOWNLOAD_PROGRESS_COLUMN = 'download_progress'
|
267
345
|
DOWNLOAD_REMAINING_COLUMN = 'download_remaining'
|
268
346
|
CONFIG_DBUSER = 'dbuser'
|
@@ -317,7 +395,7 @@ module DB
|
|
317
395
|
`#{DOWNLOAD_URL_COLUMN}` text NOT NULL,
|
318
396
|
`#{DOWNLOAD_PROGRESS_COLUMN}` VARCHAR(10),
|
319
397
|
`#{DOWNLOAD_STATUS_COLUMN}` int(11) NOT NULL,
|
320
|
-
`#{DOWNLOAD_REMAINING_COLUMN}` VARCHAR(10),
|
398
|
+
`#{DOWNLOAD_REMAINING_COLUMN}` VARCHAR(10),
|
321
399
|
PRIMARY KEY (`#{DOWNLOAD_ID_COLUMN}`)
|
322
400
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;")
|
323
401
|
|
@@ -32,8 +32,7 @@ module Vagrant
|
|
32
32
|
class ExceptionMutator < RestException
|
33
33
|
include Vagrant::Errors
|
34
34
|
def initialize(exception)
|
35
|
-
if (exception.is_a?(Vagrant::Errors::VagrantError))
|
36
|
-
puts exception.class
|
35
|
+
if (exception.is_a?(Vagrant::Errors::VagrantError))
|
37
36
|
case exception
|
38
37
|
when BaseVMNotFound,
|
39
38
|
BoxNotFound,
|
@@ -9,29 +9,26 @@ module Vagrant
|
|
9
9
|
START_COMMAND = "start"
|
10
10
|
STOP_COMMAND = "stop"
|
11
11
|
def initialize(argv, env)
|
12
|
-
|
12
|
+
super
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
14
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
15
|
+
@subcommands = Vagrant::Registry.new
|
16
|
+
|
17
|
+
@subcommands.register(:start) do
|
18
|
+
require File.expand_path("../nodeserverstart", __FILE__)
|
19
|
+
NodeServerStart
|
20
|
+
end
|
21
|
+
|
22
|
+
@subcommands.register(:stop) do
|
23
|
+
require File.expand_path("../nodeserverstop", __FILE__)
|
24
|
+
NodeServerStop
|
25
|
+
end
|
26
|
+
|
27
|
+
@subcommands.register(:passwd) do
|
28
|
+
require File.expand_path("../nodeserverpasswd", __FILE__)
|
29
|
+
NodeServerPasswd
|
30
|
+
end
|
31
31
|
|
32
|
-
# puts "MAIN ARGS #{@main_args}"
|
33
|
-
# puts "SUB COMMAND #{@sub_command}"
|
34
|
-
# puts "SUB ARGS #{@sub_args}"
|
35
32
|
end
|
36
33
|
|
37
34
|
def execute
|
@@ -47,17 +44,7 @@ module Vagrant
|
|
47
44
|
|
48
45
|
command_class.new(@sub_args, @env).execute
|
49
46
|
|
50
|
-
|
51
|
-
# when START_COMMAND then
|
52
|
-
# @env.lock_path contiene la ruta al fichero de lock
|
53
|
-
#incluyendo el nombre de este, por lo tanto se pasa
|
54
|
-
#únicamente la ruta
|
55
|
-
# ServerAPI::ServerManager.run(File.dirname(@env.lock_path))
|
56
|
-
# when STOP_COMMAND then
|
57
|
-
# ServerAPI::ServerManager.stop(File.dirname(@env.lock_path))
|
58
|
-
# else
|
59
|
-
# return help
|
60
|
-
# end
|
47
|
+
|
61
48
|
0
|
62
49
|
end
|
63
50
|
|
@@ -77,24 +77,7 @@ module Vagrant
|
|
77
77
|
print "Can't connect to mysql with current configuration, please review provided credentials. Please execute again this command to reconfigure"
|
78
78
|
DB::DBManager.delete_config_file(@env.data_dir)
|
79
79
|
end
|
80
|
-
|
81
|
-
# #if (exception.class==Mysql2::Error)
|
82
|
-
# if (i<1)
|
83
|
-
# puts "Configuring database connection "
|
84
|
-
# puts "Do you let us create "
|
85
|
-
# puts "Insert privilege database user:"
|
86
|
-
# user=STDIN.noecho(&:gets).chomp
|
87
|
-
# print "\n"
|
88
|
-
# print "Insert privilege database password:"
|
89
|
-
# password=STDIN.noecho(&:gets).chomp
|
90
|
-
# print "\n"
|
91
|
-
# print "Insert database name:"
|
92
|
-
# database=STDIN.noecho(&:gets).chomp
|
93
|
-
# print "\n"
|
94
|
-
# DB::DBManager.create_config_file(@env.data_dir,'localhost',database,user,password)
|
95
|
-
# i=i+1
|
96
|
-
# retry
|
97
|
-
# end
|
80
|
+
|
98
81
|
end
|
99
82
|
|
100
83
|
if (!db.nil?)
|
@@ -136,9 +119,7 @@ module Vagrant
|
|
136
119
|
|
137
120
|
|
138
121
|
|
139
|
-
|
140
|
-
# puts "INTRODUCIDA EN TERMINAL"
|
141
|
-
# end
|
122
|
+
|
142
123
|
|
143
124
|
|
144
125
|
|
@@ -15,7 +15,9 @@ module Vagrant
|
|
15
15
|
# options[:password] = b
|
16
16
|
# end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
|
+
raise Errors::NoEnvironmentError if !@env.root_path
|
20
|
+
|
19
21
|
argv = parse_options(opts)
|
20
22
|
return if !argv
|
21
23
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length > 1
|
data/lib/vagrant-node/server.rb
CHANGED
@@ -42,6 +42,8 @@ module Vagrant
|
|
42
42
|
:AccessLog => access_log
|
43
43
|
}
|
44
44
|
|
45
|
+
|
46
|
+
|
45
47
|
|
46
48
|
#begin
|
47
49
|
server = WEBrick::HTTPServer.new(options)
|
@@ -52,6 +54,8 @@ module Vagrant
|
|
52
54
|
|
53
55
|
trap("USR1") {
|
54
56
|
|
57
|
+
puts "SERVER.RB RESTARTING SERVER"
|
58
|
+
|
55
59
|
#Stopping server
|
56
60
|
server.shutdown
|
57
61
|
|
@@ -64,7 +64,9 @@ module Vagrant
|
|
64
64
|
|
65
65
|
# Setup the proc that'll receive the real-time data from
|
66
66
|
# the downloader.
|
67
|
-
last_id
|
67
|
+
last_id = @db.start_box_download
|
68
|
+
|
69
|
+
#last_id=@db.add_box_download_info(@box_name,@source)
|
68
70
|
|
69
71
|
comienzo = Time.now();
|
70
72
|
|
@@ -139,12 +141,18 @@ module Vagrant
|
|
139
141
|
end
|
140
142
|
|
141
143
|
|
142
|
-
if ((!interrupted) && (result.exit_code==0))
|
143
|
-
|
144
|
-
|
145
|
-
else
|
144
|
+
# if ((!interrupted) && (result.exit_code==0))
|
145
|
+
# # @db.update_box_download_info(last_id,"100%","--:--:--")
|
146
|
+
# @db.delete_box_download(last_id)
|
147
|
+
# else
|
148
|
+
# @db.set_box_download_error(last_id)
|
149
|
+
# end
|
150
|
+
|
151
|
+
if (interrupted || (result.exit_code!=0))
|
146
152
|
@db.set_box_download_error(last_id)
|
147
153
|
end
|
154
|
+
|
155
|
+
|
148
156
|
|
149
157
|
|
150
158
|
# If the download was interrupted, then raise a specific error
|
@@ -0,0 +1,73 @@
|
|
1
|
+
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module Node
|
6
|
+
module Util
|
7
|
+
|
8
|
+
class HwFunctions
|
9
|
+
MAJOR_SATA = 8
|
10
|
+
MAJOR_IDE = 3
|
11
|
+
MAJOR_FIELD = 0
|
12
|
+
MINOR_FIELD = 1
|
13
|
+
NAME_FIELD = 2
|
14
|
+
def self.get_mem_values
|
15
|
+
|
16
|
+
mem = []
|
17
|
+
|
18
|
+
mem_file = "/proc/meminfo"
|
19
|
+
mem_values = IO.readlines(mem_file)
|
20
|
+
|
21
|
+
|
22
|
+
mem[0] = (mem_values[0].split[1].to_i / 1024.0).round(2) #Converting to MB
|
23
|
+
mem[1] = (mem_values[1].split[1].to_i / 1024.0).round(2) #Converting to MB
|
24
|
+
|
25
|
+
mem
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_disk_values
|
30
|
+
|
31
|
+
disk = []
|
32
|
+
|
33
|
+
stat_file = "/proc/diskstats"
|
34
|
+
|
35
|
+
|
36
|
+
IO.readlines(stat_file).each do |line|
|
37
|
+
major_number = line.split[MAJOR_FIELD].to_i
|
38
|
+
minor_number = line.split[MINOR_FIELD].to_i
|
39
|
+
|
40
|
+
if (((major_number==MAJOR_SATA) || (major_number==MAJOR_IDE)) && minor_number!=0)
|
41
|
+
#In this point you have all single disk partitions
|
42
|
+
#But we only want mounted ones
|
43
|
+
resout= `df -h`
|
44
|
+
resout.split("\n").each do |line1|
|
45
|
+
if (line1.split[0]=="/dev/"+line.split[NAME_FIELD])
|
46
|
+
entry =[]
|
47
|
+
entry[0] = line.split[NAME_FIELD]
|
48
|
+
entry[1] = line1.split[1]
|
49
|
+
entry[2] = line1.split[3]
|
50
|
+
entry[3] = line1.split[4]
|
51
|
+
disk << {:partition=>"/dev/"+line.split[NAME_FIELD],
|
52
|
+
:total=>line1.split[1],
|
53
|
+
:free=>line1.split[3],
|
54
|
+
:freepercent=>line1.split[4]}
|
55
|
+
# disk.push entry
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
disk
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|