Class: VolumeVisualizer::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/volume_visualizer/cli.rb

Instance Method Summary collapse

Instance Method Details

#generateObject



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/volume_visualizer/cli.rb', line 89

def generate
  json_filename = File.join( options[:output_path], options[:data_name] + ".json" )
  File.open(json_filename, "w") do |json|
    json.puts zfs.to_json
  end
  STDERR.puts "generated data file #{json_filename}"

  html_filename = File.join( options[:output_path], "index.html" )
  FileUtils.cp html_source, html_filename
  STDERR.puts "installed #{html_filename}"
end

#instawebObject



114
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
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/volume_visualizer/cli.rb', line 114

def instaweb
  if false && (ENV["USER"] != "root") # && not in parse mode

    STDERR.puts "ERROR: Sorry. Instaweb mode requires root privileges, or requires\n  input data to parse. Try one of these:\n\nsudo vv instaweb\n\n  or \n\nsudo `vv show-command` > /tmp/data\nvv instaweb --parse-file /tmp/data\n    EOF\n    exit 1\n  end\n\n  port = nil\n  begin\n    port = rand(20000) + 20000\n    server = WEBrick::HTTPServer.new(\n      :AccessLog => [],\n      :Port => port,\n      :Logger => WEBrick::Log::new(\"/dev/null\", 7)\n    )\n  rescue Errno::EADDRINUSE\n    puts \"ERROR: port \#{port} already in use -- retrying\"\n    retry\n  end\n\n\n  server.mount_proc \"/\" do |req, res|\n    res.body = File.open(html_source).read\n  end\n\n  zfs_data = zfs.to_json\n  server.mount_proc \"/volviz.json\" do |req, res|\n    res.body = zfs_data\n  end\n\n  trap 'INT' do \n    server.shutdown \n  end\n\n  STDERR.puts \"server running on http://\#{Socket.gethostname}:\#{port}\"\n\n  server.start\nend\n"

#show_commandObject



57
58
59
# File 'lib/volume_visualizer/cli.rb', line 57

def show_command
  puts ZFS::Pool.query_command options[:volume]
end