boxgrinder-ovfcatalog-delivery-plugin 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +74 -0
- data/Rakefile +31 -0
- data/lib/ovfcatalog-plugin.rb +95 -0
- data/spec/spec_helper.rb +14 -0
- metadata +85 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Sergio Rubio <rubiojr@frameos.org>
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Boxgrinder OVFCatalog
|
2
|
+
|
3
|
+
Using Boxgrinder to build and upload appliances to the Abiquo OVFCatalog
|
4
|
+
|
5
|
+
This tutorial will guide you to create an Ubuntu Oneiric appliance using [Boxgrinder](http://boxgrinder.org) and upload it to the Abiquo OVFCatalog (PlayRepo) service.
|
6
|
+
|
7
|
+
**WARNNG**
|
8
|
+
OVFCatalog is a brand new 2.0 service, not yet released.
|
9
|
+
|
10
|
+
# Pre-requisites
|
11
|
+
|
12
|
+
You need an Ubuntu based Boxgrinder meta-appliance (used to build other appliances). Get it from:
|
13
|
+
|
14
|
+
http://mirror.abiquo.com/appliances/boxgrinder-meta-ubuntu-oneiric-amd64.vmdk
|
15
|
+
|
16
|
+
and deploy it.
|
17
|
+
|
18
|
+
# Install the Boxgrinder ovfcatalog-delivery-plugin to the meta-appliance
|
19
|
+
|
20
|
+
SSH to the boxgrinder meta-appliance. Default password for the root user is 'boxgrinder'.
|
21
|
+
|
22
|
+
$ ssh root@my-boxgrinder-meta-app
|
23
|
+
|
24
|
+
Install required packages:
|
25
|
+
|
26
|
+
$ apt-get install libcurl4-openssl-dev build-essential git
|
27
|
+
|
28
|
+
Install the plugin
|
29
|
+
|
30
|
+
$ gem install --no-ri --no-rdoc boxgrinder-ovfcatalog-delivery-plugin
|
31
|
+
|
32
|
+
# Download sample appliance definitions
|
33
|
+
|
34
|
+
You can download some Ubuntu based Boxgrinder appliance definitions from [here](http://github.com/rubiojr/boxgrinder-appliances). Let's check them out using git:
|
35
|
+
|
36
|
+
$ git clone http://github.com/rubiojr/boxgrinder-appliances
|
37
|
+
|
38
|
+
We’ll use a Ubuntu appliance definition to generate a new appliance:
|
39
|
+
|
40
|
+
$ cd boxgrinder-appliances/ubuntu-jeos
|
41
|
+
|
42
|
+
$ boxgrinder-build -l boxgrinder-ubuntu-plugin,ovfcatalog-plugin \
|
43
|
+
-d ovfcatalog \
|
44
|
+
--delivery-config host:rs.bcn.abiquo.com,port:9000 \
|
45
|
+
oneiric.appl
|
46
|
+
|
47
|
+
This will build the Ubuntu Oneiric appliance and upload it to the OVFCatalog service installed in 'rs.bcn.abiquo.com' and listening on port '9000'.
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
Browse the OVFCatalog and you'll see a new appliance named 'ubuntu-oneiric' in QCOW2 format.
|
52
|
+
|
53
|
+
#OVFCatalog plugin configuration parameters
|
54
|
+
|
55
|
+
The ovfcatalog Boxgrinder plugin accepts the following list of config parameters:
|
56
|
+
|
57
|
+
**host:** the OVFCatalog host.
|
58
|
+
**port:** the OVFCatalog port.
|
59
|
+
**category:** the OVFCatalog category the appliance will have.
|
60
|
+
**icon_path:** the URL of the appliance icon.
|
61
|
+
**host:** the OVFCatalog host
|
62
|
+
**name:** the appliance name.
|
63
|
+
**description:** the appliance description.
|
64
|
+
**ram:** the amount of RAM the appliance will have.
|
65
|
+
**cpu:** the number of CPUs the appliance will have.
|
66
|
+
|
67
|
+
All the config parameters have default values and none of them are mandatory. Use the **--delivery-config** Boxgrinder parameter to configure the appliance upload to fit your needs.
|
68
|
+
|
69
|
+
|
70
|
+
# Copyright
|
71
|
+
|
72
|
+
Copyright (c) 2011 Abiquo Inc. See LICENSE.txt for
|
73
|
+
further details.
|
74
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gem|
|
6
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
7
|
+
gem.version = "0.1"
|
8
|
+
gem.name = "boxgrinder-ovfcatalog-delivery-plugin"
|
9
|
+
gem.homepage = "http://github.com/abiquo/boxgrinder-ovfcatalog-delivery-plugin"
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.summary = %Q{Deliver Boxgrider appliances to Abiquo OVFCatalog service}
|
12
|
+
gem.description = %Q{Deliver Boxgrider appliances to Abiquo OVFCatalog service}
|
13
|
+
gem.email = "rubiojr@frameos.org"
|
14
|
+
gem.authors = ["Sergio Rubio"]
|
15
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
16
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
17
|
+
gem.add_runtime_dependency 'diskid'
|
18
|
+
gem.add_runtime_dependency 'curb'
|
19
|
+
gem.add_development_dependency 'rspec', '> 1.2.3'
|
20
|
+
end
|
21
|
+
Jeweler::RubygemsDotOrgTasks.new
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/test_*.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
task :default => :build
|
31
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'diskid'
|
3
|
+
require 'curb'
|
4
|
+
require 'boxgrinder-build/plugins/base-plugin'
|
5
|
+
|
6
|
+
module BoxGrinder
|
7
|
+
class OVFCatalog < BasePlugin
|
8
|
+
def validate
|
9
|
+
set_default_config_value('category', 'Misc')
|
10
|
+
set_default_config_value('name', @appliance_config.name)
|
11
|
+
set_default_config_value('description', "#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}-#{@appliance_config.os.name}-#{@appliance_config.os.version}-#{@appliance_config.hardware.arch}")
|
12
|
+
set_default_config_value('port', '9000')
|
13
|
+
set_default_config_value('ram', '512')
|
14
|
+
set_default_config_value('cpu', '1')
|
15
|
+
set_default_config_value('host', 'rs.bcn.abiquo.com')
|
16
|
+
set_default_config_value('icon_path', 'http://rs.bcn.abiquo.com:9000/public/icons/q.png')
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
@log.info "Uploading #{@appliance_config.name} to OVFCatalog..."
|
21
|
+
begin
|
22
|
+
#TODO move to a block
|
23
|
+
upload_files(@previous_deliverables[:disk])
|
24
|
+
@log.info "Appliance #{@appliance_config.name} uploaded."
|
25
|
+
rescue => e
|
26
|
+
@log.error e
|
27
|
+
@log.error "An error occurred while uploading files."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def upload_files(disk_file)
|
32
|
+
server_host = @plugin_config['host']
|
33
|
+
server_port = @plugin_config['port']
|
34
|
+
name = @plugin_config['name']
|
35
|
+
ram = @plugin_config['ram']
|
36
|
+
cpu = @plugin_config['cpu']
|
37
|
+
category = @plugin_config['category']
|
38
|
+
icon_path = @plugin_config['icon_path']
|
39
|
+
description = "#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}-#{@appliance_config.os.name}-#{@appliance_config.os.version}-#{@appliance_config.hardware.arch}"
|
40
|
+
disk_info = DiskID::Client.identify(disk_file)
|
41
|
+
units = disk_info['virtual_size'].gsub(/[0-9]|\./,'')
|
42
|
+
virtual_size = disk_info['virtual_size'].gsub(/G|M/,'')
|
43
|
+
if units == 'G'
|
44
|
+
vsbytes = virtual_size.to_f * 1024 * 1024 * 1024
|
45
|
+
else
|
46
|
+
vsbytes = virtual_size.to_f * 1024 * 1024
|
47
|
+
end
|
48
|
+
puts "Name:".ljust(40) + name
|
49
|
+
puts "Description:".ljust(40) + description
|
50
|
+
puts "Category:".ljust(40) + category
|
51
|
+
puts "RAM:".ljust(40) + "#{ram} MB"
|
52
|
+
puts "CPU:".ljust(40) + cpu
|
53
|
+
puts "HD:".ljust(40) + "#{virtual_size} #{units} (#{vsbytes} bytes)"
|
54
|
+
puts "Filesize:".ljust(40) + "#{FileTest.size(disk_file)} bytes"
|
55
|
+
c = Curl::Easy.new "http://#{server_host}:#{server_port}/createOvf"
|
56
|
+
c.multipart_form_post = true
|
57
|
+
c.on_progress { |dt, dn, ut, un| print "\r\e[0KUploading disk: %.0f%" % ((un*100)/ut); true }
|
58
|
+
c.http_post Curl::PostField.content('object.diskFilePath', disk_file),
|
59
|
+
Curl::PostField.content('object.diskFileSize', FileTest.size(disk_file).to_s),
|
60
|
+
Curl::PostField.content('object.diskFileFormat', guess_format(disk_file)),
|
61
|
+
Curl::PostField.content('object.name', name),
|
62
|
+
Curl::PostField.content('object.description', description),
|
63
|
+
Curl::PostField.content('object.categoryName', category),
|
64
|
+
Curl::PostField.content('object.iconPath', icon_path),
|
65
|
+
Curl::PostField.content('object.cpu', cpu),
|
66
|
+
Curl::PostField.content('object.ram', ram),
|
67
|
+
Curl::PostField.content('object.ramSizeUnit', "MB"),
|
68
|
+
Curl::PostField.content('object.hd', virtual_size),
|
69
|
+
Curl::PostField.content('object.hdSizeUnit', "#{units}B"),
|
70
|
+
Curl::PostField.content('object.hdInBytes', vsbytes.to_s ),
|
71
|
+
Curl::PostField.file('diskFile', disk_file)
|
72
|
+
puts
|
73
|
+
end
|
74
|
+
|
75
|
+
def guess_format(file)
|
76
|
+
format_map = {
|
77
|
+
"vmdk_streamOptimized" => "VMDK_STREAM_OPTIMIZED",
|
78
|
+
"qcow2" => "QCOW2_SPARSE",
|
79
|
+
"vmdk_monolithicSparse" => "VMDK_SPARSE"
|
80
|
+
}
|
81
|
+
f = DiskID::Client.identify(file)
|
82
|
+
fstring = ''
|
83
|
+
if f['format'] == 'vmdk'
|
84
|
+
fstring = format_map["vmdk_#{f['variant']}"]
|
85
|
+
elsif f['format'] == 'qcow2'
|
86
|
+
fstring = "QCOW2_SPARSE"
|
87
|
+
else
|
88
|
+
end
|
89
|
+
fstring
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
plugin :class => BoxGrinder::OVFCatalog, :type => :delivery, :name => :ovfcatalog, :full_name => "Upload appliance to Abiquo OVFCatalog"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec/autorun'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
require 'lib-here'
|
7
|
+
|
8
|
+
module TestHelpersMod
|
9
|
+
|
10
|
+
def data_dir
|
11
|
+
File.join(File.dirname(__FILE__),"data")
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boxgrinder-ovfcatalog-delivery-plugin
|
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-11-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: diskid
|
16
|
+
requirement: &23040360 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *23040360
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: curb
|
27
|
+
requirement: &23039880 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *23039880
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &23039400 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>'
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.2.3
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *23039400
|
47
|
+
description: Deliver Boxgrider appliances to Abiquo OVFCatalog service
|
48
|
+
email: rubiojr@frameos.org
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
files:
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/ovfcatalog-plugin.rb
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
homepage: http://github.com/abiquo/boxgrinder-ovfcatalog-delivery-plugin
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.10
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Deliver Boxgrider appliances to Abiquo OVFCatalog service
|
85
|
+
test_files: []
|