Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ Usage
=====

libvirt_network 'fake_network' do
netmask '255.255.0.0'
gateway '192.168.42.1'
bridge 'fakebr'
forward 'nat'
netmask '255.255.0.0'
gateway '192.168.42.1'
bridge 'fakebr'
forward 'nat'
virtualport 'openvswitch'
dhcp_range :start => '192.168.42.100', :end => '192.168.42.200'

action [:define, :create, :autostart]
Expand Down
11 changes: 6 additions & 5 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
maintainer "VPSLab"
maintainer_email "[email protected]"
license "Apache 2.0"
description "Installs libvirt and provides libvirt resources."
name 'libvirt'
maintainer 'VPSLab'
maintainer_email '[email protected]'
license 'Apache 2.0'
description 'Installs libvirt and provides libvirt resources.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.2.1"
version '0.2.2'

%w(ubuntu debian).each do |os|
supports os
Expand Down
1 change: 1 addition & 0 deletions providers/domain_kvm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def load_current_resource
:memory => memory_in_bytes,
:vcpu => new_resource.vcpu,
:arch => libvirt_arch,
:boot => new_resource.boot,
:uuid => ::UUIDTools::UUID.random_create
)
action :nothing
Expand Down
3 changes: 1 addition & 2 deletions providers/network.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'uuidtools'

def load_current_resource
@current_resource = Chef::Resource::LibvirtNetwork.new(new_resource.name)
@libvirt = ::Libvirt.open(new_resource.uri)
Expand All @@ -19,6 +17,7 @@ def load_current_resource
:netmask => new_resource.netmask,
:gateway => new_resource.gateway,
:forward => new_resource.forward,
:virtualport => new_resource.virtualport,
:dhcp => new_resource.dhcp_range,
:uuid => ::UUIDTools::UUID.random_create
)
Expand Down
3 changes: 2 additions & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%w(libvirt-bin libvirt-dev).each do |name|
%w(libvirt-bin libvirt-dev build-essential).each do |name|
package name do
action :nothing
end.run_action(:install)
Expand All @@ -12,3 +12,4 @@

$LOAD_PATH.delete("/usr/bin/../lib") # scumbag LOAD_PATH: https://github.com/opscode/chef/blob/master/bin/chef-solo#L22
require 'libvirt'
require 'uuidtools'
1 change: 1 addition & 0 deletions resources/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ def initialize(*args)
attribute :vcpu, :kind_of => [Integer, String], :required => true
attribute :memory, :kind_of => [Integer, String], :required => true
attribute :arch, :kind_of => String, :required => true
attribute :boot, :kind_of => String, :default => 'hd'
attribute :uri, :kind_of => String, :default => 'qemu:///system'
1 change: 1 addition & 0 deletions resources/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ def initialize(*args)
attribute :gateway, :kind_of => String
attribute :forward, :kind_of => String
attribute :dhcp_range, :kind_of => Hash
attribute :virtualport, :kind_of => String
attribute :uri, :kind_of => String, :default => 'qemu:///system'
2 changes: 1 addition & 1 deletion templates/default/kvm_domain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<uuid><%= @uuid %></uuid>
<os>
<type arch='<%= @arch %>'>hvm</type>
<boot dev='hd'/>
<boot dev='<%= @boot %>'/>
</os>
<features>
<acpi/><apic/><pae/>
Expand Down
7 changes: 6 additions & 1 deletion templates/default/network.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
<bridge name="<%= @bridge %>" />
<% if @forward %>
<forward mode="<%= @forward %>"/>
<%end %>
<% end %>
<% if @virtualport %>
<virtualport type="<%= @virtualport %>"/>
<% end %>
<% if @gateway && @netmask %>
<ip address="<%= @gateway %>" netmask="<%= @netmask %>">
<% if @dhcp %>
<dhcp>
<range start="<%= @dhcp[:start] %>" end="<%= @dhcp[:end] %>" />
</dhcp>
<% end %>
</ip>
<% end %>
</network>