From b38083fb9b59d339497959392ac43427bc9b1e7d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 10 Mar 2012 14:03:09 -0800 Subject: [PATCH] OpenBSD guest [GH-773] --- CHANGELOG.md | 1 + lib/vagrant.rb | 1 + lib/vagrant/guest.rb | 1 + lib/vagrant/guest/openbsd.rb | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 lib/vagrant/guest/openbsd.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 216eeac18..050e93fd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - The `:facter` option now works for puppet server. [GH-790] - The `--no-provision` and `--provision-with` flags are available to `vagrant reload` now. + - `:openbsd` guest which supports only halting at the moment. [GH-773] ## 1.0.0 (March 6, 2012) diff --git a/lib/vagrant.rb b/lib/vagrant.rb index 749bee9ee..1cfe0abcf 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -178,6 +178,7 @@ Vagrant.guests.register(:fedora) { Vagrant::Guest::Fedora } Vagrant.guests.register(:freebsd) { Vagrant::Guest::FreeBSD } Vagrant.guests.register(:gentoo) { Vagrant::Guest::Gentoo } Vagrant.guests.register(:linux) { Vagrant::Guest::Linux } +Vagrant.guests.register(:openbsd) { Vagrant::Guest::OpenBSD } Vagrant.guests.register(:redhat) { Vagrant::Guest::Redhat } Vagrant.guests.register(:solaris) { Vagrant::Guest::Solaris } Vagrant.guests.register(:suse) { Vagrant::Guest::Suse } diff --git a/lib/vagrant/guest.rb b/lib/vagrant/guest.rb index 34b71601b..b7c219065 100644 --- a/lib/vagrant/guest.rb +++ b/lib/vagrant/guest.rb @@ -9,6 +9,7 @@ module Vagrant autoload :FreeBSD, 'vagrant/guest/freebsd' autoload :Gentoo, 'vagrant/guest/gentoo' autoload :Linux, 'vagrant/guest/linux' + autoload :OpenBSD, 'vagrant/guest/openbsd' autoload :Redhat, 'vagrant/guest/redhat' autoload :Solaris, 'vagrant/guest/solaris' autoload :Suse, 'vagrant/guest/suse' diff --git a/lib/vagrant/guest/openbsd.rb b/lib/vagrant/guest/openbsd.rb new file mode 100644 index 000000000..a673ecf2a --- /dev/null +++ b/lib/vagrant/guest/openbsd.rb @@ -0,0 +1,20 @@ +module Vagrant + module Guest + class OpenBSD < Base + def halt + vm.channel.sudo("shutdown -p -h now") + + # Wait until the VM's state is actually powered off. If this doesn't + # occur within a reasonable amount of time then simply return which + # will cause Vagrant to force kill the machine. + count = 0 + while vm.state != :poweroff + count += 1 + + return if count >= 30 + sleep 1 + end + end + end + end +end