Add types, providers for OVS and some manifests
This commit is contained in:
@@ -11,9 +11,11 @@ require "set"
|
||||
|
||||
module OpenVSwitch
|
||||
def self.exec(short, cmd)
|
||||
bin = "/usr/bin/ovs-" + short + "ctl"
|
||||
shell_cmd = bin + " " + cmd
|
||||
result = Facter::Util::Resolution.exec(shell_cmd).split("\n")
|
||||
shell_cmd = "/usr/bin/ovs-" + short + "ctl " + cmd
|
||||
result = Facter::Util::Resolution.exec(shell_cmd)
|
||||
if result
|
||||
result = result.split("\n")
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
@@ -59,10 +61,11 @@ if Facter.value(:openvswitch_module) == true
|
||||
|
||||
bridges.each do |bridge|
|
||||
ports = OpenVSwitch.list_ports(bridge)
|
||||
|
||||
Facter.add("openvswitch_ports_#{bridge}") do
|
||||
setcode do
|
||||
ports.join(",")
|
||||
if ports
|
||||
Facter.add("openvswitch_ports_#{bridge}") do
|
||||
setcode do
|
||||
ports.join(",")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
19
lib/puppet/provider/vs_bridge/ovs.rb
Normal file
19
lib/puppet/provider/vs_bridge/ovs.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require "puppet"
|
||||
|
||||
Puppet::Type.type(:vs_bridge).provide(:ovs) do
|
||||
commands :vsctl => "/usr/bin/ovs-vsctl"
|
||||
|
||||
def exists?
|
||||
vsctl("br-exists", @resource[:name])
|
||||
rescue Puppet::ExecutionFailure
|
||||
return false
|
||||
end
|
||||
|
||||
def create
|
||||
vsctl("add-br", @resource[:name])
|
||||
end
|
||||
|
||||
def destroy
|
||||
vsctl("del-br", @resource[:name])
|
||||
end
|
||||
end
|
||||
9
lib/puppet/provider/vs_port/ovs.rb
Normal file
9
lib/puppet/provider/vs_port/ovs.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require "puppet"
|
||||
|
||||
Puppet::Type.type(:vs_port).provide(:ovs) do
|
||||
commands :vsctl => "/usr/bin/vsctl"
|
||||
|
||||
def exists?
|
||||
vsctl("list-ports", @resource[:bridge]).include? @resource[:interface]
|
||||
end
|
||||
end
|
||||
14
lib/puppet/type/vs_bridge.rb
Normal file
14
lib/puppet/type/vs_bridge.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require "puppet"
|
||||
|
||||
module Puppet
|
||||
Puppet::Type.newtype(:vs_bridge) do
|
||||
@doc = "A Switch - For example 'br-int' in OpenStack"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
isnamevar
|
||||
desc "The bridge to configure"
|
||||
end
|
||||
end
|
||||
end
|
||||
19
lib/puppet/type/vs_port.rb
Normal file
19
lib/puppet/type/vs_port.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require "puppet"
|
||||
|
||||
module Puppet
|
||||
Puppet::Type.newtype(:vs_port) do
|
||||
@doc = "A Virtuak Switch"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:interface) do
|
||||
isnamevar
|
||||
desc "The interface to attach to the bridge"
|
||||
end
|
||||
|
||||
newparam(:bridge) do
|
||||
desc "What bridge to use"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
8
manifests/bridge.pp
Normal file
8
manifests/bridge.pp
Normal file
@@ -0,0 +1,8 @@
|
||||
class vswitch::bridge (
|
||||
$br_name,
|
||||
$ensure
|
||||
) {
|
||||
vs_bridge { $br_name:
|
||||
ensure => $ensure
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
class openvswitch {
|
||||
class vswitch {
|
||||
package { ["openvswitch-switch", "openvswitch-datapath-dkms"]:
|
||||
ensure => present
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user