Skip to content

Conversation

willmeek
Copy link
Contributor

This commit adds the logfile_name, logfile_severity_level and logfile_size fields to syslog_settings for Cisco Nexus

@willmeek
Copy link
Contributor Author

Customer request. Requires the release of netdev-stdlib and the merging of cisco/cisco-network-node-utils#590

@shermdog
Copy link
Contributor

@willmeek there is an issue with this PR. If attempting to manage the size of a logfile entry that was not previously set, the provider does not issue any updates to the device and is not idempotent.

Manage logfile w/out size

    syslog_settings {'default':
      console                => 'unset',
      monitor                => 'unset',
      source_interface       => 'unset',
      time_stamp_units       => 'seconds',
      logfile_name           => 'testlogfile',
      logfile_severity_level => '3',
    }
Notice: /Stage[main]/Main/Node[default]/Syslog_settings[default]/logfile_severity_level: logfile_severity_level changed 'unset' to 3
Notice: /Stage[main]/Main/Node[default]/Syslog_settings[default]/logfile_name: logfile_name changed 'unset' to 'testlogfile'
Debug: Set state using data format 'cli'
Debug:   to value(s):
     logging logfile testlogfile 3 
Debug: Input (cli_conf): ' logging logfile testlogfile 3 '
Debug: Sending HTTP request to NX-API at localhost:
{"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], "accept"=>["*/*"], "user-agent"=>["Ruby"], "cookie"=>["nxapi_auth=admin:local"], "content-type"=>["application/json"]}
{"ins_api":{"version":"1.0","type":"cli_conf","chunk":"0","sid":"1","input":" logging logfile testlogfile 3 ","output_format":"json"}}
Debug: HTTP Response: OK
{
	"ins_api":	{
		"sid":	"eoc",
		"type":	"cli_conf",
		"version":	"1.0",
		"outputs":	{
			"output":	{
				"code":	"200",
				"msg":	"Success",
				"body":	{
			}
			}
		}
	}
}

Linux# /opt/puppetlabs/puppet/bin/puppet resource syslog_settings                  
syslog_settings { 'default':
  console                => 'unset',
  logfile_name           => 'testlogfile',
  logfile_severity_level => '3',
  logfile_size           => 'unset',
  monitor                => 'unset',
  source_interface       => ['unset'],
  time_stamp_units       => 'seconds',
}

Add logfile size

    syslog_settings {'default':
      console                => 'unset',
      monitor                => 'unset',
      source_interface       => 'unset',
      time_stamp_units       => 'seconds',
      logfile_name           => 'testlogfile',
      logfile_severity_level => '3',
      logfile_size           => '4098',
    }
Notice: /Stage[main]/Main/Node[default]/Syslog_settings[default]/logfile_size: logfile_size changed 'unset' to 4098
Debug: /Stage[main]/Main/Node[default]/Syslog_settings[default]: The container Node[default] will propagate my refresh event
Debug: Node[default]: The container Class[Main] will propagate my refresh event
Debug: Class[Main]: The container Stage[main] will propagate my refresh event
Debug: Executing: '/etc/init.d/pxp-agent status'
Debug: /Stage[main]/Puppet_enterprise::Profile::Agent/File[/opt/puppetlabs/puppet/cache/state/package_inventory_enabled]: Nothing to manage: no ensure and the resource doesn't exist
Debug: Finishing transaction 21714220
Debug: Storing state
Debug: Stored state in 0.04 seconds
Notice: Applied catalog in 0.42 seconds
Linux# /opt/puppetlabs/puppet/bin/puppet resource syslog_settings                  
syslog_settings { 'default':
  console                => 'unset',
  logfile_name           => 'testlogfile',
  logfile_severity_level => '3',
  logfile_size           => 'unset',
  monitor                => 'unset',
  source_interface       => ['unset'],
  time_stamp_units       => 'seconds',
}


#### Parameters

##### `name`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a caveats table and indicate that these properties are being added in version 1.10.0 of the module.

Here is an example:

https://github.com/cisco/cisco-network-puppet-module/blob/86132da1bbf4c4b34199675fb5e286100e68f0df/README.md#caveats-5

Also please add a link under the Caveats column in the support matrix.

https://github.com/cisco/cisco-network-puppet-module#resource-platform-support-matrix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mike, I have added the Caveat and link

README.md Outdated

##### `logfile_size`

Logging file maximum size [4096-2147483647]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The range will probably be dynamic on different NX-OS platforms so I would omit the range here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mike, removed the range (which simplifies the validation regex hugely! :) )

@willmeek willmeek force-pushed the syslog_settings_logfile branch from 86132da to 5d3f459 Compare August 29, 2018 10:26
@willmeek
Copy link
Contributor Author

@shermdog Good catch. I had assumed that the purge hash contained the logfile name, however if the size was the only change then this was not the case. Grab from the resource existing settings if that is the case. Added a beaker test.

@willmeek willmeek force-pushed the syslog_settings_logfile branch from 5d3f459 to ca9a096 Compare August 29, 2018 10:39
@mikewiebe
Copy link
Contributor

@willmeek Have you completed the changes and are just waiting for a final review?

@willmeek
Copy link
Contributor Author

willmeek commented Sep 6, 2018

@mikewiebe The changes should be there, awaiting final review, let me know if there is anything that needs changed / fixed, thanks! :)

(@resource[:logfile_severity_level] && !@resource[:logfile_name]))
fail ArgumentError,
'This provider requires that a logfile_name and logfile_severity_level are both specified in order '\
'to set logfile size.' if @resource[:logfile_size] && !@resource[:logfile_name] && !@resource[:logfile_severity_level]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit /logfile size/logfile_size/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mike, updated

@mikewiebe
Copy link
Contributor

One additional nit, otherwise 👍 Will merge once Rick approves.

@willmeek willmeek force-pushed the syslog_settings_logfile branch from ca9a096 to 22d9309 Compare September 6, 2018 13:12
@shermdog
Copy link
Contributor

shermdog commented Sep 6, 2018

@willmeek looks like the default resource output is clashing with current netdev_stdlib type definition:

[root@puppet-device-devel ~]# puppet device -v -t nxapi --resource syslog_settings --trace 
Info: retrieving resource: syslog_settings from nxapi at file:///root/nxapi.yaml
syslog_settings { 'default':
  console                => 2,
  logfile_name           => 'unset',
  logfile_severity_level => 'unset',
  logfile_size           => 'unset',
  monitor                => '5',
  source_interface       => ['unset'],
  time_stamp_units       => 'seconds',
}
Error: Parameter logfile_severity_level failed on Syslog_settings[default]: Munging failed for value "unset" in class logfile_severity_level: invalid value for Integer(): "unset" (file: /root/syslog.pp, line: 1)
/etc/puppetlabs/code/environments/production/modules/netdev_stdlib/lib/puppet/type/syslog_settings.rb:80:in `Integer'
/etc/puppetlabs/code/environments/production/modules/netdev_stdlib/lib/puppet/type/syslog_settings.rb:80:in `block (3 levels) in <top (required)>'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parameter.rb:423:in `munge'

It also looks like 'unset' is being configured as a long destination when logfile_name is 'unset', but severity level is set

syslog_settings {'default':
      console                => 'unset',
      monitor                => 'unset',
      source_interface       => 'unset',
      time_stamp_units       => 'seconds',
      logfile_name           => 'unset',
      logfile_severity_level => '3',
      logfile_size           => 'unset',
    }
Notice: /Stage[main]/Main/Syslog_settings[default]/logfile_severity_level: logfile_severity_level changed 'unset' to 3
Debug: Set state using data format 'cli'
Debug:   to value(s):
     logging logfile unset 3 
Debug: Input (cli_conf): ' logging logfile unset 3 '

nxos-local-1# sh run | inc log
logging logfile unset 3

This commit adds the logfile_name, logfile_severity_level and logfile_size fields to syslog_settings for Cisco Nexus
@willmeek willmeek force-pushed the syslog_settings_logfile branch from 22d9309 to fe39436 Compare September 10, 2018 14:43
@willmeek
Copy link
Contributor Author

@shermdog Thanks for the thoroughness :)

I have re-added 'unset' to logfile_severity_level in netdev stdlib puppetlabs/netdev_stdlib#47

And have amended the validation here to catch if we are trying to unset without unsetting the logfile_name (to avoid possible idempotency issues)

'unset' for the name not being 'unset' was the resource to property_flush field logic being in the wrong place.

@shermdog shermdog merged commit 83a1f92 into cisco:develop Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants