diskid 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (9) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.md +18 -0
  5. data/Rakefile +42 -0
  6. data/bin/diskid +17 -0
  7. data/bin/diskid-ws +72 -0
  8. data/lib/diskid.rb +3 -0
  9. metadata +134 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Sergio Rubio
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # Disk Identification Service
2
+
3
+ ## Installation
4
+
5
+ gem install diskid
6
+
7
+ ## Usage
8
+
9
+ diskid path-to-disk-file
10
+
11
+ i.e.
12
+
13
+ diskid my-vm-disk.vmdk
14
+
15
+
16
+ Copyright (c) 2011 Sergio Rubio. See LICENSE.txt for
17
+ further details.
18
+
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require './lib/diskid.rb'
6
+
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |gem|
9
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
10
+ gem.version = DiskID::VERSION
11
+ gem.name = "diskid"
12
+ gem.homepage = "http://github.com/rubiojr/diskid"
13
+ gem.license = "MIT"
14
+ gem.summary = %Q{Virtual Disk Identification Service}
15
+ gem.description = %Q{Virtual Disk Identification Service}
16
+ gem.email = "rubiojr@frameos.org"
17
+ gem.authors = ["Sergio Rubio"]
18
+ gem.add_runtime_dependency 'sinatra'
19
+ gem.add_runtime_dependency 'clamp'
20
+ gem.add_runtime_dependency 'alchemist'
21
+ # dependencies defined in Gemfile
22
+ end
23
+ Jeweler::RubygemsDotOrgTasks.new
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/test_*.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ task :default => :build
33
+
34
+ require 'rdoc/task'
35
+ Rake::RDocTask.new do |rdoc|
36
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
37
+
38
+ rdoc.rdoc_dir = 'rdoc'
39
+ rdoc.title = "diskid #{version}"
40
+ rdoc.rdoc_files.include('README*')
41
+ rdoc.rdoc_files.include('lib/**/*.rb')
42
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ require 'clamp'
4
+
5
+ disk_file = ARGV[0]
6
+ if disk_file.nil? or not File.exist?(disk_file)
7
+ puts
8
+ puts "Usage: diskid path-to-disk-file"
9
+ puts
10
+ puts "Supported formats: vvfat vpc vmdk vdi sheepdog raw host_cdrom host_floppy host_device file qed qcow2 qcow parallels nbd dmg tftp ftps ftp https http cow cloop bochs blkverify blkdebug"
11
+ exit 1
12
+ end
13
+ host = 'diskid.frameos.org'
14
+
15
+ puts "\n#{host}\n\n"
16
+
17
+ puts `head -n 20 #{disk_file}|curl -s -X POST -F chunk=@- -F file_size=#{File.size(disk_file)} -F file_name=#{File.basename(disk_file)} http://#{host}`
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+ require 'sinatra'
3
+ require 'alchemist'
4
+
5
+ DOCS = """
6
+ <h1>FrameOS Virtual Disk Identification Service</h1>
7
+
8
+ <h2>Installation:</h2>
9
+
10
+ gem install diskid
11
+ <br/>
12
+
13
+ <h2>Usage:</h2>
14
+
15
+ <i>diskid path-to-disk-file.vmdk</i>
16
+ <br/>
17
+ <br/>
18
+
19
+ <b>Supported formats:</b> vvfat vpc vmdk vdi sheepdog raw host_cdrom host_floppy host_device file qed qcow2 qcow parallels nbd dmg tftp ftps ftp https http cow cloop bochs blkverify blkdebug
20
+
21
+ """
22
+ class DiskIDWS < Sinatra::Base
23
+
24
+ post '/' do
25
+ tmpfile = params[:chunk][:tempfile] rescue nil
26
+ file_name = params[:file_name] rescue ''
27
+
28
+ if tmpfile.nil?
29
+ halt 400, "Couldn't understand the file you sent me dude."
30
+ end
31
+ file_size = params[:file_size]
32
+ out = `qemu-img-bleeding info #{tmpfile.path}`
33
+ if $? != 0
34
+ halt 400, "Couldn't understand the file you sent me dude."
35
+ end
36
+
37
+ begin
38
+ buf = ''
39
+ buf << "file name: #{file_name}\n"
40
+ out.each_line do |l|
41
+ buf << l if l !~ /(image:|disk size:)/
42
+ end
43
+
44
+ buf << "disk size: #{'%.0f' % file_size.to_i.bytes.to.megabytes.to_f}M (#{file_size} bytes)"
45
+ tmpfile.close
46
+ FileUtils.rm_f tmpfile.path
47
+ buf
48
+ rescue => e
49
+ puts $!
50
+ puts $@
51
+ halt 400, "Something bad happened :("
52
+ end
53
+ end
54
+
55
+ get '/service-check' do
56
+ DOCS
57
+ end
58
+
59
+ error do
60
+ DOCS
61
+ end
62
+
63
+ not_found do
64
+ DOCS
65
+ end
66
+
67
+ end
68
+
69
+ DiskIDWS.set :bind => '127.0.0.1'
70
+ #DiskIDWS.set :raise_errors => false
71
+ DiskIDWS.set :show_exceptions => false
72
+ DiskIDWS.run!
@@ -0,0 +1,3 @@
1
+ module DiskID
2
+ VERSION = "0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diskid
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sergio Rubio
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: &19481420 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *19481420
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &19480920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *19480920
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &19480340 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *19480340
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &19496120 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *19496120
58
+ - !ruby/object:Gem::Dependency
59
+ name: sinatra
60
+ requirement: &19495620 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *19495620
69
+ - !ruby/object:Gem::Dependency
70
+ name: clamp
71
+ requirement: &19495060 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *19495060
80
+ - !ruby/object:Gem::Dependency
81
+ name: alchemist
82
+ requirement: &19494580 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *19494580
91
+ description: Virtual Disk Identification Service
92
+ email: rubiojr@frameos.org
93
+ executables:
94
+ - diskid
95
+ - diskid-ws
96
+ extensions: []
97
+ extra_rdoc_files:
98
+ - LICENSE.txt
99
+ - README.md
100
+ files:
101
+ - .document
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - bin/diskid
107
+ - bin/diskid-ws
108
+ - lib/diskid.rb
109
+ homepage: http://github.com/rubiojr/diskid
110
+ licenses:
111
+ - MIT
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.10
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Virtual Disk Identification Service
134
+ test_files: []