veewee 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/Rakefile +23 -23
- data/bin/veewee +1 -1
- data/doc/kvm.md +58 -9
- data/doc/providers.md +2 -2
- data/doc/vagrant.md +1 -1
- data/lib/vagrant_init.rb +0 -1
- data/lib/veewee/cli.rb +1 -1
- data/lib/veewee/command.rb +2 -2
- data/lib/veewee/command/fusion.rb +2 -2
- data/lib/veewee/command/kvm.rb +1 -1
- data/lib/veewee/command/parallels.rb +2 -2
- data/lib/veewee/command/vagrant/define.rb +1 -1
- data/lib/veewee/command/vagrant/undefine.rb +1 -1
- data/lib/veewee/command/vbox.rb +2 -2
- data/lib/veewee/config.rb +8 -10
- data/lib/veewee/definition.rb +41 -41
- data/lib/veewee/definitions.rb +27 -30
- data/lib/veewee/environment.rb +16 -16
- data/lib/veewee/error.rb +18 -15
- data/lib/veewee/provider/core/box/build.rb +1 -1
- data/lib/veewee/provider/kvm/box.rb +1 -6
- data/lib/veewee/provider/kvm/box/validate_kvm.rb +1 -1
- data/lib/veewee/provider/kvm/provider.rb +19 -32
- data/lib/veewee/provider/virtualbox/box/helper/create.rb +5 -1
- data/lib/veewee/providers.rb +22 -21
- data/lib/veewee/template.rb +9 -9
- data/lib/veewee/templates.rb +14 -15
- data/lib/veewee/ui.rb +7 -7
- data/lib/veewee/version.rb +1 -1
- data/templates/CentOS-6.3-i386-minimal/base.sh +1 -1
- data/templates/CentOS-6.3-i386-minimal/definition.rb +13 -4
- data/templates/CentOS-6.3-i386-minimal/ks.cfg +50 -14
- data/templates/CentOS-6.3-i386-minimal/virtualbox.sh +3 -3
- data/templates/CentOS-6.3-x86_64-minimal/base.sh +1 -1
- data/templates/CentOS-6.3-x86_64-netboot/base.sh +14 -0
- data/templates/CentOS-6.3-x86_64-netboot/chef.sh +3 -0
- data/templates/CentOS-6.3-x86_64-netboot/cleanup.sh +5 -0
- data/templates/CentOS-6.3-x86_64-netboot/definition.rb +40 -0
- data/templates/CentOS-6.3-x86_64-netboot/ks.cfg +41 -0
- data/templates/CentOS-6.3-x86_64-netboot/puppet.sh +12 -0
- data/templates/CentOS-6.3-x86_64-netboot/ruby.sh +3 -0
- data/templates/CentOS-6.3-x86_64-netboot/vagrant.sh +18 -0
- data/templates/CentOS-6.3-x86_64-netboot/virtualbox.sh +8 -0
- data/templates/{Debian-7.0-b2-i386-netboot → CentOS-6.3-x86_64-netboot}/zerodisk.sh +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/base.sh +2 -3
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/chef.sh +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/cleanup-virtualbox.sh +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/cleanup.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-amd64-netboot}/definition.rb +3 -3
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-amd64-netboot}/preseed.cfg +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/puppet.sh +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/ruby.sh +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/vagrant.sh +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-amd64-netboot}/virtualbox.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-amd64-netboot}/zerodisk.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/base.sh +2 -3
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/chef.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/cleanup-virtualbox.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/cleanup.sh +0 -0
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-i386-netboot}/definition.rb +3 -3
- data/templates/{Debian-7.0-b2-i386-netboot → Debian-7.0-b4-i386-netboot}/preseed.cfg +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/puppet.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/ruby.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/vagrant.sh +0 -0
- data/templates/{Debian-7.0-b3-amd64-netboot → Debian-7.0-b4-i386-netboot}/virtualbox.sh +0 -0
- data/templates/Debian-7.0-b4-i386-netboot/zerodisk.sh +3 -0
- data/templates/Fedora-18-i386/definition.rb +6 -6
- data/templates/Fedora-18-i386/postinstall.sh +3 -1
- data/templates/Fedora-18-x86_64/definition.rb +5 -5
- data/templates/Fedora-18-x86_64/postinstall.sh +6 -1
- data/templates/ubuntu-12.04.1-server-amd64-packages/postinstall.sh +4 -5
- data/templates/ubuntu-12.04.1-server-amd64/postinstall.sh +4 -5
- data/templates/ubuntu-8.04.4-server-amd64/postinstall.sh +6 -6
- data/templates/ubuntu-8.04.4-server-i386/postinstall.sh +6 -6
- data/templates/windows-8-amd64/Autounattend.xml +140 -0
- data/templates/windows-8-amd64/README.md +134 -0
- data/templates/windows-8-amd64/cygwin-setup.exe +0 -0
- data/templates/windows-8-amd64/definition.rb +101 -0
- data/templates/windows-8-amd64/install-cygwin-sshd.bat +38 -0
- data/templates/windows-8-amd64/install-winrm.bat +11 -0
- data/templates/windows-8-amd64/oracle-cert.cer +0 -0
- data/templates/windows-8-amd64/postinstall.sh +122 -0
- data/templates/windows-8-amd64/winrm.rb +8 -0
- data/templates/windows-8-i386/Autounattend.xml +140 -0
- data/templates/windows-8-i386/README.md +134 -0
- data/templates/windows-8-i386/cygwin-setup.exe +0 -0
- data/templates/windows-8-i386/definition.rb +101 -0
- data/templates/windows-8-i386/install-cygwin-sshd.bat +38 -0
- data/templates/windows-8-i386/install-winrm.bat +11 -0
- data/templates/windows-8-i386/oracle-cert.cer +0 -0
- data/templates/windows-8-i386/postinstall.sh +122 -0
- data/templates/windows-8-i386/winrm.rb +8 -0
- data/test/build_realtest.rb +4 -4
- data/veewee.gemspec +8 -9
- metadata +55 -27
data/lib/veewee/definitions.rb
CHANGED
|
@@ -9,13 +9,13 @@ module Veewee
|
|
|
9
9
|
attr_accessor :env
|
|
10
10
|
|
|
11
11
|
def initialize(env)
|
|
12
|
-
@env=env
|
|
12
|
+
@env = env
|
|
13
13
|
return self
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def [](name)
|
|
17
17
|
begin
|
|
18
|
-
definition=Veewee::Definition.load(name,env)
|
|
18
|
+
definition = Veewee::Definition.load(name, env)
|
|
19
19
|
return definition
|
|
20
20
|
rescue Veewee::DefinitionNotExist
|
|
21
21
|
return nil
|
|
@@ -24,22 +24,22 @@ module Veewee
|
|
|
24
24
|
|
|
25
25
|
# Fetch all definitions
|
|
26
26
|
def each(&block)
|
|
27
|
-
definitions=Hash.new
|
|
27
|
+
definitions = Hash.new
|
|
28
28
|
|
|
29
29
|
env.logger.debug("[Definition] Searching #{env.definition_dir} for definitions:")
|
|
30
|
-
subdirs=Dir.glob("#{env.definition_dir}/*")
|
|
30
|
+
subdirs = Dir.glob("#{env.definition_dir}/*")
|
|
31
31
|
|
|
32
32
|
subdirs.each do |sub|
|
|
33
|
-
name=File.basename(sub)
|
|
33
|
+
name = File.basename(sub)
|
|
34
34
|
env.logger.debug("[Definition] possible definition '#{name}' found")
|
|
35
35
|
begin
|
|
36
|
-
definitions[name]=Veewee::Definition.load(name,env)
|
|
36
|
+
definitions[name] = Veewee::Definition.load(name, env)
|
|
37
37
|
rescue Veewee::DefinitionError => ex
|
|
38
38
|
env.logger.debug("[Definition] failed to load definition from directory '#{name}' #{ex}")
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
if definitions.length==0
|
|
42
|
+
if definitions.length == 0
|
|
43
43
|
env.logger.debug("[Definition] no definitions found")
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -53,23 +53,21 @@ module Veewee
|
|
|
53
53
|
# Options are : :force => true to overwrite an existing definition
|
|
54
54
|
#
|
|
55
55
|
# Returns definition object
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def define(definition_name,template_name,options = {})
|
|
56
|
+
def define(definition_name, template_name, options = {})
|
|
59
57
|
|
|
60
58
|
# Default is not to overwrite
|
|
61
|
-
options = {'force' => false}.merge(options)
|
|
59
|
+
options = { 'force' => false }.merge(options)
|
|
62
60
|
|
|
63
61
|
env.logger.debug("Forceflag : #{options['force']}")
|
|
64
62
|
|
|
65
|
-
git_template=false
|
|
63
|
+
git_template = false
|
|
66
64
|
# Check if the template is a git repo
|
|
67
65
|
if template_name.start_with?("git://")
|
|
68
|
-
git_template=true
|
|
66
|
+
git_template = true
|
|
69
67
|
end
|
|
70
68
|
|
|
71
69
|
# Check if template exists
|
|
72
|
-
template=env.templates[template_name]
|
|
70
|
+
template = env.templates[template_name]
|
|
73
71
|
if template.nil? and ! git_template
|
|
74
72
|
env.logger.fatal("Template '#{template_name}' does not exist")
|
|
75
73
|
raise Veewee::TemplateError, "Template '#{template_name}' does not exist"
|
|
@@ -80,20 +78,20 @@ module Veewee
|
|
|
80
78
|
create_definition_dir_if_needed
|
|
81
79
|
|
|
82
80
|
# Check if definition does not exist
|
|
83
|
-
definition=env.definitions[definition_name]
|
|
81
|
+
definition = env.definitions[definition_name]
|
|
84
82
|
unless definition.nil?
|
|
85
83
|
env.logger.debug("Definition '#{definition_name}' exists")
|
|
86
|
-
if options['force']==true
|
|
87
|
-
self.undefine(definition_name,options)
|
|
84
|
+
if options['force'] == true
|
|
85
|
+
self.undefine(definition_name, options)
|
|
88
86
|
else
|
|
89
|
-
|
|
87
|
+
raise Veewee::DefinitionError, "Definition #{definition_name} already exists and no force option was given"
|
|
90
88
|
end
|
|
91
89
|
end
|
|
92
90
|
|
|
93
91
|
env.logger.info("Creating definition #{definition_name} in directory '#{env.definition_dir}' ")
|
|
94
|
-
dst_dir="#{File.join(env.definition_dir,definition_name)}"
|
|
92
|
+
dst_dir = "#{File.join(env.definition_dir, definition_name)}"
|
|
95
93
|
FileUtils.mkdir(dst_dir)
|
|
96
|
-
env.logger.debug("Definition Directory '#{File.join(env.definition_dir,definition_name)}' succesfuly created")
|
|
94
|
+
env.logger.debug("Definition Directory '#{File.join(env.definition_dir, definition_name)}' succesfuly created")
|
|
97
95
|
|
|
98
96
|
# Start copying/cloning the directory of the template to the definition directory
|
|
99
97
|
if (git_template)
|
|
@@ -109,33 +107,33 @@ module Veewee
|
|
|
109
107
|
else
|
|
110
108
|
begin
|
|
111
109
|
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}'
|
|
110
|
+
FileUtils.cp_r(template.path + "/.", dst_dir)
|
|
111
|
+
env.logger.debug("Copy '#{template.path}' to '#{dst_dir}' succesful")
|
|
114
112
|
rescue Exception => ex
|
|
115
113
|
env.logger.fatal("Copy '#{template.path}' to #{dst_dir}' failed: #{ex}")
|
|
116
|
-
raise Veewee::Error
|
|
114
|
+
raise Veewee::Error, "Copy '#{template.path}' to #{dst_dir}' failed: #{ex}"
|
|
117
115
|
end
|
|
118
116
|
end
|
|
119
117
|
|
|
120
|
-
definition=env.definitions[definition_name]
|
|
118
|
+
definition = env.definitions[definition_name]
|
|
121
119
|
return definition
|
|
122
120
|
end
|
|
123
121
|
|
|
124
122
|
|
|
125
123
|
# This function undefines/removes the definition by removing the directoy with definition_name
|
|
126
124
|
# under env.definition_dir
|
|
127
|
-
def undefine(definition_name,options = {})
|
|
128
|
-
definition=env.definitions[definition_name]
|
|
125
|
+
def undefine(definition_name, options = {})
|
|
126
|
+
definition = env.definitions[definition_name]
|
|
129
127
|
unless definition.nil?
|
|
130
128
|
|
|
131
129
|
#TODO: Needs to be more defensive!!
|
|
132
130
|
env.logger.debug("[Undefine] About to remove '#{definition.path} for '#{definition_name}'")
|
|
133
131
|
begin
|
|
134
|
-
if File.exists?(File.join(definition.path,"definition.rb"))
|
|
132
|
+
if File.exists?(File.join(definition.path, "definition.rb"))
|
|
135
133
|
FileUtils.rm_rf(definition.path)
|
|
136
134
|
else
|
|
137
135
|
env.logger.fatal("Aborting delete: The directory definition.path does not contain a definition.rb file")
|
|
138
|
-
raise Veewee::DefinitionError,"Aborting delete: The directory definition.path does not contain a definition.rb file"
|
|
136
|
+
raise Veewee::DefinitionError, "Aborting delete: The directory definition.path does not contain a definition.rb file"
|
|
139
137
|
end
|
|
140
138
|
rescue Exception => ex
|
|
141
139
|
env.logger.fatal("Removing '#{definition.path} for '#{definition_name}' failed: #{ex}")
|
|
@@ -143,7 +141,7 @@ module Veewee
|
|
|
143
141
|
end
|
|
144
142
|
env.logger.debug("Removing '#{definition.path} for '#{definition_name}' succesful")
|
|
145
143
|
else
|
|
146
|
-
raise Veewee::DefinitionError,"Definition '#{definition_name}' does not exist"
|
|
144
|
+
raise Veewee::DefinitionError, "Definition '#{definition_name}' does not exist"
|
|
147
145
|
end
|
|
148
146
|
end
|
|
149
147
|
|
|
@@ -170,6 +168,5 @@ module Veewee
|
|
|
170
168
|
end
|
|
171
169
|
end
|
|
172
170
|
|
|
173
|
-
|
|
174
171
|
end
|
|
175
172
|
end
|
data/lib/veewee/environment.rb
CHANGED
|
@@ -51,25 +51,25 @@ module Veewee
|
|
|
51
51
|
# Hash elelement of all OStypes
|
|
52
52
|
attr_reader :ostypes
|
|
53
53
|
|
|
54
|
-
def initialize(options={})
|
|
54
|
+
def initialize(options = {})
|
|
55
55
|
|
|
56
56
|
cwd = ENV['VEEWEE_DIR'] || Dir.pwd
|
|
57
57
|
# If a cwd was provided as option it overrules the default
|
|
58
58
|
cwd = options[:cwd] if options.has_key?(:cwd)
|
|
59
59
|
|
|
60
|
-
defaults={
|
|
60
|
+
defaults = {
|
|
61
61
|
:cwd => cwd,
|
|
62
62
|
:veewee_filename => "Veeweefile",
|
|
63
63
|
:loglevel => :info,
|
|
64
|
-
:definition_dir => File.join(cwd,"definitions"),
|
|
65
|
-
:template_path => [File.expand_path(File.join(File.dirname(__FILE__),"..","..",'templates')),"templates"],
|
|
66
|
-
:iso_dir => File.join(cwd,"iso"),
|
|
67
|
-
:validation_dir => File.join(File.expand_path(File.join(File.dirname(__FILE__),"..","..")),"validation"),
|
|
68
|
-
:tmp_dir => File.join(cwd,"tmp")
|
|
64
|
+
:definition_dir => File.join(cwd, "definitions"),
|
|
65
|
+
:template_path => [File.expand_path(File.join(File.dirname(__FILE__), "..", "..", 'templates')), "templates"],
|
|
66
|
+
:iso_dir => File.join(cwd, "iso"),
|
|
67
|
+
:validation_dir => File.join(File.expand_path(File.join(File.dirname(__FILE__), "..", "..")), "validation"),
|
|
68
|
+
:tmp_dir => File.join(cwd, "tmp")
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
options = defaults.merge(options)
|
|
72
|
-
veeweefile_config = defaults.keys.inject({}) do |memo,obj|
|
|
72
|
+
veeweefile_config = defaults.keys.inject({}) do |memo, obj|
|
|
73
73
|
if config.env.methods.include?(obj) && !config.env.send(obj).nil?
|
|
74
74
|
memo.merge({ obj => config.env.send(obj) })
|
|
75
75
|
else
|
|
@@ -81,7 +81,7 @@ module Veewee
|
|
|
81
81
|
# We need to set this variable before the first call to the logger object
|
|
82
82
|
if options.has_key?("debug")
|
|
83
83
|
if options["debug"] == true
|
|
84
|
-
ENV['VEEWEE_LOG']="STDOUT"
|
|
84
|
+
ENV['VEEWEE_LOG'] = "STDOUT"
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -94,14 +94,14 @@ module Veewee
|
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
# Definitions
|
|
97
|
-
@definitions=Veewee::Definitions.new(self)
|
|
98
|
-
@templates=Veewee::Templates.new(self)
|
|
99
|
-
@providers=Veewee::Providers.new(self)
|
|
97
|
+
@definitions = Veewee::Definitions.new(self)
|
|
98
|
+
@templates = Veewee::Templates.new(self)
|
|
99
|
+
@providers = Veewee::Providers.new(self, options)
|
|
100
100
|
|
|
101
101
|
# Read ostypes
|
|
102
|
-
yamlfile=File.join(File.dirname(__FILE__),"config","ostypes.yml")
|
|
102
|
+
yamlfile = File.join(File.dirname(__FILE__), "config", "ostypes.yml")
|
|
103
103
|
logger.info "Reading ostype yamlfile #{yamlfile}"
|
|
104
|
-
@ostypes=YAML.load_file(yamlfile)
|
|
104
|
+
@ostypes = YAML.load_file(yamlfile)
|
|
105
105
|
|
|
106
106
|
return self
|
|
107
107
|
end
|
|
@@ -125,7 +125,7 @@ module Veewee
|
|
|
125
125
|
#
|
|
126
126
|
# @return [UI]
|
|
127
127
|
def ui
|
|
128
|
-
@ui ||=
|
|
128
|
+
@ui ||= UI.new(self)
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
#---------------------------------------------------------------
|
|
@@ -155,7 +155,7 @@ module Veewee
|
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
def load_config!
|
|
158
|
-
@config=Config.new({:env => self}).load_veewee_config()
|
|
158
|
+
@config = Config.new({ :env => self }).load_veewee_config()
|
|
159
159
|
|
|
160
160
|
return self
|
|
161
161
|
end
|
data/lib/veewee/error.rb
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
module Veewee
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def initialize(msg, original=$!)
|
|
5
|
-
super(msg)
|
|
6
|
-
@original = original; end
|
|
7
|
-
end
|
|
2
|
+
class Error < StandardError
|
|
3
|
+
attr_reader :orginal
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
def initialize(msg, original = $!)
|
|
6
|
+
super(msg)
|
|
7
|
+
@original = original
|
|
10
8
|
end
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
end
|
|
10
|
+
end
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
class DefinitionError < Error
|
|
13
|
+
end
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
class DefinitionNotExist < DefinitionError
|
|
16
|
+
end
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
class TemplateError < Error
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class SshError < Error
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class WinrmError < Error
|
|
25
|
+
end
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
#Usage (from the exceptional ruby book)
|
|
@@ -86,7 +86,7 @@ module Veewee
|
|
|
86
86
|
|
|
87
87
|
self.handle_postinstall(options)
|
|
88
88
|
|
|
89
|
-
ui.success "The box #{name} was build
|
|
89
|
+
ui.success "The box #{name} was build successfully!"
|
|
90
90
|
ui.info "You can now login to the box with:"
|
|
91
91
|
if (definition.winrm_user && definition.winrm_password)
|
|
92
92
|
env.ui.info winrm_command_string
|
|
@@ -29,14 +29,9 @@ module Veewee
|
|
|
29
29
|
|
|
30
30
|
def initialize(name,env)
|
|
31
31
|
|
|
32
|
-
require 'libvirt'
|
|
33
|
-
require 'fog'
|
|
34
|
-
|
|
35
32
|
super(name,env)
|
|
36
33
|
|
|
37
|
-
@connection=::Fog::Compute
|
|
38
|
-
:libvirt_uri => "qemu:///system",
|
|
39
|
-
:libvirt_ip_command => "arp -an |grep $mac|cut -d '(' -f 2 | cut -d ')' -f 1")
|
|
34
|
+
@connection=::Fog::Compute[:libvirt]
|
|
40
35
|
|
|
41
36
|
end
|
|
42
37
|
|
|
@@ -5,62 +5,49 @@ module Veewee
|
|
|
5
5
|
module Kvm
|
|
6
6
|
class Provider < Veewee::Provider::Core::Provider
|
|
7
7
|
|
|
8
|
-
# Translate the definition ssh options to ssh options that can be passed to Net::Ssh calls
|
|
9
|
-
# We expect plain ssh for a connection
|
|
10
|
-
|
|
11
8
|
def check_requirements
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
require 'fog'
|
|
10
|
+
|
|
11
|
+
env.logger.info "Falling back to qemu:///system for libvirt URI if no value is specified in the .fog config file"
|
|
12
|
+
Fog.credentials[:libvirt_uri] ||= "qemu:///system"
|
|
13
|
+
|
|
14
|
+
env.logger.info "Setting libvirt IP Command if not already defined in .fog config file"
|
|
15
|
+
Fog.credentials[:libvirt_ip_command] ||= "arp -an |grep $mac|cut -d '(' -f 2 | cut -d ')' -f 1"
|
|
17
16
|
|
|
18
|
-
env.logger.info "Checking for version of libvirt"
|
|
19
17
|
begin
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
conn = ::Libvirt::open("qemu:///system")
|
|
18
|
+
env.logger.info "Opening a libvirt connection using fog.io"
|
|
19
|
+
conn = Fog::Compute[:libvirt]
|
|
23
20
|
env.logger.info "Libvirt connection established"
|
|
24
21
|
|
|
25
|
-
env.logger.
|
|
26
|
-
env.logger.
|
|
22
|
+
env.logger.debug "Found capabilities:"
|
|
23
|
+
env.logger.debug "#{conn.client.capabilities}"
|
|
27
24
|
|
|
28
25
|
env.logger.info "Checking available storagepools"
|
|
29
|
-
|
|
30
|
-
env.logger.info "Storagepools: #{pools.join(',')}"
|
|
31
|
-
if pools.count < 1
|
|
32
|
-
raise Veewee::Error,"You need at least one (active) storage pool defined. This needs to be available if you connect to qemu:///system"
|
|
33
|
-
end
|
|
26
|
+
conn.pools.any? or raise Veewee::Error, "You need at least one (active) storage pool defined in #{Fog.credentials[:libvirt_uri]}."
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#env.logger.info "Networks: #{networks.join(',')}"
|
|
38
|
-
#if networks.count < 1
|
|
39
|
-
# raise Veewee::Error,"You need at least one (active) network defined. This needs to be available if you connect to qemu:///system"
|
|
40
|
-
#end
|
|
28
|
+
env.logger.info "Checking available networks"
|
|
29
|
+
conn.networks.any? or raise Veewee::Error,"You need at least one (active) network defined. This needs to be available if you connect to qemu:///system"
|
|
41
30
|
|
|
42
31
|
# http://www.libvirt.org/html/libvirt-libvirt.html#virGetVersion
|
|
43
32
|
# format major * 1,000,000 + minor * 1,000 + release
|
|
44
33
|
env.logger.info "Checking libvirt version"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
raise Veewee::Error,"You need at least libvirt version 0.8.3 or higher "
|
|
34
|
+
if conn.client.libversion < 8003
|
|
35
|
+
raise Veewee::Error, "You need at least libvirt version 0.8.3 or higher "
|
|
48
36
|
end
|
|
49
|
-
conn.close
|
|
50
37
|
rescue Exception => ex
|
|
51
38
|
raise Veewee::Error, "There was a problem opening a connection to libvirt: #{ex}"
|
|
52
39
|
end
|
|
53
40
|
|
|
54
41
|
unless self.shell_exec("arp").status == 0
|
|
55
|
-
raise Veewee::Error,"Could not execute the arp command. This is required to find the IP address of the VM"
|
|
42
|
+
raise Veewee::Error, "Could not execute the arp command. This is required to find the IP address of the VM"
|
|
56
43
|
end
|
|
57
44
|
|
|
58
45
|
end
|
|
59
46
|
|
|
60
47
|
|
|
61
|
-
def build(definition_name,box_name,options)
|
|
48
|
+
def build(definition_name, box_name, options)
|
|
62
49
|
|
|
63
|
-
super(definition_name,box_name,options)
|
|
50
|
+
super(definition_name, box_name, options)
|
|
64
51
|
|
|
65
52
|
end
|
|
66
53
|
|
|
@@ -35,7 +35,7 @@ module Veewee
|
|
|
35
35
|
|
|
36
36
|
unless definition.nil?
|
|
37
37
|
#Map SSH Ports
|
|
38
|
-
command="#{@vboxcmd} modifyvm
|
|
38
|
+
command="#{@vboxcmd} modifyvm \"#{name}\" --natpf1 'guestwinrm,tcp,,#{definition.winrm_host_port},,#{definition.winrm_guest_port}'"
|
|
39
39
|
shell_exec("#{command}")
|
|
40
40
|
end
|
|
41
41
|
end
|
|
@@ -162,6 +162,10 @@ module Veewee
|
|
|
162
162
|
command="#{@vboxcmd} modifyvm \"#{name}\" --memory #{definition.memory_size}"
|
|
163
163
|
shell_exec("#{command}")
|
|
164
164
|
|
|
165
|
+
#setting video memory size
|
|
166
|
+
command="#{@vboxcmd} modifyvm \"#{name}\" --vram #{definition.video_memory_size}"
|
|
167
|
+
shell_exec("#{command}")
|
|
168
|
+
|
|
165
169
|
#setting bootorder
|
|
166
170
|
command="#{@vboxcmd} modifyvm \"#{name}\" --boot1 disk --boot2 dvd --boot3 none --boot4 none"
|
|
167
171
|
shell_exec("#{command}")
|
data/lib/veewee/providers.rb
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
module Veewee
|
|
2
|
+
class Providers
|
|
3
|
+
def initialize(env, options = {})
|
|
4
|
+
@env = env
|
|
5
|
+
@options = options
|
|
6
|
+
@providers = Hash.new
|
|
7
|
+
end
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@env=env
|
|
6
|
-
@providers=Hash.new
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def [](name)
|
|
10
|
-
return @providers[name] if @providers.has_key?(name)
|
|
9
|
+
def [](name)
|
|
10
|
+
return @providers[name] if @providers.has_key?(name)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
begin
|
|
13
|
+
require_path = 'veewee/provider/' + name.to_s.downcase + "/provider"
|
|
14
|
+
require require_path
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
provider = Object.const_get("Veewee").const_get("Provider").const_get(name.to_s.capitalize).const_get("Provider").new(name, @options, @env)
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
end
|
|
18
|
+
@providers[name] = provider
|
|
19
|
+
rescue ::Veewee::Error => e
|
|
20
|
+
raise
|
|
21
|
+
rescue Error => e
|
|
22
|
+
env.ui.error "Error loading provider with #{name}, #{$!}", :prefix => false
|
|
24
23
|
end
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def length
|
|
28
|
+
@providers.length
|
|
29
|
+
end
|
|
29
30
|
|
|
30
31
|
end
|
|
31
32
|
end #Module Veewee
|