Skip to content

Commit d439f42

Browse files
committed
Merge pull request #113 from camptocamp/development
Development
2 parents bffb6fd + cbf5f74 commit d439f42

2 files changed

Lines changed: 39 additions & 37 deletions

File tree

lib/puppet/provider/onevm/cli.rb

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,10 @@
1414

1515
mk_resource_methods
1616

17-
# Create a VM with onevm by passing in a temporary template.
17+
# Create a VM with onetemplate instantiate.
1818
def create
19-
# create template content from template
20-
template_output = onetemplate('show', resource[:template])
21-
template_content = `#{template_output} | grep -A 100000 'TEMPLATE CONTENT' | grep -v 'TEMPLATE CONTENT'`
22-
file = Tempfile.new("onevm-#{resource[:name]}")
23-
template = ERB.new <<-EOF
24-
NAME = <%= resource[:name] %>
25-
<%= template_content %>
26-
EOF
27-
28-
tempfile = template.result(binding)
29-
file.write(tempfile)
30-
file.close
31-
self.debug "Creating onevm with template content: #{tempfile}"
32-
onevm('create', file.path)
33-
@property_hash[:ensure] = :present
19+
onetemplate('instantiate', resource[:template], '--name', resource[:name])
20+
@property_hash[:ensure] = :present
3421
end
3522

3623
# Destroy a VM using onevm delete

spec/acceptance/onevm_spec.rb

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
11
require 'spec_helper_acceptance'
22

33
describe 'onevm type' do
4+
before :all do
5+
pp = <<-EOS
6+
class { 'one':
7+
oned => true,
8+
}
9+
onetemplate { 'test-vm':
10+
# Capacity
11+
cpu => 1,
12+
memory => 128,
13+
14+
# OS
15+
os_kernel => '/vmlinuz',
16+
os_initrd => '/initrd.img',
17+
os_root => 'sda1',
18+
os_kernel_cmd => 'ro xencons=tty console=tty1',
19+
20+
# Features
21+
acpi => true,
22+
pae => true,
23+
24+
# Disks
25+
disks => [ 'Data', 'Experiments', ],
26+
27+
# Network
28+
nics => [ 'Blue', 'Red', ],
29+
30+
# I/O Devices
31+
graphics_type => 'vnc',
32+
graphics_listen => '0.0.0.0',
33+
graphics_port => 5,
34+
}
35+
EOS
36+
apply_manifest(pp, :catch_failures => true)
37+
apply_manifest(pp, :catch_changes => true)
38+
end
439

540
describe 'when creating vm' do
641
it 'should idempotently run' do
742
pending 'Need fix'
843
pp = <<-EOS
9-
class { 'one':
10-
oned => true,
11-
} ->
12-
oneimage { 'new_image':
13-
source => '/foo/bar.img',
14-
size => '50',
15-
}
16-
->
17-
onevnet { 'new_vnet':
18-
bridge => 'vbr0',
19-
network_address => '192.168.0.0',
20-
}
21-
->
22-
onetemplate { 'new_template':
23-
nics => 'bar',
24-
memory => 512,
25-
cpu => 1,
26-
disks => 'new_image',
27-
}
28-
->
2944
onevm { 'new_vm':
30-
template => 'new_template',
45+
template => 'test-vm',
3146
}
3247
EOS
3348

0 commit comments

Comments
 (0)