Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from immerda #6

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3889b71
Features :importable and :buildable declared to virt type.
carlasouza Oct 20, 2010
f46b676
Feature for live migration declared
carlasouza Oct 21, 2010
36d5532
Feature for live migration declared
carlasouza Oct 21, 2010
da2a35f
Starting support for PXE boot protocol
carlasouza Oct 30, 2010
eece972
Starting support for PXE boot protocol
carlasouza Oct 30, 2010
7af124c
Syntax fix
carlasouza Nov 20, 2010
663541e
Merge branch 'unstable' of [email protected]:carlasouza/puppet-virt into…
carlasouza Nov 20, 2010
d02ad44
Newvalue no longer exists. Using newvalues instead.
carlasouza Nov 21, 2010
e460190
place examples outside
duritong Dec 6, 2010
4af6a2d
refactor classes - no behavior change
duritong Dec 6, 2010
4f7ac3d
enricht virt module
duritong Dec 6, 2010
c95ba39
check value on undef
duritong Dec 9, 2010
c3ed7e9
fixing source
duritong Dec 9, 2010
3fc38f8
naming for lenny
duritong Dec 9, 2010
a239cd3
fix package naming
duritong Dec 9, 2010
971c448
fix path
duritong Dec 9, 2010
61cb63c
get the service right for lenny
duritong Dec 10, 2010
ee8b039
various fixes to get things running on lenny
duritong Dec 10, 2010
ac77354
using env in /usr as e.g. debian only has that one
duritong Dec 10, 2010
e301957
update to latest upstream
duritong Apr 11, 2011
6f5c6e1
add script to generate mac addresses for virtualizations
duritong Jul 6, 2011
7727683
fixing concatenation
duritong Jul 7, 2011
a38b41a
no need to install qemu
duritong Dec 22, 2011
846cdcf
actually this should not be installed on a guest
duritong Dec 22, 2011
4b63c82
use proper names on squeeze
duritong Dec 22, 2011
879e850
kvm are kvm guests, need to find another way to identify a kvm host
duritong Dec 22, 2011
ec582c3
ensure that we install amd64 package on x86_64 archtiecture
duritong Jan 21, 2012
31cfdc4
fix typo
duritong Jan 21, 2012
69f0e9a
more typos
duritong Jan 21, 2012
627257f
new style for 2.7
duritong Jun 5, 2012
c2bf859
new style for 2.7
duritong Jun 5, 2012
a476c4b
line is deprecated better use file_line
duritong Jun 17, 2012
52e57e5
get rid off config_file wrapper
duritong Jun 18, 2012
089737e
Merge branch 'master' into upstream
micah Jul 1, 2012
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
29 changes: 7 additions & 22 deletions examples/virt-example.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,12 @@
}

class ovz-guest {
virt { "ovz1":
os_template => 'ubuntu-10.10-x86_64',
ensure => 'running',
virt_type => 'openvz',
autoboot => 'false',
configfile => 'basic',
ipaddr => ['10.0.0.1'],
features => ["nfs:on", "sit:off"],
resources_parameters => ["NUMPTY=20:20", "NUMSIGINFO=255:255"],
}

virt { "ovz2":
ctid => 101,
os_template => 'ubuntu-11.04-x86_64',
ensure => 'stopped',
virt_type => 'openvz',
ve_root => '/home/a/root/$VEID',
ve_private => '/home/a/private/$VEID',
user => 'user:password',
capability => ["chown:off"],
devices => ["b:8:19:rw", "b:8:18:rw", "cdrom:rw"]
virt { "101":
memory => 1024,
vcpu => 4,
xml_file => "/etc/libvirt/qemu/systems/101.xml",
tmpl_cache => "debian-5.0-x86",
ensure => installed,
virt_type => "openvz"
}

}
68 changes: 68 additions & 0 deletions files/libvirt/guest_starter
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env ruby

require 'facter'
class GuestStarter
def self.factory
if Facter[:virtual].value == 'xen0'
XenGuestStarter.new
else
raise "No such virtual type supported so far!"
end
end

def guests
@guests ||= get_guests
end

def started_guests
@started_guests ||= `virsh list | egrep -v '(^.*Id.*Name.*State$|^-*$|Domain-0|^$)' | awk '{ print $2 }'`.split("\n")
end

def start_missing_guests
ret = 0
guests.keys.reject{ |name| started_guests.include?(name) }.each do |guest|
if (missing_disks=guests[guest][:disks].reject{|disk| File.exists?(disk) }).empty?
start_guest(guest)
else
ret += 1
puts "Guest #{guest} can't yet be started as the following disks are missing: #{missing_disks.join(',')}"
end
end
ret
end

def start_guest(guest)
puts "Starting guest #{guest}"
system start_guest_cmd(guest)
end

def get_guests
raise "Implement method!"
end
def start_guest_cmd(guest)
raise "Implement method!"
end
end

class XenGuestStarter < GuestStarter
def get_guests
guests = {}
(Dir['/etc/xen/auto/*'] | Dir['/etc/xen/*.sxp']).each do |file|
next if File.basename(file) =~ /^xend\-.*.sxp$/
content = File.read(file).split("\n").select{|l| l =~ /^.*(name|disk).*=.*$/ }.join("\n")
name = disk = nil
eval content
guests[name] = {
:file => file,
:disks => disk.collect{|d| d.split(':',2).last.split(',').first }
}
end
guests
end

def start_guest_cmd(guest)
"xm create #{guests[guest][:file]}"
end
end

exit GuestStarter.factory.start_missing_guests
20 changes: 20 additions & 0 deletions files/libvirt/random_mac_address.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env ruby


prefixes = {
'xen' => '00:16:3E',
}

def random_hex
rand(15).to_s(16).upcase
end

type = ARGV.shift
unless prefixes[type]
puts "Usage: #{File.basename(__FILE__)} <type>"
puts "Where known types are: #{prefixes.keys.join(', ')}"
exit 1
end


puts "#{prefixes[type]<<':'<<(0..(5-prefixes[type].split(':').length)).collect{ random_hex + random_hex }.join(':')}"
11 changes: 11 additions & 0 deletions files/xen/CentOS/sysconfig/xend
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NB. changing these requires a reboot.
# A simple 'xend restart' will not take effect

# Log all hypervisor messages (cf xm dmesg)
#XENCONSOLED_LOG_HYPERVISOR=no

# Log all guest console output (cf xm console)
#XENCONSOLED_LOG_GUESTS=no

# Location to store guest & hypervisor logs
#XENCONSOLED_LOG_DIR=/var/log/xen/console
148 changes: 148 additions & 0 deletions files/xen/CentOS/sysconfig/xendomains
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
## Path: System/xen
## Description: xen domain start/stop on boot
## Type: string
## Default:
#
# The xendomains script can send SysRq requests to domains on shutdown.
# If you don't want to MIGRATE, SAVE, or SHUTDOWN, this may be a possibility
# to do a quick and dirty shutdown ("s e i u o") or at least sync the disks
# of the domains ("s").
#
XENDOMAINS_SYSRQ=""

## Type: integer
## Default: 100000
#
# If XENDOMAINS_SYSRQ is set, this variable determines how long to wait
# (in microseconds) after each SysRq, so the domain has a chance to react.
# If you want to a quick'n'dirty shutdown via SysRq, you may want to set
# it to a relatively high value (1200000).
#
XENDOMAINS_USLEEP=100000

## Type: integer
## Default: 5000000
#
# When creating a guest domain, it is sensible to allow a little time for it
# to get started before creating another domain or proceeding through the
# boot process. Without this, the booting guests will thrash the disk as they
# start up. This timeout (in microseconds) specifies the delay after guest
# domain creation.
#
XENDOMAINS_CREATE_USLEEP=5000000

## Type: string
## Default: ""
#
# Set this to a non-empty string if you want to migrate virtual machines
# on shutdown. The string will be passed to the xm migrate DOMID command
# as is: It should contain the target IP address of the physical machine
# to migrate to and optionally parameters like --live. Leave empty if
# you don't want to try virtual machine relocation on shutdown.
# If migration succeeds, neither SAVE nor SHUTDOWN will be executed for
# that domain.
#
XENDOMAINS_MIGRATE=""

## Type: string
## Default: /var/lib/xen/save
#
# Directory to save running domains to when the system (dom0) is
# shut down. Will also be used to restore domains from if # XENDOMAINS_RESTORE
# is set (see below). Leave empty to disable domain saving on shutdown
# (e.g. because you rather shut domains down).
# If domain saving does succeed, SHUTDOWN will not be executed.
#
XENDOMAINS_SAVE=

## Type: string
## Default: "none"
#
# If you're restoring domain and the restore fails you can specify the
# type of action to be done. Possible values are:
# "none" - do nothing, standard behaviour
# "rename" - rename /savePath/invalidRestoreImage to /savePath/.invalidRestoreImage
# "delete" - delete /savePath/invalidRestoreImage
#
XENDOMAINS_RESTOREFAILTYPE="none"

## Type: string
## Default: "--halt --wait"
#
# If neither MIGRATE nor SAVE were enabled or if they failed, you can
# try to shut down a domain by sending it a shutdown request. To do this,
# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting
# for the domain to be really down. Leave empty to skip domain shutdown.
#
XENDOMAINS_SHUTDOWN="--halt --wait"

## Type: string
## Default: "--all --halt --wait"
#
# After we have gone over all virtual machines (resp. all automatically
# started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq,
# migrated, saved and/or shutdown according to the settings above, we
# might want to shutdown the virtual machines that are still running
# for some reason or another. To do this, set this variable to
# "--all --halt --wait", it will be passed to xm shutdown.
# Leave it empty not to do anything special here.
# (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY
# is set.)
#
XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait"

## Type: boolean
## Default: true
#
# This variable determines whether saved domains from XENDOMAINS_SAVE
# will be restored on system startup.
#
XENDOMAINS_RESTORE=false

## Type: string
## Default: /etc/xen/auto
#
# This variable sets the directory where domains configurations
# are stored that should be started on system startup automatically.
# Leave empty if you don't want to start domains automatically
# (or just don't place any xen domain config files in that dir).
# Note that the script tries to be clever if both RESTORE and AUTO are
# set: It will first restore saved domains and then only start domains
# in AUTO which are not running yet.
# Note that the name matching is somewhat fuzzy.
#
XENDOMAINS_AUTO=/etc/xen/auto

## Type: boolean
## Default: false
#
# If this variable is set to "true", only the domains started via config
# files in XENDOMAINS_AUTO will be treated according to XENDOMAINS_SYSRQ,
# XENDOMAINS_MIGRATE, XENDOMAINS_SAVE, XENDMAINS_SHUTDOWN; otherwise
# all running domains will be.
# Note that the name matching is somewhat fuzzy.
#
XENDOMAINS_AUTO_ONLY=false

## Type: integer
## Default: 300
#
# On xendomains stop, a number of xm commands (xm migrate, save, shutdown,
# shutdown --all) may be executed. In the worst case, these commands may
# stall forever, which will prevent a successful shutdown of the machine.
# If this variable is non-zero, the script will set up a watchdog timer
# for every of these xm commands and time it out after the number of seconds
# specified by this variable.
# Note that SHUTDOWN_ALL will not be called if no virtual machines or only
# zombies are still running, so you don't need to enable this timeout just
# for the zombie case.
# The setting should be large enough to make sure that migrate/save/shutdown
# can succeed. If you do live migrations, keep in mind that live migration
# of a 1GB machine over Gigabit ethernet may actually take something like
# 100s (assuming that live migration uses 10% of the network # bandwidth).
# Depending on the virtual machine, a shutdown may also require a significant
# amount of time. So better setup this variable to a huge number and hope the
# watchdog never fires.
#
XENDOMAINS_STOP_MAXWAIT=300

Loading