Add interface_type parameter

This parameter allows to specify the interface type. Currently only
'system', 'internal' and 'tap' are supported. Any types like tunnels
that need further configuration are not (yet) supported.

The parameter is only supported on providers that have the
interface_type feature. This feature is currently only supported on the
ovs provider.

Change-Id: Iac65696c0ff714395f81529fc091d44fed92c173
This commit is contained in:
Gaudenz Steinlin 2014-08-06 12:12:21 +02:00 committed by Alex Schultz
parent b797ae79a0
commit 16db56f391
2 changed files with 30 additions and 0 deletions

View File

@ -8,6 +8,7 @@ Puppet::Type.type(:vs_port).provide(:ovs) do
has_feature :bonding
has_feature :vlan
has_feature :interface_type
commands :vsctl => 'ovs-vsctl'
@ -39,6 +40,10 @@ Puppet::Type.type(:vs_port).provide(:ovs) do
:vlan_trunks,
]
end
if @resource.provider.class.feature?(:interface_type)
sync_properties += [:interface_type,
]
end
for prop_name in sync_properties
property = @resource.property(prop_name)
property.sync unless property.safe_insync?(property.retrieve)
@ -64,6 +69,17 @@ Puppet::Type.type(:vs_port).provide(:ovs) do
vsctl(*args)
end
def interface_type
types = get_port_interface_column('type').uniq
types != nil ? types.join(' ') : :system
end
def interface_type=(value)
@resource.property(:interface).retrieve.each do |iface|
vsctl('set', 'Interface', iface, "type=#{value}")
end
end
def bond_mode
get_port_column('bond_mode')
end

View File

@ -44,6 +44,20 @@ Puppet::Type.newtype(:vs_port) do
end
end
newproperty(:interface_type, :required_features => :interface_type) do
desc "The type of network interface connected to this port.
Supported types are 'system', 'internal' and 'tap'. Currently the
interface configuration required for tunnel ports is not supported.
Currently all interfaces on a port are set to the same type. Bonding
configurations with different types on the same port are not supported."
defaultto :system
newvalues(:system, :internal, :tap)
end
newproperty(:bond_mode, :required_features => :bonding) do
desc "Interface bonding mode for this port.