Merge "vs_port: Fail early if the target bridge does not exist"
This commit is contained in:
commit
4af35cdd47
lib/puppet/provider/vs_port
@ -19,6 +19,10 @@ Puppet::Type.type(:vs_port).provide(:ovs) do
|
||||
end
|
||||
|
||||
def create
|
||||
if ! bridge_exists?
|
||||
raise Puppet::Error, "Bridge #{@resource[:bridge]} does not exist"
|
||||
end
|
||||
|
||||
# create with first interface, other interfaces will be added later when synchronizing properties
|
||||
vsctl('--', '--id=@iface0', 'create', 'Interface', "name=#{@resource[:interface][0]}", '--', 'add-port', @resource[:bridge], @resource[:port], 'interfaces=@iface0')
|
||||
|
||||
@ -128,6 +132,15 @@ Puppet::Type.type(:vs_port).provide(:ovs) do
|
||||
set_port_column('trunks', value.join(' '))
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def bridge_exists?
|
||||
vsctl('br-exists', @resource[:bridge])
|
||||
return true
|
||||
rescue Puppet::ExecutionFailure
|
||||
return false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def port_column_command(command, column, value=nil)
|
||||
|
@ -37,6 +37,10 @@ Puppet::Type.type(:vs_port).provide(
|
||||
end
|
||||
|
||||
def create
|
||||
if ! bridge_exists?
|
||||
raise Puppet::Error, "Bridge #{@resource[:bridge]} does not exist"
|
||||
end
|
||||
|
||||
unless vsctl('list-ports',
|
||||
@resource[:bridge]).include? @resource[:port]
|
||||
super
|
||||
|
Loading…
x
Reference in New Issue
Block a user