diff --git a/CHANGELOG.md b/CHANGELOG.md
index a42731e2f..04d8916e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,8 +2,29 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
-## [0.9.0] - 2015-06-22
+## [Unreleased]
+
+## [0.9.1] - 2015-08-13
+### Added
+- Added CONTRIBUTING.md
+- Added README-creating-types-providers.md and associated templates.
+- Added SUPPORT.md
+- Added Beaker test cases for cisco_command_config, file, package, and service providers.
+
+### Fixed
+- 'puppet resource cisco_vtp' now works properly.
+- cisco_interface, cisco_ospf_vrf, and cisco_vlan now properly handle destroy/recreate scenarios.
+- Added missing methods in cisco_ospf_vrf provider.
+- Style cleanup of many Beaker test scripts.
+- Fixed title pattern error in 'puppet resource cisco_snmp_group'.
+- Avoid inadvertently suppressing relevant exceptions.
+- Added dotted-decimal munging for area in cisco_interface_ospf
+- Modified template placeholder names to meet lint reqs
+
+## 0.9.0 - 2015-07-24
### Added
-- Initial release of cisco-ciscolib_nxos module for puppet, supporting Cisco NX-OS software release 7.0(3)I2(1) on Cisco Nexus switch platforms: N95xx, N93xx, N30xx and N31xx.
+- Initial release of puppetlabs-ciscopuppet module, supporting Cisco NX-OS software release 7.0(3)I2(1) on Cisco Nexus switch platforms: N95xx, N93xx, N30xx and N31xx.
- Please note: 0.9.0 is an EFT pre-release for a limited audience with access to NX-OS 7.0(3)I2(1). Additional code changes may occur in 0.9.x prior to the final 1.0.0 release.
+[unreleased]: https://github.com/cisco/cisco-network-puppet-module/compare/v0.9.1...develop
+[0.9.1]: https://github.com/cisco/cisco-network-puppet-module/compare/v0.9.0...v0.9.1
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..abafa0cf9
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,36 @@
+# How to Contribute
+Cisco Network Elements support a rich set of features to make networks robust, efficient and secure. This project enables Cisco Network Elements to be managed by Puppet by defining a set of resource types and providers. This set is expected to grow with contributions from Cisco, Puppet Labs and third-party alike. Contributions to this project are welcome. To ensure code quality, contributers will be requested to follow a few guidelines.
+
+## Getting Started
+
+* Create a [GitHub account](https://github.com/signup/free)
+* Make sure you have a [cisco.com](http://cisco.com) account, if you need access to a Network Simulator to test your code.
+
+## Making Changes
+
+* Fork the repository
+* Pull a branch under the "develop" branch for your changes.
+* Follow all guidelines documented in [README-creating-types-providers](#README-creating-types-providers.md)
+* Make changes in your branch.
+* Testing
+ * TBD: Add beaker test cases to validate your changes.
+ * Run all the tests to ensure there was no collateral damage to existing code.
+ * Check for unnecessary whitespace with `git diff --check`
+ * Run `rubocop --lint` against all changed files. See [https://rubygems.org/gems/rubocop](https://rubygems.org/gems/rubocop)
+ * TBD: Run [puppet-lint](https://rubygems.org/gems/puppet-lint) against changed files.
+* For new resources, add a 'demo' entry to examples/demo_install.rb
+* Ensure that your commit messages clearly describe the problem you are trying to solve and the proposed solution.
+
+## Submitting Changes
+
+* All contributions you submit to this project are voluntary and subject to the terms of the Apache 2.0 license.
+* Submit a pull request for commit approval to the "develop" branch.
+* A core team consisting of Cisco and Puppet Labs employees will looks at Pull Request and provide feedback.
+* After feedback has been given we expect responses within two weeks. After two weeks we may close the pull request if it isn't showing any activity.
+
+# Additional Resources
+
+* [General GitHub documentation](http://help.github.com/)
+* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
+* \#puppet-dev IRC channel on freenode.org ([Archive](https://botbot.me/freenode/puppet-dev/))
+* [puppet-dev mailing list](https://groups.google.com/forum/#!forum/puppet-dev)
diff --git a/README-AGENT-INSTALL.md b/README-AGENT-INSTALL.md
index f645084d7..0d85c2ba2 100644
--- a/README-AGENT-INSTALL.md
+++ b/README-AGENT-INSTALL.md
@@ -1,7 +1,7 @@
# Puppet Agent Installation & Setup: Cisco Nexus
----
-### _EARLY FIELD TRIAL:_ This is a puppet agent EFT for use with Cisco NX-OS release 7.0(3)I2(1). Please see the [Limitations](#limitations) section for more information.
+### _EARLY FIELD TRIAL:_ This is a Puppet agent EFT for use with Cisco NX-OS release 7.0(3)I2(1). Please see the [Limitations](#limitations) section for more information.
----
#### Table of Contents
@@ -11,23 +11,23 @@
3. [Puppet Agent Environment: bash-shell](#env-bs)
4. [Puppet Agent Environment: guestshell](#env-gs)
5. [Puppet Agent Installation, Configuration and Usage](#agent-config)
-6. [(optional) guestshell & High Availability (HA) Platforms](#ha)
-7. [(optional) Puppet Agent Persistence](#persistence)
-8. [(optional) Automated Installation Options](#auto-install)
+6. [Optional: Guestshell & High Availability (HA) Platforms](#ha)
+7. [Optional: Puppet Agent Persistence](#persistence)
+8. [Optional: Automated Installation Options](#auto-install)
9. [References](#references)
-10. [Known Issues](#issues)
## Overview
-This document describes Puppet agent installation and setup on Cisco Nexus switches. These instructions focus on manual setup. See [Automated Installation](#auto-install) section for documentation regarding alternative installation methods.
+This document describes Puppet agent installation and setup on Cisco Nexus switches. These instructions focus on manual setup. See the [Automated Installation](#auto-install) section for documentation regarding alternative installation methods.
-The Cisco NX-OS puppet implementation requires Puppet version 4.0 or newer.
+The Cisco NX-OS Puppet implementation requires open source Puppet version 4.0 or newer, or Puppet Enterprise 2015.2 or greater.
![1](puppet_outline.png)
## Pre-Install Tasks
#### Platform and Software Requirements
+
* Puppet 4.0 or higher
* Cisco NX-OS release 7.0(3)I2(1) or later
* Supported Platforms: Cisco Nexus 95xx, Nexus 93xx, Nexus 30xx, Nexus 31xx
@@ -35,26 +35,29 @@ The Cisco NX-OS puppet implementation requires Puppet version 4.0 or newer.
#### Disk space
400MB of free disk space on bootflash is recommended before installing the
-puppet agent software.
+Puppet agent software.
#### Environment
-NX-OS supports two possible environments for running 3rd party software:
+
+NX-OS supports two possible environments for running third party software:
`bash-shell` and `guestshell`. Choose one environment for running the
-puppet agent software. You may run puppet from either environment but not both
+Puppet agent software. You may run Puppet from either environment but not from both
at the same time.
* `bash-shell`
- * This is the native WRL linux environment underlying NX-OS. It is disabled by default.
+ * This is the native WRL Linux environment underlying NX-OS. It is disabled by default.
* `guestshell`
- * This is a secure linux container environment running CentOS. It is enabled by default in most platforms.
+ * This is a secure Linux container environment running CentOS. It is enabled by default in most platforms.
+
+#### Set Up the Network
-#### Network Setup
+Ensure that you have network connectivity prior to Puppet installation. Some basic NX-OS cli configuration may be necessary.
-Ensure that network connectivity exists prior to puppet install. Some basic NX-OS cli configuration may be necessary.
+**Example:** Connectivity via management interface
-**Example:** Connectivity via Management interface. _Note: The management interface exists in a separate VRF context and requires additional configuration as shown._
+_Note: The management interface exists in a separate VRF context and requires additional configuration as shown._
-```
+~~~
config term
ntp server 10.0.0.201 use-vrf management
@@ -67,71 +70,83 @@ config term
vrf member management
ip address 10.0.0.99/24
end
-```
+~~~
-#### NXAPI (EFT-only)
-NXAPI is a NX-OS feature that is required for ciscopuppet. NX-OS EFT images may have this feature disabled, while release images will have this feature enabled by default. Manually enable NXAPI with this syntax:
+#### Enable NXAPI (EFT-only)
-```
+NXAPI is a NX-OS feature that is required for ciscopuppet. NX-OS EFT images might have this feature disabled, while release images have this feature enabled by default. Manually enable NXAPI with this syntax:
+
+~~~
config term
feature nxapi
end
-```
+~~~
## Puppet Agent Environment: bash-shell
-This section is only necessary if puppet will run from the `bash-shell`.
+This section is only necessary if Puppet will run from the `bash-shell`.
-#### NX-OS Setup
+#### Set Up NX-OS
The `bash-shell` is disabled by default. Enable it with the feature configuration command.
-```
+~~~
config term
feature bash-shell
end
-```
+~~~
-#### Puppet Agent Install in bash-shell
+#### Install Puppet Agent in bash-shell
-Enter the `bash-shell` environment and become root.
+Enter the `bash-shell` environment and become root:
-```bash
+~~~bash
n3k# run bash
bash-4.2$
bash-4.2$ sudo su -
-```
+~~~
+
+If you're using the management interface, you must next switch to the management namespace:
-If using the management interface you must next switch to the management namespace
-```bash
+~~~bash
ip netns exec management bash
-```
+~~~
-Set up DNS configuration
-```
+Then set up DNS configuration:
+
+~~~
cat >> /etc/resolv.conf << EOF
nameserver 10.0.0.202
domain mycompany.com
search mycompany.com
EOF
-```
+~~~
+
+Optionally, configure a proxy server:
+
+~~~bash
+export http_proxy=http://proxy.yourdomain.com:
+export https_proxy=https://proxy.yourdomain.com:
+~~~
+
## Puppet Agent Environment: guestshell
-This section is only necessary if puppet will run from the `guestshell`.
+This section is only necessary if Puppet will run from the `guestshell`.
-#### NX-OS Setup
+#### Set Up NX-OS
-The `guestshell` container environment is enabled by default on most platforms; however, the default disk and memory resources allocated to the guestshell container may be too small to support puppet agent requirements. These resource limits may be increased with the NX-OS CLI `guestshell resize` commands as shown below.
+The `guestshell` container environment is enabled by default on most platforms; however, the default disk and memory resources allocated to the guestshell container might be too small to support Puppet agent requirements. These resource limits can be increased with the NX-OS CLI `guestshell resize` commands as shown below.
The recommended minimum values are currently:
-```bash
+
+~~~bash
Disk : 400MB
Memory : 300MB
-```
+~~~
Use the `show guestshell detail` command to display the current state of the guestshell:
-```
+~~~
n3k# show guestshell detail
Virtual service guestshell+ detail
State : Activated
@@ -140,13 +155,13 @@ Virtual service guestshell+ detail
Disk : 150 MB
Memory : 128 MB
-```
+~~~
-Use the `guestshell resize rootfs` command to resize the guestshell filesystem. Use the `guestshell resize memory` command to resize the guestshell memory allocation. These commands may be executed even when the guestshell is not yet enabled. Note that the resize command does not take effect until after the guestshell container is (re)started with the `guestshell reboot` or `guestshell enable` command.
+To resize the guestshell filesystem, use the `guestshell resize rootfs` command. To resize the guestshell memory allocation, use the `guestshell resize memory` command. These commands can be executed even when the guestshell is not yet enabled. Note that the resize command does not take effect until after the guestshell container is (re)started with the `guestshell reboot` or `guestshell enable` command.
-**Example.** Guestshell is currently enabled. Resize guestshell filesystem to 400MB and memory to 300MB
+**Example.** Guestshell is currently enabled. Resize guestshell filesystem to 400MB and memory to 300MB:
-```
+~~~
n3k# guestshell resize rootfs ?
<158-600> New root filesystem size (in MB)
@@ -159,11 +174,11 @@ Note: Please disable/enable or reboot the Guest shell for system memory to be re
n3k# guestshell reboot
Access to the guest shell will be temporarily disabled while it reboots.
Are you sure you want to reboot the guest shell? (y/n) [n] y
-```
+~~~
-**Example.** Guestshell is currently disabled. Resize guestshell filesystem to 400MB and memory to 300MB
+**Example.** Guestshell is currently disabled. Resize guestshell filesystem to 400MB and memory to 300MB:
-```
+~~~
n3k# guestshell resize rootfs 400
Note: Root filesystem will be resized on Guest shell enable
@@ -171,19 +186,19 @@ n3k# guestshell resize memory 300
Note: System memory will be resized on Guest shell enable
n3k# guestshell enable
-```
+~~~
See [References](#references) for more guestshell documentation.
-#### guestshell network setup
+#### Set Up Guestshell Network
-The `guestshell` is an independent CentOS container which doesn't inherit settings from NX-OS; thus it requires additional network configuration.
+The `guestshell` is an independent CentOS container that doesn't inherit settings from NX-OS; thus it requires additional network configuration.
-```bash
+~~~bash
# Enter the guestshell environment using the 'guestshell' command
guestshell
-# If using the management interface you must enter the management namespace
+# If using the management interface, you must enter the management namespace
sudo su -
chvrf management
@@ -197,51 +212,55 @@ nameserver 10.0.0.202
domain mycompany.com
search mycompany.com
EOF
-```
+~~~
-## Puppet Agent Installation, Configuration and Usage
+## Puppet Agent Installation, Configuration, and Usage
This section is common to both `bash-shell` and `guestshell`.
-#### Puppet Agent Install
+#### Install Puppet Agent
##### Special instructions for EFT customers
-EFT images may not have the updated platform family definitions needed for yum to differentiate between `bash-shell` and `guestshell` environments. Therefore the puppet-agent RPM will need to be specified explicitly during the installation:
+
+EFT images may not have the updated platform family definitions needed for yum to differentiate between `bash-shell` and `guestshell` environments. Therefore, the puppet-agent RPM needs to be specified explicitly during the installation:
* For `bash-shell` use:
-```bash
-yum install http://yum.puppetlabs.com/nxos/5/PC1/x86_64/puppetlabs-release-pc1-.nxos5.noarch.rpm
-yum install puppet
-```
+
+ ~~~bash
+ yum install http://yum.puppetlabs.com/nxos/5/PC1/x86_64/puppetlabs-release-pc1-.nxos5.noarch.rpm
+ yum install puppet
+ ~~~
* For `guestshell` use:
-```bash
-yum install http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
-yum install puppet
-```
+
+ ~~~bash
+ yum install http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
+ yum install puppet
+ ~~~
-Update PATH var
-```bash
+Update PATH var:
+
+~~~bash
export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/puppet/lib
-```
+~~~
-Edit the puppet config file:
+####Edit the Puppet config file:
**/etc/puppetlabs/puppet/puppet.conf**
-```bash
-# This file can be used to override the default puppet settings.
-# The following settings should be used at a minimum:
+This file can be used to override the default Puppet settings. At a minimum, the following settings should be used:
+~~~bash
[main]
server = mypuppetmaster.mycompany.com
[agent]
pluginsync = true
ignorecache = true
-```
+~~~
See the following references for more puppet.conf settings:
+
@@ -249,39 +268,38 @@ See the following references for more puppet.conf settings:
#### Run the Puppet Agent
-```bash
+~~~bash
puppet agent -t
-```
+~~~
+## Guestshell & High Availability (HA) Platforms
-## guestshell & High Availability (HA) Platforms
+Optional. This section discusses `guestshell` usage on HA platforms. This section does not apply to the bash-shell environment or to single-sup platforms.
-(Optional) This section discusses `guestshell` usage on HA platforms. This section does not apply to the bash-shell environment or to single-sup platforms.
+The `guestshell` container does not automatically sync filesystem changes from the active processor to the standby processor. This means that Puppet installation files and related file changes performed in the earlier steps will not be present on the standby until they are manually synced with the following NX-OS exec command:
-The `guestshell` container does not automatically sync filesystem changes from the active processor to the standby processor. This means that puppet installation files and related file changes performed in the earlier steps will not be present on the standby until they are manually synced with the following NX-OS exec command:
-
-```
+~~~
guestshell sync
-```
+~~~
## Puppet Agent Persistence
-(Optional) This section discusses puppet agent persistence after system restarts.
+Optional. This section discusses Puppet agent persistence after system restarts.
1. [Service Management in bash-shell using init.d](#svc-mgmt-bs)
2. [Service Management in guestshell using systemd](#svc-mgmt-gs)
#### Service Management
-It may be desirable to set up automatic restart of the puppet agent in the event of a system reset. The bash and guestshell environments use different methods to achieve this.
+It may be desirable to set up automatic restart of the Puppet agent in the event of a system reset. The bash and guestshell environments use different methods to achieve this.
-#### (optional) bash-shell / init.d
+#### Optional: bash-shell / init.d
The `bash-shell` environment uses **init.d** for service management.
**Example:** Create an initd script file as `/etc/init.d/puppet`
-```bash
+~~~bash
#!/bin/bash
#
# puppet Startup script
@@ -371,24 +389,24 @@ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force
exit 2
esac
exit $?
-```
+~~~
Next, add your service to initd management and optionally start it:
-```bash
+~~~bash
chkconfig --add puppet
chkconfig --level 345 puppet on
service puppet start
-```
+~~~
-#### (optional) guestshell / systemd
+#### Optional: guestshell / systemd
The `guestshell` environment uses **systemd** for service management.
-**Example:** Cut&paste the following to create a service file in `/usr/lib/systemd/system/`
+**Example:** Cut and paste the following to create a service file in `/usr/lib/systemd/system/`:
-```bash
+~~~bash
cat >> /usr/lib/systemd/system/my_puppet.service << EOF
@@ -412,19 +430,20 @@ RestartSec=42s
[Install]
WantedBy=multi-user.target
EOF
-```
-Now enable your puppet systemd service (the enable command adds it to systemd for autostarting the next time you boot) and optionally start it now.
+~~~
+
+Now enable your Puppet systemd service (the `enable` command adds it to systemd for autostarting the next time you boot) and optionally start it.
-```bash
+~~~bash
systemctl enable my_puppet
systemctl start my_puppet
-```
+~~~
## Automated Installation Options
-[Beaker](README-BEAKER.md) - Installing & Configuring puppet agent using the Beaker tool
+[Beaker](README-BEAKER.md) - Installing and Configuring Puppet Agent Using the Beaker Tool
## References
@@ -433,12 +452,8 @@ systemctl start my_puppet
[Cisco Nexus Programmability Guide](http://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/6-x/programmability/guide/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_chapter_01010.html) - Guestshell Documentation
-## Known Issues
-
-TBD
-
----
-```bash
+~~~
Copyright (c) 2014-2015 Cisco and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
@@ -452,4 +467,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-```
+~~~
diff --git a/README-BEAKER-TESTCASE-EXECUTION.md b/README-BEAKER-TESTCASE-EXECUTION.md
new file mode 100644
index 000000000..8d07162c9
--- /dev/null
+++ b/README-BEAKER-TESTCASE-EXECUTION.md
@@ -0,0 +1,50 @@
+# Beaker Test Case Execution For Cisco Systems' Puppet providers #
+
+## Beaker Test Environment ##
+
+The Beaker execution test environment for Cisco Systems' Puppet provider test cases on Nexus devices assumes that the following prerequisites are satisfied before start of execution:
+
+A. Install Beaker and Bundle software on a test server or VM that can ping both the Puppet master and agent successfully. The test server or VM used to execute Beaker test cases is distinct from the Puppet master and agent. Create the Beaker test environment on the test server or VM using this HTTPs wiki link as a reference: https://github.com/puppetlabs/beaker/wiki/Creating-A-Test-Environment.
+
+B. Populate the Beaker host configuration file on the test server or VM that is used to execute Beaker test cases.
+
+C. Enable SSH on the Nexus switch. No other Nexus switch specific configuration steps should be required for executing Beaker tests.
+
+D. Start the Puppet master.
+
+E. Configure SSL certificate exchange between Puppet master and agent.
+
+## Beaker Test Cases ##
+
+Each Puppet provider test case is implemented in a single Beaker test script. A test directory will consist of a suite of test scripts that test a single Puppet provider.
+
+The test case names follow the convention of testdirname-provider-defaults.rb or testdirname-provider-nondefaults.rb or testdirname-provider-negatives.rb. As the naming convention shows, the defaults testcase tests for default attribute values of a Puppet provider resource instance while the non-defaults testcase tests for non-default attribute values of a Puppet provider resource instance. The negative testcase tests for negative attribute values of a Puppet provider resource instance.
+
+## Beaker Test Case Execution ##
+
+A Beaker test case can be executed with these instructions:
+
+(1) cd to the directory that is the top-level for Beaker test directories. This is the repository based path: @cisco-ciscopuppet/tests/beaker_tests.
+
+(2) Execute the 'bundle exec beaker' command string from below with the mentioned options to do a testrun for all test cases under the @cisco-ciscopuppet/tests/beaker_tests directory. This will aggregate all test case results after a single test run.
+
+~~~
+beaker --hosts hosts.cfg \
+--pre-suite tests/beaker_tests/presuite/presuite-certcheck.rb \
+--no-validate --no-configure \
+--test tests/beaker_tests/*/*-provider-*.rb
+~~~
+
+The --debug option may be added if detailed Beaker testcode debug logs are desired.
+
+The --no-validate option disables validation of the host switch that is performed by default by the Beaker tool. This host validation will currently fail for Nexus platform.
+
+The --no-configure option prevents any host or VM images from being configured on the host switch that is performed by default by the Beaker tool. No such host configuration is necessary for executing Beaker tests.
+
+
+
+
+
+
+
+
diff --git a/README-BEAKER-TESTCASE-WRITING.md b/README-BEAKER-TESTCASE-WRITING.md
new file mode 100644
index 000000000..0f0f28dca
--- /dev/null
+++ b/README-BEAKER-TESTCASE-WRITING.md
@@ -0,0 +1,40 @@
+# Beaker Test Case Writing For Cisco Systems' Puppet providers #
+
+
+## Beaker Test Cases ##
+
+Each Puppet provider test case is implemented in a single Beaker test script. A test directory will consist of a suite of test scripts that test a single Puppet provider.
+
+The test case names follow the convention of testdirname-provider-defaults.rb or testdirname-provider-nondefaults.rb or testdirname-provider-negatives.rb. As the naming convention shows, the defaults testcase tests for default attribute values of a Puppet provider resource instance while the non-defaults testcase tests for non-default attribute values of a Puppet provider resource instance. The negative testcase tests for negative attribute values of a Puppet provider resource instance.
+
+## Beaker Test Case Sections ##
+
+Every Beaker test case is expected to have:
+
+- a test case setup section,
+- a resource creation section and
+- a resource deletion section.
+
+The setup section sets the switch up for test case execution.
+
+The creation section creates the Puppet resource instance and performs attribute verification using resource command on switch agent. It also verifies the switch state using NXOS running-config show CLI commands.
+
+The deletion section deletes the Puppet resource instance and performs attribute verification using resource command on switch agent. It also verifies the lack of switch state using NXOS running-config show CLI commands.
+
+The library file in the test directory is expected to contain the manifest generation methods defined in a module for usage in the test cases.
+
+## Beaker Test Case Writing ##
+
+A new Beaker test case may be added using these instructions:
+
+(1) Add a Setup test step to the test script. This step will consist of setting the Puppet Master's manifest filename as well as cleaning up the switch test state before start of further test steps using a call to `on()` method with the command string set to the vshell command for the feature cleanup for the particular Puppet provider in test.
+
+(2) Add a set of test steps after (1) for the creation of the Puppet provider resource. This section will consist of a `puppet agent` command transaction executed using `on()` method invocation with host set to agent, command set to the `puppet agent` command string to get the creation manifest with `ensure` set to `present` from the master server and the expected exit code for a successful transaction. It will be followed by verification of resource attributes using an `on()` method invocation with command string set to the `puppet resource` command for the resource instance of the Puppet provider. Further verification will involve a call to `on()` method using a command string set to the `vshell` command for the NXOS running-config show CLI. The matching in these test steps will occur for presence of RegExp patterns.
+
+(3) Add another set of test steps after (2) for the deletion of the Puppet provider resource. The list of test steps will be similar to (2) except that the manifest will typically have the `ensure` attribute set to `absent` to delete the resource. The resource attribute verification and show running-config CLI command verification steps will be similar to (2) except that the matching will occur for absence of RegExp patterns.
+
+## Beaker Test Case Template ##
+
+There is a sample Beaker test template located at @cisco-ciscopuppet/docs/ called template-provider-ensurabilitytest.rb that can be used to write test cases for Puppet providers. The test template is written for a sample Cisco Systems' Nexus Puppet provider called cisco_provider. It is a single test case that is implemented in a Beaker test script.
+
+
\ No newline at end of file
diff --git a/README-BEAKER.md b/README-BEAKER.md
index 5057094f5..2bc56c05a 100644
--- a/README-BEAKER.md
+++ b/README-BEAKER.md
@@ -13,7 +13,7 @@
## Overview
-This document describes automated Puppet agent installation and setup on Cisco Nexus switches using Puppetlabs [Beaker](https://github.com/puppetlabs/beaker/blob/master/README.md).
+This document describes automated Puppet agent installation and setup on Cisco Nexus switches using Puppet Labs [Beaker](https://github.com/puppetlabs/beaker/blob/master/README.md).
## Pre-Install Tasks
@@ -39,38 +39,38 @@ at the same time.
Access the following [link](README-AGENT-INSTALL.md) for more information on enabling these environments.
-### Beaker Installation
+### Install Beaker
[Install Beaker](https://github.com/puppetlabs/beaker/wiki/Beaker-Installation) on your designated server.
-### NX-OS Configuration
+### Configure NX-OS
-The ssh feature needs to be enabled and a devops user with sudo access will be needed for the Beaker workstation to access and install the puppet agent software into the `bash-shell` or `guestshell` environment.
+You must enable the ssh feature and give sudo access to the 'devops' user for the Beaker workstation to access and install the Puppet agent software into the `bash-shell` or `guestshell` environment.
**Example:**
-```bash
+~~~bash
configure terminal
feature ssh
username devops password devopspassword role network-admin
username devops shelltype bash
end
-```
+~~~
## Beaker Installer Configuration
-### Access the automated puppet agent installer
+### Access the automated Puppet agent installer
-The following commands should be run on your beaker workstation.
+The following commands should be run on your Beaker workstation.
-```
+~~~
$ git clone https://github.com/puppetlabs/cisco-ciscopuppet.git
$ cd cisco-ciscopuppet/utilities/installer
-```
+~~~
### Copy and modify the SAMPLE* configuration files.
-Within the `installer` directory you will need to make copies and modify the following configuration files. Any naming convention can be used when making copies of the files.
+Within the `installer` directory, make copies of and modify the following configuration files. Any naming convention can be used when making copies of the files.
SAMPLE_host.cfg (***Mandatory***)
@@ -78,19 +78,19 @@ SAMPLE_puppet.conf (***Optional***)
SAMPLE_resolver.conf (***Optional***)
-The `installer` directory also contains the **install_puppet.rb** script that will be used to install the agent rpm.
+The `installer` directory also contains the **install_puppet.rb** script that is used to install the agent rpm.
### Modify host.cfg
See the SAMPLE_host.cfg file for examples on how to modify the host.cfg file for your network.
-### Modify puppet.conf (Optional)
+### Modify puppet.conf
-This is an optional template that can be used to configure the puppet agent. The `certname` and `server` fields are automatically filled in using the information from the host.cfg file. If the template is not used, the installer will configure the default puppet.conf file created as part of the rpm install.
+This is an optional template that can be used to configure the Puppet agent. The `certname` and `server` fields are automatically filled in using the information from the host.cfg file. If the template is not used, the installer configures the default puppet.conf file created as part of the rpm install.
**Example:**
-```ini
+~~~ini
[main]
vardir = /var/opt/lib/pe-puppet
logdir = /var/log/pe-puppet
@@ -108,53 +108,53 @@ This is an optional template that can be used to configure the puppet agent. Th
graph = true
pluginsync = true
environment = production
-```
+~~~
Enable use of the puppet.conf template file by setting **`puppet_config_template:`** in the host.cfg file.
-### Modify resolver.conf (Optional)
+### Modify resolver.conf
-This is an optional file that contains information that needs to be configured in the /etc/resolv.conf file on the puppet agent.
+This is an optional file that contains information that needs to be configured in the `/etc/resolv.conf` file on the Puppet agent.
**Example:**
-```
+~~~
nameserver
domain yourdomain.com
search yourdomain.com
-```
+~~~
Enable use of the resolver.conf file by setting **`resolver:`** in the host.cfg file.
## Automated Puppet Agent Install: bash-shell
-On the beaker workstation run the following command:
+On the Beaker workstation, run the following command:
-```bash
+~~~bash
beaker --host --pre-suite --no-validate --no-config
-```
+~~~
**Note:** Make sure the `target: guestshell` field is commented out in the host.cfg file.
## Automated Puppet Agent Install: guestshell
-For installs into the `guestshell` simply uncomment the `target: guestshell` field in the host.cfg file and run the beaker tool.
+For installs into the `guestshell`, uncomment the `target: guestshell` field in the host.cfg file and run the Beaker tool.
## Limitations
Puppet agent is currently supported on:
- * Cisco NX-OS software release 7.0(3)I2(1) and later
- * Cisco Nexus switch platform models: N95xx, N93xx, N30xx, N31xx
- * Puppet version 4.0 and later
+ * Cisco NX-OS software release 7.0(3)I2(1) and later.
+ * Cisco Nexus switch platform models: N95xx, N93xx, N30xx, N31xx.
+ * Open source Puppet version 4.0 or greater, or Puppet Enterprise 2015.2 or greater.
Please ensure that the platform is running a supported version of NX-OS software.
-Puppet agent will run in either the native NX-OS `bash-shell` environment or in the NX-OS `guestshell` environment.
+Puppet agent runs in either the native NX-OS `bash-shell` environment or in the NX-OS `guestshell` environment.
## License Information
-```
+~~~
Copyright (c) 2014-2015 Cisco and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
@@ -168,4 +168,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-```
+~~~
diff --git a/README-Managing_packages.md b/README-Managing_packages.md
index 12539a0ce..aec2c65cb 100644
--- a/README-Managing_packages.md
+++ b/README-Managing_packages.md
@@ -11,94 +11,92 @@
## Overview
-This document describes the Cisco **package** provider for puppet, which serves as a common package provider for both Cisco NX-OS RPM packages and 3rd Party RPM packages.
+This document describes the Cisco **package** provider for Puppet, which serves as a common package provider for both Cisco NX-OS RPM packages and third-party RPM packages.
-The Cisco **package** provider is a sub-class of Puppet's **yum_package**. It utilizes the yum provider for 3rd Party RPM management but uses custom install & uninstall methods to support NXAPI-based CLI installs for Cisco RPMs that target the NX-OS host environment.
+The Cisco **package** provider is a sub-class of Puppet's **yum_package**. It uses the yum provider for third-party RPM management but uses custom install and uninstall methods to support NXAPI-based CLI installation for Cisco RPMs that target the NX-OS host environment.
-* **3rd Party RPM**
- * These RPMs target one of the Cisco NX-OS 3rd Party environments:
- * `bash-shell` : The WRL linux environment underlying NX-OS
- * `guestshell` : A secure linux container running CentOS
- * The Cisco **package** provider uses yum for 3rd Party RPMs
- * May also be managed directly with **yum_package** or **rpm_package**
+* **Third-Party RPM**
+ * These RPMs target one of the Cisco NX-OS third party environments:
+ * `bash-shell`: The WRL Linux environment underlying NX-OS.
+ * `guestshell`: A secure Linux container running CentOS.
+ * The Cisco **package** provider uses yum for third-party RPMs.
+ * May also be managed directly with **yum_package** or **rpm_package**.
* **Cisco RPM**
- * These RPMS target the Cisco NX-OS host environment
+ * These RPMS target the Cisco NX-OS host environment.
## Syntax
-```
+~~~
package { 'name':
ensure => String,
package_settings => String, Array
source => String,
provider => String,
}
-```
+~~~
+
where:
-* `package` tells the puppet agent to manage a package
+* `package`: Tells the Puppet agent to manage a package.
-* `name` is the name of the package
+* `name`: The name of the package.
-* `ensure` Optional. Valid settings are `absent` or `present`. Default is `present`
+* `ensure`: Optional. Valid settings are `absent` or `present`. Default is `present`.
-* `package_settings` Required for Cisco RPM installs. This is necessary to indicate that the given RPM should be installed to the host environment. Currently the only valid setting for this attribute is `{'target' => 'host'}`. This attribute is not used for 3rd Party installs.
+* `package_settings`: Required for Cisco RPM installs. This is necessary to indicate that the given RPM should be installed to the host environment. The only valid setting for this attribute is `{'target' => 'host'}`. This attribute is not used for third-party installs.
-* `source` Optional. Path to local file or URI for remote RPMs.
+* `source`: Optional. Path to local file or URI for remote RPMs.
-* `provider` Optional. Set to 'nxapi' if installling a cisco package.
+* `provider`: Optional. Set to 'nxapi' if installling a Cisco package.
## Examples
* **Cisco RPMs**
-```
+~~~
package { 'n9000_sample':
source => "http://myrepo.my_company.com/n9000_sample-1.0.0-7.0.3.x86_64.rpm",
package_settings => {'target' => 'host'}
provider => 'nxapi',
}
-```
-```
+~~~
+
+~~~
package { 'n9000_sample':
ensure => absent,
package_settings => {'target' => 'host'},
provider => 'nxapi',
}
-```
-```
+~~~
+
+~~~
# Local RPM file
package { 'n9000_sample':
source => '/bootflash/n9000_sample-1.0.0-7.0.3.x86_64.rpm',
package_settings => {'target' => 'host'}
}
-```
+~~~
-* **3rd Party RPMs**
+* **Third-Party RPMs**
-```
+~~~
# Install directly to bash-shell or guestshell environments
package { 'package_A':
ensure => present
}
-```
-```
+~~~
+~~~
package { 'package_B':
ensure => absent
}
-```
+~~~
## References
-[Puppet package resource types](https://docs.puppetlabs.com/references/latest/type.html#package) - Generic and specific package management resources
+[Puppet package resource types](https://docs.puppetlabs.com/references/latest/type.html#package) - Generic and specific package management resources.
[Cisco Nexus Puppet Modules](README.md) - Types, Providers, Utilities
[Cisco Nexus Programmability Guide](http://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/6-x/programmability/guide/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_chapter_01010.html) - Guestshell Documentation
-
-## Limitations
-
-## Known Issues
-
diff --git a/README-creating-types-providers.md b/README-creating-types-providers.md
new file mode 100644
index 000000000..2544625de
--- /dev/null
+++ b/README-creating-types-providers.md
@@ -0,0 +1,711 @@
+# Creating Cisco NX-OS Types and Providers
+
+#### Table of Contents
+
+* [Overview](#overview)
+* [Start here: Clone the Repo](#clone)
+* [Basic Example: feature bash-shell](#simp_example)
+ * [Step 1. Type: feature bash-shell](#simp_type)
+ * [Step 2. Provider: feature bash-shell](#simp_prov)
+ * [Step 3. Testing: feature bash-shell](#simp_test)
+ * [Static Analysis](#simp_sa)
+* [Complex Example: router eigrp](#comp_example)
+ * [Step 1. Type: router eigrp](#comp_type)
+ * [Step 2. Provider: router eigrp](#comp_prov)
+ * [Step 3. Testing: router eigrp](#comp_test)
+ * [Static Analysis](#comp_sa)
+* [Next Steps](#next)
+
+## Overview
+
+This document is a guide for writing new Puppet resource types and providers for Cisco NX-OS.
+
+There are multiple components involved when creating new resources. This document focuses on the type and provider files:
+
+![1](docs/tp_files.png)
+
+* Every resource is associated with a [resource type](https://docs.puppetlabs.com/puppet/latest/reference/lang_resources.html), which determines the kind of configuration it manages.
+
+* [Resource providers](https://docs.puppetlabs.com/guides/provider_development.html) are essentially backends that implement support for a specific implementation of a given resource type.
+
+* The types and providers work in conjunction with a node\_utils API, which is the interface between Puppet agent and the NX-OS CLI. Please see the [README-creating-node_utils-APIs.md](#README-creating-node_utils-APIs.md) guide for more information on writing node_utils APIs.
+
+This document relies heavily on example code. The examples in this document can be written independently, but they are intended to work in conjuction with the example node_utils APIs created in the [README-creating-node_utils-APIs.md](#README-creating-node_utils-APIs.md) guide. The examples in that guide are based on code templates for the `feature bash-shell` CLI and the `router eigrp` CLI. Note that some people prefer to write the node_utils API before the resource types and providers, while others might prefer the opposite workflow.
+
+## Start here: Clone the Repo
+
+Please see the [CONTRIBUTING](#CONTRIBUTING) document for workflow instructions. In general, fork the ciscopuppet repository for your changes and submit a pull request when it is ready for commit.
+
+First install the code base. Clone the ciscopuppet repo into a workspace:
+
+~~~bash
+git clone https://github.com/puppetlabs/cisco-ciscopuppet
+~~~
+
+## Basic Example: feature bash-shell
+
+The NX-OS CLI for `feature bash-shell` is a simple on / off style configuration:
+
+`[no] feature bash-shell`
+
+This resource has no other properties.
+
+*Note. This example disables the bash-shell, so use the guestshell environment when testing.*
+
+## Step 1. Type: feature bash-shell
+
+* There are template files in `/docs` that might help when you write new types and providers. These templates provide most of the necessary code with a few customizations required for a new resource. Copy the `template-type-feature.rb` file to use as the basis for our new `cisco_bash_shell.rb` type file:
+
+~~~bash
+cp cisco-ciscopuppet/docs/template-type-feature.rb \
+ cisco-ciscopuppet/lib/puppet/type/cisco_bash_shell.rb
+~~~
+
+* Edit `cisco_bash_shell.rb` and substitute the placeholder text as shown here:
+
+~~~bash
+/X__RESOURCE_NAME__X/bash_shell/
+~~~
+
+#### Example: cisco_bash_shell.rb type file
+
+This is the completed bash_shell resource type based on `template-type-feature.rb`:
+
+~~~puppet
+#
+# Puppet resource type for feature bash_shell
+#
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Puppet::Type.newtype(:bash_shell) do
+
+ @doc = "Manages configuration of feature bash-shell
+
+ ~~~
+ cisco_bash_shell {'':
+ ..attributes..
+ }
+ ~~~
+
+ Example:
+
+ ~~~
+ cisco_bash_shell {'xxxxx' :
+ ensure => present,
+ }
+ ~~~
+ "
+
+ ensurable
+
+ newparam(:name, :namevar => true) do
+ desc "Resource title. Valid values are string."
+ end
+
+ # There are no additional properties for this command.
+end
+~~~
+
+## Step 2. Provider: feature bash-shell
+
+* The provider files for Cisco NX-OS are named nxapi.rb and are each stored in a unique provider directory. Create a new directory for the bash_shell provider and use `template-provider-feature.rb` to populate the new provider file:
+
+~~~bash
+mkdir cisco-ciscopuppet/lib/puppet/provider/cisco_bash_shell
+
+cp cisco-ciscopuppet/docs/template-provider-feature.rb \
+ cisco-ciscopuppet/lib/puppet/provider/cisco_bash_shell/nxapi.rb
+~~~
+
+* Edit `nxapi.rb` and substitute the placeholder text as shown here:
+
+~~~bash
+/X__RESOURCE_NAME__X/bash_shell/
+
+/X__CLASS_NAME__X/BashShell/
+~~~
+
+#### Example: cisco_bash_shell.rb provider file
+
+This is the completed bash_shell provider based on `template-provider-feature.rb`:
+
+~~~puppet
+:Type.type(:cisco_bash_shell).provide(:nxapi) do
+
+ confine :feature => :cisco_node_utils
+
+ mk_resource_methods
+
+ def initialize(value={})
+ super(value)
+ @property_flush = {}
+ end
+
+ def self.instances
+ inst = []
+ return inst unless Cisco::BashShell.feature_enabled
+ current_state = { :name => 'default', :ensure => :present}
+ inst << new(current_state)
+ return inst
+ end
+
+ def self.prefetch(resources)
+ provider = instances
+ resources.values.first.provider = provider.first unless provider.first.nil?
+ end
+
+ def exists?
+ @property_hash[:ensure] == :present
+ end
+
+ def create
+ @property_flush[:ensure] = :present
+ end
+
+ def destroy
+ @property_flush[:ensure] = :absent
+ end
+
+ def flush
+ case @property_flush[:ensure]
+ when :present
+ Cisco::BashShell.new.feature_enable
+ when :absent
+ Cisco::BashShell.new.feature_disable
+ end
+ end
+
+end
+~~~
+
+## Step 3. Testing: feature bash-shell
+
+Test the new resource using the guestshell environment. See [README-AGENT-INSTALL](#README-AGENT-INSTALL.md) for using Puppet agent in guestshell.
+
+* Create a manifest for the new resource:
+
+~~~puppet
+cisco_bash_shell { 'bash_on' :
+ ensure => present,
+}
+~~~
+
+* Manually check that the state of the resource is disabled on the switch. In this case the NX-OS CLI config is not present when feature bash-shell is disabled.
+
+~~~
+n3k# sh run | i 'feature bash'
+n3k#
+~~~
+
+* Run the Puppet agent:
+
+*Note. The --trace option is helpful when troubleshooting agent failures*
+
+~~~
+[root@guestshell guestshell]# puppet agent -t --trace
+Info: Retrieving pluginfacts
+Info: Retrieving plugin
+Info: Loading facts
+Info: Caching catalog for n3k.cisco.com
+Info: Applying configuration version '1438270388'
+Notice: /Stage[main]/Main/Node[n3k]/Cisco_bash_shell[bash_on]/ensure: created
+Notice: Applied catalog in 0.26 seconds
+~~~
+
+* Check state on the switch again:
+
+~~~
+n3k# sh run | i 'feature bash'
+feature bash-shell
+~~~
+
+* We now have the expected state. Next, test the Puppet resource command while the feature is still enabled:
+
+~~~
+[root@guestshell guestshell]# puppet resource cisco_bash_shell
+cisco_bash_shell { 'default':
+ ensure => 'present',
+}
+~~~
+*Note. This test manifest should be added to examples/demo_install.rb*
+
+* Change the manifest to ensure => absent to disable the state, then repeat the tests:
+
+~~~puppet
+cisco_bash_shell { 'bash_off' :
+ ensure => absent,
+}
+~~~
+
+~~~
+n3k# sh run | i 'feature bash'
+feature bash-shell
+~~~
+~~~
+[root@guestshell guestshell]# puppet agent -t
+Info: Retrieving pluginfacts
+Info: Retrieving plugin
+Info: Loading facts
+Info: Caching catalog for n3k.cisco.com
+Info: Applying configuration version '1438270530'
+Notice: /Stage[main]/Main/Node[n3k]/Cisco_bash_shell[bash_off]/ensure: removed
+Notice: Applied catalog in 0.35 seconds
+~~~
+~~~
+n3k# sh run | i 'feature bash'
+n3k#
+~~~
+~~~
+[root@guestshell guestshell]# puppet resource cisco_bash_shell
+
+ (a blank response is correct here)
+~~~
+
+* `puppet resource` can also be used for testing changes to provider states. This method is often easier and doesn't require a manifest:
+
+~~~puppet
+puppet resource cisco_bash_shell 'test_on' ensure=present
+
+puppet resource cisco_bash_shell 'test_off' ensure=absent
+~~~
+
+
+## Static Analysis
+
+* rubocop is a Ruby static analysis tool. Run [rubocop](https://rubygems.org/gems/rubocop) with the --lint option to validate the new code:
+
+~~~bash
+% rubocop --lint type/cisco_bash_feature.rb provider/cisco_bash_feature/nxapi.rb
+warning: parser/current is loading parser/ruby21, which recognizes
+warning: 2.1.7-compliant syntax, but you are running 2.1.1.
+Inspecting 2 files
+..
+
+2 files inspected, no offenses detected
+~~~
+
+* TBD: Run [puppet-lint](https://rubygems.org/gems/puppet-lint) against changed files.
+
+
+## Complex Example: router eigrp
+
+This resource type and provider exercise will build on the router_eigrp API example shown in the cisco node_utils [README-creating-node_utils-APIs](#README-creating-node_utils-APIs.md) document.
+
+The router_eigrp node_utils example created a new API for the cli below:
+
+~~~
+[no] feature eigrp
+[no] router eigrp [name] (string)
+ maximum-paths [n] (integer)
+ [no] shutdown (boolean)
+~~~
+
+This example needs to support:
+
+* multiple router eigrp instances, identified by 'name'
+* an integer property
+* a boolean property
+
+Router eigrp also supports `vrf` and `address-family` sub-modes, which further complicate the configuration but are not included in this exercise.
+
+The Puppet type and provider code doesn't need any knowledge of `feature eigrp` because that configuration is controlled automatically by the router_eigrp node_utils API; therefore, we need to implement only the router commands themselves.
+
+## Step 1. Type: router eigrp
+
+* Copy the `template-type-router.rb` file to use as the basis for the `cisco_router_eigrp.rb` type file:
+
+~~~bash
+cp cisco-ciscopuppet/docs/template-type-router.rb \
+ cisco-ciscopuppet/lib/puppet/type/cisco_router_eigrp.rb
+~~~
+
+* Edit `cisco_router_eigrp.rb` and substitute the placeholder text as shown here:
+
+~~~bash
+/X__CLASS_NAME__X/RouterEigrp/
+
+/X__RESOURCE_NAME__X/router_eigrp/
+
+/X__PROPERTY_INT__X/maximum_paths/
+
+/X__PROPERTY_BOOL__X/shutdown/
+~~~
+
+There might be additional steps to follow in the template.
+
+#### Example: cisco_router_eigrp.rb type file
+
+This is the completed router_eigrp type based on `template-type-router.rb`:
+
+~~~puppet
+#
+# Puppet resource type for router_eigrp
+#
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Puppet::Type.newtype(:cisco_router_eigrp) do
+
+ @doc = "Manages configuration of a router_eigrp instance
+
+ ~~~
+ cisco_router_eigrp {'':
+ ..attributes..
+ }
+ ~~~
+
+ `` is the name of the router_eigrp instance.
+
+ Example:
+
+ ~~~
+ cisco_router_eigrp { 'green' :
+ ensure => present,
+ maximum_paths => 5,
+ shutdown => true,
+ }
+ ~~~
+ "
+
+ ensurable
+
+ ###################
+ # Resource Naming #
+ ###################
+
+ # Parse the title to populate the attributes in these patterns.
+ # These attributes might be overwritten later.
+ def self.title_patterns
+ identity = lambda { |x| x }
+ patterns = []
+
+ # Below pattern matches the resource name.
+ patterns << [
+ /^(\S+)$/,
+ [
+ [:name, identity]
+ ]
+ ]
+ return patterns
+ end
+
+ newparam(:name, :namevar => true) do
+ desc "Name of the router_eigrp instance. Valid values are string."
+ end
+
+ newproperty(:maximum_paths) do
+ desc "Sets the number of equal cost paths that EIGRP accepts in the route table.
+ Valid values are integer, keyword 'default'."
+
+ munge { |value|
+ value = :default if value == 'default'
+ begin
+ value = Integer(value) unless value == :default
+ rescue
+ fail "maximum_paths must be a valid integer, or default."
+ end
+ value
+ }
+ end
+
+ newproperty(:shutdown) do
+ desc "shutdown state of the interface."
+
+ newvalues(:true, :false, :default)
+ end
+
+end
+~~~
+
+## Step 2. Provider: router eigrp
+
+* Create a new directory for the router_eigrp provider and use `template-provider-router.rb` to populate the new provider file:
+
+~~~bash
+mkdir cisco-ciscopuppet/lib/puppet/provider/cisco_router_eigrp
+
+cp cisco-ciscopuppet/docs/template-provider-router.rb \
+ cisco-ciscopuppet/lib/puppet/provider/cisco_router_eigrp/nxapi.rb
+~~~
+
+* Edit `nxapi.rb` and substitute the placeholder text as shown here:
+
+
+~~~bash
+/X__CLASS_NAME__X/RouterEigrp/
+
+/X__RESOURCE_NAME__X/router_eigrp/
+
+/X__CONSTANT_NAME__X/ROUTER_EIGRP/
+
+/X__PROPERTY_INT__X/maximum_paths/
+
+/X__PROPERTY_BOOL__X/shutdown/
+~~~
+
+There might be additional steps to follow in the template.
+
+#### Example: cisco_router_eigrp.rb provider file
+
+~~~puppet
+#
+# The NXAPI provider for cisco_router_eigrp.
+#
+# Copyright (c) 2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'cisco_node_utils' if Puppet.features.cisco_node_utils?
+begin
+ require 'puppet_x/cisco/autogen'
+rescue LoadError # seen on master, not on agent
+ # See longstanding Puppet issues #4248, #7316, #14073, #14149, etc. Ugh.
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..',
+ 'puppet_x', 'cisco', 'autogen.rb'))
+end
+
+Puppet::Type.type(:cisco_router_eigrp).provide(:nxapi) do
+ desc "The NXAPI provider for cisco_router_eigrp."
+
+ confine :feature => :cisco_node_utils
+
+ mk_resource_methods
+
+ # Property symbol arrays for method auto-generation. There are separate arrays
+ # because the boolean-based methods are processed slightly different.
+ ROUTER_EIGRP_NON_BOOL_PROPS = [
+ :maximum_paths,
+ ]
+ ROUTER_EIGRP_BOOL_PROPS = [
+ :shutdown,
+ ]
+ ROUTER_EIGRP_ALL_PROPS =
+ ROUTER_EIGRP_NON_BOOL_PROPS + ROUTER_EIGRP_BOOL_PROPS
+
+ # Dynamic method generation for getters & setters
+ PuppetX::Cisco::AutoGen.mk_puppet_methods(:non_bool, self, "@router_eigrp",
+ ROUTER_EIGRP_NON_BOOL_PROPS)
+ PuppetX::Cisco::AutoGen.mk_puppet_methods(:bool, self, "@router_eigrp",
+ ROUTER_EIGRP_BOOL_PROPS)
+
+ def initialize(value={})
+ super(value)
+ @router_eigrp = Cisco::RouterEigrp.routers[@property_hash[:name]]
+ @property_flush = {}
+ end
+
+ def self.get_properties(instance_name, inst)
+ debug "Checking instance, #{instance_name}."
+ current_state = {
+ :name => instance_name,
+ :ensure => :present,
+ }
+ # Call node_utils getter for each property
+ ROUTER_EIGRP_NON_BOOL_PROPS.each { |prop|
+ current_state[prop] = inst.send(prop)
+ }
+ ROUTER_EIGRP_BOOL_PROPS.each { |prop|
+ val = inst.send(prop)
+ current_state[prop] = val.nil? ? nil : (val ? :true : :false)
+ }
+ new(current_state)
+ end # self.get_properties
+
+ def self.instances
+ instance_array = []
+ Cisco::RouterEigrp.routers.each { | instance_name, inst |
+ begin
+ instance_array << get_properties(instance_name, inst)
+ end
+ }
+ return instance_array
+ end # self.instances
+
+ def self.prefetch(resources)
+ instance_array = instances
+ resources.keys.each do |name|
+ provider = instance_array.find { |inst| inst.name == name }
+ resources[name].provider = provider unless provider.nil?
+ end
+ end # self.prefetch
+
+ def exists?
+ return (@property_hash[:ensure] == :present)
+ end
+
+ def create
+ @property_flush[:ensure] = :present
+ end
+
+ def destroy
+ @property_flush[:ensure] = :absent
+ end
+
+ def set_properties(new_instance=false)
+ ROUTER_EIGRP_ALL_PROPS.each { |prop|
+ if @resource[prop]
+ if new_instance
+ # Call puppet setter to set @property_flush[prop]
+ self.send("#{prop}=", @resource[prop])
+ end
+ unless @property_flush[prop].nil?
+ # Call node_utils setter to update node
+ @router_eigrp.send("#{prop}=", @property_flush[prop]) if
+ @router_eigrp.respond_to?("#{prop}=")
+ end
+ end
+ }
+ end
+
+ def flush
+ if @property_flush[:ensure] == :absent
+ @router_eigrp.destroy
+ @router_eigrp = nil
+ else
+ # Create/Update
+ if @router_eigrp.nil?
+ new_instance = true
+ @router_eigrp = Cisco::RouterEigrp.new(@resource[:name])
+ end
+ set_properties(new_instance)
+ end
+ end
+
+end
+~~~
+
+## Step 3. Testing: router eigrp
+
+* Create a manifest for the new resource:
+
+~~~puppet
+cisco_router_eigrp { 'test' :
+ ensure => present,
+ maximum_paths => 5,
+ shutdown => true,
+}
+~~~
+
+* Manually check that the state of the resource is disabled on the switch.
+
+~~~
+n3k# sh run eigrp
+ ^
+% Invalid command at '^' marker.
+
+ (feature eigrp is disabled so this error is expected)
+~~~
+
+* Run the Puppet agent:
+
+*Note. The --trace option is helpful when troubleshooting agent failures*
+
+~~~
+[root@guestshell guestshell]# puppet agent -t
+[root@guestshell guestshell]# puppet agent -t
+Info: Retrieving pluginfacts
+Info: Retrieving plugin
+Info: Loading facts
+Info: Caching catalog for n3k.cisco.com
+Info: Applying configuration version '1438344401'
+Notice: /Stage[main]/Main/Node[n3k]/Cisco_router_eigrp[test]/ensure: created
+Notice: Applied catalog in 4.65 seconds
+~~~
+
+* Check state on the switch again:
+
+~~~
+n3k# sh run eigrp
+feature eigrp
+
+router eigrp test
+ maximum-paths 5
+ shutdown
+~~~
+
+* Run Puppet agent again to test for idempotency. You should NOT see `Cisco_router_eigrp[test]/ensure: created` in the log, indicating that the state has not changed:
+
+~~~
+[root@guestshell guestshell]# puppet agent -t
+Info: Retrieving pluginfacts
+Info: Retrieving plugin
+Info: Loading facts
+Info: Caching catalog for n3k.cisco.com
+Info: Applying configuration version '1438344623'
+Notice: Applied catalog in 0.16 seconds
+~~~
+
+* Test the `puppet resource` command while the feature is enabled:
+
+~~~
+[root@guestshell guestshell]# puppet resource cisco_router_eigrp
+cisco_router_eigrp { 'test':
+ ensure => 'present',
+ maximum_paths => '5',
+ shutdown => 'true',
+}
+
+~~~
+*Note. This test manifest should be added to examples/demo_install.rb*
+
+* Alternative tests with `puppet resource`:
+
+~~~puppet
+puppet resource cisco_router_eigrp "xyz" ensure=present shutdown=true maximum_paths=3
+
+puppet resource cisco_router_eigrp "xyz" shutdown='default'
+
+puppet resource cisco_router_eigrp "xyz" ensure=absent
+~~~
+
+## Static Analysis
+
+* Run [rubocop](https://rubygems.org/gems/rubocop) with the --lint option to validate the new code:
+
+~~~bash
+% rubocop --lint type/cisco_router_eigrp.rb provider/cisco_router_eigrp/nxapi.rb
+Inspecting 2 files
+..
+
+2 files inspected, no offenses detected
+~~~
+
+* TBD: Run [puppet-lint](https://rubygems.org/gems/puppet-lint) against changed files.
+
+
+## Next Steps
+
+Please see the [CONTRIBUTING](#CONTRIBUTING) document for workflow instructions.
diff --git a/README.md b/README.md
index e27feb03c..e0c83adfc 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,11 @@ Before the module can be run properly on the agent, enable pluginsync in the pup
You must also install the following gems on the agent: net_http_unix, cisco_nxapi,
and cisco_node_utils. Since these have dependencies on each other, when you
-install cisco_node_utils, the other two gems will be automatically installed. You can include the package provider in the manifest to automate installing these gems as shown in the following example.
+install cisco_node_utils, the other two gems will be automatically installed.
+Gems installed under Puppet are not persistent across system reload on Nexus
+switches. To avoid issues after reload, you should include the package
+provider in the manifest to automate installing these gems, as shown in
+the following example.
~~~Puppet
package { 'cisco_node_utils' :
@@ -114,6 +118,7 @@ are string.
This provider allows raw configurations to be managed by Puppet. It serves as a stopgap until specialized types are created. It has the following limitations:
* The input message buffer is limited to 500KB. Large configurations are often easier to debug if broken up into multiple smaller resource blocks.
+* The cisco_command_config configuration block must use the same syntax as displayed by the `show running-config` command on the switch. In some cases, configuration commands that omit optional keywords when entered may actually appear with a different syntax when displayed by `show running-config`; for example, some access-list entries may be configured without a sequence number but yet an implicit sequence number is created regardless. This then creates an idempotency problem because there is a mismatch between `show running-config` and the manifest. The solution in this case is for the manifest to include explicit sequence numbers for the affected access-list entries.
* Order is important. Some dependent commands may fail if their associated `feature` configuration is not enabled first. Use Puppet's `before`, `after`, or `require` keywords to establish dependencies between blocks.
* Indentation counts! It implies sub-mode configuration. Use the switch's running-config as a guide and do not indent configurations that are not normally indented. Do not use tabs to indent.
* Inline comments must be prefixed by '!' or '#'.
@@ -571,4 +576,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-~~~
\ No newline at end of file
+~~~
diff --git a/SUPPORT.md b/SUPPORT.md
new file mode 100644
index 000000000..157b83d06
--- /dev/null
+++ b/SUPPORT.md
@@ -0,0 +1,3 @@
+Supported versions of this Puppet Module are available at [Puppet Forge](http://forge.puppetlabs.com/puppetlabs/ciscopuppet)
+
+Please report any issues with this Puppet Module to [https://tickets.puppetlabs.com/browse/MODULES/](https://tickets.puppetlabs.com/browse/MODULES/)
diff --git a/docs/template-provider-ensurabilitytest.rb b/docs/template-provider-ensurabilitytest.rb
new file mode 100644
index 000000000..cb44d6beb
--- /dev/null
+++ b/docs/template-provider-ensurabilitytest.rb
@@ -0,0 +1,172 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# TestCase Name:
+# -------------
+# Template-Provider-EnsurabilityTest.rb
+#
+# TestCase Prerequisites:
+# -----------------------
+# This is a Puppet Provider resource testcase for Puppet Agent on Nexus devices.
+# The test case assumes the following prerequisites are already satisfied:
+# A. Populating the HOSTS configuration file with the agent and master
+# information.
+# B. Enabling SSH connection prerequisites on the N9K switch based Agent.
+# C. Starting of Puppet master server on master.
+# D. Sending to and signing of Puppet agent certificate request on master.
+#
+# TestCase:
+# ---------
+# This is a PROVIDER resource test that tests for 'ensure' attribute with
+# a state transition from 'present' to 'absent'.
+#
+# There are 2 sections to the testcase: Setup, group of teststeps.
+# The 1st step is the Setup teststep that cleans up the switch state.
+# Steps 2-4 deal with cisco_provider resource creation and its
+# verification using Puppet Agent and the switch running-config.
+# Steps 5-7 deal with cisco_provider resource deletion and its
+# verification using Puppet Agent and the switch running-config.
+#
+# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
+# Bash shell command executions. For Vegas shell and Bash shell command
+# string executions, this is the exit_code convention:
+# 0 - successful command execution, > 0 - failed command execution.
+# For Puppet Agent command string executions, this is the exit_code convention:
+# 0 - no changes have occurred, 1 - errors have occurred,
+# 2 - changes have occurred, 4 - failures have occurred and
+# 6 - changes and failures have occurred.
+# 0 is the default exit_code checked in Beaker::DSL::Helpers::on() method.
+# The testcode also uses RegExp pattern matching on stdout or output IO
+# instance attributes of Result object from on() method invocation.
+#
+###############################################################################
+
+# Require UtilityLib.rb and ProviderLib.rb paths.
+require File.expand_path("../../lib/utilitylib.rb", __FILE__)
+require File.expand_path("../providerlib.rb", __FILE__)
+
+result = 'PASS'
+testheader = "PROVIDER Resource :: Ensurability"
+
+# @test_name [TestCase] Executes ensurability testcase for PROVIDER Resource.
+test_name "TestCase :: #{testheader}" do
+
+ # @step [Step] Sets up switch for provider test.
+ step "TestStep :: Setup switch for provider test" do
+ # Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
+ UtilityLib.set_manifest_path(master, self)
+
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ cmd_str = UtilityLib.get_vshell_cmd("conf t ; no feature provider")
+ on(agent, cmd_str)
+
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config section provider")
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout, [/feature provider/],
+ true, self, logger)
+ end
+
+ logger.info("Setup switch for provider test :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource present manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, ProviderLib.create_provider_manifest_present())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+
+ logger.info("Get resource present manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks cisco_provider resource on agent using resource cmd.
+ step "TestStep :: Check cisco_provider resource presence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_provider test", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout, {'ensure' => 'present'},
+ false, self, logger)
+ end
+
+ logger.info("Check cisco_provider resource presence on agent :: #{result}")
+ end
+
+ # @step [Step] Checks provider instance on agent using switch show cli cmds.
+ step "TestStep :: Check provider instance presence on agent" do
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config section provider")
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout, [/provider test/],
+ false, self, logger)
+ end
+
+ logger.info("Check provider instance presence on agent :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource absent manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, ProviderLib.create_provider_manifest_absent())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+
+ logger.info("Get resource absent manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks cisco_provider resource on agent using resource cmd.
+ step "TestStep :: Check cisco_provider resource absence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_provider test", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout, {'ensure' => 'present'},
+ true, self, logger)
+ end
+
+ logger.info("Check cisco_provider resource absence on agent :: #{result}")
+ end
+
+ # @step [Step] Checks provider instance on agent using switch show cli cmds.
+ step "TestStep :: Check provider instance absence on agent" do
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config section provider")
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout, [/provider test/],
+ true, self, logger)
+ end
+
+ logger.info("Check provider instance absence on agent :: #{result}")
+ end
+
+ # @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
+ UtilityLib.raise_passfail_exception(result, testheader, self, logger)
+
+end
+
+logger.info("TestCase :: #{testheader} :: End")
+
diff --git a/docs/template-provider-feature.rb b/docs/template-provider-feature.rb
new file mode 100644
index 000000000..e9e650d71
--- /dev/null
+++ b/docs/template-provider-feature.rb
@@ -0,0 +1,65 @@
+#
+# Puppet provider for feature X__RESOURCE_NAME__X
+#
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'cisco_node_utils' if Puppet.features.cisco_node_utils?
+
+Puppet::Type.type(:cisco_X__RESOURCE_NAME__X).provide(:nxapi) do
+
+ confine :feature => :cisco_node_utils
+
+ mk_resource_methods
+
+ def initialize(value={})
+ super(value)
+ @property_flush = {}
+ end
+
+ def self.instances
+ inst = []
+ return inst unless Cisco::X__CLASS_NAME__X.feature_enabled
+ current_state = { :name => 'default', :ensure => :present}
+ inst << new(current_state)
+ return inst
+ end
+
+ def self.prefetch(resources)
+ provider = instances
+ resources.values.first.provider = provider.first unless provider.first.nil?
+ end
+
+ def exists?
+ @property_hash[:ensure] == :present
+ end
+
+ def create
+ @property_flush[:ensure] = :present
+ end
+
+ def destroy
+ @property_flush[:ensure] = :absent
+ end
+
+ def flush
+ case @property_flush[:ensure]
+ when :present
+ Cisco::X__CLASS_NAME__X.new.feature_enable
+ when :absent
+ Cisco::X__CLASS_NAME__X.new.feature_disable
+ end
+ end
+
+end
diff --git a/docs/template-provider-router.rb b/docs/template-provider-router.rb
new file mode 100644
index 000000000..cf58dc7a3
--- /dev/null
+++ b/docs/template-provider-router.rb
@@ -0,0 +1,141 @@
+#
+# The NXAPI provider for cisco_X__RESOURCE_NAME__X.
+#
+# Copyright (c) 2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'cisco_node_utils' if Puppet.features.cisco_node_utils?
+begin
+ require 'puppet_x/cisco/autogen'
+rescue LoadError # seen on master, not on agent
+ # See longstanding Puppet issues #4248, #7316, #14073, #14149, etc. Ugh.
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..',
+ 'puppet_x', 'cisco', 'autogen.rb'))
+end
+
+Puppet::Type.type(:cisco_X__RESOURCE_NAME__X).provide(:nxapi) do
+ desc "The NXAPI provider for cisco_X__RESOURCE_NAME__X."
+
+ confine :feature => :cisco_node_utils
+
+ mk_resource_methods
+
+ # -----------------------------------------------------------------------
+ # TEMPLATE STEP 1. Add property names to the *_PROPS arrays. The AutoGen
+ # code will dynamically create getter & setter methods for each
+ # property in the arrays. Some multi-value properties like
+ # ip_address/masklen will require customer getters & setters.
+ # See existing providers for example code.
+ # -----------------------------------------------------------------------
+ # Property symbol arrays for method auto-generation. There are separate arrays
+ # because the boolean-based methods are processed slightly different.
+ X__CONSTANT_NAME__X_NON_BOOL_PROPS = [
+ :X__PROPERTY_INT__X,
+ ]
+ X__CONSTANT_NAME__X_BOOL_PROPS = [
+ :X__PROPERTY_BOOL__X,
+ ]
+ X__CONSTANT_NAME__X_ALL_PROPS =
+ X__CONSTANT_NAME__X_NON_BOOL_PROPS + __CONSTANT_NAME___BOOL_PROPS
+
+ # Dynamic method generation for getters & setters
+ PuppetX::Cisco::AutoGen.mk_puppet_methods(:non_bool, self, "@X__RESOURCE_NAME__X",
+ X__CONSTANT_NAME__X_NON_BOOL_PROPS)
+ PuppetX::Cisco::AutoGen.mk_puppet_methods(:bool, self, "@X__RESOURCE_NAME__X",
+ X__CONSTANT_NAME__X_BOOL_PROPS)
+
+ def initialize(value={})
+ super(value)
+ @X__RESOURCE_NAME__X = Cisco::X__CLASS_NAME__X.routers[@property_hash[:name]]
+ @property_flush = {}
+ end
+
+ def self.get_properties(instance_name, inst)
+ debug "Checking instance, #{instance_name}."
+ current_state = {
+ :name => instance_name,
+ :ensure => :present,
+ }
+ # Call node_utils getter for each property
+ X__CONSTANT_NAME__X_NON_BOOL_PROPS.each { |prop|
+ current_state[prop] = inst.send(prop)
+ }
+ X__CONSTANT_NAME__X_BOOL_PROPS.each { |prop|
+ val = inst.send(prop)
+ current_state[prop] = val.nil? ? nil : (val ? :true : :false)
+ }
+ new(current_state)
+ end # self.get_properties
+
+ def self.instances
+ instance_array = []
+ Cisco::X__CLASS_NAME__X.routers.each { | instance_name, inst |
+ begin
+ instance_array << get_properties(instance_name, inst)
+ end
+ }
+ return instance_array
+ end # self.instances
+
+ def self.prefetch(resources)
+ instance_array = instances
+ resources.keys.each do |name|
+ provider = instance_array.find { |inst| inst.name == name }
+ resources[name].provider = provider unless provider.nil?
+ end
+ end # self.prefetch
+
+ def exists?
+ return (@property_hash[:ensure] == :present)
+ end
+
+ def create
+ @property_flush[:ensure] = :present
+ end
+
+ def destroy
+ @property_flush[:ensure] = :absent
+ end
+
+ def set_properties(new_instance=false)
+ X__CONSTANT_NAME__X_ALL_PROPS.each { |prop|
+ if @resource[prop]
+ if new_instance
+ # Call puppet setter to set @property_flush[prop]
+ self.send("#{prop}=", @resource[prop])
+ end
+ unless @property_flush[prop].nil?
+ # Call node_utils setter to update node
+ @X__RESOURCE_NAME__X.send("#{prop}=", @property_flush[prop]) if
+ @X__RESOURCE_NAME__X.respond_to?("#{prop}=")
+ end
+ end
+ }
+ end
+
+ def flush
+ if @property_flush[:ensure] == :absent
+ @X__RESOURCE_NAME__X.destroy
+ @X__RESOURCE_NAME__X = nil
+ else
+ # Create/Update
+ if @X__RESOURCE_NAME__X.nil?
+ new_instance = true
+ @X__RESOURCE_NAME__X = Cisco::X__CLASS_NAME__X.new(@resource[:name])
+ end
+ set_properties(new_instance)
+ end
+ end
+
+end
diff --git a/docs/template-type-feature.rb b/docs/template-type-feature.rb
new file mode 100644
index 000000000..065cde251
--- /dev/null
+++ b/docs/template-type-feature.rb
@@ -0,0 +1,43 @@
+#
+# Puppet resource type for feature X__RESOURCE_NAME__X
+#
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Puppet::Type.newtype(:X__RESOURCE_NAME__X) do
+
+ @doc = "Manages configuration of feature bash-shell
+
+ ```
+ cisco_bash_shell {'':
+ ..attributes..
+ }
+ ```
+
+ Example:
+ ```
+ cisco_X__RESOURCE_NAME__X {'xxxxx' :
+ ensure => present,
+ }
+ ```
+ "
+
+ ensurable
+
+ newparam(:name, :namevar => true) do
+ desc "Resource title. Valid values are string."
+ end
+
+ # There are no additional properties for this command.
+end
diff --git a/docs/template-type-router.rb b/docs/template-type-router.rb
new file mode 100644
index 000000000..8061c84c9
--- /dev/null
+++ b/docs/template-type-router.rb
@@ -0,0 +1,102 @@
+#
+# Puppet resource type for X__RESOURCE_NAME__X
+#
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Puppet::Type.newtype(:cisco_X__RESOURCE_NAME__X) do
+
+ # ---------------------------------------------------------------
+ # STEP 1. Create a @doc entry to describe the resource and usage
+ # ---------------------------------------------------------------
+ @doc = "Manages configuration of a X__RESOURCE_NAME__X instance
+
+ ```
+ cisco_X__RESOURCE_NAME__X {'':
+ ..attributes..
+ }
+ ```
+
+ `` is the name of the X__RESOURCE_NAME__X instance.
+
+ Example:
+
+ ```
+ cisco_X__RESOURCE_NAME__X { 'green' :
+ ensure => present,
+ # ---------------------------------------------------------------
+ # STEP 2. Include an example of each property this resource will
+ # support, e.g. shutdown => true
+ # ---------------------------------------------------------------
+ }
+ ```
+ "
+
+ ensurable
+
+ ###################
+ # Resource Naming #
+ ###################
+
+ # Parse the title to populate the attributes in these patterns.
+ # These attributes may be overwritten later.
+ def self.title_patterns
+ identity = lambda { |x| x }
+ patterns = []
+
+ # Below pattern matches the resource name.
+ patterns << [
+ /^(\S+)$/,
+ [
+ [:name, identity]
+ ]
+ ]
+ return patterns
+ end
+
+ newparam(:name, :namevar => true) do
+ desc "Name of the X__RESOURCE_NAME__X instance. Valid values are string."
+ end
+
+ # ---------------------------------------------------------------
+ # STEP 3. Define any properties. Examples are shown.
+ # ---------------------------------------------------------------
+
+ # -------------------------
+ # EXAMPLE. INTEGER PROPERTY
+ # -------------------------
+ newproperty(:X__PROPERTY_INT__X) do
+ desc " xxxxxxxxx. Valid values are integer, keyword 'default'."
+
+ munge { |value|
+ value = :default if value == 'default'
+ begin
+ value = Integer(value) unless value == :default
+ rescue
+ fail "X__PROPERTY_INT__X must be a valid integer, or default."
+ end
+ value
+ }
+ end
+
+ # -------------------------
+ # EXAMPLE. BOOLEAN PROPERTY
+ # -------------------------
+ newproperty(:X__PROPERTY_BOOL__X) do
+ desc "X__PROPERTY_BOOL__X state of the interface."
+
+ newvalues(:true, :false, :default)
+ end
+
+end
diff --git a/docs/tp_files.png b/docs/tp_files.png
new file mode 100644
index 000000000..e04615bd1
Binary files /dev/null and b/docs/tp_files.png differ
diff --git a/examples/README.md b/examples/README.md
new file mode 100644
index 000000000..d16dae4de
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,209 @@
+# Example Manifest Usage
+
+#### Table of Contents
+
+1. [Overview](#overview)
+2. [Initial Setup](#setup)
+3. [Run Basic Demo](#basic-demo)
+4. [Run Role Based Demo](#role-based-demo)
+5. [Run BGP IPv4/IPv6 Demo](#bgp-demo)
+6. [License Information](#license-information)
+
+## Overview
+
+This document describes how to use the example demo manifest files contained within the `examples` directory. There are several different demo's to choose from.
+
+* `demo_site.pp`
+ * Provides basic sample manifests to demo all cisco providers.
+* `demo_roles_site.pp`
+ * Provides a role based hierarchical set of sample manifests that can be used to demonstrate configuration of switches with different roles in a network.
+* `demo_bgp_[ipv4|ipv6]_site.pp`
+ * Provides sample manifests to configure bgp using the `cisco_command_config` provider.
+
+**Note:** Before following the steps in this guide make sure the puppet agent is [installed and configured.](https://github.com/puppetlabs/cisco-ciscopuppet/blob/master/README-AGENT-INSTALL.md)
+
+## Initial Setup
+
+### (Optional:) Uninstall Older Version of the `puppetlabs-ciscopuppet` Module.
+
+If your puppet master has an older version of the `puppetlabs-ciscopuppet` module installed go ahead and uninstall it now.
+
+#### List Current Module
+
+```bash
+puppetmaster:# puppet module list
+/etc/puppetlabs/code/environments/production/modules
+|
++-- puppetlabs-ciscopuppet (v0.9.0)
+/etc/puppetlabs/code/modules (no modules installed)
+/opt/puppetlabs/puppet/modules (no modules installed)
+```
+
+#### Remove Current Module
+
+```bash
+puppetmaster:# puppet module uninstall puppetlabs-ciscopuppet
+Notice: Preparing to uninstall 'puppetlabs-ciscopuppet' ...
+Removed 'puppetlabs-ciscopuppet' (v0.9.0) from /etc/puppetlabs/code/environments/production/modules
+```
+
+### Build and Install `puppetlabs-ciscopuppet` Module.
+
+The recommended workflow is to clone the `cisco-ciscopuppet.git` repository on your puppet master. This allows for easy build and installation of the `puppetlabs-ciscopuppet` module.
+
+#### Clone the `cisco-ciscopuppet.git` repo on your puppet master
+
+```bash
+puppetmaster:# git clone https://github.com/puppetlabs/cisco-ciscopuppet.git
+```
+
+#### Build the `puppetlabs-ciscopuppet` module on your puppet master
+
+Issue the following command one layer **above** the `cisco-ciscopuppet` directory on your puppet master.
+
+```bash
+puppetmaster:# puppet module build cisco-ciscopuppet/
+Notice: Building /githubpuppet/cisco-ciscopuppet for release
+Module built: /githubpuppet/cisco-ciscopuppet/pkg/puppetlabs-ciscopuppet-0.9.0.tar.gz
+```
+
+#### Install the `puppetlabs-ciscopuppet` module on your puppet master
+
+```bash
+puppetmaster:# cd cisco-ciscopuppet/pkg/
+puppetmaster:# puppet module install ./puppetlabs-ciscopuppet-[version].tar.gz
+Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
+Notice: Downloading from https://forgeapi.puppetlabs.com ...
+Notice: Installing -- do not interrupt ...
+/etc/puppetlabs/code/environments/production/modules
+|
++-- puppetlabs-ciscopuppet (v0.9.0)
+```
+
+**Note:** Optionally, restart your puppet server following the install.
+
+
+#### Copy all demo files under the `modules/ciscopuppet/examples/` directory to the `modules/ciscopuppet/manifests` directory
+
+```bash
+puppetmaster:# cd /etc/puppetlabs/code/environments/production/modules/ciscopuppet/examples
+puppetmaster:# cp -r ./demo* /etc/puppetlabs/code/environments/production/modules/ciscopuppet/manifests/
+```
+
+## Run Basic Demo
+
+The basic demo covers all existing cisco providers using a flat hierarchy. The `demo_site.pp` file is the sample `site.pp` file for this demo. For a current list of all cisco providers included in this demo visit the `demo_all.pp` file.
+
+### Copy `demo_site.pp` file to `production/manifests` directory
+
+```bash
+puppetmaster:# cd /etc/puppetlabs/code/environments/production/modules/ciscopuppet/examples
+puppetmaster:# cp ./demo_site.pp /etc/puppetlabs/code/environments/production/manifests/site.pp
+```
+
+### Modify the `site.pp` file to use your agent node name
+
+```puppet
+node 'your_node_name' { <---------------- Modify
+ include ciscopuppet::demo_all
+}
+```
+### Apply the demo `site.pp` manifest using the `puppet agent -t` command on the agent
+
+```bash
+root@n9k#puppet agent -t
+Info: Retrieving pluginfacts
+Info: Retrieving plugin
+Info: Loading facts
+Info: Caching catalog for n9k.domain.com
+Warning: Found multiple default providers for package: yum, puppet_gem, pip3; using yum
+Info: Applying configuration version '1438692679'
+Notice: /Stage[main]/Ciscopuppet::Install/Package[net_http_unix]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Install/Package[cisco_nxapi]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Install/Package[cisco_node_utils]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_command_config/Cisco_command_config[feature_bgp]/command: command changed '' to 'feature bgp
+'
+Notice: /Stage[main]/Ciscopuppet::Demo_command_config/Cisco_command_config[router_bgp_42]/command: command changed '' to 'router bgp 42
+router-id 192.168.1.42
+address-family ipv4 unicast
+network 10.0.0.0/8
+redistribute static route-map bgp-statics
+'
+Notice: /Stage[main]/Ciscopuppet::Demo_interface/Cisco_interface[Vlan22]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_ospf/Cisco_ospf[Sample]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_ospf/Cisco_interface_ospf[Ethernet1/1 Sample]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_ospf/Cisco_ospf_vrf[dark_blue default]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_ospf/Cisco_ospf_vrf[dark_blue vrf1]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_tacacs_server/Cisco_tacacs_server[default]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_tacacs_server_host/Cisco_tacacs_server_host[tachost]/ensure: created
+Notice: /Stage[main]/Ciscopuppet::Demo_vtp/Cisco_vtp[default]/ensure: created
+Notice: Applied catalog in 51.70 seconds
+root@n9k#
+```
+
+## Run Role Based Demo
+
+The role based demo covers resources that can be applied to switches that perform different roles in the network. The `demo_roles_site.pp` file is the sample `site.pp` file for this demo.
+
+### Copy `demo_roles_site.pp` file to `production/manifests` directory
+
+```bash
+puppetmaster:# cd /etc/puppetlabs/code/environments/production/modules/ciscopuppet/examples
+puppetmaster:# cp ./demo_roles_site.pp /etc/puppetlabs/code/environments/production/manifests/site.pp
+```
+
+#### Modify the `site.pp` file to use your agent node names
+
+```puppet
+node 'your_n9k-edge-switch' { <---------------- Modify
+ include ciscopuppet::demo_role::edge_switch
+}
+
+node 'your_n9k-internal-switch' { <---------------- Modify
+ include ciscopuppet::demo_role::internal_switch
+}
+
+node 'your_n3k-internal-switch' { <---------------- Modify
+ include demo_role::internal_switch
+}
+```
+#### Apply the demo `site.pp` manifest using the `puppet agent -t` command on the agent
+
+## Run BGP IPv4/IPv6 Demo
+
+The BGP [IPv4|IPv6] demo uses the `cisco_command_config` provider to apply sample bgp configuraton. The `demo_bgp_[ipv4|ipv6]_site.pp` file is the sample `site.pp` file for this demo.
+
+### Copy `demo_bgp_[ipv4|ipv6]_site.pp` file to `production/manifests` directory
+
+```bash
+puppetmaster:# cd /etc/puppetlabs/code/environments/production/modules/ciscopuppet/examples
+puppetmaster:# cp ./demo_bgp_[ipv4|ipv6]_site.pp /etc/puppetlabs/code/environments/production/manifests/site.pp
+```
+
+#### Modify the `site.pp` file to use your agent node name
+
+```puppet
+node 'cisco_[bgpv4|bgpv6]_device_name' { <------ Modify
+ include ciscopuppet::demo_bgp_[ipv4|ipv6]
+}
+```
+#### Apply the demo `site.pp` manifest using the `puppet agent -t` command on the agent
+
+
+## License Information
+
+```
+Copyright (c) 2014-2015 Cisco and/or its affiliates.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
diff --git a/examples/demo_bgp_ipv4_site.pp b/examples/demo_bgp_ipv4_site.pp
index 059e77d81..d5dfb6beb 100644
--- a/examples/demo_bgp_ipv4_site.pp
+++ b/examples/demo_bgp_ipv4_site.pp
@@ -14,6 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-node 'cisco_device_name' {
+node 'cisco_bgpv4_device_name' {
include ciscopuppet::demo_bgp_ipv4
}
diff --git a/examples/demo_bgp_ipv6_site.pp b/examples/demo_bgp_ipv6_site.pp
index 860b3fa93..68aad43f7 100644
--- a/examples/demo_bgp_ipv6_site.pp
+++ b/examples/demo_bgp_ipv6_site.pp
@@ -14,6 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-node 'cisco_device_name' {
+node 'cisco_bgpv6_device_name' {
include ciscopuppet::demo_bgp_ipv6
}
diff --git a/examples/demo_cisco_patch_rpm.pp b/examples/demo_cisco_patch_rpm.pp
index 75cb4bd4a..72098161e 100644
--- a/examples/demo_cisco_patch_rpm.pp
+++ b/examples/demo_cisco_patch_rpm.pp
@@ -16,13 +16,23 @@
class ciscopuppet::demo_cisco_patch_rpm {
- $repo = 'http://example_repo.domain.com/repo'
- #Install a Patch file
- $target = { 'target' => 'host' }
- package { "${repo}/n9000_sample-1.0.0-7.0.3.x86_64.rpm":
+ $ciscoPatchName = 'n9000_sample-1.0.0-7.0.3.x86_64.rpm'
+ $ciscoPatchSource = "puppet:///modules/ciscopuppet/${ciscoPatchName}"
+ $ciscoPatchFile = "/bootflash/${ciscoPatchName}"
+
+ file { $ciscoPatchFile :
+ ensure => file,
+ source => $ciscoPatchSource,
+ owner => 'root',
+ group => 'root',
+ mode => 'ug+rwx',
+ }
+
+ $settings = {'target' => 'host'}
+ package { 'n9000_sample':
ensure => present,
provider => 'nxapi',
- source => $::repo,
- package_settings => $::target,
+ source => $ciscoPatchFile,
+ package_settings => $settings,
}
}
diff --git a/examples/demo_patching.pp b/examples/demo_patching.pp
index 11d8d792c..33101f129 100644
--- a/examples/demo_patching.pp
+++ b/examples/demo_patching.pp
@@ -14,33 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# To apply this demo_patching manifest first you must setup your own local
+# repository and replace the '<>' markers with your local repo information.
+
class ciscopuppet::demo_patching {
- $repo = 'http://example.domain.com/repo'
- yumrepo { 'reponame' :
- name => 'reponame',
- baseurl => $repo,
- enabled => 1,
- gpgcheck => 0,
- }
# Handle differences between Native and Guestshell#
case $::osfamily {
- # TODO: 'RedHat' is no longer a value returned in the GS
- # by facter. This needs to be updated to another value
- # once we identify one.
'RedHat': { # GuestShell
- $rpmMibSource = $repo
-
- # GS/Centos: systemd services
- $svcDemoTarget = '/usr/lib/systemd/system/demo-one.service'
- $svcDemoSource = 'puppet:///modules/ciscopuppet/demo-one.service'
+ # GS/Centos: systemd services
+ $svcDemoTarget = '/usr/lib/systemd/system/demo-one.service'
+ $svcDemoSource = 'puppet:///modules/ciscopuppet/demo-one.service'
}
-
- 'wrLinux': { # Native
- $rpmMibSource = $repo
-
- # Native/WRL: init.d services
+ 'cisco-wrlinux': { # Native
+ # Native/WRL: init.d services
$svcDemoTarget = '/etc/init.d/demo-one'
$svcDemoSource = 'puppet:///modules/ciscopuppet/demo-one.initd'
}
@@ -50,34 +38,56 @@
#Use Case 1: install cisco package
- $rpmMib = "${rpmMibSource}/n9000_sample-1.0.0-7.0.3.x86_64.rpm"
+ $ciscoPatchName = 'n9000_sample-1.0.0-7.0.3.x86_64.rpm'
+ $ciscoPatchSource = "puppet:///modules/ciscopuppet/${ciscoPatchName}"
+ $ciscoPatchFile = "/bootflash/${ciscoPatchName}"
+
+ file { $ciscoPatchFile :
+ ensure => file,
+ source => $ciscoPatchSource,
+ owner => 'root',
+ group => 'root',
+ mode => 'ug+rwx',
+ }
+
$settings = {'target' => 'host'}
package { 'n9000_sample':
ensure => present,
provider => 'nxapi',
- source => $rpmMib,
+ source => $ciscoPatchFile,
package_settings => $settings,
}
- #Use Case 2: install third party package:
-
- $rpmDemo = "${repo}/demo-one-1.0-1.x86_64.rpm"
- package { 'demo-one':
- ensure => present,
- source => $rpmDemo,
- }
+ #Use Case 2: install third party package and
+ # start the service:
- #Use Case 3: install and start a service locally
+ #To install third party packages uncomment the
+ #following and replace the '<>' markers with
+ #your information.
- file { $svcDemoTarget :
- ensure => file,
- source => $svcDemoSource,
- owner => 'root',
- group => root,
- mode => 'ug+rwx',
- }
-
- service { 'demo-one':
- ensure => running,
- }
+ # $repo = '<>'
+ # yumrepo { '<>' :
+ # name => '<>',
+ # baseurl => $repo,
+ # enabled => 1,
+ # gpgcheck => 0,
+ # }
+ #
+ # $rpmDemo = "${repo}/"
+ # package { 'thirdParty':
+ # ensure => present,
+ # source => $rpmDemo,
+ # }
+ #
+ # file { $svcDemoTarget :
+ # ensure => file,
+ # source => $svcDemoSource,
+ # owner => 'root',
+ # group => root,
+ # mode => 'ug+rwx',
+ # }
+ #
+ # service { 'thirdParty':
+ # ensure => running,
+ #}
}
diff --git a/files/n9000_sample-1.0.0-7.0.3.x86_64.rpm b/files/n9000_sample-1.0.0-7.0.3.x86_64.rpm
new file mode 100644
index 000000000..4a5fdb918
Binary files /dev/null and b/files/n9000_sample-1.0.0-7.0.3.x86_64.rpm differ
diff --git a/lib/puppet/provider/cisco_command_config/nxapi.rb b/lib/puppet/provider/cisco_command_config/nxapi.rb
index f5053a2d7..1b96977fa 100644
--- a/lib/puppet/provider/cisco_command_config/nxapi.rb
+++ b/lib/puppet/provider/cisco_command_config/nxapi.rb
@@ -67,9 +67,6 @@ def command
debug "Minimum changeset to satisfy manifest:\n>#{@resource[:command]}<"
end
return @property_hash[:command]
-
- rescue Cisco::CliError => e
- fail e.message
end # command
def command=(cmds)
@@ -78,8 +75,9 @@ def command=(cmds)
debug "Output from node:\n#{output}" unless output.nil?
rescue Cisco::CliError => e
- info "Successfully updated:\n#{e.previous}" unless e.previous.empty?
- error e.message
+ # Tell the user what succeeded, then fail with the actual failure.
+ info "Successfully updated:\n#{e.previous.join("\n")}" unless e.previous.empty?
+ raise
end # command=
end # Puppet::Type
diff --git a/lib/puppet/provider/cisco_interface/nxapi.rb b/lib/puppet/provider/cisco_interface/nxapi.rb
index 6a6830cab..889bc682b 100644
--- a/lib/puppet/provider/cisco_interface/nxapi.rb
+++ b/lib/puppet/provider/cisco_interface/nxapi.rb
@@ -151,6 +151,7 @@ def ipv4_addr_mask_set
def flush
if @property_flush[:ensure] == :absent
@interface.destroy
+ @interface = nil
else
# Create/Update
if @interface.nil?
diff --git a/lib/puppet/provider/cisco_interface_ospf/nxapi.rb b/lib/puppet/provider/cisco_interface_ospf/nxapi.rb
index ccdfd03e6..40965ff36 100644
--- a/lib/puppet/provider/cisco_interface_ospf/nxapi.rb
+++ b/lib/puppet/provider/cisco_interface_ospf/nxapi.rb
@@ -40,7 +40,7 @@
# Setter properties
SETTER_NON_BOOL_PROPS = [
:cost, :hello_interval, :dead_interval, :message_digest_key_id,
- :message_digest_password,
+ :message_digest_password, :area,
]
SETTER_BOOL_PROPS = [
@@ -177,7 +177,5 @@ def flush
else
set_properties
end
- rescue RuntimeError => e
- fail e.message
end
end
diff --git a/lib/puppet/provider/cisco_ospf/nxapi.rb b/lib/puppet/provider/cisco_ospf/nxapi.rb
index 25878257a..1944b4a1a 100644
--- a/lib/puppet/provider/cisco_ospf/nxapi.rb
+++ b/lib/puppet/provider/cisco_ospf/nxapi.rb
@@ -28,20 +28,14 @@
def self.instances
ospf_instances = []
Cisco::RouterOspf.routers.each { |name, ospf_instance|
- begin
- debug "Checking resource OSPF #{name}"
- ospf_instances << new(
- :name => name,
- :ospf => ospf_instance,
- :ensure => :present)
- rescue RuntimeError => e
- warning "Failed to retrieve resource OSPF \"#{name}\: #{e.message}"
- end
+ debug "Checking resource OSPF #{name}"
+ ospf_instances << new(
+ :name => name,
+ :ospf => ospf_instance,
+ :ensure => :present)
}
return ospf_instances
- rescue RuntimeError => e
- fail(e.message)
end # self.instances
def self.prefetch(resources)
diff --git a/lib/puppet/provider/cisco_ospf_vrf/nxapi.rb b/lib/puppet/provider/cisco_ospf_vrf/nxapi.rb
index 5402f269b..4bf191564 100644
--- a/lib/puppet/provider/cisco_ospf_vrf/nxapi.rb
+++ b/lib/puppet/provider/cisco_ospf_vrf/nxapi.rb
@@ -102,6 +102,7 @@ def create
end
def destroy
+ fail "VRF default cannot be removed by cisco_ospf_vrf. Use cisco_ospf to remove the entire OSPF process including the default VRF." if @resource[:vrf] == 'default'
@property_flush[:ensure] = :absent
end
@@ -201,13 +202,9 @@ def timer_throttle_spf_set
end
def flush
- vrf_name = "ospf: #{@resource[:ospf]} vrf: #{@resource[:vrf]}"
if @property_flush[:ensure] == :absent
- begin
- @vrf.destroy
- rescue RuntimeError
- warning "Failed: Use cisco_ospf provider to remove #{vrf_name}"
- end
+ @vrf.destroy
+ @vrf = nil
else
if @vrf.nil?
new_vrf = true
diff --git a/lib/puppet/provider/cisco_snmp_group/nxapi.rb b/lib/puppet/provider/cisco_snmp_group/nxapi.rb
index a3b25eaf3..009c5c7fd 100644
--- a/lib/puppet/provider/cisco_snmp_group/nxapi.rb
+++ b/lib/puppet/provider/cisco_snmp_group/nxapi.rb
@@ -27,12 +27,10 @@
def self.instances
group_instances = []
- Cisco::SnmpGroup.groups.each { |id|
- begin
- group_instances << new(
- :name => id,
- :ensure => :present)
- end
+ Cisco::SnmpGroup.groups.each_key { |id|
+ group_instances << new(
+ :name => id,
+ :ensure => :present)
}
return group_instances
end
@@ -61,18 +59,16 @@ def exists?
@property_hash[:ensure] = :present
@property_hash[:group] = @resource[:group]
return true
- rescue RuntimeError => e
- fail(e.message)
end
def create
- error "Snmp group creation not supported. " +
- "Group #{@resource[:group]} not created."
+ fail "Snmp group creation not supported. " +
+ "Group #{@resource[:group]} not created."
end
def destroy
- error "Snmp group deletion not supported. " +
- "Group #{@resource[:group]} not deleted."
+ fail "Snmp group deletion not supported. " +
+ "Group #{@resource[:group]} not deleted."
end
end
diff --git a/lib/puppet/provider/cisco_snmp_user/nxapi.rb b/lib/puppet/provider/cisco_snmp_user/nxapi.rb
index 06d020e0c..11b27847b 100644
--- a/lib/puppet/provider/cisco_snmp_user/nxapi.rb
+++ b/lib/puppet/provider/cisco_snmp_user/nxapi.rb
@@ -28,23 +28,18 @@
def self.instances
snmp_users = []
- Cisco::SnmpUser.users.each { |index, snmp_user|
- begin
- snmp_users << new(
- :user => snmp_user.name,
- :name => "#{snmp_user.name} #{snmp_user.engine_id}".strip,
- :ensure => :present,
- :engine_id => snmp_user.engine_id,
- :groups => snmp_user.groups,
- :priv_protocol => snmp_user.priv_protocol,
- :priv_password => snmp_user.priv_password,
- :auth_protocol => snmp_user.auth_protocol,
- :auth_password => snmp_user.auth_password,
- :localized_key => :true)
-
- rescue RuntimeError => e
- warning "Failed to retrieve resources for #{index}: #{e.message}"
- end
+ Cisco::SnmpUser.users.each_value { |snmp_user|
+ snmp_users << new(
+ :user => snmp_user.name,
+ :name => "#{snmp_user.name} #{snmp_user.engine_id}".strip,
+ :ensure => :present,
+ :engine_id => snmp_user.engine_id,
+ :groups => snmp_user.groups,
+ :priv_protocol => snmp_user.priv_protocol,
+ :priv_password => snmp_user.priv_password,
+ :auth_protocol => snmp_user.auth_protocol,
+ :auth_password => snmp_user.auth_password,
+ :localized_key => :true)
}
return snmp_users
end
@@ -223,8 +218,6 @@ def unconfigure_snmp_user
@snmp_user.destroy()
@snmp_user = nil
@property_hash[:ensure] = :absent
- rescue RuntimeError => e
- fail e.message
end
def flush
diff --git a/lib/puppet/provider/cisco_tacacs_server/nxapi.rb b/lib/puppet/provider/cisco_tacacs_server/nxapi.rb
index 8f75c3929..6aaaed5f8 100644
--- a/lib/puppet/provider/cisco_tacacs_server/nxapi.rb
+++ b/lib/puppet/provider/cisco_tacacs_server/nxapi.rb
@@ -79,8 +79,6 @@ def self.instances
:source_interface => src_intf)
debug "Found a tacacs server on the device."
return tacacs_servers
- rescue RuntimeError => e
- fail e.message
end # self.instances
def self.prefetch(resources)
@@ -96,8 +94,6 @@ def create
@tacacs_server = Cisco::TacacsServer.new
- fail("Could not create a tacacs server.") if @tacacs_server.nil?
-
debug "Created a tacacs server on #{@resource[:name]}"
# Call all property setters
@@ -111,16 +107,12 @@ def create
@resource[:source_interface].nil?
tacacs_server_encryption_key_set
- rescue RuntimeError => e
- fail e.message
end # create
def destroy
debug "Removing a tacacs server."
@tacacs_server.destroy
@tacacs_server = nil
- rescue RuntimeError => e
- fail e.message
end # destroy
def timeout
@@ -142,14 +134,10 @@ def timeout=(should_value)
end
@tacacs_server.timeout = timeout_value
- rescue RuntimeError => e
- fail e.message
end # timeout=
def directed_request=(should_value)
@tacacs_server.directed_request = (should_value == :true)
- rescue RuntimeError => e
- fail e.message
end # directed_request=
def deadtime
@@ -173,8 +161,6 @@ def deadtime=(should_value)
end
@tacacs_server.deadtime = deadtime_value
- rescue RuntimeError => e
- fail e.message
end # deadtime=
def source_interface=(should_value)
@@ -185,8 +171,6 @@ def source_interface=(should_value)
end
@tacacs_server.source_interface = source_interface_value
- rescue RuntimeError => e
- fail e.message
end # source_interface=
def encryption_password=(should_value)
@@ -230,8 +214,6 @@ def tacacs_server_encryption_key_set
def flush
tacacs_server_encryption_key_set if @property_flush[:encryption_password]
- rescue RuntimeError => e
- fail e.message
end
end # provider
diff --git a/lib/puppet/provider/cisco_tacacs_server_host/nxapi.rb b/lib/puppet/provider/cisco_tacacs_server_host/nxapi.rb
index 0abdbc1ea..e44169f68 100644
--- a/lib/puppet/provider/cisco_tacacs_server_host/nxapi.rb
+++ b/lib/puppet/provider/cisco_tacacs_server_host/nxapi.rb
@@ -37,19 +37,14 @@ def initialize(value={})
def self.instances
tacacs_server_hosts = []
Cisco::TacacsServerHost.hosts.each { | host_name, tacacs_server_host |
- begin
- tacacs_server_hosts << new(
- :host => host_name,
- :name => host_name,
- :ensure => :present,
- :port => tacacs_server_host.port,
- :timeout => tacacs_server_host.timeout,
- :encryption_type => tacacs_server_host.encryption_type,
- :encryption_password => tacacs_server_host.encryption_password)
-
- rescue RuntimeError => e
- warning "Failed to retrieve resource for #{host_name}: #{e.message}"
- end
+ tacacs_server_hosts << new(
+ :host => host_name,
+ :name => host_name,
+ :ensure => :present,
+ :port => tacacs_server_host.port,
+ :timeout => tacacs_server_host.timeout,
+ :encryption_type => tacacs_server_host.encryption_type,
+ :encryption_password => tacacs_server_host.encryption_password)
}
return tacacs_server_hosts
end
@@ -147,8 +142,6 @@ def tacacs_server_host_encryption_key_set
@tacacs_server_host.encryption_key_set(encryption_type_value,
encryption_pw_value)
end
- rescue RuntimeError => e
- fail e.message
end
def update_port_or_timeout_attribute(attribute)
diff --git a/lib/puppet/provider/cisco_vlan/nxapi.rb b/lib/puppet/provider/cisco_vlan/nxapi.rb
index 2ef1253a1..c66bc3514 100644
--- a/lib/puppet/provider/cisco_vlan/nxapi.rb
+++ b/lib/puppet/provider/cisco_vlan/nxapi.rb
@@ -117,6 +117,7 @@ def set_properties(new_vlan=false)
def flush
if @property_flush[:ensure] == :absent
@vlan.destroy
+ @vlan = nil
else
# Create/Update
if @vlan.nil?
diff --git a/lib/puppet/provider/cisco_vtp/nxapi.rb b/lib/puppet/provider/cisco_vtp/nxapi.rb
index 81dc41968..b604376dd 100644
--- a/lib/puppet/provider/cisco_vtp/nxapi.rb
+++ b/lib/puppet/provider/cisco_vtp/nxapi.rb
@@ -45,7 +45,7 @@ def initialize(value={})
def self.get_properties(vtp)
current_state = {
- :name => name,
+ :name => 'default',
:ensure => :present,
}
@@ -108,7 +108,7 @@ def flush
# Create/Update
if @vtp.nil?
new_vtp = true
- @vtp = Cisco::Vtp.new(@resource[:domain])
+ @vtp = Cisco::Vtp.new
end
set_properties(new_vtp)
end
diff --git a/lib/puppet/type/cisco_interface_ospf.rb b/lib/puppet/type/cisco_interface_ospf.rb
index 6bd8fbad1..a58fddc7b 100644
--- a/lib/puppet/type/cisco_interface_ospf.rb
+++ b/lib/puppet/type/cisco_interface_ospf.rb
@@ -71,6 +71,10 @@ def name
newparam(:interface, :namevar => :true) do
desc "Name of this cisco_interface resource. Valid values are string."
+
+ munge { |value|
+ value.downcase
+ }
end
newparam(:ospf, :namevar => :true) do
@@ -208,7 +212,7 @@ def name
end
end
- newparam(:area) do
+ newproperty(:area) do
desc "Ospf area associated with this cisco_interface_ospf
instance. Valid values are string, formatted as an IP address
i.e. \"0.0.0.0\" or as an integer. Mandatory parameter."
@@ -219,20 +223,26 @@ def name
Integer(value) rescue valid_integer = false
IPAddr.new(value) rescue valid_ipaddr = false
- fail "area parameter - #{@resource[:area]} must be either a valid integer or a valid ip address" if valid_integer == false and valid_ipaddr == false
+ fail "area [#{value}] must be a valid ip address or integer" if
+ valid_integer == false and valid_ipaddr == false
}
munge { |value|
+ # Coerce numeric area to the expected dot-decimal format.
+ value = IPAddr.new(value, Socket::AF_INET) unless value.to_s[/\./]
value.to_s
}
end
- # validation for message_digest_key_id,
+ # validation for area, message_digest_key_id,
# message_digest_encryption_type, message_digest_encryption_password
# and message_digest_password combination
validate do
+ fail("area must be supplied when ensure=present") if
+ self[:ensure] == :present and self[:area].nil?
+
if (self[:message_digest_key_id].nil?) and
(!self[:message_digest_algorithm_type].nil? or
!self[:message_digest_encryption_type].nil? or
diff --git a/metadata.json b/metadata.json
index 21f12ca23..89270d616 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,17 +1,18 @@
{
"name": "puppetlabs-ciscopuppet",
- "version": "0.9.0",
+ "version": "0.9.1",
"author": "cisco",
"summary": "Cisco Puppet providers and types for NX-OS devices",
"license": "Apache-2.0",
"source": "https://github.com/puppetlabs/cisco-ciscopuppet",
+ "tags": ["cisco","nxos","nx-os","network"],
"project_page": "https://github.com/puppetlabs/cisco-ciscopuppet",
"issues_url": "https://github.com/puppetlabs/cisco-ciscopuppet/issues",
"operatingsystem_support": [
{
- "operatingsystem":"nexus",
+ "operatingsystem":"NX-OS",
"operatingsystemrelease": [
- "7.0"
+ "7.0(3)I2"
]
}
],
diff --git a/tests/beaker_tests/cisco_snmp_group/snmpgroup-provider-defaults.rb b/tests/beaker_tests/cisco_snmp_group/snmpgroup-provider-defaults.rb
new file mode 100644
index 000000000..1ceb86666
--- /dev/null
+++ b/tests/beaker_tests/cisco_snmp_group/snmpgroup-provider-defaults.rb
@@ -0,0 +1,151 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# TestCase Name:
+# -------------
+# SnmpGroup-Provider-Defaults.rb
+#
+# TestCase Prerequisites:
+# -----------------------
+# This is a SNMPGROUP resource testcase for Puppet Agent on Nexus devices.
+# The test case assumes the following prerequisites are already satisfied:
+# A. Populating the HOSTS configuration file with the agent and master
+# information.
+# B. Enabling SSH connection prerequisites on the N9K switch based Agent.
+# C. Starting of Puppet master server on master.
+# D. Sending to and signing of Puppet agent certificate request on master.
+#
+# TestCase:
+# ---------
+# This is a SNMPGROUP resource test that tests for default value for
+# 'ensure' attribute of a
+# cisco_snmp_group resource.
+#
+# There are 2 sections to the testcase: Setup, group of teststeps.
+# The 1st step is the Setup teststep that cleans up the switch state.
+# Steps 2-4 deal with cisco_snmp_group_resource and its
+# verification using Puppet Agent and the switch running-config.
+#
+# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
+# Bash shell command executions. For Vegas shell and Bash shell command
+# string executions, this is the exit_code convention:
+# 0 - successful command execution, > 0 - failed command execution.
+# For Puppet Agent command string executions, this is the exit_code convention:
+# 0 - no changes have occurred, 1 - errors have occurred,
+# 2 - changes have occurred, 4 - failures have occurred and
+# 6 - changes and failures have occurred.
+# 0 is the default exit_code checked in Beaker::DSL::Helpers::on() method.
+# The testcode also uses RegExp pattern matching on stdout or output IO
+# instance attributes of Result object from on() method invocation.
+#
+###############################################################################
+
+# Require UtilityLib.rb and SnmpGroupLib.rb paths.
+require File.expand_path('../../lib/utilitylib.rb', __FILE__)
+require File.expand_path('../snmpgrouplib.rb', __FILE__)
+
+result = 'PASS'
+testheader = 'SNMPGROUP Resource :: All Attributes Defaults'
+
+# @test_name [TestCase] Executes defaults testcase for SNMPGROUP Resource.
+test_name "TestCase :: #{testheader}" do
+ # @step [Step] Sets up switch for provider test.
+ step 'TestStep :: Setup switch for provider test' do
+ # Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
+ UtilityLib.set_manifest_path(master, self)
+
+ # In NX-OS there's no direct configuration of SNMP groups.
+ # Instead SNMP groups correspond to user roles, and our Puppet provider
+ # for cisco_snmp_group provides read-only access.
+
+ # Let's check and make sure that an expected default group/role is present
+ # and an unexpected non-default group/role is absent
+
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ cmd_str = UtilityLib.get_vshell_cmd('show snmp group | i Role')
+ on(agent, cmd_str) do
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *network-admin/],
+ false, self, logger)
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *foobar/],
+ true, self, logger)
+ end
+ logger.info("Setup switch for provider test :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step 'TestStep :: Get default manifest from master' do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, SnmpGroupLib.create_snmpgroup_manifest_defaults)
+
+ # Expected exit_code is 0 since this is a puppet agent cmd without change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ 'agent -t', options)
+ on(agent, cmd_str)
+
+ logger.info("Get default manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks cisco_snmp_group resource on agent using resource cmd.
+ step 'TestStep :: Check cisco_snmp_group resource state on agent' do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_snmp_group 'network-admin'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ { 'ensure' => 'present' },
+ false, self, logger)
+ end
+
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_snmp_group 'foobar'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ { 'ensure' => 'absent' },
+ false, self, logger)
+ end
+
+ logger.info("Check cisco_snmp_group resource state on agent :: #{result}")
+ end
+
+ # @step [Step] Checks snmpgroup instance on agent using switch show cli cmds.
+ step 'TestStep :: Check snmpgroup instance state in CLI' do
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ cmd_str = UtilityLib.get_vshell_cmd('show snmp group | i Role')
+ on(agent, cmd_str) do
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *network-admin/],
+ false, self, logger)
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *foobar/],
+ true, self, logger)
+ end
+
+ logger.info("Check snmpgroup instance state in CLI:: #{result}")
+ end
+
+ # @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
+ UtilityLib.raise_passfail_exception(result, testheader, self, logger)
+end
+
+logger.info("TestCase :: #{testheader} :: End")
diff --git a/tests/beaker_tests/cisco_snmp_group/snmpgroup-provider-negatives.rb b/tests/beaker_tests/cisco_snmp_group/snmpgroup-provider-negatives.rb
new file mode 100644
index 000000000..bbe4645de
--- /dev/null
+++ b/tests/beaker_tests/cisco_snmp_group/snmpgroup-provider-negatives.rb
@@ -0,0 +1,162 @@
+###############################################################################
+# Copyright (c) 2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# TestCase Name:
+# -------------
+# SnmpGroup-Provider-Negatives.rb
+#
+# TestCase Prerequisites:
+# -----------------------
+# This is a SNMPGROUP resource testcase for Puppet Agent on Nexus devices.
+# The test case assumes the following prerequisites are already satisfied:
+# A. Populating the HOSTS configuration file with the agent and master
+# information.
+# B. Enabling SSH connection prerequisites on the N9K switch based Agent.
+# C. Starting of Puppet master server on master.
+# D. Sending to and signing of Puppet agent certificate request on master.
+#
+# TestCase:
+# ---------
+# This is a SNMPGROUP resource test that tests for negative values for
+# aaa_user_cache_timeout, global_enforce_priv, packet_size, protocol,
+# tcp_session_auth, contact and location attributes of a
+# cisco_snmp_server resource.
+#
+# There are 2 sections to the testcase: Setup, group of teststeps.
+# The 1st step is the Setup teststep that cleans up the switch state.
+# The next set of teststeps deal with attribute negative tests and their
+# verification using Puppet Agent and the switch running-config.
+#
+# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
+# Bash shell command executions. For Vegas shell and Bash shell command
+# string executions, this is the exit_code convention:
+# 0 - successful command execution, > 0 - failed command execution.
+# For Puppet Agent command string executions, this is the exit_code convention:
+# 0 - no changes have occurred, 1 - errors have occurred,
+# 2 - changes have occurred, 4 - failures have occurred and
+# 6 - changes and failures have occurred.
+# 0 is the default exit_code checked in Beaker::DSL::Helpers::on() method.
+# The testcode also uses RegExp pattern matching on stdout or output IO
+# instance attributes of Result object from on() method invocation.
+#
+###############################################################################
+
+# Require UtilityLib.rb and SnmpGroupLib.rb paths.
+require File.expand_path('../../lib/utilitylib.rb', __FILE__)
+require File.expand_path('../snmpgrouplib.rb', __FILE__)
+
+result = 'PASS'
+testheader = 'SNMPGROUP Resource :: All Attributes Negatives'
+
+test_name "TestCase :: #{testheader}" do
+ # @step [Step] Sets up switch for provider test.
+ step 'TestStep :: Setup switch for provider test' do
+ # Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
+ UtilityLib.set_manifest_path(master, self)
+
+ # In NX-OS there's no direct configuration of SNMP groups.
+ # Instead SNMP groups correspond to user roles, and our Puppet provider
+ # for cisco_snmp_group provides read-only access.
+
+ # Let's check and make sure that an expected default group/role is present
+ # and an unexpected non-default group/role is absent
+
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ cmd_str = UtilityLib.get_vshell_cmd('show snmp group | i Role')
+ on(agent, cmd_str) do
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *network-operator/],
+ false, self, logger)
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *go-jackets/],
+ true, self, logger)
+ end
+ logger.info("Setup switch for provider test :: #{result}")
+ end
+
+ step 'TestStep :: Get negative test manifest #1 from master' do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, SnmpGroupLib.create_snmpgroup_manifest_negative_1)
+
+ # Expected exit_code is 4 since this is a puppet agent cmd with failure.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ 'agent -t', options)
+ on(agent, cmd_str, acceptable_exit_codes: [4])
+
+ logger.info("Get negative test manifest #1 from master :: #{result}")
+ end
+
+ step 'TestStep :: Get negative test manifest #2 from master' do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, SnmpGroupLib.create_snmpgroup_manifest_negative_2)
+
+ # Expected exit_code is 4 since this is a puppet agent cmd with failure.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ 'agent -t', options)
+ on(agent, cmd_str, acceptable_exit_codes: [4])
+
+ logger.info("Get negative test manifest #2 from master :: #{result}")
+ end
+
+ # @step [Step] Checks cisco_snmp_group resource on agent using resource cmd.
+ step 'TestStep :: Check cisco_snmp_group resource state on agent' do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_snmp_group 'network-operator'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ { 'ensure' => 'present' },
+ false, self, logger)
+ end
+
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_snmp_group 'go-jackets'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ { 'ensure' => 'absent' },
+ false, self, logger)
+ end
+
+ logger.info("Check cisco_snmp_group resource state on agent :: #{result}")
+ end
+
+ # @step [Step] Checks snmpgroup instance on agent using switch show cli cmds.
+ step 'TestStep :: Check snmpgroup instance state in CLI' do
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ cmd_str = UtilityLib.get_vshell_cmd('show snmp group | i Role')
+ on(agent, cmd_str) do
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *network-operator/],
+ false, self, logger)
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ UtilityLib.search_pattern_in_output(stdout,
+ [/Role: *go-jackets/],
+ true, self, logger)
+ end
+
+ logger.info("Check snmpgroup instance state in CLI:: #{result}")
+ end
+
+ # @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
+ UtilityLib.raise_passfail_exception(result, testheader, self, logger)
+end
+
+logger.info("TestCase :: #{testheader} :: End")
diff --git a/tests/beaker_tests/cisco_snmp_group/snmpgrouplib.rb b/tests/beaker_tests/cisco_snmp_group/snmpgrouplib.rb
new file mode 100644
index 000000000..247b6a129
--- /dev/null
+++ b/tests/beaker_tests/cisco_snmp_group/snmpgrouplib.rb
@@ -0,0 +1,76 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# SNMPGROUP Utility Library:
+# ---------------------------
+# snmpgrouplib.rb
+#
+# This is the utility library for the SNMPGROUP provider Beaker test cases that
+# contains the common methods used across the SNMPGROUP testsuite's cases. The
+# library is implemented as a module with related methods and constants defined
+# inside it for use as a namespace. All of the methods are defined as module
+# methods.
+#
+# Every Beaker SNMPGROUP test case that runs an instance of Beaker::TestCase
+# requires SnmpGroupLib module.
+#
+# The module has a single set of methods:
+# A. Methods to create manifests for cisco_snmp_group Puppet provider tests.
+###############################################################################
+
+# Require UtilityLib.rb path.
+require File.expand_path('../../lib/utilitylib.rb', __FILE__)
+
+module SnmpGroupLib
+ # Create a manifest describing SNMP group default state.
+ def self.create_snmpgroup_manifest_defaults
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ cisco_snmp_group { 'network-admin':
+ ensure => 'present',
+ }
+
+ cisco_snmp_group { 'foobar':
+ ensure => 'absent',
+ }
+}
+EOF"
+ manifest_str
+ end
+
+ # Negative test #1 - try to create a group that does not exist.
+ def self.create_snmpgroup_manifest_negative_1
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ cisco_snmp_group { 'go-jackets':
+ ensure => 'present',
+ }
+}
+EOF"
+ manifest_str
+ end
+
+ # Negative test #2 - try to delete a group that exists.
+ def self.create_snmpgroup_manifest_negative_2
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ cisco_snmp_group { 'network-operator':
+ ensure => 'absent',
+ }
+}
+EOF"
+ manifest_str
+ end
+end
diff --git a/tests/beaker_tests/ciscocommand/ciscocommand-provider-nondefaults.rb b/tests/beaker_tests/ciscocommand/ciscocommand-provider-nondefaults.rb
new file mode 100644
index 000000000..a012a1949
--- /dev/null
+++ b/tests/beaker_tests/ciscocommand/ciscocommand-provider-nondefaults.rb
@@ -0,0 +1,107 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# TestCase Name:
+# --------------
+# CiscoCommand-Provider-NonDefaults.rb
+#
+# TestCase Prerequisites:
+# -----------------------
+# This is a Puppet CISCOCMD resource testcase for Puppet Agent on Nexus devices.
+# The test case assumes the following prerequisites are already satisfied:
+# A. Populating the HOSTS configuration file with the agent and master
+# information.
+# B. Enabling SSH connection prerequisites on the N9K switch based Agent.
+# C. Starting of Puppet master server on master.
+# D. Sending to and signing of Puppet agent certificate request on master.
+#
+# TestCase:
+# ---------
+# This is a CISCOCMD resource test that tests for nondefault values for
+# command attribute of a cisco_command_config resource.
+#
+# There are 2 sections to the testcase: Setup, group of teststeps.
+# The 1st step is the Setup teststep that cleans up the switch state.
+# Steps 2-3 deal with cisco_command_config resource creation and its
+# verification using Puppet Agent and the switch running-config.
+#
+# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
+# Bash shell command executions. For Vegas shell and Bash shell command
+# string executions, this is the exit_code convention:
+# 0 - successful command execution, > 0 - failed command execution.
+# For Puppet Agent command string executions, this is the exit_code convention:
+# 0 - no changes have occurred, 1 - errors have occurred,
+# 2 - changes have occurred, 4 - failures have occurred and
+# 6 - changes and failures have occurred.
+# 0 is the default exit_code checked in Beaker::DSL::Helpers::on() method.
+# The testcode also uses RegExp pattern matching on stdout or output IO
+# instance attributes of Result object from on() method invocation.
+#
+###############################################################################
+
+# Require UtilityLib.rb and CiscoCommandLib.rb paths.
+require File.expand_path("../../lib/utilitylib.rb", __FILE__)
+require File.expand_path("../ciscocommandlib.rb", __FILE__)
+
+result = 'PASS'
+testheader = "CISCOCOMMAND Resource :: All Attributes NonDefaults"
+
+# @test_name [TestCase] Executes nondefaults testcase for CISCOCOMMAND Resource.
+test_name "TestCase :: #{testheader}" do
+
+ # @step [Step] Sets up switch for provider test.
+ step "TestStep :: Setup switch for provider test" do
+ # Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
+ UtilityLib.set_manifest_path(master, self)
+
+ logger.info("Setup switch for provider test :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource present manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, CiscoCommandLib.create_cisco_command_nondefaults())
+
+ # Expected exit_code is 0 since this is a puppet agent cmd with no change.
+ # Or expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [0, 2]})
+
+ logger.info("Get resource present manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks ciscocommand instance on agent using show cli cmds.
+ step "TestStep :: Check ciscocommand instance presence on agent" do
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config interface ethernet1/2")
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ [/description This is the new interface config/,
+ /switchport access vlan 100/],
+ false, self, logger)
+ end
+
+ logger.info("Check ciscocommand instance presence on agent :: #{result}")
+ end
+
+ # @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
+ UtilityLib.raise_passfail_exception(result, testheader, self, logger)
+
+end
+
+logger.info("TestCase :: #{testheader} :: End")
+
diff --git a/tests/beaker_tests/ciscocommand/ciscocommandlib.rb b/tests/beaker_tests/ciscocommand/ciscocommandlib.rb
new file mode 100644
index 000000000..6e4f1cf68
--- /dev/null
+++ b/tests/beaker_tests/ciscocommand/ciscocommandlib.rb
@@ -0,0 +1,67 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# CISCOCOMMAND Utility Library:
+# -----------------------------
+# ciscocommandlib.rb
+#
+# This is the utility library for the CISCOCMD provider Beaker test cases that
+# contains the common methods used across the CISCOCMD testsuite's cases. The
+# library is implemented as a module with related methods and constants defined
+# inside it for use as a namespace. All of the methods are defined as module
+# methods.
+#
+# Every Beaker CISCOCMD test case that runs an instance of Beaker::TestCase
+# requires CiscoCommandLib module.
+#
+# The module has a single set of methods:
+# A. Methods to create manifests for cisco_command_config Puppet test cases.
+###############################################################################
+
+# Require UtilityLib.rb path.
+require File.expand_path("../../lib/utilitylib.rb", __FILE__)
+
+module CiscoCommandLib
+
+ # A. Methods to create manifests for cisco_command_config Puppet test cases.
+
+ # Method to create a manifest for CISCOCOMMAND resource attribute:
+ # command.
+ # 'command' is set to the NXOS command list to be applied to switch config.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def CiscoCommandLib.create_cisco_command_nondefaults()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ cisco_command_config { 'interface_config':
+ command => '
+ vlan 100
+ state suspend
+ exit
+ interface Ethernet1/2
+ description This is the new interface config.
+ switchport
+ switchport mode access
+ switchport access vlan 100
+ no shutdown
+ exit',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+end
+
diff --git a/tests/beaker_tests/fileservicepkg/file-provider-nondefaults.rb b/tests/beaker_tests/fileservicepkg/file-provider-nondefaults.rb
new file mode 100644
index 000000000..bfd6527b3
--- /dev/null
+++ b/tests/beaker_tests/fileservicepkg/file-provider-nondefaults.rb
@@ -0,0 +1,156 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# TestCase Name:
+# --------------
+# File-Provider-NonDefaults.rb
+#
+# TestCase Prerequisites:
+# -----------------------
+# This is a Puppet FILE resource testcase for Puppet Agent on Nexus devices.
+# The test case assumes the following prerequisites are already satisfied:
+# A. Populating the HOSTS configuration file with the agent and master
+# information.
+# B. Enabling SSH connection prerequisites on the N9K switch based Agent.
+# C. Starting of Puppet master server on master.
+# D. Sending to and signing of Puppet agent certificate request on master.
+#
+# TestCase:
+# ---------
+# This is a FILE resource test that tests for nondefault values for
+# path, ensure, content, checksum, mode, owner and provider attributes of a
+# file resource when created with 'ensure' => 'present'.
+#
+# There are 2 sections to the testcase: Setup, group of teststeps.
+# The 1st step is the Setup teststep that cleans up the switch state.
+# Steps 2-3 deal with file resource creation and its
+# verification using Puppet Agent and the switch running-config.
+# Steps 4-5 deal with file resource deletion and its
+# verification using Puppet Agent and the switch running-config.
+#
+# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
+# Bash shell command executions. For Vegas shell and Bash shell command
+# string executions, this is the exit_code convention:
+# 0 - successful command execution, > 0 - failed command execution.
+# For Puppet Agent command string executions, this is the exit_code convention:
+# 0 - no changes have occurred, 1 - errors have occurred,
+# 2 - changes have occurred, 4 - failures have occurred and
+# 6 - changes and failures have occurred.
+# 0 is the default exit_code checked in Beaker::DSL::Helpers::on() method.
+# The testcode also uses RegExp pattern matching on stdout or output IO
+# instance attributes of Result object from on() method invocation.
+#
+###############################################################################
+
+# Require UtilityLib.rb and FileSvcPkgLib.rb paths.
+require File.expand_path("../../lib/utilitylib.rb", __FILE__)
+require File.expand_path("../filesvcpkglib.rb", __FILE__)
+
+result = 'PASS'
+testheader = "FILE Resource :: All Attributes NonDefaults"
+
+# @test_name [TestCase] Executes nondefaults testcase for FILE Resource.
+test_name "TestCase :: #{testheader}" do
+
+ # @step [Step] Sets up switch for provider test.
+ step "TestStep :: Setup switch for provider test" do
+ # Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
+ UtilityLib.set_manifest_path(master, self)
+
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_file_manifest_absent())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ # Or expected exit_code is 0 since this is a puppet agent cmd with no change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [0, 2]})
+
+ logger.info("Setup switch for provider test :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource nondefaults manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_file_manifest_nondefaults())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+
+ logger.info("Get resource nondefaults manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks file resource on agent using resource cmd.
+ step "TestStep :: Check file resource presence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource file '/tmp/testfile.txt'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'file',
+ 'content' => '{md5}[0-9a-fA-F]*',
+ 'group' => '0',
+ 'mode' => '0664',
+ 'owner' => '0',
+ 'type' => 'file'},
+ false, self, logger)
+ end
+
+ logger.info("Check file resource presence on agent :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource absent manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_file_manifest_absent())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+
+ logger.info("Get resource absent manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks file resource on agent using resource cmd.
+ step "TestStep :: Check file resource absence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource file '/tmp/testfile.txt'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'file',
+ 'content' => '{md5}[0-9a-fA-F]*',
+ 'group' => '0',
+ 'mode' => '0664',
+ 'owner' => '0',
+ 'type' => 'file'},
+ true, self, logger)
+ end
+
+ logger.info("Check file resource absence on agent :: #{result}")
+ end
+
+ # @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
+ UtilityLib.raise_passfail_exception(result, testheader, self, logger)
+
+end
+
+logger.info("TestCase :: #{testheader} :: End")
+
diff --git a/tests/beaker_tests/fileservicepkg/filesvcpkglib.rb b/tests/beaker_tests/fileservicepkg/filesvcpkglib.rb
new file mode 100644
index 000000000..67fe4bb1d
--- /dev/null
+++ b/tests/beaker_tests/fileservicepkg/filesvcpkglib.rb
@@ -0,0 +1,181 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# FILESVCPKG Utility Library:
+# ----------------------------
+# filesvcpkglib.rb
+#
+# This is the utility library for the FILESVCPKG provider Beaker test cases that
+# contains the common methods used across the FILESVCPKG testsuite's cases. The
+# library is implemented as a module with related methods and constants defined
+# inside it for use as a namespace. All of the methods are defined as module
+# methods.
+#
+# Every Beaker FILESVCPKG test case that runs an instance of Beaker::TestCase
+# requires FileSvcPkgLib module.
+#
+# The module has a single set of methods:
+# A. Methods to create manifests for file, service and pkg Puppet test cases.
+###############################################################################
+
+# Require UtilityLib.rb path.
+require File.expand_path("../../lib/utilitylib.rb", __FILE__)
+
+module FileSvcPkgLib
+
+ # A. Methods to create manifests for file, service and pkg Puppet test cases.
+
+ # Method to create a manifest for FILE resource attributes:
+ # path, ensure, content, checksum, mode, owner and provider.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_file_manifest_nondefaults()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ file { 'testfile.txt':
+ path => '/tmp/testfile.txt',
+ ensure => present,
+ content => 'These are the contents of the file.',
+ checksum => 'sha256',
+ mode => 'ug+rw',
+ owner => 'root',
+ provider => 'posix',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for FILE resource attribute 'ensure' where
+ # 'ensure' is set to absent.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_file_manifest_absent()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ file { 'testfile.txt':
+ path => '/tmp/testfile.txt',
+ ensure => absent,
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for SVC resource attributes:
+ # name, ensure and enable.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_service_manifest_nondefaults()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ service { 'syslog':
+ name => 'syslog',
+ ensure => 'running',
+ enable => 'true',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for SVC resource attribute 'ensure' where
+ # 'ensure' is set to stopped.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_service_manifest_stopped()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ service { 'syslog':
+ name => 'syslog',
+ ensure => 'stopped',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for PKG resource attribute 'ensure' where
+ # 'ensure' is set to installed.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_package_curl_manifest_installed()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ package { 'curl':
+ name => 'curl',
+ ensure => installed,
+ provider => 'yum',
+ allow_virtual => 'false',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for PKG resource attribute 'ensure' where
+ # 'ensure' is set to latest.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_package_curl_manifest_latest()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ package { 'curl':
+ name => 'curl',
+ ensure => latest,
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for PKG resource attribute 'ensure' where
+ # 'ensure' is set to present.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_package_sample_manifest_present()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ package { 'n9000_sample.x86_64':
+ name => 'n9000_sample-1.0.0-7.0.3.x86_64.rpm',
+ ensure => present,
+ provider => 'yum',
+ source => '/bootflash/n9000_sample-1.0.0-7.0.3.x86_64.rpm',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for PKG resource attribute 'ensure' where
+ # 'ensure' is set to absent.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def FileSvcPkgLib.create_package_sample_manifest_absent()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ package { 'n9000_sample.x86_64':
+ name => 'n9000_sample-1.0.0-7.0.3.x86_64.rpm',
+ ensure => absent,
+ provider => 'yum',
+ source => '/bootflash/puppet-rpm/n9000_sample-1.0.0-7.0.3.x86_64.rpm',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+end
+
diff --git a/tests/beaker_tests/fileservicepkg/package-provider-nondefaults-1.rb b/tests/beaker_tests/fileservicepkg/package-provider-nondefaults-1.rb
new file mode 100644
index 000000000..86a538367
--- /dev/null
+++ b/tests/beaker_tests/fileservicepkg/package-provider-nondefaults-1.rb
@@ -0,0 +1,116 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# TestCase Name:
+# --------------
+# Package-Provider-NonDefaults-1.rb
+#
+# TestCase Prerequisites:
+# -----------------------
+# This is a Puppet PACKAGE resource testcase for Puppet Agent on Nexus devices.
+# The test case assumes the following prerequisites are already satisfied:
+# A. Populating the HOSTS configuration file with the agent and master
+# information.
+# B. Enabling SSH connection prerequisites on the N9K switch based Agent.
+# C. Starting of Puppet master server on master.
+# D. Sending to and signing of Puppet agent certificate request on master.
+#
+# TestCase:
+# ---------
+# This is a PACKAGE resource test that tests for nondefault values for
+# name, ensure, provider and allow_virtual attributes of a
+# package resource when installed with 'ensure' => 'installed'.
+#
+# There are 2 sections to the testcase: Setup, group of teststeps.
+# The 1st step is the Setup teststep that cleans up the switch state.
+# Steps 2-3 deal with package resource installation and its
+# verification using Puppet Agent and the switch running-config.
+#
+# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
+# Bash shell command executions. For Vegas shell and Bash shell command
+# string executions, this is the exit_code convention:
+# 0 - successful command execution, > 0 - failed command execution.
+# For Puppet Agent command string executions, this is the exit_code convention:
+# 0 - no changes have occurred, 1 - errors have occurred,
+# 2 - changes have occurred, 4 - failures have occurred and
+# 6 - changes and failures have occurred.
+# 0 is the default exit_code checked in Beaker::DSL::Helpers::on() method.
+# The testcode also uses RegExp pattern matching on stdout or output IO
+# instance attributes of Result object from on() method invocation.
+#
+###############################################################################
+
+# Require UtilityLib.rb and FileSvcPkgLib.rb paths.
+require File.expand_path("../../lib/utilitylib.rb", __FILE__)
+require File.expand_path("../filesvcpkglib.rb", __FILE__)
+
+result = 'PASS'
+testheader = "PACKAGE Resource :: All Attributes NonDefaults"
+
+# @test_name [TestCase] Executes nondefaults testcase for PACKAGE Resource.
+test_name "TestCase :: #{testheader}" do
+
+ # @step [Step] Sets up switch for provider test.
+ step "TestStep :: Setup switch for provider test" do
+ # Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
+ UtilityLib.set_manifest_path(master, self)
+
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_package_curl_manifest_latest())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ # Or expected exit_code is 0 since this is a puppet agent cmd with no change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [0, 2]})
+
+ logger.info("Setup switch for provider test :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource installed manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_package_curl_manifest_installed())
+
+ # Expected exit_code is 0 since this is a puppet agent cmd with no change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [0]})
+
+ logger.info("Get resource installed manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks package resource on agent using resource cmd.
+ step "TestStep :: Check package resource presence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource package 'curl'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present'},
+ false, self, logger)
+ end
+
+ logger.info("Check package resource presence on agent :: #{result}")
+ end
+
+ # @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
+ UtilityLib.raise_passfail_exception(result, testheader, self, logger)
+
+end
+
+logger.info("TestCase :: #{testheader} :: End")
+
diff --git a/tests/beaker_tests/snmpserver/snmpgroup-provider-defaults.rb b/tests/beaker_tests/fileservicepkg/package-provider-nondefaults-2.rb
similarity index 62%
rename from tests/beaker_tests/snmpserver/snmpgroup-provider-defaults.rb
rename to tests/beaker_tests/fileservicepkg/package-provider-nondefaults-2.rb
index 0b95dc4e7..a854e98e1 100644
--- a/tests/beaker_tests/snmpserver/snmpgroup-provider-defaults.rb
+++ b/tests/beaker_tests/fileservicepkg/package-provider-nondefaults-2.rb
@@ -14,12 +14,12 @@
# limitations under the License.
###############################################################################
# TestCase Name:
-# -------------
-# SnmpGroup-Provider-Defaults.rb
+# --------------
+# Package-Provider-NonDefaults-2.rb
#
# TestCase Prerequisites:
# -----------------------
-# This is a Puppet SNMPGROUP resource testcase for Puppet Agent on Nexus devices.
+# This is a Puppet PACKAGE resource testcase for Puppet Agent on Nexus devices.
# The test case assumes the following prerequisites are already satisfied:
# A. Populating the HOSTS configuration file with the agent and master
# information.
@@ -29,13 +29,13 @@
#
# TestCase:
# ---------
-# This is a SNMPGROUP resource test that tests for default value for
-# 'ensure' attribute of a
-# cisco_snmp_group resource.
+# This is a PACKAGE resource test that tests for nondefault values for
+# name, ensure, provider and source attributes of a
+# package resource when installed with 'ensure' => 'present'.
#
# There are 2 sections to the testcase: Setup, group of teststeps.
# The 1st step is the Setup teststep that cleans up the switch state.
-# Steps 2-4 deal with cisco_snmp_group_resource and its
+# Steps 2-3 deal with package resource installation and its
# verification using Puppet Agent and the switch running-config.
#
# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
@@ -52,14 +52,14 @@
#
###############################################################################
-# Require UtilityLib.rb and SnmpServerLib.rb paths.
+# Require UtilityLib.rb and FileSvcPkgLib.rb paths.
require File.expand_path("../../lib/utilitylib.rb", __FILE__)
-require File.expand_path("../snmpserverlib.rb", __FILE__)
+require File.expand_path("../filesvcpkglib.rb", __FILE__)
result = 'PASS'
-testheader = "SNMPGROUP Resource :: All Attributes Defaults"
+testheader = "PACKAGE Resource :: All Attributes NonDefaults"
-# @test_name [TestCase] Executes defaults testcase for SNMPGROUP Resource.
+# @test_name [TestCase] Executes nondefaults testcase for PACKAGE Resource.
test_name "TestCase :: #{testheader}" do
# @step [Step] Sets up switch for provider test.
@@ -67,63 +67,53 @@
# Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
UtilityLib.set_manifest_path(master, self)
- # Expected exit_code is 0 since this is a vegas shell cmd.
- # Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_vshell_cmd("show running-config snmp")
- on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout,
- [/snmp-server user admin network-admin auth md5/],
- false, self, logger)
- end
+ # Expected exit_code is 0 since this is a puppet agent cmd with no change.
+ cmd_str =
+ UtilityLib.get_vshell_cmd("dir bootflash:n9000_sample-1.0.0-7.0.3.x86_64.rpm")
+ on(agent, cmd_str, {:acceptable_exit_codes => [0]})
+
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_package_sample_manifest_absent())
+
+ # Expected exit_code is 0 since this is a puppet agent cmd with no change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [0]})
logger.info("Setup switch for provider test :: #{result}")
end
# @step [Step] Requests manifest from the master server to the agent.
- step "TestStep :: Get resource present manifest from master" do
+ step "TestStep :: Get resource present manifest from master" do
# Expected exit_code is 0 since this is a bash shell cmd.
- on(master, SnmpServerLib.create_snmpgroup_manifest_present())
+ on(master, FileSvcPkgLib.create_package_sample_manifest_present())
- # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ # Expected exit_code is 0 since this is a puppet agent cmd with no change.
cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
- on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+ on(agent, cmd_str, {:acceptable_exit_codes => [0]})
logger.info("Get resource present manifest from master :: #{result}")
end
- # @step [Step] Checks cisco_snmp_group resource on agent using resource cmd.
- step "TestStep :: Check cisco_snmp_group resource absence on agent" do
+ # @step [Step] Checks package resource on agent using resource cmd.
+ step "TestStep :: Check package resource presence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
- # Flag is set to true to check for absence of RegExp pattern in stdout.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
- "resource cisco_snmp_group 'netadmin-test'", options)
- on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout,
- {'ensure' => 'present'},
- true, self, logger)
- end
-
- logger.info("Check cisco_snmp_group resource absence on agent :: #{result}")
- end
-
- # @step [Step] Checks snmpgroup instance on agent using switch show cli cmds.
- step "TestStep :: Check snmpgroup instance absence on agent" do
- # Expected exit_code is 0 since this is a vegas shell cmd.
- # Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_vshell_cmd("show running-config snmp")
+ "resource package 'n9000_sample.x86_64'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout,
- [/netadmin-test/],
- true, self, logger)
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present'},
+ false, self, logger)
end
- logger.info("Check snmpgroup instance absence on agent :: #{result}")
+ logger.info("Check package resource presence on agent :: #{result}")
end
# @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
UtilityLib.raise_passfail_exception(result, testheader, self, logger)
-
+
end
logger.info("TestCase :: #{testheader} :: End")
diff --git a/tests/beaker_tests/fileservicepkg/service-provider-nondefaults.rb b/tests/beaker_tests/fileservicepkg/service-provider-nondefaults.rb
new file mode 100644
index 000000000..1fc8213e3
--- /dev/null
+++ b/tests/beaker_tests/fileservicepkg/service-provider-nondefaults.rb
@@ -0,0 +1,146 @@
+###############################################################################
+# Copyright (c) 2014-2015 Cisco and/or its affiliates.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+# TestCase Name:
+# --------------
+# Service-Provider-NonDefaults.rb
+#
+# TestCase Prerequisites:
+# -----------------------
+# This is a Puppet SERVICE resource testcase for Puppet Agent on Nexus devices.
+# The test case assumes the following prerequisites are already satisfied:
+# A. Populating the HOSTS configuration file with the agent and master
+# information.
+# B. Enabling SSH connection prerequisites on the N9K switch based Agent.
+# C. Starting of Puppet master server on master.
+# D. Sending to and signing of Puppet agent certificate request on master.
+#
+# TestCase:
+# ---------
+# This is a SERVICE resource test that tests for nondefault values for
+# name, ensure and enable attributes of a
+# service resource when ran with 'ensure' => 'running'.
+#
+# There are 2 sections to the testcase: Setup, group of teststeps.
+# The 1st step is the Setup teststep that cleans up the switch state.
+# Steps 2-3 deal with service resource running and its
+# verification using Puppet Agent and the switch running-config.
+# Steps 4-5 deal with service resource stopping and its
+# verification using Puppet Agent and the switch running-config.
+#
+# The testcode checks for exit_codes from Puppet Agent, Vegas shell and
+# Bash shell command executions. For Vegas shell and Bash shell command
+# string executions, this is the exit_code convention:
+# 0 - successful command execution, > 0 - failed command execution.
+# For Puppet Agent command string executions, this is the exit_code convention:
+# 0 - no changes have occurred, 1 - errors have occurred,
+# 2 - changes have occurred, 4 - failures have occurred and
+# 6 - changes and failures have occurred.
+# 0 is the default exit_code checked in Beaker::DSL::Helpers::on() method.
+# The testcode also uses RegExp pattern matching on stdout or output IO
+# instance attributes of Result object from on() method invocation.
+#
+###############################################################################
+
+# Require UtilityLib.rb and FileSvcPkgLib.rb paths.
+require File.expand_path("../../lib/utilitylib.rb", __FILE__)
+require File.expand_path("../filesvcpkglib.rb", __FILE__)
+
+result = 'PASS'
+testheader = "SERVICE Resource :: All Attributes NonDefaults"
+
+# @test_name [TestCase] Executes nondefaults testcase for SERVICE Resource.
+test_name "TestCase :: #{testheader}" do
+
+ # @step [Step] Sets up switch for provider test.
+ step "TestStep :: Setup switch for provider test" do
+ # Define PUPPETMASTER_MANIFESTPATH constant using puppet config cmd.
+ UtilityLib.set_manifest_path(master, self)
+
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_service_manifest_stopped())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ # Or expected exit_code is 0 since this is a puppet agent cmd with no change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [0, 2]})
+
+ logger.info("Setup switch for provider test :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource nondefaults manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_service_manifest_nondefaults())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+
+ logger.info("Get resource nondefaults manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks service resource on agent using resource cmd.
+ step "TestStep :: Check service resource presence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to false to check for presence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource service 'syslog'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'running'},
+ false, self, logger)
+ end
+
+ logger.info("Check service resource presence on agent :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get resource stopped manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, FileSvcPkgLib.create_service_manifest_stopped())
+
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+
+ logger.info("Get resource stopped manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks service resource on agent using resource cmd.
+ step "TestStep :: Check service resource absence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource service 'syslog'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'running'},
+ true, self, logger)
+ end
+
+ logger.info("Check service resource absence on agent :: #{result}")
+ end
+
+ # @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
+ UtilityLib.raise_passfail_exception(result, testheader, self, logger)
+
+end
+
+logger.info("TestCase :: #{testheader} :: End")
+
diff --git a/tests/beaker_tests/ospf/ospf-provider-ensurability.rb b/tests/beaker_tests/ospf/ospf-provider-ensurability.rb
index 7e8d50779..40afd19a9 100644
--- a/tests/beaker_tests/ospf/ospf-provider-ensurability.rb
+++ b/tests/beaker_tests/ospf/ospf-provider-ensurability.rb
@@ -76,7 +76,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -89,7 +89,7 @@
on(master, OspfLib.create_ospf_manifest_present())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -100,10 +100,10 @@
step "TestStep :: Check cisco_ospf resource presence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf green", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, {"ensure" => "present"}, \
+ UtilityLib.search_pattern_in_output(stdout, {'ensure' => 'present'},
false, self, logger)
end
@@ -116,7 +116,7 @@
# Flag is set to false to check for presence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf green/],
false, self, logger)
end
@@ -129,7 +129,7 @@
on(master, OspfLib.create_ospf_manifest_absent())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -140,10 +140,10 @@
step "TestStep :: Check cisco_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf green", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, {"ensure" => "present"}, \
+ UtilityLib.search_pattern_in_output(stdout, {'ensure' => 'present'},
true, self, logger)
end
@@ -156,7 +156,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf green/],
true, self, logger)
end
diff --git a/tests/beaker_tests/ospf/ospf-provider-negative.rb b/tests/beaker_tests/ospf/ospf-provider-negative.rb
index 76b4b2298..17d15fa33 100644
--- a/tests/beaker_tests/ospf/ospf-provider-negative.rb
+++ b/tests/beaker_tests/ospf/ospf-provider-negative.rb
@@ -74,7 +74,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -87,7 +87,7 @@
on(master, OspfLib.create_ospf_manifest_negative())
# Expected exit_code is 1 since this is a puppet agent cmd with error.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [1]})
@@ -98,11 +98,11 @@
step "TestStep :: Check cisco_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf green", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => OspfLib::ENSURE_NEGATIVE}, true, self, logger)
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => OspfLib::ENSURE_NEGATIVE}, true, self, logger)
end
logger.info("Check cisco_ospf resource absence on agent :: #{result}")
@@ -114,7 +114,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf green/],
true, self, logger)
end
diff --git a/tests/beaker_tests/ospfintf/ospfintf-provider-defaults.rb b/tests/beaker_tests/ospfintf/ospfintf-provider-defaults.rb
index 48326b55b..197be8a57 100644
--- a/tests/beaker_tests/ospfintf/ospfintf-provider-defaults.rb
+++ b/tests/beaker_tests/ospfintf/ospfintf-provider-defaults.rb
@@ -78,7 +78,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -91,28 +91,38 @@
on(master, OspfIntfLib.create_ospfintf_manifest_present())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
logger.info("Get resource present manifest from master :: #{result}")
end
+ # @step [Step] Test idempotence by running the same manifest
+ step "TestStep :: Test idempotence by running the same manifest" do
+ # Expected exit_code is 0 since there should not be any changes this time
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [0]})
+
+ logger.info("Test idempotence by running the same manifest :: #{result}")
+ end
+
# @step [Step] Checks cisco_intf_ospf resource on agent using resource cmd.
step "TestStep :: Check cisco_intf_ospf resource presence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "cost" => "1", \
- "dead_interval" => "40", \
- "hello_interval" => "10", \
- "message_digest" => "false", \
- "message_digest_key_id" => "0", \
- "passive_interface" => "false"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'cost' => '1',
+ 'dead_interval' => '40',
+ 'hello_interval' => '10',
+ 'message_digest' => 'false',
+ 'message_digest_key_id' => '0',
+ 'passive_interface' => 'false'},
false, self, logger)
end
@@ -125,11 +135,11 @@
# Flag is set to false to check for presence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /interface Ethernet1\/4/, \
- /ip ospf cost 1/, \
- /ip ospf dead-interval 40/, \
- /ip router ospf test area 0.0.0.1/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /interface Ethernet1\/4/,
+ /ip ospf cost 1/,
+ /ip ospf dead-interval 40/,
+ /ip router ospf test area 0.0.0.1/],
false, self, logger)
end
@@ -142,7 +152,7 @@
on(master, OspfIntfLib.create_ospfintf_manifest_absent())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -153,17 +163,17 @@
step "TestStep :: Check cisco_intf_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "cost" => "1", \
- "dead_interval" => "40", \
- "hello_interval" => "10", \
- "message_digest" => "false", \
- "message_digest_key_id" => "0", \
- "passive_interface" => "false"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'cost' => '1',
+ 'dead_interval' => '40',
+ 'hello_interval' => '10',
+ 'message_digest' => 'false',
+ 'message_digest_key_id' => '0',
+ 'passive_interface' => 'false'},
true, self, logger)
end
@@ -176,11 +186,11 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str, {:acceptable_exit_codes => [16]}) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /interface Ethernet1\/4/, \
- /ip ospf cost 1/, \
- /ip ospf dead-interval 40/, \
- /ip router ospf test area 0.0.0.1/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /interface Ethernet1\/4/,
+ /ip ospf cost 1/,
+ /ip ospf dead-interval 40/,
+ /ip router ospf test area 0.0.0.1/],
true, self, logger)
end
diff --git a/tests/beaker_tests/ospfintf/ospfintf-provider-negatives.rb b/tests/beaker_tests/ospfintf/ospfintf-provider-negatives.rb
index d977a962a..992689422 100644
--- a/tests/beaker_tests/ospfintf/ospfintf-provider-negatives.rb
+++ b/tests/beaker_tests/ospfintf/ospfintf-provider-negatives.rb
@@ -76,7 +76,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -89,7 +89,7 @@
on(master, OspfIntfLib.create_ospfintf_manifest_cost_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failure.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -100,13 +100,17 @@
step "TestStep :: Check cisco_intf_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"cost" => OspfIntfLib::COST_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"cost" => OspfIntfLib::COST_NEGATIVE},
true, self, logger)
end
+ # cleanup partially configured resource
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_interface_ospf 'ethernet1/4 test' ensure=absent", options)
+ on(agent, cmd_str)
logger.info("Check cisco_intf_ospf resource absence on agent :: #{result}")
end
@@ -117,11 +121,11 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- [/interface Ethernet1\/4/, \
- /ip ospf cost 1/, \
- /ip ospf dead-interval 40/, \
- /ip router ospf test area 0.0.0.1/], \
+ UtilityLib.search_pattern_in_output(stdout,
+ [/interface Ethernet1\/4/,
+ /ip ospf cost 1/,
+ /ip ospf dead-interval 40/,
+ /ip router ospf test area 0.0.0.1/],
true, self, logger)
end
@@ -134,7 +138,7 @@
on(master, OspfIntfLib.create_ospfintf_manifest_hellointerval_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failure.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -145,11 +149,11 @@
step "TestStep :: Check cisco_intf_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"hello_interval" => OspfIntfLib::HELLOINTERVAL_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"hello_interval" => OspfIntfLib::HELLOINTERVAL_NEGATIVE},
true, self, logger)
end
@@ -162,11 +166,11 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- [/interface Ethernet1\/4/, \
- /ip ospf cost 1/, \
- /ip ospf dead-interval 40/, \
- /ip router ospf test area 0.0.0.1/], \
+ UtilityLib.search_pattern_in_output(stdout,
+ [/interface Ethernet1\/4/,
+ /ip ospf cost 1/,
+ /ip ospf dead-interval 40/,
+ /ip router ospf test area 0.0.0.1/],
true, self, logger)
end
@@ -179,7 +183,7 @@
on(master, OspfIntfLib.create_ospfintf_manifest_deadinterval_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failure.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -190,11 +194,11 @@
step "TestStep :: Check cisco_intf_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"dead_interval" => OspfIntfLib::DEADINTERVAL_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"dead_interval" => OspfIntfLib::DEADINTERVAL_NEGATIVE},
true, self, logger)
end
@@ -207,11 +211,11 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- [/interface Ethernet1\/4/, \
- /ip ospf cost 1/, \
- /ip ospf dead-interval 40/, \
- /ip router ospf test area 0.0.0.1/], \
+ UtilityLib.search_pattern_in_output(stdout,
+ [/interface Ethernet1\/4/,
+ /ip ospf cost 1/,
+ /ip ospf dead-interval 40/,
+ /ip router ospf test area 0.0.0.1/],
true, self, logger)
end
@@ -224,7 +228,7 @@
on(master, OspfIntfLib.create_ospfintf_manifest_passiveintf_negative())
# Expected exit_code is 1 since this is a puppet agent cmd with error.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [1]})
@@ -235,11 +239,11 @@
step "TestStep :: Check cisco_intf_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"passive_interface" => OspfIntfLib::PASSIVEINTF_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"passive_interface" => OspfIntfLib::PASSIVEINTF_NEGATIVE},
true, self, logger)
end
@@ -252,11 +256,11 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- [/interface Ethernet1\/4/, \
- /ip ospf cost 1/, \
- /ip ospf dead-interval 40/, \
- /ip router ospf test area 0.0.0.1/], \
+ UtilityLib.search_pattern_in_output(stdout,
+ [/interface Ethernet1\/4/,
+ /ip ospf cost 1/,
+ /ip ospf dead-interval 40/,
+ /ip router ospf test area 0.0.0.1/],
true, self, logger)
end
diff --git a/tests/beaker_tests/ospfintf/ospfintf-provider-nondefaults.rb b/tests/beaker_tests/ospfintf/ospfintf-provider-nondefaults.rb
index a5234da52..5408de5bc 100644
--- a/tests/beaker_tests/ospfintf/ospfintf-provider-nondefaults.rb
+++ b/tests/beaker_tests/ospfintf/ospfintf-provider-nondefaults.rb
@@ -78,7 +78,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -91,7 +91,7 @@
on(master, OspfIntfLib.create_ospfintf_manifest_nondefaults())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -102,17 +102,17 @@
step "TestStep :: Check cisco_intf_ospf resource presence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "cost" => "100", \
- "dead_interval" => "80", \
- "hello_interval" => "20", \
- "message_digest" => "false", \
- "message_digest_key_id" => "0", \
- "passive_interface" => "true"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'cost' => '100',
+ 'dead_interval' => '80',
+ 'hello_interval' => '20',
+ 'message_digest' => 'false',
+ 'message_digest_key_id' => '0',
+ 'passive_interface' => 'true'},
false, self, logger)
end
@@ -125,13 +125,13 @@
# Flag is set to false to check for presence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /interface Ethernet1\/4/, \
- /ip ospf cost 100/, \
- /ip ospf dead-interval 80/, \
- /ip ospf hello-interval 20/, \
- /ip ospf passive-interface/, \
- /ip router ospf test area 0.0.0.100/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /interface Ethernet1\/4/,
+ /ip ospf cost 100/,
+ /ip ospf dead-interval 80/,
+ /ip ospf hello-interval 20/,
+ /ip ospf passive-interface/,
+ /ip router ospf test area 0.0.0.100/],
false, self, logger)
end
@@ -144,7 +144,7 @@
on(master, OspfIntfLib.create_ospfintf_manifest_absent())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -155,17 +155,17 @@
step "TestStep :: Check cisco_intf_ospf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_interface_ospf 'ethernet1/4 test'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "cost" => "100", \
- "dead_interval" => "80", \
- "hello_interval" => "20", \
- "message_digest" => "false", \
- "message_digest_key_id" => "0", \
- "passive_interface" => "true"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'cost' => '100',
+ 'dead_interval' => '80',
+ 'hello_interval' => '20',
+ 'message_digest' => 'false',
+ 'message_digest_key_id' => '0',
+ 'passive_interface' => 'true'},
true, self, logger)
end
@@ -178,19 +178,58 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
on(agent, cmd_str, {:acceptable_exit_codes => [16]}) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /interface Ethernet1\/4/, \
- /ip ospf cost 100/, \
- /ip ospf dead-interval 80/, \
- /ip ospf hello-interval 20/, \
- /ip ospf passive-interface/, \
- /ip router ospf test area 0.0.0.100/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /interface Ethernet1\/4/,
+ /ip ospf cost 100/,
+ /ip ospf dead-interval 80/,
+ /ip ospf hello-interval 20/,
+ /ip ospf passive-interface/,
+ /ip router ospf test area 0.0.0.100/],
true, self, logger)
end
logger.info("Check ospfintf instance absence on agent :: #{result}")
end
+ # @step [Step] Verify ability to configure and update ospf area
+ step "TestStep :: Check ospfintf area change on agent" do
+ area1 = "0.0.0.5"
+ area2 = "0.0.0.6"
+ on(master, OspfIntfLib.create_ospfintf_area_manifest(area1))
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+ # check for successfull configured area
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
+ on(agent, cmd_str, {:acceptable_exit_codes => [0]}) do
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /interface Ethernet1\/4/,
+ /ip router ospf test area #{area1}/],
+ false, self, logger)
+ end
+ # update area to area2
+ on(master, OspfIntfLib.create_ospfintf_area_manifest(area2))
+ # Expected exit_code is 2 since this is a puppet agent cmd with change.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [2]})
+ # check for successfull configured area
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config ospf")
+ on(agent, cmd_str, {:acceptable_exit_codes => [0]}) do
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /interface Ethernet1\/4/,
+ /ip router ospf test area #{area2}/],
+ false, self, logger)
+ end
+ # cleanup
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_interface_ospf 'ethernet1/4 test' ensure=absent", options)
+ on(agent, cmd_str)
+
+ logger.info("Check ospfintf area change on agent :: #{result}")
+ end
+
# @raise [PassTest/FailTest] Raises PassTest/FailTest exception using result.
UtilityLib.raise_passfail_exception(result, testheader, self, logger)
diff --git a/tests/beaker_tests/ospfintf/ospfintflib.rb b/tests/beaker_tests/ospfintf/ospfintflib.rb
index 1154fd4e7..f79f446ff 100644
--- a/tests/beaker_tests/ospfintf/ospfintflib.rb
+++ b/tests/beaker_tests/ospfintf/ospfintflib.rb
@@ -71,6 +71,30 @@ def OspfIntfLib.create_ospfintf_manifest_present()
return manifest_str
end
+ # Method to configure the given area inside a manifest for ensure present
+ # @param area is used to set the area for the manifest
+ # @param intf is used to optionally specify the interface to use
+ # @result manifest_str is the newly constructed manifest
+ def OspfIntfLib.create_ospfintf_area_manifest(area, intf='ethernet1/4')
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ cisco_ospf { 'test':
+ ensure => present,
+ }
+
+ cisco_interface { '#{intf}':
+ switchport_mode => disabled,
+ }
+
+ cisco_interface_ospf { '#{intf} test':
+ ensure => present,
+ area => '#{area}',
+ }
+}
+EOF"
+ return manifest_str
+ end
+
# Method to create a manifest for OSPFINTF resource attribute 'ensure' where
# 'ensure' is set to absent.
# @param none [None] No input parameters exist.
@@ -134,6 +158,7 @@ def OspfIntfLib.create_ospfintf_manifest_cost_negative()
cisco_interface_ospf { 'ethernet1/4 test':
ensure => present,
+ area => 1,
cost => #{OspfIntfLib::COST_NEGATIVE},
}
}
diff --git a/tests/beaker_tests/ospfvrf/ospfvrf-provider-defaults.rb b/tests/beaker_tests/ospfvrf/ospfvrf-provider-defaults.rb
index bdd350df0..13f96e98b 100644
--- a/tests/beaker_tests/ospfvrf/ospfvrf-provider-defaults.rb
+++ b/tests/beaker_tests/ospfvrf/ospfvrf-provider-defaults.rb
@@ -79,7 +79,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -92,7 +92,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_present())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -103,35 +103,39 @@
step "TestStep :: Check cisco_ospf_vrf resource presence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test default'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "40000", \
- "default_metric" => "0", \
- "log_adjacency" => "none", \
- "timer_throttle_lsa" => "{'hold' => '5000', 'max' => '5000', 'start' => '0'}", \
- "timer_throttle_spf_hold" => "1000", \
- "timer_throttle_spf_max" => "5000", \
- "timer_throttle_spf_start"=> "200"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '40000',
+ 'default_metric' => '0',
+ 'log_adjacency' => 'none',
+ 'timer_throttle_lsa_hold' => '5000',
+ 'timer_throttle_lsa_max' => '5000',
+ 'timer_throttle_lsa_start' => '0',
+ 'timer_throttle_spf_hold' => '1000',
+ 'timer_throttle_spf_max' => '5000',
+ 'timer_throttle_spf_start' => '200'},
false, self, logger)
end
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "40000", \
- "default_metric" => "0", \
- "log_adjacency" => "none", \
- "timer_throttle_lsa" => "{'hold' => '5000', 'max' => '5000', 'start' => '0'}", \
- "timer_throttle_spf_hold" => "1000", \
- "timer_throttle_spf_max" => "5000", \
- "timer_throttle_spf_start"=> "200"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '40000',
+ 'default_metric' => '0',
+ 'log_adjacency' => 'none',
+ 'timer_throttle_lsa_hold' => '5000',
+ 'timer_throttle_lsa_max' => '5000',
+ 'timer_throttle_lsa_start' => '0',
+ 'timer_throttle_spf_hold' => '1000',
+ 'timer_throttle_spf_max' => '5000',
+ 'timer_throttle_spf_start' => '200'},
false, self, logger)
end
@@ -144,8 +148,8 @@
# Flag is set to false to check for presence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
@@ -158,7 +162,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_absent())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -169,35 +173,39 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test default'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "40000", \
- "default_metric" => "0", \
- "log_adjacency" => "none", \
- "timer_throttle_lsa" => "{'hold' => '5000', 'max' => '5000', 'start' => '0'}", \
- "timer_throttle_spf_hold" => "1000", \
- "timer_throttle_spf_max" => "5000", \
- "timer_throttle_spf_start"=> "200"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '40000',
+ 'default_metric' => '0',
+ 'log_adjacency' => 'none',
+ 'timer_throttle_lsa_hold' => '5000',
+ 'timer_throttle_lsa_max' => '5000',
+ 'timer_throttle_lsa_start' => '0',
+ 'timer_throttle_spf_hold' => '1000',
+ 'timer_throttle_spf_max' => '5000',
+ 'timer_throttle_spf_start' => '200'},
true, self, logger)
end
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "40000", \
- "default_metric" => "0", \
- "log_adjacency" => "none", \
- "timer_throttle_lsa" => "{'hold' => '5000', 'max' => '5000', 'start' => '0'}", \
- "timer_throttle_spf_hold" => "1000", \
- "timer_throttle_spf_max" => "5000", \
- "timer_throttle_spf_start"=> "200"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '40000',
+ 'default_metric' => '0',
+ 'log_adjacency' => 'none',
+ 'timer_throttle_lsa_hold' => '5000',
+ 'timer_throttle_lsa_max' => '5000',
+ 'timer_throttle_lsa_start' => '0',
+ 'timer_throttle_spf_hold' => '1000',
+ 'timer_throttle_spf_max' => '5000',
+ 'timer_throttle_spf_start' => '200'},
true, self, logger)
end
@@ -210,8 +218,8 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
true, self, logger)
end
diff --git a/tests/beaker_tests/ospfvrf/ospfvrf-provider-negatives.rb b/tests/beaker_tests/ospfvrf/ospfvrf-provider-negatives.rb
index 899295d18..8bec67627 100644
--- a/tests/beaker_tests/ospfvrf/ospfvrf-provider-negatives.rb
+++ b/tests/beaker_tests/ospfvrf/ospfvrf-provider-negatives.rb
@@ -82,7 +82,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -95,7 +95,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_autocost_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failures.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -106,11 +106,11 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"auto_cost" => OspfVrfLib::AUTOCOST_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"auto_cost" => OspfVrfLib::AUTOCOST_NEGATIVE},
true, self, logger)
end
@@ -123,8 +123,8 @@
# Flag is set to false to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
@@ -137,7 +137,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_defaultmetric_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failures.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -148,11 +148,11 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"default_metric" => OspfVrfLib::DEFAULTMETRIC_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"default_metric" => OspfVrfLib::DEFAULTMETRIC_NEGATIVE},
true, self, logger)
end
@@ -165,8 +165,8 @@
# Flag is set to false to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
@@ -176,10 +176,10 @@
# @step [Step] Requests manifest from the master server to the agent.
step "TestStep :: Get negative test resource manifest from master" do
# Expected exit_code is 0 since this is a bash shell cmd.
- on(master, OspfVrfLib.create_ospfvrf_manifest_throttlelsa_negative())
+ on(master, OspfVrfLib.create_ospfvrf_manifest_lsahold_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failures.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -190,11 +190,11 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"timer_throttle_lsa" => OspfVrfLib::THROTTLELSA_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"timer_throttle_lsa_hold" => OspfVrfLib::LSAHOLD_NEGATIVE},
true, self, logger)
end
@@ -207,8 +207,92 @@
# Flag is set to false to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
+ false, self, logger)
+ end
+
+ logger.info("Check ospfvrf instance presence on agent :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get negative test resource manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, OspfVrfLib.create_ospfvrf_manifest_lsamax_negative())
+
+ # Expected exit_code is 6 since this is a puppet agent cmd with failures.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [6]})
+
+ logger.info("Get negative test resource manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks cisco_ospf_vrf resource on agent using resource cmd.
+ step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_ospf_vrf 'test green'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ {"timer_throttle_lsa_max" => OspfVrfLib::LSAMAX_NEGATIVE},
+ true, self, logger)
+ end
+
+ logger.info("Check cisco_ospf_vrf resource absence on agent :: #{result}")
+ end
+
+ # @step [Step] Checks ospfvrf instance on agent using switch show cli cmds.
+ step "TestStep :: Check ospfvrf instance presence on agent" do
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ # Flag is set to false to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
+ false, self, logger)
+ end
+
+ logger.info("Check ospfvrf instance presence on agent :: #{result}")
+ end
+
+ # @step [Step] Requests manifest from the master server to the agent.
+ step "TestStep :: Get negative test resource manifest from master" do
+ # Expected exit_code is 0 since this is a bash shell cmd.
+ on(master, OspfVrfLib.create_ospfvrf_manifest_lsastart_negative())
+
+ # Expected exit_code is 6 since this is a puppet agent cmd with failures.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "agent -t", options)
+ on(agent, cmd_str, {:acceptable_exit_codes => [6]})
+
+ logger.info("Get negative test resource manifest from master :: #{result}")
+ end
+
+ # @step [Step] Checks cisco_ospf_vrf resource on agent using resource cmd.
+ step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
+ # Expected exit_code is 0 since this is a puppet resource cmd.
+ # Flag is set to true to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
+ "resource cisco_ospf_vrf 'test green'", options)
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout,
+ {"timer_throttle_lsa_start" => OspfVrfLib::LSASTART_NEGATIVE},
+ true, self, logger)
+ end
+
+ logger.info("Check cisco_ospf_vrf resource absence on agent :: #{result}")
+ end
+
+ # @step [Step] Checks ospfvrf instance on agent using switch show cli cmds.
+ step "TestStep :: Check ospfvrf instance presence on agent" do
+ # Expected exit_code is 0 since this is a vegas shell cmd.
+ # Flag is set to false to check for absence of RegExp pattern in stdout.
+ cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
+ on(agent, cmd_str) do
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
@@ -221,7 +305,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_spfhold_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failures.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -232,11 +316,11 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"timer_throttle_spf_hold" => OspfVrfLib::SPFHOLD_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"timer_throttle_spf_hold" => OspfVrfLib::SPFHOLD_NEGATIVE},
true, self, logger)
end
@@ -249,8 +333,8 @@
# Flag is set to false to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
@@ -263,7 +347,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_spfmax_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failures.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -274,11 +358,11 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"timer_throttle_spf_max" => OspfVrfLib::SPFMAX_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"timer_throttle_spf_max" => OspfVrfLib::SPFMAX_NEGATIVE},
true, self, logger)
end
@@ -291,8 +375,8 @@
# Flag is set to false to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
@@ -305,7 +389,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_spfstart_negative())
# Expected exit_code is 6 since this is a puppet agent cmd with failures.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [6]})
@@ -316,11 +400,11 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"timer_throttle_spf_start" => OspfVrfLib::SPFSTART_NEGATIVE}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {"timer_throttle_spf_start" => OspfVrfLib::SPFSTART_NEGATIVE},
true, self, logger)
end
@@ -333,8 +417,8 @@
# Flag is set to false to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
diff --git a/tests/beaker_tests/ospfvrf/ospfvrf-provider-nondefaults.rb b/tests/beaker_tests/ospfvrf/ospfvrf-provider-nondefaults.rb
index 128f96d30..d2e9b5f2a 100644
--- a/tests/beaker_tests/ospfvrf/ospfvrf-provider-nondefaults.rb
+++ b/tests/beaker_tests/ospfvrf/ospfvrf-provider-nondefaults.rb
@@ -79,7 +79,7 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/feature ospf/], \
+ UtilityLib.search_pattern_in_output(stdout, [/feature ospf/],
true, self, logger)
end
@@ -92,7 +92,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_nondefaults())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -103,35 +103,39 @@
step "TestStep :: Check cisco_ospf_vrf resource presence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test default'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "40000", \
- "default_metric" => "0", \
- "log_adjacency" => "none", \
- "timer_throttle_lsa" => "{'hold' => '5000', 'max' => '5000', 'start' => '0'}", \
- "timer_throttle_spf_hold" => "1000", \
- "timer_throttle_spf_max" => "5000", \
- "timer_throttle_spf_start"=> "200"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '40000',
+ 'default_metric' => '0',
+ 'log_adjacency' => 'none',
+ 'timer_throttle_lsa_hold' => '5000',
+ 'timer_throttle_lsa_max' => '5000',
+ 'timer_throttle_lsa_start' => '0',
+ 'timer_throttle_spf_hold' => '1000',
+ 'timer_throttle_spf_max' => '5000',
+ 'timer_throttle_spf_start' => '200'},
false, self, logger)
end
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to false to check for presence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "80000", \
- "default_metric" => "1", \
- "log_adjacency" => "log", \
- "timer_throttle_lsa" => "{'hold' => '1000', 'max' => '10000', 'start' => '1'}", \
- "timer_throttle_spf_hold" => "2000", \
- "timer_throttle_spf_max" => "10000", \
- "timer_throttle_spf_start"=> "400"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '80000',
+ 'default_metric' => '1',
+ 'log_adjacency' => 'log',
+ 'timer_throttle_lsa_hold' => '2000',
+ 'timer_throttle_lsa_max' => '10000',
+ 'timer_throttle_lsa_start' => '1',
+ 'timer_throttle_spf_hold' => '2000',
+ 'timer_throttle_spf_max' => '10000',
+ 'timer_throttle_spf_start' => '400'},
false, self, logger)
end
@@ -144,8 +148,8 @@
# Flag is set to false to check for presence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
false, self, logger)
end
@@ -158,7 +162,7 @@
on(master, OspfVrfLib.create_ospfvrf_manifest_absent())
# Expected exit_code is 2 since this is a puppet agent cmd with change.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"agent -t", options)
on(agent, cmd_str, {:acceptable_exit_codes => [2]})
@@ -169,35 +173,39 @@
step "TestStep :: Check cisco_ospf_vrf resource absence on agent" do
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test default'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "40000", \
- "default_metric" => "0", \
- "log_adjacency" => "none", \
- "timer_throttle_lsa" => "{'hold' => '5000', 'max' => '5000', 'start' => '0'}", \
- "timer_throttle_spf_hold" => "1000", \
- "timer_throttle_spf_max" => "5000", \
- "timer_throttle_spf_start"=> "200"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '40000',
+ 'default_metric' => '0',
+ 'log_adjacency' => 'none',
+ 'timer_throttle_lsa_hold' => '5000',
+ 'timer_throttle_lsa_max' => '5000',
+ 'timer_throttle_lsa_start' => '0',
+ 'timer_throttle_spf_hold' => '1000',
+ 'timer_throttle_spf_max' => '5000',
+ 'timer_throttle_spf_start' => '200'},
true, self, logger)
end
# Expected exit_code is 0 since this is a puppet resource cmd.
# Flag is set to true to check for absence of RegExp pattern in stdout.
- cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH + \
+ cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_ospf_vrf 'test green'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {"ensure" => "present", \
- "auto_cost" => "80000", \
- "default_metric" => "1", \
- "log_adjacency" => "log", \
- "timer_throttle_lsa" => "{'hold' => '1000', 'max' => '10000', 'start' => '1'}", \
- "timer_throttle_spf_hold" => "2000", \
- "timer_throttle_spf_max" => "10000", \
- "timer_throttle_spf_start"=> "400"}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'auto_cost' => '80000',
+ 'default_metric' => '1',
+ 'log_adjacency' => 'log',
+ 'timer_throttle_lsa_hold' => '2000',
+ 'timer_throttle_lsa_max' => '10000',
+ 'timer_throttle_lsa_start' => '1',
+ 'timer_throttle_spf_hold' => '2000',
+ 'timer_throttle_spf_max' => '10000',
+ 'timer_throttle_spf_start' => '400'},
true, self, logger)
end
@@ -210,8 +218,8 @@
# Flag is set to true to check for absence of RegExp pattern in stdout.
cmd_str = UtilityLib.get_vshell_cmd("show running-config section ospf")
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, [/router ospf test/, \
- /vrf green/], \
+ UtilityLib.search_pattern_in_output(stdout, [/router ospf test/,
+ /vrf green/],
true, self, logger)
end
diff --git a/tests/beaker_tests/ospfvrf/ospfvrflib.rb b/tests/beaker_tests/ospfvrf/ospfvrflib.rb
index 761da70a6..aa5a4a393 100644
--- a/tests/beaker_tests/ospfvrf/ospfvrflib.rb
+++ b/tests/beaker_tests/ospfvrf/ospfvrflib.rb
@@ -36,12 +36,14 @@
module OspfVrfLib
# Group of Constants used in negative tests for OSPFVRF provider.
- AUTOCOST_NEGATIVE = '100000000'
- DEFAULTMETRIC_NEGATIVE = '-1'
- THROTTLELSA_NEGATIVE = {'hold' => '-1', 'max' => '-1', 'start' => '-1'}
- SPFHOLD_NEGATIVE = '-1'
- SPFMAX_NEGATIVE = '-1'
- SPFSTART_NEGATIVE = '-1'
+ AUTOCOST_NEGATIVE = '100000000'
+ DEFAULTMETRIC_NEGATIVE = '-1'
+ LSAHOLD_NEGATIVE = '-1'
+ LSAMAX_NEGATIVE = '-1'
+ LSASTART_NEGATIVE = '-1'
+ SPFHOLD_NEGATIVE = '-1'
+ SPFMAX_NEGATIVE = '-1'
+ SPFSTART_NEGATIVE = '-1'
# A. Methods to create manifests for cisco_ospf_vrf Puppet provider test cases.
@@ -57,7 +59,9 @@ def OspfVrfLib.create_ospfvrf_manifest_present()
auto_cost => 'default',
default_metric => 'default',
log_adjacency => 'default',
- timer_throttle_lsa => {'hold' => 'default', 'max' => 'default', 'start' => 'default'},
+ timer_throttle_lsa_hold => 'default',
+ timer_throttle_lsa_max => 'default',
+ timer_throttle_lsa_start => 'default',
timer_throttle_spf_hold => 'default',
timer_throttle_spf_max => 'default',
timer_throttle_spf_start => 'default',
@@ -99,7 +103,9 @@ def OspfVrfLib.create_ospfvrf_manifest_nondefaults()
auto_cost => '80000',
default_metric => '1',
log_adjacency => 'log',
- timer_throttle_lsa => {'hold' => '1000', 'max' => '10000', 'start' => '1'},
+ timer_throttle_lsa_hold => '2000',
+ timer_throttle_lsa_max => '10000',
+ timer_throttle_lsa_start => '1',
timer_throttle_spf_hold => '2000',
timer_throttle_spf_max => '10000',
timer_throttle_spf_start => '400',
@@ -139,15 +145,45 @@ def OspfVrfLib.create_ospfvrf_manifest_defaultmetric_negative()
return manifest_str
end
- # Method to create a manifest for OSPFVRF resource attribute 'throttlelsa'.
+ # Method to create a manifest for OSPFVRF resource attribute 'lsahold'.
# @param none [None] No input parameters exist.
# @result none [None] Returns no object.
- def OspfVrfLib.create_ospfvrf_manifest_throttlelsa_negative()
+ def OspfVrfLib.create_ospfvrf_manifest_lsahold_negative()
manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
node default {
cisco_ospf_vrf { 'test green':
ensure => present,
- timer_throttle_lsa => #{OspfVrfLib::THROTTLELSA_NEGATIVE},
+ timer_throttle_lsa_hold => #{OspfVrfLib::LSAHOLD_NEGATIVE},
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for OSPFVRF resource attribute 'lsamax'.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def OspfVrfLib.create_ospfvrf_manifest_lsamax_negative()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ cisco_ospf_vrf { 'test green':
+ ensure => present,
+ timer_throttle_lsa_max => #{OspfVrfLib::LSAMAX_NEGATIVE},
+ }
+}
+EOF"
+ return manifest_str
+ end
+
+ # Method to create a manifest for OSPFVRF resource attribute 'lsastart'.
+ # @param none [None] No input parameters exist.
+ # @result none [None] Returns no object.
+ def OspfVrfLib.create_ospfvrf_manifest_lsastart_negative()
+ manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
+node default {
+ cisco_ospf_vrf { 'test green':
+ ensure => present,
+ timer_throttle_lsa_start => #{OspfVrfLib::LSASTART_NEGATIVE},
}
}
EOF"
diff --git a/tests/beaker_tests/snmpserver/snmpserverlib.rb b/tests/beaker_tests/snmpserver/snmpserverlib.rb
index 619ff4427..30361182d 100644
--- a/tests/beaker_tests/snmpserver/snmpserverlib.rb
+++ b/tests/beaker_tests/snmpserver/snmpserverlib.rb
@@ -154,20 +154,6 @@ def SnmpServerLib.create_snmpserver_manifest_globalpriv_negative()
global_enforce_priv => #{SnmpServerLib::GLOBALPRIV_NEGATIVE},
}
}
-EOF"
- return manifest_str
- end
-
- # Method to create a manifest for SNMPGROUP attribute 'ensure'.
- # @param none [None] No input parameters exist.
- # @result none [None] Returns no object.
- def SnmpServerLib.create_snmpgroup_manifest_present()
- manifest_str = "cat <#{UtilityLib::PUPPETMASTER_MANIFESTPATH}
-node default {
- cisco_snmp_group { 'netadmin-test':
- ensure => 'present',
- }
-}
EOF"
return manifest_str
end
diff --git a/tests/beaker_tests/vlan/standardvlan-provider-defaults.rb b/tests/beaker_tests/vlan/standardvlan-provider-defaults.rb
index 14cf8d9a1..84a730f38 100644
--- a/tests/beaker_tests/vlan/standardvlan-provider-defaults.rb
+++ b/tests/beaker_tests/vlan/standardvlan-provider-defaults.rb
@@ -102,11 +102,11 @@
cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_vlan '128'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {'ensure' => 'present', \
- 'shutdown' => 'false', \
- 'state' => 'active', \
- 'vlan_name' => 'VLAN0128'}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'shutdown' => 'false',
+ 'state' => 'active',
+ 'vlan_name' => 'VLAN0128'},
false, self, logger)
end
@@ -146,11 +146,11 @@
cmd_str = UtilityLib.get_namespace_cmd(agent, UtilityLib::PUPPET_BINPATH +
"resource cisco_vlan '128'", options)
on(agent, cmd_str) do
- UtilityLib.search_pattern_in_output(stdout, \
- {'ensure' => 'present', \
- 'shutdown' => 'false', \
- 'state' => 'active', \
- 'vlan_name' => 'VLAN0128'}, \
+ UtilityLib.search_pattern_in_output(stdout,
+ {'ensure' => 'present',
+ 'shutdown' => 'false',
+ 'state' => 'active',
+ 'vlan_name' => 'VLAN0128'},
true, self, logger)
end