Add 'ha' parameter for neutron_router
'ha' parameter allows user to set the router's type to HA or not. If this parameter is not specified, neutron will use default value, which depends on whether L3 HA is enabled or not. Change-Id: I74a5e8482b5e0019e101f78ee9eafb964cf57810
This commit is contained in:
parent
4eeba83541
commit
fd4ba5f9f3
@ -26,6 +26,7 @@ Puppet::Type.type(:neutron_router).provide(
|
||||
:external_gateway_info => attrs['external_gateway_info'],
|
||||
:status => attrs['status'],
|
||||
:distributed => attrs['distributed'],
|
||||
:ha => attrs['ha'],
|
||||
:tenant_id => attrs['tenant_id']
|
||||
)
|
||||
end
|
||||
@ -63,6 +64,10 @@ Puppet::Type.type(:neutron_router).provide(
|
||||
opts << "--distributed=#{@resource[:distributed]}"
|
||||
end
|
||||
|
||||
if @resource[:ha]
|
||||
opts << "--ha=#{@resource[:ha]}"
|
||||
end
|
||||
|
||||
results = auth_neutron("router-create", '--format=shell',
|
||||
opts, resource[:name])
|
||||
|
||||
@ -154,4 +159,14 @@ EOT
|
||||
end
|
||||
end
|
||||
|
||||
def ha=(value)
|
||||
results = auth_neutron("router-show", '--format=shell', resource[:name])
|
||||
attrs = self.class.parse_creation_output(results)
|
||||
admin_state_up(false)
|
||||
auth_neutron('router-update', "--ha=#{value}", name)
|
||||
if attrs['admin_state_up'] == 'True'
|
||||
admin_state_up(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -84,6 +84,14 @@ Puppet::Type.newtype(:neutron_router) do
|
||||
end
|
||||
end
|
||||
|
||||
newproperty(:ha) do
|
||||
desc 'Is router of HA type or not, default depends on L3 HA state.'
|
||||
newvalues(/(t|T)rue/, /(f|F)alse/)
|
||||
munge do |v|
|
||||
v.to_s.capitalize
|
||||
end
|
||||
end
|
||||
|
||||
validate do
|
||||
if self[:ensure] != :present
|
||||
return
|
||||
|
@ -17,6 +17,7 @@ describe provider_class do
|
||||
:ensure => 'present',
|
||||
:admin_state_up => 'True',
|
||||
:distributed => 'True',
|
||||
:ha => 'False',
|
||||
:tenant_id => '60f9544eb94c42a6b7e8e98c2be981b1',
|
||||
}
|
||||
end
|
||||
@ -41,11 +42,13 @@ id="c5f799fa-b3e0-47ca-bdb7-abeff209b816"
|
||||
name="router1"
|
||||
status="ACTIVE"
|
||||
distributed="True"
|
||||
ha="False"
|
||||
tenant_id="60f9544eb94c42a6b7e8e98c2be981b1"'
|
||||
|
||||
provider.expects(:auth_neutron).with('router-create',
|
||||
'--format=shell', ["--tenant_id=#{router_attrs[:tenant_id]}",
|
||||
"--distributed=#{router_attrs[:distributed]}"],
|
||||
"--distributed=#{router_attrs[:distributed]}",
|
||||
"--ha=#{router_attrs[:ha]}"],
|
||||
router_name).returns(output)
|
||||
|
||||
provider.create
|
||||
|
Loading…
Reference in New Issue
Block a user