Add Guest support for VMware Photon.
Signed-off-by: Fabio Rapposelli <fabio@vmware.com>
This commit is contained in:
parent
27599ee897
commit
21db4470a0
|
@ -0,0 +1,15 @@
|
|||
module VagrantPlugins
|
||||
module GuestPhoton
|
||||
module Cap
|
||||
class ChangeHostName
|
||||
def self.change_host_name(machine, name)
|
||||
machine.communicate.tap do |comm|
|
||||
unless comm.test("sudo hostname --fqdn | grep '#{name}'")
|
||||
comm.sudo("hostname #{name.split('.')[0]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
require 'tempfile'
|
||||
require 'vagrant/util/template_renderer'
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestPhoton
|
||||
module Cap
|
||||
class ConfigureNetworks
|
||||
include Vagrant::Util
|
||||
|
||||
def self.configure_networks(machine, networks)
|
||||
machine.communicate.tap do |comm|
|
||||
# Read network interface names
|
||||
interfaces = []
|
||||
comm.sudo("ifconfig | grep 'eth' | cut -f1 -d' '") do |_, result|
|
||||
interfaces = result.split("\n")
|
||||
end
|
||||
|
||||
# Configure interfaces
|
||||
networks.each do |network|
|
||||
comm.sudo("ifconfig #{interfaces[network[:interface].to_i]} #{network[:ip]} netmask #{network[:netmask]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
module VagrantPlugins
|
||||
module GuestPhoton
|
||||
module Cap
|
||||
module Docker
|
||||
def self.docker_daemon_running(machine)
|
||||
machine.communicate.test('test -S /run/docker.sock')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
module VagrantPlugins
|
||||
module GuestPhoton
|
||||
class Guest < Vagrant.plugin('2', :guest)
|
||||
def detect?(machine)
|
||||
machine.communicate.test("cat /etc/photon-release | grep 'VMware Photon Linux'")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
require 'vagrant'
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestPhoton
|
||||
class Plugin < Vagrant.plugin('2')
|
||||
name 'VMware Photon guest'
|
||||
description 'VMware Photon guest support.'
|
||||
|
||||
guest('photon', 'linux') do
|
||||
require File.expand_path("../guest", __FILE__)
|
||||
Guest
|
||||
end
|
||||
|
||||
guest_capability('photon', 'change_host_name') do
|
||||
require_relative 'cap/change_host_name'
|
||||
Cap::ChangeHostName
|
||||
end
|
||||
|
||||
guest_capability('photon', 'configure_networks') do
|
||||
require_relative 'cap/configure_networks'
|
||||
Cap::ConfigureNetworks
|
||||
end
|
||||
|
||||
guest_capability('photon', 'docker_daemon_running') do
|
||||
require_relative 'cap/docker'
|
||||
Cap::Docker
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue