omf_rc 6.0.0.pre.7 → 6.0.0.pre.8
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/bin/omf_rc +13 -1
- data/lib/omf_rc/resource_proxy/abstract_resource.rb +76 -35
- data/lib/omf_rc/resource_proxy/application.rb +82 -61
- data/lib/omf_rc/resource_proxy/net.rb +1 -0
- data/lib/omf_rc/resource_proxy/node.rb +1 -31
- data/lib/omf_rc/resource_proxy/virtual_machine.rb +388 -0
- data/lib/omf_rc/resource_proxy/virtual_machine_factory.rb +52 -0
- data/lib/omf_rc/resource_proxy/wlan.rb +1 -0
- data/lib/omf_rc/resource_proxy_dsl.rb +1 -1
- data/lib/omf_rc/util/ip.rb +8 -0
- data/lib/omf_rc/util/iw.rb +2 -0
- data/lib/omf_rc/util/libvirt.rb +118 -0
- data/lib/omf_rc/util/sysfs.rb +40 -0
- data/lib/omf_rc/util/vmbuilder.rb +181 -0
- data/lib/omf_rc/version.rb +1 -1
- data/test/omf_rc/resource_proxy/abstract_resource_spec.rb +6 -4
- data/test/omf_rc/util/ip_spec.rb +3 -1
- metadata +47 -39
@@ -0,0 +1,181 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2012 National ICT Australia (NICTA), Australia
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
#
|
23
|
+
# This module defines the command specifics to build a VM image using
|
24
|
+
# the vmbuilder tool
|
25
|
+
#
|
26
|
+
# Utility dependencies: common_tools
|
27
|
+
#
|
28
|
+
# @see OmfRc::ResourceProxy::VirtualMachine
|
29
|
+
#
|
30
|
+
module OmfRc::Util::Vmbuilder
|
31
|
+
include OmfRc::ResourceProxyDSL
|
32
|
+
|
33
|
+
VMBUILDER = "/usr/bin/vmbuilder"
|
34
|
+
|
35
|
+
VMBUILDER_DEFAULT = Hashie::Mash.new({
|
36
|
+
cpus: 1, mem: 512,
|
37
|
+
rootsize: 20000, overwrite: true,
|
38
|
+
ip: nil, mask: nil, net: nil, bcast: nil,
|
39
|
+
gw: nil, dns: nil
|
40
|
+
})
|
41
|
+
|
42
|
+
UBUNTU_DEFAULT = Hashie::Mash.new({
|
43
|
+
suite: 'natty', arch: 'i386',
|
44
|
+
user: 'administrator', pass: 'omf',
|
45
|
+
mirror: 'http://10.0.0.200:9999/ubuntu',
|
46
|
+
#mirror: 'http://au.archive.ubuntu.com/ubuntu/',
|
47
|
+
bridge: nil,
|
48
|
+
#variant: 'minbase',
|
49
|
+
#pkg: ['openssh-server']
|
50
|
+
#pkg: ['openssh-server','sudo','inetutils-ping','host',
|
51
|
+
# 'net-tools','vim','gpgv']
|
52
|
+
pkg: ['openssh-server','sudo','inetutils-ping','host',
|
53
|
+
'net-tools','vim','gpgv',
|
54
|
+
'build-essential','automake', 'curl',
|
55
|
+
'zlib1g-dev','libxslt-dev','libxml2-dev',
|
56
|
+
'libssl-dev','iw']
|
57
|
+
})
|
58
|
+
|
59
|
+
property :vmbuilder_opts, :default => VMBUILDER_DEFAULT
|
60
|
+
property :ubuntu_opts, :default => UBUNTU_DEFAULT
|
61
|
+
|
62
|
+
%w(vmbuilder ubuntu).each do |prefix|
|
63
|
+
prop = "#{prefix}_opts"
|
64
|
+
configure(prop) do |res, opts|
|
65
|
+
if opts.kind_of? Hash
|
66
|
+
if res.property[prop].empty?
|
67
|
+
res.property[prop] = res.send("#{prefix}_DEFAULT").merge(opts)
|
68
|
+
else
|
69
|
+
res.property[prop] = res.property[prop].merge(opts)
|
70
|
+
end
|
71
|
+
else
|
72
|
+
res.log_inform_error "#{prefix} option configuration failed! "+
|
73
|
+
"Options not passed as Hash (#{opts.inspect})"
|
74
|
+
end
|
75
|
+
res.property[prop]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
%w(vmbuilder ubuntu).each do |prefix|
|
80
|
+
prop = "#{prefix}_opts"
|
81
|
+
request(prop) do |res, opts|
|
82
|
+
if res.property[prop].empty?
|
83
|
+
res.property[prop] = res.send("#{prefix}_DEFAULT")
|
84
|
+
else
|
85
|
+
res.property[prop]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
work :build_img_with_vmbuilder do |res|
|
91
|
+
# Construct the vmbuilder command
|
92
|
+
`mkdir -p #{res.property.image_path}`
|
93
|
+
if $?.exitstatus != 0
|
94
|
+
msg = "Cannot create VM directory at #{res.property.image_path}"
|
95
|
+
res.log_inform_error msg
|
96
|
+
cmd = msg
|
97
|
+
else
|
98
|
+
cmd = "cd #{res.property.image_path} ; "
|
99
|
+
cmd += res.property.use_sudo ? "sudo " : ""
|
100
|
+
cmd += "#{VMBUILDER} #{res.property.hypervisor} #{res.property.vm_os} "+
|
101
|
+
"--libvirt #{res.property.hypervisor_uri} "+
|
102
|
+
"--hostname #{res.property.vm_name} "
|
103
|
+
# Add vmbuilder options
|
104
|
+
res.property.vmbuilder_opts.each do |k,v|
|
105
|
+
if k.to_sym == :overwrite
|
106
|
+
cmd += "-o " if v
|
107
|
+
else
|
108
|
+
cmd += "--#{k.to_s} #{v} " unless v.nil?
|
109
|
+
end
|
110
|
+
end
|
111
|
+
# Add OS-specific options, eg. call 'vmbuilder_ubuntu_opts' if OS is ubuntu
|
112
|
+
cmd = res.send("build_img_with_#{res.property.vm_os}", cmd)
|
113
|
+
# Add first boot script
|
114
|
+
firstboot = "#{res.property.image_path}/firstboot.sh"
|
115
|
+
res.send("build_firstboot_for_#{res.property.vm_os}", firstboot)
|
116
|
+
# Return the fully constructed command line
|
117
|
+
cmd += "--firstboot #{firstboot}"
|
118
|
+
end
|
119
|
+
logger.info "Building VM with: '#{cmd}'"
|
120
|
+
result = `#{cmd} 2>&1`
|
121
|
+
if $?.exitstatus != 0
|
122
|
+
res.log_inform_error "Cannot build VM image: '#{result}'"
|
123
|
+
false
|
124
|
+
else
|
125
|
+
logger.info "VM image built successfully!"
|
126
|
+
true
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
work :build_img_with_ubuntu do |res,cmd|
|
131
|
+
res.property.ubuntu_opts.each do |k,v|
|
132
|
+
if k.to_sym == :pkg
|
133
|
+
v.each { |p| cmd += "--addpkg #{p} "} if v.length > 0
|
134
|
+
else
|
135
|
+
cmd += "--#{k.to_s} #{v} " unless v.nil?
|
136
|
+
end
|
137
|
+
end
|
138
|
+
cmd
|
139
|
+
end
|
140
|
+
|
141
|
+
work :build_firstboot_for_ubuntu do |res,file|
|
142
|
+
f = File.open(file,'w')
|
143
|
+
f << <<-eos
|
144
|
+
#!/bin/bash
|
145
|
+
# Fix DNS setting
|
146
|
+
echo 'nameserver #{res.property.vmbuilder_opts.dns}' >> /etc/resolv.conf
|
147
|
+
# Regenerate SSH key for each image instance
|
148
|
+
rm /etc/ssh/ssh_host*key*
|
149
|
+
dpkg-reconfigure -fnoninteractive -pcritical openssh-server
|
150
|
+
eos
|
151
|
+
# Add OMF install to that first boot script
|
152
|
+
if res.property.enable_omf
|
153
|
+
u = res.property.omf_opts.user.nil? ? \
|
154
|
+
"#{res.property.vm_name}" : res.property.omf_opts.user
|
155
|
+
p = res.property.omf_opts.password.nil? ? \
|
156
|
+
"123456" : res.property.omf_opts.password
|
157
|
+
t = res.property.omf_opts.topic.nil? ? \
|
158
|
+
"#{res.property.vm_name}_node" : res.property.omf_opts.topic
|
159
|
+
f << <<-eos
|
160
|
+
# Install OMF 6 RC
|
161
|
+
curl -L https://get.rvm.io | bash -s stable
|
162
|
+
source /usr/local/rvm/scripts/rvm
|
163
|
+
command rvm install 1.9.3
|
164
|
+
PATH=$PATH:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/
|
165
|
+
source /usr/local/rvm/environments/ruby-1.9.3-p194
|
166
|
+
gem install omf_rc --pre --no-ri --no-rdoc
|
167
|
+
# HACK
|
168
|
+
# Right now we dont have a Ubuntu startup script for OMF6 RC
|
169
|
+
# Do this quick hack in the meantime
|
170
|
+
echo '#!/bin/bash' >>/etc/rc2.d/S99omf_rc
|
171
|
+
echo 'source /etc/profile.d/rvm.sh' >>/etc/rc2.d/S99omf_rc
|
172
|
+
echo 'source /usr/local/rvm/environments/ruby-1.9.3-p194' >>/etc/rc2.d/S99omf_rc
|
173
|
+
echo 'nohup omf_rc -u #{u} -p #{p} -t #{t} -s #{res.property.omf_opts.server} &>>/tmp/omf_rc.log &' >>/etc/rc2.d/S99omf_rc
|
174
|
+
chmod 555 /etc/rc2.d/S99omf_rc
|
175
|
+
/etc/rc2.d/S99omf_rc
|
176
|
+
eos
|
177
|
+
end
|
178
|
+
f.close
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
data/lib/omf_rc/version.rb
CHANGED
@@ -64,10 +64,12 @@ describe AbstractResource do
|
|
64
64
|
|
65
65
|
describe "when destroyed" do
|
66
66
|
it "must destroy itself together with any resources created by it" do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
@node.comm.stub :delete_topic, nil do
|
68
|
+
child = @node.create(:wifi, { hrn: 'default_wifi' })
|
69
|
+
@node.children.wont_be_empty
|
70
|
+
@node.release(child.uid)
|
71
|
+
@node.children.must_be_empty
|
72
|
+
end
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
data/test/omf_rc/util/ip_spec.rb
CHANGED
@@ -41,7 +41,9 @@ describe OmfRc::Util::Ip do
|
|
41
41
|
it "could configure the device's prorperty" do
|
42
42
|
lambda { @wlan00.configure_ip_addr("192.168.1.124/24") }.must_raise Cocaine::ExitStatusError
|
43
43
|
Cocaine::CommandLine.stub(:new, @command) do
|
44
|
-
|
44
|
+
3.times do
|
45
|
+
@command.expect(:run, "")
|
46
|
+
end
|
45
47
|
@command.expect(:run, fixture("ip/addr_show"))
|
46
48
|
@wlan00.configure_ip_addr("192.168.1.124/24")
|
47
49
|
@command.verify
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_rc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.pre.
|
4
|
+
version: 6.0.0.pre.8
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70355490301900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.2'
|
24
|
+
version_requirements: *70355490301900
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: em-minitest-spec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70355490301000 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ~>
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: 1.1.1
|
38
33
|
type: :development
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.1.1
|
35
|
+
version_requirements: *70355490301000
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: simplecov
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70355490299940 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ! '>='
|
@@ -53,15 +43,10 @@ dependencies:
|
|
53
43
|
version: '0'
|
54
44
|
type: :development
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
46
|
+
version_requirements: *70355490299940
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
48
|
name: omf_common
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &70355490298920 !ruby/object:Gem::Requirement
|
65
50
|
none: false
|
66
51
|
requirements:
|
67
52
|
- - ~>
|
@@ -69,15 +54,10 @@ dependencies:
|
|
69
54
|
version: 6.0.0.pre
|
70
55
|
type: :runtime
|
71
56
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 6.0.0.pre
|
57
|
+
version_requirements: *70355490298920
|
78
58
|
- !ruby/object:Gem::Dependency
|
79
59
|
name: cocaine
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &70355490298000 !ruby/object:Gem::Requirement
|
81
61
|
none: false
|
82
62
|
requirements:
|
83
63
|
- - ~>
|
@@ -85,12 +65,7 @@ dependencies:
|
|
85
65
|
version: 0.3.0
|
86
66
|
type: :runtime
|
87
67
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 0.3.0
|
68
|
+
version_requirements: *70355490298000
|
94
69
|
description: Resource controller of OMF, a generic framework for controlling and managing
|
95
70
|
networking testbeds.
|
96
71
|
email:
|
@@ -116,17 +91,22 @@ files:
|
|
116
91
|
- lib/omf_rc/resource_proxy/node.rb
|
117
92
|
- lib/omf_rc/resource_proxy/openflow_slice.rb
|
118
93
|
- lib/omf_rc/resource_proxy/openflow_slice_factory.rb
|
94
|
+
- lib/omf_rc/resource_proxy/virtual_machine.rb
|
95
|
+
- lib/omf_rc/resource_proxy/virtual_machine_factory.rb
|
119
96
|
- lib/omf_rc/resource_proxy/wlan.rb
|
120
97
|
- lib/omf_rc/resource_proxy_dsl.rb
|
121
98
|
- lib/omf_rc/util/common_tools.rb
|
122
99
|
- lib/omf_rc/util/hostapd.rb
|
123
100
|
- lib/omf_rc/util/ip.rb
|
124
101
|
- lib/omf_rc/util/iw.rb
|
102
|
+
- lib/omf_rc/util/libvirt.rb
|
125
103
|
- lib/omf_rc/util/mock.rb
|
126
104
|
- lib/omf_rc/util/mod.rb
|
127
105
|
- lib/omf_rc/util/openflow_tools.rb
|
128
106
|
- lib/omf_rc/util/package.rb
|
129
107
|
- lib/omf_rc/util/platform_tools.rb
|
108
|
+
- lib/omf_rc/util/sysfs.rb
|
109
|
+
- lib/omf_rc/util/vmbuilder.rb
|
130
110
|
- lib/omf_rc/util/wpa.rb
|
131
111
|
- lib/omf_rc/version.rb
|
132
112
|
- omf_rc.gemspec
|
@@ -178,8 +158,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
158
|
version: 1.3.1
|
179
159
|
requirements: []
|
180
160
|
rubyforge_project: omf_rc
|
181
|
-
rubygems_version: 1.8.
|
161
|
+
rubygems_version: 1.8.17
|
182
162
|
signing_key:
|
183
163
|
specification_version: 3
|
184
164
|
summary: OMF resource controller
|
185
|
-
test_files:
|
165
|
+
test_files:
|
166
|
+
- test/fixture/ip/addr_show
|
167
|
+
- test/fixture/iw/help
|
168
|
+
- test/fixture/iw/info
|
169
|
+
- test/fixture/iw/link
|
170
|
+
- test/fixture/lsmod
|
171
|
+
- test/fixture/oml.hash
|
172
|
+
- test/fixture/oml.spec
|
173
|
+
- test/fixture/oml.xml
|
174
|
+
- test/fixture/sys/class/ieee80211/phy0/device/uevent
|
175
|
+
- test/fixture/sys/class/ieee80211/phy0/uevent
|
176
|
+
- test/fixture/sys/class/net/eth0/device/uevent
|
177
|
+
- test/fixture/sys/class/net/eth0/uevent
|
178
|
+
- test/fixture/sys/class/net/wlan0/device/uevent
|
179
|
+
- test/fixture/sys/class/net/wlan0/uevent
|
180
|
+
- test/omf_rc/deferred_process_spec.rb
|
181
|
+
- test/omf_rc/message_process_error_spec.rb
|
182
|
+
- test/omf_rc/resource_factory_spec.rb
|
183
|
+
- test/omf_rc/resource_proxy/abstract_resource_spec.rb
|
184
|
+
- test/omf_rc/resource_proxy/application_spec.rb
|
185
|
+
- test/omf_rc/resource_proxy/mock_spec.rb
|
186
|
+
- test/omf_rc/resource_proxy/node_spec.rb
|
187
|
+
- test/omf_rc/resource_proxy_dsl_spec.rb
|
188
|
+
- test/omf_rc/util/common_tools_spec.rb
|
189
|
+
- test/omf_rc/util/ip_spec.rb
|
190
|
+
- test/omf_rc/util/iw_spec.rb
|
191
|
+
- test/omf_rc/util/mock_spec.rb
|
192
|
+
- test/omf_rc/util/mod_spec.rb
|
193
|
+
- test/test_helper.rb
|