veewee 0.3.0.alpha9 → 0.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/doc/definition.md +8 -1
- data/lib/fission/config.rb +52 -5
- data/lib/fission.rb +3 -5
- data/lib/veewee/cli.rb +1 -1
- data/lib/veewee/command/base.rb +1 -1
- data/lib/veewee/command/{vmfusion.rb → fusion.rb} +1 -1
- data/lib/veewee/command/group_base.rb +2 -1
- data/lib/veewee/command/kvm.rb +1 -0
- data/lib/veewee/command/{virtualbox.rb → vbox.rb} +1 -1
- data/lib/veewee/command.rb +2 -2
- data/lib/veewee/definitions.rb +29 -10
- data/lib/veewee/environment.rb +8 -0
- data/lib/veewee/provider/core/box/exec.rb +1 -1
- data/lib/veewee/provider/core/box/floppy.rb +2 -2
- data/lib/veewee/provider/core/helper/iso.rb +1 -1
- data/lib/veewee/provider/core/helper/web.rb +9 -4
- data/lib/veewee/provider/kvm/box/create.rb +1 -0
- data/lib/veewee/provider/vmfusion/box/create.rb +1 -1
- data/lib/veewee/provider/vmfusion/box/destroy.rb +1 -1
- data/lib/veewee/provider/vmfusion/box/export_ova.rb +1 -1
- data/lib/veewee/provider/vmfusion/box/helper/buildinfo.rb +16 -8
- data/lib/veewee/provider/vmfusion/box/helper/ip.rb +48 -3
- data/lib/veewee/provider/vmfusion/box/helper/vnc.rb +2 -2
- data/lib/veewee/provider/vmfusion/box.rb +3 -11
- data/lib/veewee/provider/vmfusion/provider.rb +15 -2
- data/lib/veewee/templates.rb +1 -2
- data/lib/veewee/version.rb +1 -1
- data/templates/CentOS-6.2-i386-minimal/base.sh +14 -0
- data/templates/CentOS-6.2-i386-minimal/chef.sh +3 -0
- data/templates/CentOS-6.2-i386-minimal/cleanup.sh +5 -0
- data/templates/CentOS-6.2-i386-minimal/definition.rb +39 -0
- data/templates/CentOS-6.2-i386-minimal/ks.cfg +39 -0
- data/templates/CentOS-6.2-i386-minimal/puppet.sh +12 -0
- data/templates/CentOS-6.2-i386-minimal/ruby.sh +3 -0
- data/templates/CentOS-6.2-i386-minimal/vagrant.sh +17 -0
- data/templates/CentOS-6.2-i386-minimal/virtualbox.sh +8 -0
- data/templates/CentOS-6.3-i386-minimal/base.sh +14 -0
- data/templates/CentOS-6.3-i386-minimal/chef.sh +3 -0
- data/templates/CentOS-6.3-i386-minimal/cleanup.sh +5 -0
- data/templates/CentOS-6.3-i386-minimal/definition.rb +39 -0
- data/templates/CentOS-6.3-i386-minimal/ks.cfg +42 -0
- data/templates/CentOS-6.3-i386-minimal/puppet.sh +12 -0
- data/templates/CentOS-6.3-i386-minimal/ruby.sh +3 -0
- data/templates/CentOS-6.3-i386-minimal/vagrant.sh +17 -0
- data/templates/CentOS-6.3-i386-minimal/virtualbox.sh +8 -0
- data/templates/CentOS-6.3-x86_64-minimal/base.sh +14 -0
- data/templates/CentOS-6.3-x86_64-minimal/chef.sh +3 -0
- data/templates/CentOS-6.3-x86_64-minimal/cleanup.sh +5 -0
- data/templates/CentOS-6.3-x86_64-minimal/definition.rb +39 -0
- data/templates/CentOS-6.3-x86_64-minimal/ks.cfg +42 -0
- data/templates/CentOS-6.3-x86_64-minimal/puppet.sh +12 -0
- data/templates/CentOS-6.3-x86_64-minimal/ruby.sh +3 -0
- data/templates/CentOS-6.3-x86_64-minimal/vagrant.sh +17 -0
- data/templates/CentOS-6.3-x86_64-minimal/virtualbox.sh +8 -0
- data/templates/Debian-6.0.3-amd64-netboot/base.sh +14 -0
- data/templates/Debian-6.0.3-i386-netboot/base.sh +14 -0
- data/templates/Debian-6.0.4-amd64-netboot/base.sh +14 -0
- data/templates/Debian-6.0.4-i386-netboot/base.sh +14 -0
- data/templates/Debian-6.0.5-amd64-netboot/base.sh +27 -0
- data/templates/Debian-6.0.5-amd64-netboot/chef.sh +2 -0
- data/templates/Debian-6.0.5-amd64-netboot/cleanup-virtualbox.sh +4 -0
- data/templates/Debian-6.0.5-amd64-netboot/cleanup.sh +17 -0
- data/templates/Debian-6.0.5-amd64-netboot/definition.rb +49 -0
- data/templates/Debian-6.0.5-amd64-netboot/preseed.cfg +315 -0
- data/templates/Debian-6.0.5-amd64-netboot/puppet.sh +2 -0
- data/templates/Debian-6.0.5-amd64-netboot/ruby.sh +10 -0
- data/templates/Debian-6.0.5-amd64-netboot/vagrant.sh +21 -0
- data/templates/Debian-6.0.5-amd64-netboot/virtualbox.sh +13 -0
- data/templates/Debian-6.0.5-amd64-netboot/zerodisk.sh +3 -0
- data/templates/Debian-6.0.5-i386-netboot/base.sh +27 -0
- data/templates/Debian-6.0.5-i386-netboot/chef.sh +2 -0
- data/templates/Debian-6.0.5-i386-netboot/cleanup-virtualbox.sh +4 -0
- data/templates/Debian-6.0.5-i386-netboot/cleanup.sh +17 -0
- data/templates/Debian-6.0.5-i386-netboot/definition.rb +51 -0
- data/templates/Debian-6.0.5-i386-netboot/preseed.cfg +315 -0
- data/templates/Debian-6.0.5-i386-netboot/puppet.sh +2 -0
- data/templates/Debian-6.0.5-i386-netboot/ruby.sh +10 -0
- data/templates/Debian-6.0.5-i386-netboot/vagrant.sh +21 -0
- data/templates/Debian-6.0.5-i386-netboot/virtualbox.sh +13 -0
- data/templates/Debian-6.0.5-i386-netboot/zerodisk.sh +3 -0
- data/templates/Fedora-16-x86_64-netboot/definition.rb +29 -0
- data/templates/Fedora-16-x86_64-netboot/ks.cfg +70 -0
- data/templates/Fedora-16-x86_64-netboot/postinstall.sh +26 -0
- data/templates/Fedora-17-i386/definition.rb +17 -0
- data/templates/Fedora-17-i386/ks.cfg +72 -0
- data/templates/Fedora-17-i386/postinstall.sh +35 -0
- data/templates/Fedora-17-x86_64/definition.rb +17 -0
- data/templates/Fedora-17-x86_64/ks.cfg +72 -0
- data/templates/Fedora-17-x86_64/postinstall.sh +35 -0
- data/templates/gentoo-latest-x86_64-experimental/definition.rb +1 -1
- data/templates/scientificlinux-6.2-i386-netboot/base.sh +1 -0
- data/templates/scientificlinux-6.2-i386-netboot/chef.sh +1 -0
- data/templates/scientificlinux-6.2-i386-netboot/cleanup.sh +4 -0
- data/templates/scientificlinux-6.2-i386-netboot/definition.rb +36 -0
- data/templates/scientificlinux-6.2-i386-netboot/ks.cfg +53 -0
- data/templates/scientificlinux-6.2-i386-netboot/postinstall.sh +30 -0
- data/templates/scientificlinux-6.2-i386-netboot/puppet.sh +1 -0
- data/templates/scientificlinux-6.2-i386-netboot/vagrant.sh +8 -0
- data/templates/scientificlinux-6.2-i386-netboot/virtualbox.sh +8 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/base.sh +1 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/chef.sh +1 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/cleanup.sh +4 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/definition.rb +36 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/ks.cfg +53 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/postinstall.sh +30 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/puppet.sh +1 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/vagrant.sh +8 -0
- data/templates/scientificlinux-6.2-x86_64-netboot/virtualbox.sh +8 -0
- data/templates/ubuntu-10.04.4-server-amd64/postinstall.sh +9 -0
- data/templates/ubuntu-12.04-server-amd64/definition.rb +1 -3
- data/templates/ubuntu-12.04-server-amd64-packages/definition.rb +1 -3
- data/templates/ubuntu-12.04-server-i386/definition.rb +1 -3
- data/templates/ubuntu-12.04-server-i386-packages/definition.rb +35 -0
- data/templates/ubuntu-12.04-server-i386-packages/postinstall.sh +72 -0
- data/templates/ubuntu-12.04-server-i386-packages/preseed.cfg +87 -0
- data/templates/windows-7-enterprise-amd64/Autounattend.xml +8 -8
- data/validation/features/steps/veewee_steps.rb +1 -1
- data/veewee.gemspec +5 -3
- metadata +104 -37
- data/lib/fission/cli.rb +0 -76
- data/lib/fission/command/clone.rb +0 -68
- data/lib/fission/command/delete.rb +0 -71
- data/lib/fission/command/snapshot_create.rb +0 -52
- data/lib/fission/command/snapshot_list.rb +0 -45
- data/lib/fission/command/snapshot_revert.rb +0 -54
- data/lib/fission/command/start.rb +0 -69
- data/lib/fission/command/status.rb +0 -31
- data/lib/fission/command/stop.rb +0 -49
- data/lib/fission/command/suspend.rb +0 -67
- data/lib/fission/command.rb +0 -15
- data/lib/fission/core_ext/class.rb +0 -5
- data/lib/fission/core_ext/file.rb +0 -7
- data/lib/fission/core_ext/object.rb +0 -112
- data/lib/fission/error.rb +0 -9
- data/lib/fission/fusion.rb +0 -17
- data/lib/fission/leasesfile.rb +0 -74
- data/lib/fission/metadata.rb +0 -39
- data/lib/fission/response.rb +0 -16
- data/lib/fission/ui.rb +0 -22
- data/lib/fission/version.rb +0 -3
- data/lib/fission/vm.rb +0 -365
- data/templates/openbsd50_i386/.definition.rb.swp +0 -0
data/Gemfile
CHANGED
data/doc/definition.md
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# Veewee definition
|
2
2
|
|
3
3
|
## Creating a definition
|
4
|
-
A definition is
|
4
|
+
A definition is created by 'cloning' a *template*.
|
5
5
|
|
6
6
|
To create a definition you use the 'define' subcommand:
|
7
7
|
|
8
8
|
veewee vbox define 'myubuntu' 'ubuntu-10.10-server-amd64'
|
9
9
|
|
10
|
+
If you want to use an external repo for the definition you can specify a git-url
|
11
|
+
|
12
|
+
veewee vbox define 'myubuntu' 'git://github.com/jedi4ever/myubuntu'
|
13
|
+
|
10
14
|
## Modifying a definition
|
11
15
|
Definitions are stored under a directory 'definitions' relative to the current directory.
|
12
16
|
|
@@ -48,6 +52,9 @@ The 'Veewee::Session.declare' is now deprecated and you should use 'Veewee::Defi
|
|
48
52
|
|
49
53
|
The default user of definitions is now 'veewee' and not 'vagrant'. This is because on other virtualizations like fusion and kvm, there is not relationship with the 'vagrant'. Users 'vagrant' are created by the 'vagrant.sh' script and not by the preseed or kickstart.
|
50
54
|
|
55
|
+
_Using ERB in files_
|
56
|
+
|
57
|
+
Add '.erb' to your files in a definition and they will get rendered (useful for generting kickstart,postinstall) (thx @mconigilaro)
|
51
58
|
|
52
59
|
## Listing existing definitions
|
53
60
|
|
data/lib/fission/config.rb
CHANGED
@@ -1,24 +1,71 @@
|
|
1
1
|
module Fission
|
2
2
|
class Config
|
3
|
+
|
4
|
+
# Public: Gets/Sets the Hash of attributes.
|
3
5
|
attr_accessor :attributes
|
4
6
|
|
7
|
+
# Public: Path to the Fission conf file (default: ~/.fissionrc).
|
5
8
|
CONF_FILE = File.expand_path '~/.fissionrc'
|
6
9
|
|
10
|
+
# Public: Initializes a Config object. This also sets the default config
|
11
|
+
# attributes for 'vmrun_bin', 'vmrun_cmd', 'vm_dir', 'plist_file', and
|
12
|
+
# 'gui_bin'.
|
13
|
+
#
|
14
|
+
# Examples
|
15
|
+
#
|
16
|
+
# Fission::Config.new
|
17
|
+
#
|
18
|
+
# Returns a new Config instance.
|
7
19
|
def initialize
|
8
20
|
@attributes = {}
|
9
|
-
load_from_file
|
10
21
|
|
11
|
-
|
12
|
-
|
22
|
+
@attributes['vm_dir'] = File.expand_path('~/Documents/Virtual Machines.localized/')
|
23
|
+
@attributes['lease_file'] = '/var/db/vmware/vmnet-dhcpd-vmnet8.leases'
|
24
|
+
|
25
|
+
fusion_version = :unknown
|
26
|
+
|
27
|
+
if File.exists?("/Library/Application Support/VMware Fusion/vmrun")
|
28
|
+
@attributes['vmrun_bin'] = '/Library/Application Support/VMware Fusion/vmrun'
|
29
|
+
end
|
30
|
+
|
31
|
+
if File.exists?("/Applications/VMware Fusion.app/Contents/Library/vmrun")
|
32
|
+
@attributes['vmrun_bin'] = "/Applications/VMware Fusion.app/Contents/Library/vmrun"
|
33
|
+
end
|
34
|
+
|
35
|
+
if fusion_version == :unknown
|
13
36
|
end
|
14
37
|
|
15
|
-
@attributes['vmrun_bin'] = '/Library/Application Support/VMware Fusion/vmrun'
|
16
|
-
@attributes['vmrun_cmd'] = "#{@attributes['vmrun_bin'].gsub(' ', '\ ')} -T fusion"
|
17
38
|
@attributes['plist_file'] = File.expand_path('~/Library/Preferences/com.vmware.fusion.plist')
|
18
39
|
@attributes['gui_bin'] = File.expand_path('/Applications/VMware Fusion.app/Contents/MacOS/vmware')
|
40
|
+
|
41
|
+
load_from_file
|
42
|
+
|
43
|
+
@attributes['vmrun_cmd'] = "#{@attributes['vmrun_bin'].gsub(' ', '\ ')} -T fusion"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Public: Helper method to access config atributes. This is a shortcut for
|
47
|
+
# querying the config attributes.
|
48
|
+
#
|
49
|
+
# item - The config item to query.
|
50
|
+
#
|
51
|
+
# Examples
|
52
|
+
#
|
53
|
+
# Fission.config['vmrun_bin']
|
54
|
+
# # => '/foo/bar/vmrun'
|
55
|
+
#
|
56
|
+
# Returns the value of the specified config item.
|
57
|
+
def [](item)
|
58
|
+
@attributes[item]
|
19
59
|
end
|
20
60
|
|
21
61
|
private
|
62
|
+
# Internal: Loads config values from the Fission conf file into attributes.
|
63
|
+
#
|
64
|
+
# Examples
|
65
|
+
#
|
66
|
+
# load_from_file
|
67
|
+
#
|
68
|
+
# Returns nothing.
|
22
69
|
def load_from_file
|
23
70
|
if File.file?(CONF_FILE)
|
24
71
|
@attributes.merge!(YAML.load_file(CONF_FILE))
|
data/lib/fission.rb
CHANGED
@@ -5,9 +5,10 @@ require 'yaml'
|
|
5
5
|
|
6
6
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
7
7
|
|
8
|
-
require 'fission/error'
|
8
|
+
#require 'fission/error'
|
9
9
|
require 'fission/cli'
|
10
10
|
require 'fission/command'
|
11
|
+
require 'fission/command_helpers'
|
11
12
|
require 'fission/command/clone'
|
12
13
|
require 'fission/command/snapshot_create'
|
13
14
|
require 'fission/command/snapshot_list'
|
@@ -16,12 +17,12 @@ require 'fission/command/start'
|
|
16
17
|
require 'fission/command/status'
|
17
18
|
require 'fission/command/stop'
|
18
19
|
require 'fission/command/suspend'
|
19
|
-
require 'fission/command/delete'
|
20
20
|
require 'fission/config'
|
21
21
|
require 'fission/core_ext/class'
|
22
22
|
require 'fission/core_ext/file'
|
23
23
|
require 'fission/core_ext/object'
|
24
24
|
require 'fission/fusion'
|
25
|
+
require 'fission/lease'
|
25
26
|
require 'fission/metadata'
|
26
27
|
require 'fission/response'
|
27
28
|
require 'fission/ui'
|
@@ -35,7 +36,4 @@ module Fission
|
|
35
36
|
@config ||= Fission::Config.new
|
36
37
|
end
|
37
38
|
|
38
|
-
def ui
|
39
|
-
@ui ||= Fission::UI.new
|
40
|
-
end
|
41
39
|
end
|
data/lib/veewee/cli.rb
CHANGED
data/lib/veewee/command/base.rb
CHANGED
data/lib/veewee/command/kvm.rb
CHANGED
@@ -10,6 +10,7 @@ module Veewee
|
|
10
10
|
method_option :auto,:type => :boolean , :default => false, :aliases => "-a", :desc => "auto answers"
|
11
11
|
method_option :postinstall_include, :type => :array, :default => [], :aliases => "-i", :desc => "ruby regexp of postinstall filenames to additionally include"
|
12
12
|
method_option :postinstall_exclude, :type => :array, :default => [], :aliases => "-e", :desc => "ruby regexp of postinstall filenames to exclude"
|
13
|
+
method_option :use_emulation, :type => :boolean , :default => false, :desc => "Use QEMU emulation"
|
13
14
|
def build(box_name)
|
14
15
|
venv=Veewee::Environment.new(options)
|
15
16
|
venv.ui=env.ui
|
data/lib/veewee/command.rb
CHANGED
@@ -10,6 +10,6 @@ end
|
|
10
10
|
# The built-in commands must always be loaded
|
11
11
|
require 'veewee/command/version'
|
12
12
|
require 'veewee/command/kvm'
|
13
|
-
require 'veewee/command/
|
14
|
-
require 'veewee/command/
|
13
|
+
require 'veewee/command/vbox'
|
14
|
+
require 'veewee/command/fusion'
|
15
15
|
require 'veewee/command/parallels'
|
data/lib/veewee/definitions.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'grit'
|
1
2
|
require 'veewee/definition'
|
2
3
|
require 'veewee/templates'
|
3
4
|
require 'veewee/template'
|
@@ -39,7 +40,7 @@ module Veewee
|
|
39
40
|
end
|
40
41
|
|
41
42
|
if definitions.length==0
|
42
|
-
env.logger.debug("[Definition] no definitions found")
|
43
|
+
env.logger.debug("[Definition] no definitions found")
|
43
44
|
end
|
44
45
|
|
45
46
|
definitions.each(&block)
|
@@ -61,9 +62,15 @@ module Veewee
|
|
61
62
|
|
62
63
|
env.logger.debug("Forceflag : #{options['force']}")
|
63
64
|
|
65
|
+
git_template=false
|
66
|
+
# Check if the template is a git repo
|
67
|
+
if template_name.start_with?("git://")
|
68
|
+
git_template=true
|
69
|
+
end
|
70
|
+
|
64
71
|
# Check if template exists
|
65
72
|
template=env.templates[template_name]
|
66
|
-
if template.nil?
|
73
|
+
if template.nil? and ! git_template
|
67
74
|
env.logger.fatal("Template '#{template_name}' does not exist")
|
68
75
|
raise Veewee::TemplateError, "Template '#{template_name}' does not exist"
|
69
76
|
else
|
@@ -83,19 +90,31 @@ module Veewee
|
|
83
90
|
end
|
84
91
|
end
|
85
92
|
|
86
|
-
env.logger.
|
93
|
+
env.logger.info("Creating definition #{definition_name} in directory '#{env.definition_dir}' ")
|
87
94
|
dst_dir="#{File.join(env.definition_dir,definition_name)}"
|
88
95
|
FileUtils.mkdir(dst_dir)
|
89
96
|
env.logger.debug("Definition Directory '#{File.join(env.definition_dir,definition_name)}' succesfuly created")
|
90
97
|
|
91
98
|
# Start copying/cloning the directory of the template to the definition directory
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
+
if (git_template)
|
100
|
+
begin
|
101
|
+
env.logger.info("Starting git clone #{template_name} #{dst_dir}")
|
102
|
+
g = Grit::Git.new(dst_dir)
|
103
|
+
g.clone({ :timeout => false }, template_name, dst_dir)
|
104
|
+
rescue Exception => ex
|
105
|
+
err = "git clone #{template_name} #{dst_dir} failed: #{ex}"
|
106
|
+
env.logger.fatal(err)
|
107
|
+
raise Veewee::DefinitionError, err
|
108
|
+
end
|
109
|
+
else
|
110
|
+
begin
|
111
|
+
env.logger.debug("Starting copy '#{template.path}' to '#{dst_dir}'")
|
112
|
+
FileUtils.cp_r(template.path+"/.",dst_dir)
|
113
|
+
env.logger.debug("Copy '#{template.path}' to '#{dst_dir}' succesfull")
|
114
|
+
rescue Exception => ex
|
115
|
+
env.logger.fatal("Copy '#{template.path}' to #{dst_dir}' failed: #{ex}")
|
116
|
+
raise Veewee::Error , "Copy '#{template.path}' to #{dst_dir}' failed: #{ex}"
|
117
|
+
end
|
99
118
|
end
|
100
119
|
|
101
120
|
definition=env.definitions[definition_name]
|
data/lib/veewee/environment.rb
CHANGED
@@ -69,6 +69,14 @@ module Veewee
|
|
69
69
|
}
|
70
70
|
|
71
71
|
options = defaults.merge(options)
|
72
|
+
veeweefile_config = defaults.keys.inject({}) do |memo,obj|
|
73
|
+
if config.env.methods.include?(obj) && !config.env.send(obj).nil?
|
74
|
+
memo.merge({ obj => config.env.send(obj) })
|
75
|
+
else
|
76
|
+
memo
|
77
|
+
end
|
78
|
+
end
|
79
|
+
options = options.merge(veeweefile_config)
|
72
80
|
|
73
81
|
# We need to set this variable before the first call to the logger object
|
74
82
|
if options.has_key?("debug")
|
@@ -2,7 +2,7 @@ module Veewee
|
|
2
2
|
module Provider
|
3
3
|
module Core
|
4
4
|
module BoxCommand
|
5
|
-
def create_floppy(
|
5
|
+
def create_floppy(floppy_filename)
|
6
6
|
# Todo Check for java
|
7
7
|
# Todo check output of commands
|
8
8
|
|
@@ -15,7 +15,7 @@ module Veewee
|
|
15
15
|
FileUtils.cp("#{full_filename}","#{temp_dir}")
|
16
16
|
end
|
17
17
|
javacode_dir=File.expand_path(File.join(__FILE__,'..','..','..','..','..','java'))
|
18
|
-
floppy_file=File.join(definition.path,
|
18
|
+
floppy_file=File.join(definition.path,floppy_filename)
|
19
19
|
if File.exists?(floppy_file)
|
20
20
|
env.logger.info "Removing previous floppy file"
|
21
21
|
FileUtils.rm(floppy_file)
|
@@ -91,7 +91,7 @@ module Veewee
|
|
91
91
|
rel_path=path1.relative_path_from(path2).to_s
|
92
92
|
|
93
93
|
ui.info ""
|
94
|
-
ui.info "We did not find an isofile
|
94
|
+
ui.info "We did not find an isofile here : #{full_path}. \n\nThe definition provided the following download information:"
|
95
95
|
unless "#{self.iso_src}"==""
|
96
96
|
ui.info "- Download url: #{self.iso_src}"
|
97
97
|
end
|
@@ -21,10 +21,15 @@ module Veewee
|
|
21
21
|
def do_GET(request,response)
|
22
22
|
response['Content-Type']='text/plain'
|
23
23
|
response.status = 200
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
content = File.open(@localfile, "r").read
|
25
|
+
response.body = case File.extname(@localfile)
|
26
|
+
when ".erb"
|
27
|
+
ui.info "Rendering and serving file #{@localfile}"
|
28
|
+
ERB.new(content).result(binding)
|
29
|
+
else
|
30
|
+
ui.info "Serving file #{@localfile}"
|
31
|
+
content
|
32
|
+
end
|
28
33
|
#If we shut too fast it might not get the complete file
|
29
34
|
sleep 2
|
30
35
|
@server.shutdown
|
@@ -22,6 +22,7 @@ module Veewee
|
|
22
22
|
:cpus => definition.cpu_count.to_i,
|
23
23
|
:volume_capacity => "#{definition.disk_size}M",
|
24
24
|
:network_interface_type => "nat",
|
25
|
+
:domain_type => options['use_emulation'] ? 'qemu': 'kvm',
|
25
26
|
:iso_file => definition.iso_file,
|
26
27
|
:arch => definition.os_type_id.end_with?("_64") ? "x86_64" : "i686",
|
27
28
|
:iso_dir => env.config.veewee.iso_dir
|
@@ -27,7 +27,7 @@ module Veewee
|
|
27
27
|
current_dir=FileUtils.pwd
|
28
28
|
FileUtils.chdir(vm_path)
|
29
29
|
env.ui.info "Creating disk"
|
30
|
-
command="#{
|
30
|
+
command="#{File.dirname(vmrun_cmd).shellescape}/vmware-vdiskmanager -c -s #{definition.disk_size}M -a lsilogic -t #{disk_type} #{name}.vmdk"
|
31
31
|
shell_results=shell_exec("#{command}",{:mute => true})
|
32
32
|
FileUtils.chdir(current_dir)
|
33
33
|
end
|
@@ -41,7 +41,7 @@ module Veewee
|
|
41
41
|
# before exporting the system needs to be shut down
|
42
42
|
|
43
43
|
# otherwise the debug log will show - The specified virtual disk needs repair
|
44
|
-
shell_exec("#{
|
44
|
+
shell_exec("#{File.dirname(vmrun_cmd).shellescape}/ovftool/ovftool.bin #{debug} #{flags} #{vmx_file_path.shellescape} #{name}.ova")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -5,22 +5,30 @@ module Veewee
|
|
5
5
|
|
6
6
|
def build_info
|
7
7
|
info=super
|
8
|
-
|
9
|
-
output=IO.popen("#{command.shellescape}").readlines
|
8
|
+
output=IO.popen("#{vmrun_cmd.shellescape}").readlines
|
10
9
|
info << {:filename => ".vmfusion_version",:content => output[1].split(/ /)[2..3].join.strip}
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def guest_iso_directory
|
14
|
+
# use vmware fusion 3.x as default path
|
15
|
+
iso_images_dir="/Library/Application Support/VMware Fusion/isoimages"
|
11
16
|
|
17
|
+
# if path doesn't exist check for vmware fusion 4.x path
|
18
|
+
if( ! File.exists?(iso_images_dir) )
|
19
|
+
iso_images_dir="/Applications/VMware Fusion.app/Contents/Library/isoimages"
|
20
|
+
end
|
21
|
+
return iso_images_dir
|
12
22
|
end
|
13
23
|
|
14
24
|
# Determine the iso of the guest additions
|
15
25
|
def guest_iso_path
|
16
26
|
# So we begin by transferring the ISO file of the vmware tools
|
17
|
-
|
18
|
-
iso_image="
|
19
|
-
iso_image="
|
20
|
-
iso_image="
|
21
|
-
iso_image="/Library/Application Support/VMware Fusion/isoimages/windows.iso" if definition.os_type_id=~/^Win/
|
27
|
+
iso_image=File.join(guest_iso_directory, "linux.iso")
|
28
|
+
iso_image=File.join(guest_iso_directory, "darwin.iso") if definition.os_type_id=~/^Darwin/
|
29
|
+
iso_image=File.join(guest_iso_directory, "freebsd.iso") if definition.os_type_id=~/^Free/
|
30
|
+
iso_image=File.join(guest_iso_directory, "windows.iso") if definition.os_type_id=~/^Win/
|
22
31
|
return iso_image
|
23
|
-
|
24
32
|
end
|
25
33
|
|
26
34
|
# Transfer information provide by the provider to the box
|
@@ -3,14 +3,59 @@ module Veewee
|
|
3
3
|
module Vmfusion
|
4
4
|
module BoxCommand
|
5
5
|
|
6
|
-
#
|
6
|
+
# Retrieve the first mac address for a vm
|
7
|
+
# This will only retrieve the first auto generate mac address
|
8
|
+
def mac_address
|
9
|
+
raise ::Fission::Error,"VM #{name} does not exist" unless self.exists?
|
10
|
+
|
11
|
+
line=File.new(vmx_file_path).grep(/^ethernet0.generatedAddress =/)
|
12
|
+
if line.nil?
|
13
|
+
#Fission.ui.output "Hmm, the vmx file #{vmx_path} does not contain a generated mac address "
|
14
|
+
return nil
|
15
|
+
end
|
16
|
+
address=line.first.split("=")[1].strip.split(/\"/)[1]
|
17
|
+
return address
|
18
|
+
end
|
19
|
+
|
20
|
+
# Retrieve the ip address for a vm.
|
21
|
+
# This will only look for dynamically assigned ip address via vmware dhcp
|
7
22
|
def ip_address
|
8
|
-
|
23
|
+
# Does not work for now as the vmx path is not escape correctly by fission 0.4.0
|
24
|
+
#return raw.network_info.data.first['ip_address']
|
25
|
+
raise ::Fission::Error,"VM #{name} does not exist" unless self.exists?
|
26
|
+
|
27
|
+
unless mac_address.nil?
|
28
|
+
lease = Fission::Lease.all.data.find { |l| l.mac_address=mac_address}
|
29
|
+
return lease.ip_address unless lease.nil?
|
30
|
+
return nil
|
31
|
+
else
|
32
|
+
# No mac address was found for this machine so we can't calculate the ip-address
|
33
|
+
return nil
|
34
|
+
end
|
9
35
|
end
|
10
36
|
|
11
37
|
# http://www.thirdbit.net/articles/2008/03/04/dhcp-on-vmware-fusion/
|
12
38
|
def host_ip_as_seen_by_guest
|
13
|
-
|
39
|
+
|
40
|
+
# if File.exists?("/Library/Application Support/VMware Fusion/vmnet8/nat.conf")
|
41
|
+
# file = "/Library/Application Support/VMware Fusion/vmnet8/nat.conf"
|
42
|
+
# end
|
43
|
+
|
44
|
+
# if File.exists?("/Library/Preferences/VMware Fusion/vmnet8/nat.conf")
|
45
|
+
# file = "/Library/Preferences/VMware Fusion/vmnet8/nat.conf"
|
46
|
+
# end
|
47
|
+
# File.open(file).readlines.grep(/ip = /).first.split(" ")[2]
|
48
|
+
|
49
|
+
# The above is not always correct
|
50
|
+
# There seems also an entry for vmnet8 in the dhcpd.conf
|
51
|
+
# /Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf
|
52
|
+
# host vmnet8 {
|
53
|
+
# fixed-address
|
54
|
+
|
55
|
+
# The above is fancy but doesn't always agree, we need to do is ifconfig vmnet8
|
56
|
+
# Ifconfig never lies
|
57
|
+
shell_results = shell_exec("ifconfig vmnet8", { :mute => true})
|
58
|
+
shell_results.stdout.split(/\n/).grep(/inet /)[0].strip.split(/ /)[1]
|
14
59
|
end
|
15
60
|
|
16
61
|
end
|
@@ -4,7 +4,7 @@ module Veewee
|
|
4
4
|
module BoxCommand
|
5
5
|
|
6
6
|
def vnc_port
|
7
|
-
lines=File.readlines(
|
7
|
+
lines=File.readlines(vmx_file_path)
|
8
8
|
matches=lines.grep(/^RemoteDisplay.vnc.port/)
|
9
9
|
if matches.length==0
|
10
10
|
raise Veewee::Error,"No VNC port found, maybe it is not enabled?"
|
@@ -42,7 +42,7 @@ module Veewee
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def vnc_enabled?
|
45
|
-
lines=File.readlines(
|
45
|
+
lines=File.readlines(vmx_file_path)
|
46
46
|
matches=lines.grep(/^RemoteDisplay.vnc.enabled/)
|
47
47
|
if matches.length==0
|
48
48
|
return false
|
@@ -33,23 +33,15 @@ module Veewee
|
|
33
33
|
def initialize(name,env)
|
34
34
|
|
35
35
|
require 'fission'
|
36
|
-
|
37
36
|
super(name,env)
|
38
37
|
end
|
39
38
|
|
40
|
-
def
|
41
|
-
return
|
39
|
+
def vmrun_cmd
|
40
|
+
return ::Fission.config['vmrun_bin']
|
42
41
|
end
|
43
42
|
|
44
43
|
def vm_path
|
45
|
-
|
46
|
-
dir="#{home}/Documents/Virtual Machines.localized/#{name}.vmwarevm"
|
47
|
-
return dir
|
48
|
-
end
|
49
|
-
|
50
|
-
def fusion_path
|
51
|
-
dir="/Library/Application Support/VMware Fusion/"
|
52
|
-
return dir
|
44
|
+
return File.join(::Fission.config['vm_dir'], "#{name}.vmwarevm")
|
53
45
|
end
|
54
46
|
|
55
47
|
def vmx_file_path
|
@@ -8,8 +8,21 @@ module Veewee
|
|
8
8
|
#include ::Veewee::Provider::Vmfusion::ProviderCommand
|
9
9
|
|
10
10
|
def check_requirements
|
11
|
-
|
12
|
-
|
11
|
+
fusion_version = :unknown
|
12
|
+
|
13
|
+
require 'fission'
|
14
|
+
if File.exists?("/Library/Application Support/VMware Fusion/vmrun")
|
15
|
+
fusion_version = "3.x"
|
16
|
+
::Fission.config.attributes["vmrun_bin"] = "/Library/Application Support/VMware Fusion/vmrun"
|
17
|
+
end
|
18
|
+
|
19
|
+
if File.exists?("/Applications/VMware Fusion.app/Contents/Library/vmrun")
|
20
|
+
fusion_version = "4.x"
|
21
|
+
::Fission.config.attributes["vmrun_bin"] = "/Applications/VMware Fusion.app/Contents/Library/vmrun"
|
22
|
+
end
|
23
|
+
|
24
|
+
if fusion_version == :unknown
|
25
|
+
raise Veewee::Error,"Could not find vmrun at standard locations. Probably you don't have Vmware fusion installed"
|
13
26
|
end
|
14
27
|
end
|
15
28
|
|
data/lib/veewee/templates.rb
CHANGED
data/lib/veewee/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Base install
|
2
|
+
|
3
|
+
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
4
|
+
|
5
|
+
cat > /etc/yum.repos.d/epel.repo << EOM
|
6
|
+
[epel]
|
7
|
+
name=epel
|
8
|
+
baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
|
9
|
+
enabled=1
|
10
|
+
gpgcheck=0
|
11
|
+
EOM
|
12
|
+
|
13
|
+
yum -y install gcc make gcc-c++ kernel-devel-`uname -r` zlib-devel openssl-devel readline-devel sqlite-devel perl wget
|
14
|
+
|