From e956eba8296a77e28aa4bd83e6769a2db8fdab87 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Thu, 6 Aug 2015 13:06:07 +0200 Subject: [PATCH] Reflect provider change in puppet-openstacklib With the creation of the new openstack_config provider, some processing that was done in neutron_config has been centralized in openstack_config. The same logic applies for all the neutron resources that edit a ini-like configuration file. Impacted methods are : * section * setting * separator Also, this commit adds the fact that, when passing a specific string (ensure_absent_val) the provider will behave as if ensure => absent was specified. '' is the default value for ensure_absent_val. The use case is the following : neutron_config { 'DEFAULT/foo' : value => 'bar' } # will work as usual neutron_config { 'DEFAULT/foo' : value => '' } # will mean absent That means that all the current : if $myvar { neutron_config { 'DEFAULT/foo' : value => $myvar } } else { neutron_config { 'DEFAULT/foo' : ensure => absent } } can be removed in favor of : neutron_config { 'DEFAULT/foo' : value => $myvar } If for any reason '' turns out to be a valid value for a specific parameter. One could by pass that doing the following : neutron_config { 'DEFAULT/foo' : value => '', ensure_absent_val => 'foo' } Change-Id: I3f972ecbde3719fe71a82a64f894d41f6ea7e842 Depends-On: I0eeebde3aac2662cc7e69bfad7f8d2481463a218 --- README.md | 30 ++ .../neutron_agent_linuxbridge/ini_setting.rb | 14 +- .../provider/neutron_agent_ovs/ini_setting.rb | 14 +- .../neutron_api_config/ini_setting.rb | 14 +- .../provider/neutron_config/ini_setting.rb | 14 +- .../neutron_dhcp_agent_config/ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- .../neutron_l3_agent_config/ini_setting.rb | 14 +- .../neutron_lbaas_agent_config/ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- .../neutron_plugin_cisco/ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- .../neutron_plugin_linuxbridge/ini_setting.rb | 14 +- .../neutron_plugin_midonet/ini_setting.rb | 14 +- .../neutron_plugin_ml2/ini_setting.rb | 14 +- .../neutron_plugin_nvp/ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- .../neutron_plugin_plumgrid/ini_setting.rb | 14 +- .../neutron_plumlib_plumgrid/ini_setting.rb | 14 +- .../ini_setting.rb | 14 +- lib/puppet/type/neutron_agent_linuxbridge.rb | 5 + lib/puppet/type/neutron_agent_ovs.rb | 5 + lib/puppet/type/neutron_api_config.rb | 5 + lib/puppet/type/neutron_config.rb | 6 + lib/puppet/type/neutron_dhcp_agent_config.rb | 5 + .../type/neutron_fwaas_service_config.rb | 5 + lib/puppet/type/neutron_l3_agent_config.rb | 5 + lib/puppet/type/neutron_lbaas_agent_config.rb | 5 + .../type/neutron_metadata_agent_config.rb | 5 + .../type/neutron_metering_agent_config.rb | 5 + lib/puppet/type/neutron_plugin_cisco.rb | 5 + .../type/neutron_plugin_cisco_credentials.rb | 5 + .../type/neutron_plugin_cisco_db_conn.rb | 5 + .../type/neutron_plugin_cisco_l2network.rb | 5 + lib/puppet/type/neutron_plugin_linuxbridge.rb | 6 + lib/puppet/type/neutron_plugin_midonet.rb | 14 +- lib/puppet/type/neutron_plugin_ml2.rb | 5 + lib/puppet/type/neutron_plugin_nvp.rb | 5 + .../type/neutron_plugin_opencontrail.rb | 5 + lib/puppet/type/neutron_plugin_plumgrid.rb | 5 + lib/puppet/type/neutron_plumlib_plumgrid.rb | 5 + .../type/neutron_vpnaas_agent_config.rb | 5 + spec/acceptance/neutron_config_spec.rb | 506 ++++++++++++++++++ .../ini_setting_spec.rb | 30 ++ .../neutron_agent_ovs/ini_setting_spec.rb | 11 + .../neutron_api_config/ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../neutron_plugin_cisco/ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 74 +++ .../neutron_plugin_ml2/ini_setting_spec.rb | 74 +++ .../neutron_plugin_nvp/ini_setting_spec.rb | 74 +++ .../ini_setting_spec.rb | 11 + .../ini_setting_spec.rb | 11 + .../ini_setting_spec.rb | 11 + .../ini_setting_spec.rb | 74 +++ .../neutron_spec.rb | 8 +- 67 files changed, 1862 insertions(+), 295 deletions(-) create mode 100644 spec/acceptance/neutron_config_spec.rb create mode 100644 spec/unit/provider/neutron_api_config/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_dhcp_agent_config/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_fwaas_service_config/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_l3_agent_config/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_lbaas_agent_config/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_metadata_agent_config/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_metering_agent_config/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_plugin_cisco/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_plugin_cisco_credentials/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_plugin_cisco_db_conn/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_plugin_cisco_l2network/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_plugin_midonet/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_plugin_ml2/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_plugin_nvp/ini_setting_spec.rb create mode 100644 spec/unit/provider/neutron_vpnaas_agent_config/ini_setting_spec.rb diff --git a/README.md b/README.md index af6345aea..d6beb2c80 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,36 @@ Implementation neutron is a combination of Puppet manifest and ruby code to deliver configuration and extra functionality through *types* and *providers*. +### Types + +#### neutron_config + +The `neutron_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/neutron/neutron.conf` file. + +```puppet +neutron_config { 'DEFAULT/verbose' : + value => true, +} +``` + +This will write `verbose=true` in the `[DEFAULT]` section. + +##### name + +Section/setting name to manage from `neutron.conf` + +##### value + +The value of the setting to be defined. + +##### secret + +Whether to hide the value from Puppet logs. Defaults to `false`. + +##### ensure_absent_val + +If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `` + Limitations ----------- diff --git a/lib/puppet/provider/neutron_agent_linuxbridge/ini_setting.rb b/lib/puppet/provider/neutron_agent_linuxbridge/ini_setting.rb index f699ad50d..a4909cf06 100644 --- a/lib/puppet/provider/neutron_agent_linuxbridge/ini_setting.rb +++ b/lib/puppet/provider/neutron_agent_linuxbridge/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_agent_linuxbridge).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path if Facter['operatingsystem'].value == 'Ubuntu' '/etc/neutron/plugins/ml2/ml2_conf.ini' diff --git a/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb b/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb index 06b1fadfd..575d6817d 100644 --- a/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb +++ b/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_agent_ovs).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path if Facter['operatingsystem'].value == 'Ubuntu' '/etc/neutron/plugins/ml2/ml2_conf.ini' diff --git a/lib/puppet/provider/neutron_api_config/ini_setting.rb b/lib/puppet/provider/neutron_api_config/ini_setting.rb index cc9e81e19..a1db1cf69 100644 --- a/lib/puppet/provider/neutron_api_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_api_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_api_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/api-paste.ini' end diff --git a/lib/puppet/provider/neutron_config/ini_setting.rb b/lib/puppet/provider/neutron_config/ini_setting.rb index a1e97b06e..4efaa5793 100644 --- a/lib/puppet/provider/neutron_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/neutron.conf' end diff --git a/lib/puppet/provider/neutron_dhcp_agent_config/ini_setting.rb b/lib/puppet/provider/neutron_dhcp_agent_config/ini_setting.rb index 88f2d31ba..c507c4ec6 100644 --- a/lib/puppet/provider/neutron_dhcp_agent_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_dhcp_agent_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_dhcp_agent_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/dhcp_agent.ini' end diff --git a/lib/puppet/provider/neutron_fwaas_service_config/ini_setting.rb b/lib/puppet/provider/neutron_fwaas_service_config/ini_setting.rb index 9196679ab..96d3cc0eb 100644 --- a/lib/puppet/provider/neutron_fwaas_service_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_fwaas_service_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_fwaas_service_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/fwaas_driver.ini' end diff --git a/lib/puppet/provider/neutron_l3_agent_config/ini_setting.rb b/lib/puppet/provider/neutron_l3_agent_config/ini_setting.rb index c52c0cee7..0d9b0bfbb 100644 --- a/lib/puppet/provider/neutron_l3_agent_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_l3_agent_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_l3_agent_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/l3_agent.ini' end diff --git a/lib/puppet/provider/neutron_lbaas_agent_config/ini_setting.rb b/lib/puppet/provider/neutron_lbaas_agent_config/ini_setting.rb index 908c77d1e..566043b18 100644 --- a/lib/puppet/provider/neutron_lbaas_agent_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_lbaas_agent_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_lbaas_agent_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/lbaas_agent.ini' end diff --git a/lib/puppet/provider/neutron_metadata_agent_config/ini_setting.rb b/lib/puppet/provider/neutron_metadata_agent_config/ini_setting.rb index 94a5c8555..7b3675395 100644 --- a/lib/puppet/provider/neutron_metadata_agent_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_metadata_agent_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_metadata_agent_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/metadata_agent.ini' end diff --git a/lib/puppet/provider/neutron_metering_agent_config/ini_setting.rb b/lib/puppet/provider/neutron_metering_agent_config/ini_setting.rb index 0abd3db4e..4a315bc7c 100644 --- a/lib/puppet/provider/neutron_metering_agent_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_metering_agent_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_metering_agent_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/metering_agent.ini' end diff --git a/lib/puppet/provider/neutron_plugin_cisco/ini_setting.rb b/lib/puppet/provider/neutron_plugin_cisco/ini_setting.rb index 4bc621a06..e76adb4ea 100644 --- a/lib/puppet/provider/neutron_plugin_cisco/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_cisco/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_cisco).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/cisco/cisco_plugins.ini' end diff --git a/lib/puppet/provider/neutron_plugin_cisco_credentials/ini_setting.rb b/lib/puppet/provider/neutron_plugin_cisco_credentials/ini_setting.rb index 758b1ed16..5362fa7bc 100644 --- a/lib/puppet/provider/neutron_plugin_cisco_credentials/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_cisco_credentials/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_cisco_credentials).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/cisco/credentials.ini' end diff --git a/lib/puppet/provider/neutron_plugin_cisco_db_conn/ini_setting.rb b/lib/puppet/provider/neutron_plugin_cisco_db_conn/ini_setting.rb index 472132fc1..eb673f073 100644 --- a/lib/puppet/provider/neutron_plugin_cisco_db_conn/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_cisco_db_conn/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_cisco_db_conn).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/cisco/db_conn.ini' end diff --git a/lib/puppet/provider/neutron_plugin_cisco_l2network/ini_setting.rb b/lib/puppet/provider/neutron_plugin_cisco_l2network/ini_setting.rb index 07b223eac..255b94074 100644 --- a/lib/puppet/provider/neutron_plugin_cisco_l2network/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_cisco_l2network/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_cisco_l2network).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/cisco/l2network_plugin.ini' end diff --git a/lib/puppet/provider/neutron_plugin_linuxbridge/ini_setting.rb b/lib/puppet/provider/neutron_plugin_linuxbridge/ini_setting.rb index 8d6c9a748..6bfe51b7f 100644 --- a/lib/puppet/provider/neutron_plugin_linuxbridge/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_linuxbridge/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_linuxbridge).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini' end diff --git a/lib/puppet/provider/neutron_plugin_midonet/ini_setting.rb b/lib/puppet/provider/neutron_plugin_midonet/ini_setting.rb index ad3e48313..098d18a0d 100644 --- a/lib/puppet/provider/neutron_plugin_midonet/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_midonet/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_midonet).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/midonet/midonet.ini' end diff --git a/lib/puppet/provider/neutron_plugin_ml2/ini_setting.rb b/lib/puppet/provider/neutron_plugin_ml2/ini_setting.rb index 9f724b517..d4bdef132 100644 --- a/lib/puppet/provider/neutron_plugin_ml2/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_ml2/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_ml2).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/ml2/ml2_conf.ini' end diff --git a/lib/puppet/provider/neutron_plugin_nvp/ini_setting.rb b/lib/puppet/provider/neutron_plugin_nvp/ini_setting.rb index b967f486c..ab1918dfd 100644 --- a/lib/puppet/provider/neutron_plugin_nvp/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_nvp/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_nvp).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/nicira/nvp.ini' end diff --git a/lib/puppet/provider/neutron_plugin_opencontrail/ini_setting.rb b/lib/puppet/provider/neutron_plugin_opencontrail/ini_setting.rb index dd882e5f7..bef3f10fa 100644 --- a/lib/puppet/provider/neutron_plugin_opencontrail/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_opencontrail/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_opencontrail).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini' end diff --git a/lib/puppet/provider/neutron_plugin_plumgrid/ini_setting.rb b/lib/puppet/provider/neutron_plugin_plumgrid/ini_setting.rb index f7ab15679..4e1fcfe92 100644 --- a/lib/puppet/provider/neutron_plugin_plumgrid/ini_setting.rb +++ b/lib/puppet/provider/neutron_plugin_plumgrid/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plugin_plumgrid).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/plumgrid/plumgrid.ini' end diff --git a/lib/puppet/provider/neutron_plumlib_plumgrid/ini_setting.rb b/lib/puppet/provider/neutron_plumlib_plumgrid/ini_setting.rb index c65a4d7cf..67f1ace6f 100644 --- a/lib/puppet/provider/neutron_plumlib_plumgrid/ini_setting.rb +++ b/lib/puppet/provider/neutron_plumlib_plumgrid/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_plumlib_plumgrid).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/plugins/plumgrid/plumlib.ini' end diff --git a/lib/puppet/provider/neutron_vpnaas_agent_config/ini_setting.rb b/lib/puppet/provider/neutron_vpnaas_agent_config/ini_setting.rb index ee6b74425..f49c5812c 100644 --- a/lib/puppet/provider/neutron_vpnaas_agent_config/ini_setting.rb +++ b/lib/puppet/provider/neutron_vpnaas_agent_config/ini_setting.rb @@ -1,20 +1,8 @@ Puppet::Type.type(:neutron_vpnaas_agent_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def file_path '/etc/neutron/vpn_agent.ini' end diff --git a/lib/puppet/type/neutron_agent_linuxbridge.rb b/lib/puppet/type/neutron_agent_linuxbridge.rb index 425722a35..5e75bbf38 100644 --- a/lib/puppet/type/neutron_agent_linuxbridge.rb +++ b/lib/puppet/type/neutron_agent_linuxbridge.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_agent_linuxbridge) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron-plugin-linuxbridge-agent' end diff --git a/lib/puppet/type/neutron_agent_ovs.rb b/lib/puppet/type/neutron_agent_ovs.rb index e491154ae..df4e4c98b 100644 --- a/lib/puppet/type/neutron_agent_ovs.rb +++ b/lib/puppet/type/neutron_agent_ovs.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_agent_ovs) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron-ovs-agent' end diff --git a/lib/puppet/type/neutron_api_config.rb b/lib/puppet/type/neutron_api_config.rb index eed70e105..6b6ef9f73 100644 --- a/lib/puppet/type/neutron_api_config.rb +++ b/lib/puppet/type/neutron_api_config.rb @@ -40,4 +40,9 @@ Puppet::Type.newtype(:neutron_api_config) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + end diff --git a/lib/puppet/type/neutron_config.rb b/lib/puppet/type/neutron_config.rb index b95c16fd5..0570def1d 100644 --- a/lib/puppet/type/neutron_config.rb +++ b/lib/puppet/type/neutron_config.rb @@ -14,6 +14,7 @@ Puppet::Type.newtype(:neutron_config) do value.capitalize! if value =~ /^(true|false)$/i value end + newvalues(/^[\S ]*$/) def is_to_s( currentvalue ) if resource.secret? @@ -40,6 +41,11 @@ Puppet::Type.newtype(:neutron_config) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + def create provider.create end diff --git a/lib/puppet/type/neutron_dhcp_agent_config.rb b/lib/puppet/type/neutron_dhcp_agent_config.rb index fbba16e7f..befc01873 100644 --- a/lib/puppet/type/neutron_dhcp_agent_config.rb +++ b/lib/puppet/type/neutron_dhcp_agent_config.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_dhcp_agent_config) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron' end diff --git a/lib/puppet/type/neutron_fwaas_service_config.rb b/lib/puppet/type/neutron_fwaas_service_config.rb index 65112e0f7..1d60c7e18 100644 --- a/lib/puppet/type/neutron_fwaas_service_config.rb +++ b/lib/puppet/type/neutron_fwaas_service_config.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_fwaas_service_config) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron-fwaas' end diff --git a/lib/puppet/type/neutron_l3_agent_config.rb b/lib/puppet/type/neutron_l3_agent_config.rb index 1b862040e..569350f3e 100644 --- a/lib/puppet/type/neutron_l3_agent_config.rb +++ b/lib/puppet/type/neutron_l3_agent_config.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_l3_agent_config) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron' end diff --git a/lib/puppet/type/neutron_lbaas_agent_config.rb b/lib/puppet/type/neutron_lbaas_agent_config.rb index 03ce9173d..a599a6f6a 100644 --- a/lib/puppet/type/neutron_lbaas_agent_config.rb +++ b/lib/puppet/type/neutron_lbaas_agent_config.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_lbaas_agent_config) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron-lbaas-agent' end diff --git a/lib/puppet/type/neutron_metadata_agent_config.rb b/lib/puppet/type/neutron_metadata_agent_config.rb index 625246d74..b7034b2e3 100644 --- a/lib/puppet/type/neutron_metadata_agent_config.rb +++ b/lib/puppet/type/neutron_metadata_agent_config.rb @@ -40,6 +40,11 @@ Puppet::Type.newtype(:neutron_metadata_agent_config) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron' end diff --git a/lib/puppet/type/neutron_metering_agent_config.rb b/lib/puppet/type/neutron_metering_agent_config.rb index 2509c6cfc..8a526be0b 100644 --- a/lib/puppet/type/neutron_metering_agent_config.rb +++ b/lib/puppet/type/neutron_metering_agent_config.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_metering_agent_config) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do ['neutron', 'neutron-metering-agent'] end diff --git a/lib/puppet/type/neutron_plugin_cisco.rb b/lib/puppet/type/neutron_plugin_cisco.rb index b7989f39c..b7a85ae90 100644 --- a/lib/puppet/type/neutron_plugin_cisco.rb +++ b/lib/puppet/type/neutron_plugin_cisco.rb @@ -40,6 +40,11 @@ Puppet::Type.newtype(:neutron_plugin_cisco) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:file) do ['/etc/neutron/plugins/cisco'] end diff --git a/lib/puppet/type/neutron_plugin_cisco_credentials.rb b/lib/puppet/type/neutron_plugin_cisco_credentials.rb index 08c71dede..aaa4143c2 100644 --- a/lib/puppet/type/neutron_plugin_cisco_credentials.rb +++ b/lib/puppet/type/neutron_plugin_cisco_credentials.rb @@ -41,6 +41,11 @@ Puppet::Type.newtype(:neutron_plugin_cisco_credentials) do end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:file) do ['/etc/neutron/plugins/cisco'] end diff --git a/lib/puppet/type/neutron_plugin_cisco_db_conn.rb b/lib/puppet/type/neutron_plugin_cisco_db_conn.rb index e4c1f5d94..6c94cb24f 100644 --- a/lib/puppet/type/neutron_plugin_cisco_db_conn.rb +++ b/lib/puppet/type/neutron_plugin_cisco_db_conn.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_plugin_cisco_db_conn) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:file) do ['/etc/neutron/plugins/cisco'] end diff --git a/lib/puppet/type/neutron_plugin_cisco_l2network.rb b/lib/puppet/type/neutron_plugin_cisco_l2network.rb index c05ab8ae4..bba6fb036 100644 --- a/lib/puppet/type/neutron_plugin_cisco_l2network.rb +++ b/lib/puppet/type/neutron_plugin_cisco_l2network.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_plugin_cisco_l2network) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:file) do ['/etc/neutron/plugins/cisco'] end diff --git a/lib/puppet/type/neutron_plugin_linuxbridge.rb b/lib/puppet/type/neutron_plugin_linuxbridge.rb index 1c848744b..81e9fa90a 100644 --- a/lib/puppet/type/neutron_plugin_linuxbridge.rb +++ b/lib/puppet/type/neutron_plugin_linuxbridge.rb @@ -15,4 +15,10 @@ Puppet::Type.newtype(:neutron_plugin_linuxbridge) do value end end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + end diff --git a/lib/puppet/type/neutron_plugin_midonet.rb b/lib/puppet/type/neutron_plugin_midonet.rb index f68dac23a..43aaeec95 100644 --- a/lib/puppet/type/neutron_plugin_midonet.rb +++ b/lib/puppet/type/neutron_plugin_midonet.rb @@ -7,10 +7,6 @@ Puppet::Type.newtype(:neutron_plugin_midonet) do newvalues(/\S+\/\S+/) end - autorequire(:file) do - ['/etc/neutron/plugins/midonet'] - end - autorequire(:package) do ['neutron'] end newproperty(:value) do @@ -46,9 +42,17 @@ Puppet::Type.newtype(:neutron_plugin_midonet) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + + autorequire(:file) do + ['/etc/neutron/plugins/midonet'] + end + autorequire(:package) do 'python-neutron-plugin-midonet' end - end diff --git a/lib/puppet/type/neutron_plugin_ml2.rb b/lib/puppet/type/neutron_plugin_ml2.rb index b6bef9159..0ac513739 100644 --- a/lib/puppet/type/neutron_plugin_ml2.rb +++ b/lib/puppet/type/neutron_plugin_ml2.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_plugin_ml2) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do ['neutron', 'neutron-plugin-ml2'] end diff --git a/lib/puppet/type/neutron_plugin_nvp.rb b/lib/puppet/type/neutron_plugin_nvp.rb index c4d2a2bd9..0bef0709d 100644 --- a/lib/puppet/type/neutron_plugin_nvp.rb +++ b/lib/puppet/type/neutron_plugin_nvp.rb @@ -40,6 +40,11 @@ Puppet::Type.newtype(:neutron_plugin_nvp) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do 'neutron-plugin-nvp' end diff --git a/lib/puppet/type/neutron_plugin_opencontrail.rb b/lib/puppet/type/neutron_plugin_opencontrail.rb index b35476347..b4e7bc6af 100644 --- a/lib/puppet/type/neutron_plugin_opencontrail.rb +++ b/lib/puppet/type/neutron_plugin_opencontrail.rb @@ -40,6 +40,11 @@ Puppet::Type.newtype(:neutron_plugin_opencontrail) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:file) do ['/etc/neutron/plugins/opencontrail'] end diff --git a/lib/puppet/type/neutron_plugin_plumgrid.rb b/lib/puppet/type/neutron_plugin_plumgrid.rb index 577734f91..d1d4b46a4 100644 --- a/lib/puppet/type/neutron_plugin_plumgrid.rb +++ b/lib/puppet/type/neutron_plugin_plumgrid.rb @@ -40,6 +40,11 @@ Puppet::Type.newtype(:neutron_plugin_plumgrid) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:file) do ['/etc/neutron/plugins/plumgrid'] end diff --git a/lib/puppet/type/neutron_plumlib_plumgrid.rb b/lib/puppet/type/neutron_plumlib_plumgrid.rb index e5b43a5ae..5109a9f0e 100644 --- a/lib/puppet/type/neutron_plumlib_plumgrid.rb +++ b/lib/puppet/type/neutron_plumlib_plumgrid.rb @@ -40,6 +40,11 @@ Puppet::Type.newtype(:neutron_plumlib_plumgrid) do defaultto false end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:file) do ['/etc/neutron/plugins/plumgrid'] end diff --git a/lib/puppet/type/neutron_vpnaas_agent_config.rb b/lib/puppet/type/neutron_vpnaas_agent_config.rb index 14ad0c956..4e56da3f0 100644 --- a/lib/puppet/type/neutron_vpnaas_agent_config.rb +++ b/lib/puppet/type/neutron_vpnaas_agent_config.rb @@ -16,6 +16,11 @@ Puppet::Type.newtype(:neutron_vpnaas_agent_config) do end end + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + autorequire(:package) do ['neutron', 'neutron-vpnaas-agent'] end diff --git a/spec/acceptance/neutron_config_spec.rb b/spec/acceptance/neutron_config_spec.rb new file mode 100644 index 000000000..2c7bc3b23 --- /dev/null +++ b/spec/acceptance/neutron_config_spec.rb @@ -0,0 +1,506 @@ +require 'spec_helper_acceptance' + +describe 'basic neutron_config resource' do + + context 'default parameters' do + + it 'should work with no errors' do + pp= <<-EOS + Exec { logoutput => 'on_failure' } + + File <||> -> Neutron_config <||> + File <||> -> Neutron_api_config <||> + File <||> -> Neutron_dhcp_agent_config <||> + File <||> -> Neutron_fwaas_service_config <||> + File <||> -> Neutron_l3_agent_config <||> + File <||> -> Neutron_lbaas_agent_config <||> + File <||> -> Neutron_metadata_agent_config <||> + File <||> -> Neutron_metering_agent_config <||> + File <||> -> Neutron_plugin_cisco <||> + File <||> -> Neutron_plugin_cisco_credentials <||> + File <||> -> Neutron_plugin_cisco_db_conn <||> + File <||> -> Neutron_plugin_cisco_l2network <||> + File <||> -> Neutron_plugin_linuxbridge <||> + File <||> -> Neutron_plugin_ml2 <||> + File <||> -> Neutron_plugin_nvp <||> + File <||> -> Neutron_vpnaas_agent_config <||> + File <||> -> Neutron_plugin_midonet <||> + File <||> -> Neutron_plugin_opencontrail <||> + File <||> -> Neutron_agent_linuxbridge <||> + File <||> -> Neutron_agent_ovs <||> + File <||> -> Neutron_plugin_plumgrid <||> + File <||> -> Neutron_plumlib_plumgrid <||> + + $neutron_directories = ['/etc/neutron', + '/etc/neutron/plugins', + '/etc/neutron/plugins/cisco', + '/etc/neutron/plugins/linuxbridge', + '/etc/neutron/plugins/ml2', + '/etc/neutron/plugins/nicira', + '/etc/neutron/plugins/midonet', + '/etc/neutron/plugins/opencontrail', + '/etc/neutron/plugins/plumgrid'] + + $neutron_files = [ '/etc/neutron/api-paste.ini', + '/etc/neutron/neutron.conf', + '/etc/neutron/dhcp_agent.ini', + '/etc/neutron/fwaas_driver.ini', + '/etc/neutron/l3_agent.ini', + '/etc/neutron/lbaas_agent.ini', + '/etc/neutron/metadata_agent.ini', + '/etc/neutron/metering_agent.ini', + '/etc/neutron/plugins/cisco/cisco_plugins.ini', + '/etc/neutron/plugins/cisco/credentials.ini', + '/etc/neutron/plugins/cisco/db_conn.ini', + '/etc/neutron/plugins/cisco/l2network_plugin.ini', + '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini', + '/etc/neutron/plugins/ml2/ml2_conf.ini', + '/etc/neutron/plugins/nicira/nvp.ini', + '/etc/neutron/vpn_agent.ini', + '/etc/neutron/plugins/midonet/midonet.ini', + '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', + '/etc/neutron/plugins/plumgrid/plumgrid.ini'] + + file { $neutron_directories : + ensure => directory, + } + + file { $neutron_files : + ensure => file, + } + + neutron_api_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_api_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_api_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_api_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_dhcp_agent_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_dhcp_agent_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_dhcp_agent_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_dhcp_agent_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_fwaas_service_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_fwaas_service_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_fwaas_service_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_fwaas_service_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_l3_agent_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_l3_agent_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_l3_agent_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_l3_agent_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_lbaas_agent_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_lbaas_agent_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_lbaas_agent_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_lbaas_agent_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_metadata_agent_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_metadata_agent_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_metadata_agent_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_metadata_agent_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_metering_agent_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_metering_agent_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_metering_agent_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_metering_agent_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_cisco { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_cisco { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco_credentials { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_cisco_credentials { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_cisco_credentials { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco_credentials { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco_db_conn { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_cisco_db_conn { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_cisco_db_conn { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco_db_conn { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco_l2network { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_cisco_l2network { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_cisco_l2network { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_cisco_l2network { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_linuxbridge { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_linuxbridge { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_linuxbridge { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_linuxbridge { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_ml2 { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_ml2 { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_ml2 { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_ml2 { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_nvp { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_nvp { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_nvp { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_nvp { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_vpnaas_agent_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_vpnaas_agent_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_vpnaas_agent_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_vpnaas_agent_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_midonet { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_midonet { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_midonet { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_midonet { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_opencontrail { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_opencontrail { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_opencontrail { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_opencontrail { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_agent_linuxbridge { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_agent_linuxbridge { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_agent_linuxbridge { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_agent_linuxbridge { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_agent_ovs { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_agent_ovs { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_agent_ovs { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_agent_ovs { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plugin_plumgrid { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plugin_plumgrid { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plugin_plumgrid { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plugin_plumgrid { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + neutron_plumlib_plumgrid { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + neutron_plumlib_plumgrid { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + neutron_plumlib_plumgrid { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + neutron_plumlib_plumgrid { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + EOS + + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + $neutron_files = [ '/etc/neutron/api-paste.ini', + '/etc/neutron/neutron.conf', + '/etc/neutron/dhcp_agent.ini', + '/etc/neutron/fwaas_driver.ini', + '/etc/neutron/l3_agent.ini', + '/etc/neutron/lbaas_agent.ini', + '/etc/neutron/metadata_agent.ini', + '/etc/neutron/metering_agent.ini', + '/etc/neutron/plugins/cisco/cisco_plugins.ini', + '/etc/neutron/plugins/cisco/credentials.ini', + '/etc/neutron/plugins/cisco/db_conn.ini', + '/etc/neutron/plugins/cisco/l2network_plugin.ini', + '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini', + '/etc/neutron/plugins/ml2/ml2_conf.ini', + '/etc/neutron/plugins/nicira/nvp.ini', + '/etc/neutron/vpn_agent.ini', + '/etc/neutron/plugins/midonet/midonet.ini', + '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', + '/etc/neutron/plugins/plumgrid/plumgrid.ini'] + + $neutron_files.each do |neutron_conf_file| + describe file(neutron_conf_file) do + it { should exist } + it { should contain('thisshouldexist=foo') } + it { should contain('thisshouldexist2=') } + + its(:content) { should_not match /thisshouldnotexist/ } + end + end + + end +end diff --git a/spec/unit/provider/neutron_agent_linuxbridge/ini_setting_spec.rb b/spec/unit/provider/neutron_agent_linuxbridge/ini_setting_spec.rb index bdd11d188..1f915e706 100644 --- a/spec/unit/provider/neutron_agent_linuxbridge/ini_setting_spec.rb +++ b/spec/unit/provider/neutron_agent_linuxbridge/ini_setting_spec.rb @@ -9,6 +9,17 @@ $LOAD_PATH.push( 'inifile', 'lib') ) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) require 'spec_helper' @@ -41,4 +52,23 @@ describe provider_class do expect(provider.setting).to eq('foo') expect(provider.file_path).to eq('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini') end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_agent_linuxbridge.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_agent_linuxbridge.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + end diff --git a/spec/unit/provider/neutron_agent_ovs/ini_setting_spec.rb b/spec/unit/provider/neutron_agent_ovs/ini_setting_spec.rb index 5b70360f4..f851f7197 100644 --- a/spec/unit/provider/neutron_agent_ovs/ini_setting_spec.rb +++ b/spec/unit/provider/neutron_agent_ovs/ini_setting_spec.rb @@ -9,6 +9,17 @@ $LOAD_PATH.push( 'inifile', 'lib') ) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) require 'spec_helper' diff --git a/spec/unit/provider/neutron_api_config/ini_setting_spec.rb b/spec/unit/provider/neutron_api_config/ini_setting_spec.rb new file mode 100644 index 000000000..3855d4327 --- /dev/null +++ b/spec/unit/provider/neutron_api_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_api_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_api_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/api-paste.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_api_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/api-paste.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_api_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_api_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_dhcp_agent_config/ini_setting_spec.rb b/spec/unit/provider/neutron_dhcp_agent_config/ini_setting_spec.rb new file mode 100644 index 000000000..983f7f926 --- /dev/null +++ b/spec/unit/provider/neutron_dhcp_agent_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_dhcp_agent_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_dhcp_agent_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/dhcp_agent.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_dhcp_agent_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/dhcp_agent.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_dhcp_agent_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_dhcp_agent_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_fwaas_service_config/ini_setting_spec.rb b/spec/unit/provider/neutron_fwaas_service_config/ini_setting_spec.rb new file mode 100644 index 000000000..d837974ea --- /dev/null +++ b/spec/unit/provider/neutron_fwaas_service_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_fwaas_service_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_fwaas_service_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/fwaas_driver.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_fwaas_service_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/fwaas_driver.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_fwaas_service_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_fwaas_service_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_l3_agent_config/ini_setting_spec.rb b/spec/unit/provider/neutron_l3_agent_config/ini_setting_spec.rb new file mode 100644 index 000000000..0226422d2 --- /dev/null +++ b/spec/unit/provider/neutron_l3_agent_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_l3_agent_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_l3_agent_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/l3_agent.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_l3_agent_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/l3_agent.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_l3_agent_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_l3_agent_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_lbaas_agent_config/ini_setting_spec.rb b/spec/unit/provider/neutron_lbaas_agent_config/ini_setting_spec.rb new file mode 100644 index 000000000..e08a031fb --- /dev/null +++ b/spec/unit/provider/neutron_lbaas_agent_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_lbaas_agent_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_lbaas_agent_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/lbaas_agent.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_lbaas_agent_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/lbaas_agent.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_lbaas_agent_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_lbaas_agent_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_metadata_agent_config/ini_setting_spec.rb b/spec/unit/provider/neutron_metadata_agent_config/ini_setting_spec.rb new file mode 100644 index 000000000..05a717a92 --- /dev/null +++ b/spec/unit/provider/neutron_metadata_agent_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_metadata_agent_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_metadata_agent_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/metadata_agent.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_metadata_agent_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/metadata_agent.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_metadata_agent_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_metadata_agent_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_metering_agent_config/ini_setting_spec.rb b/spec/unit/provider/neutron_metering_agent_config/ini_setting_spec.rb new file mode 100644 index 000000000..5bf8c8a53 --- /dev/null +++ b/spec/unit/provider/neutron_metering_agent_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_metering_agent_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_metering_agent_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/metering_agent.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_metering_agent_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/metering_agent.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_metering_agent_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_metering_agent_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_cisco/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_cisco/ini_setting_spec.rb new file mode 100644 index 000000000..33c03a274 --- /dev/null +++ b/spec/unit/provider/neutron_plugin_cisco/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_plugin_cisco).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_plugin_cisco.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/cisco_plugins.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_plugin_cisco.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/cisco_plugins.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_plugin_cisco.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_plugin_cisco.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_cisco_credentials/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_cisco_credentials/ini_setting_spec.rb new file mode 100644 index 000000000..4596e888c --- /dev/null +++ b/spec/unit/provider/neutron_plugin_cisco_credentials/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_plugin_cisco_credentials).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_plugin_cisco_credentials.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/credentials.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_plugin_cisco_credentials.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/credentials.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_plugin_cisco_credentials.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_plugin_cisco_credentials.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_cisco_db_conn/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_cisco_db_conn/ini_setting_spec.rb new file mode 100644 index 000000000..056cbf944 --- /dev/null +++ b/spec/unit/provider/neutron_plugin_cisco_db_conn/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_plugin_cisco_db_conn).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_plugin_cisco_db_conn.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/db_conn.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_plugin_cisco_db_conn.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/db_conn.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_plugin_cisco_db_conn.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_plugin_cisco_db_conn.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_cisco_l2network/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_cisco_l2network/ini_setting_spec.rb new file mode 100644 index 000000000..93d3a801f --- /dev/null +++ b/spec/unit/provider/neutron_plugin_cisco_l2network/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_plugin_cisco_l2network).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_plugin_cisco_l2network.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/l2network_plugin.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_plugin_cisco_l2network.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/cisco/l2network_plugin.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_plugin_cisco_l2network.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_plugin_cisco_l2network.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_midonet/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_midonet/ini_setting_spec.rb new file mode 100644 index 000000000..42597b5a8 --- /dev/null +++ b/spec/unit/provider/neutron_plugin_midonet/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_plugin_midonet).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_plugin_midonet.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/midonet/midonet.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_plugin_midonet.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/midonet/midonet.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_plugin_midonet.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_plugin_midonet.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_ml2/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_ml2/ini_setting_spec.rb new file mode 100644 index 000000000..6a3427bfb --- /dev/null +++ b/spec/unit/provider/neutron_plugin_ml2/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_plugin_ml2).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_plugin_ml2.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/ml2/ml2_conf.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_plugin_ml2.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/ml2/ml2_conf.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_plugin_ml2.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_plugin_ml2.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_nvp/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_nvp/ini_setting_spec.rb new file mode 100644 index 000000000..bc8dee0ce --- /dev/null +++ b/spec/unit/provider/neutron_plugin_nvp/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_plugin_nvp).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_plugin_nvp.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/nicira/nvp.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_plugin_nvp.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/plugins/nicira/nvp.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_plugin_nvp.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_plugin_nvp.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/neutron_plugin_opencontrail/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_opencontrail/ini_setting_spec.rb index 80711e166..86af8c847 100644 --- a/spec/unit/provider/neutron_plugin_opencontrail/ini_setting_spec.rb +++ b/spec/unit/provider/neutron_plugin_opencontrail/ini_setting_spec.rb @@ -9,6 +9,17 @@ $LOAD_PATH.push( 'inifile', 'lib') ) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) require 'spec_helper' diff --git a/spec/unit/provider/neutron_plugin_plumgrid/ini_setting_spec.rb b/spec/unit/provider/neutron_plugin_plumgrid/ini_setting_spec.rb index bb5667d1c..31b2506e2 100644 --- a/spec/unit/provider/neutron_plugin_plumgrid/ini_setting_spec.rb +++ b/spec/unit/provider/neutron_plugin_plumgrid/ini_setting_spec.rb @@ -9,6 +9,17 @@ $LOAD_PATH.push( 'inifile', 'lib') ) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) require 'spec_helper' diff --git a/spec/unit/provider/neutron_plumlib_plumgrid/ini_setting_spec.rb b/spec/unit/provider/neutron_plumlib_plumgrid/ini_setting_spec.rb index 358eab90b..ee1613316 100644 --- a/spec/unit/provider/neutron_plumlib_plumgrid/ini_setting_spec.rb +++ b/spec/unit/provider/neutron_plumlib_plumgrid/ini_setting_spec.rb @@ -9,6 +9,17 @@ $LOAD_PATH.push( 'inifile', 'lib') ) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) require 'spec_helper' diff --git a/spec/unit/provider/neutron_vpnaas_agent_config/ini_setting_spec.rb b/spec/unit/provider/neutron_vpnaas_agent_config/ini_setting_spec.rb new file mode 100644 index 000000000..ce627f3cf --- /dev/null +++ b/spec/unit/provider/neutron_vpnaas_agent_config/ini_setting_spec.rb @@ -0,0 +1,74 @@ +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) + +require 'spec_helper' + +provider_class = Puppet::Type.type(:neutron_vpnaas_agent_config).provider(:ini_setting) + +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::Neutron_vpnaas_agent_config.new( + { + :name => 'DEFAULT/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/vpn_agent.ini') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::Neutron_vpnaas_agent_config.new( + { + :name => 'dude/foo', + :value => 'bar' + } + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + expect(provider.file_path).to eq('/etc/neutron/vpn_agent.ini') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Neutron_vpnaas_agent_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Neutron_vpnaas_agent_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end diff --git a/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb b/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb index 2dd22a988..06e745e55 100644 --- a/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb +++ b/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb @@ -32,12 +32,12 @@ tenants_response = { ] } -# Stub for ini_setting resource -Puppet::Type.newtype(:ini_setting) do +# Stub for openstack_config resource +Puppet::Type.newtype(:openstack_config) do end -# Stub for ini_setting provider -Puppet::Type.newtype(:ini_setting).provide(:ruby) do +# Stub for openstack_config provider +Puppet::Type.newtype(:openstack_config).provide(:ini_setting) do def create end end