puppetmodule-netdev_stdlib 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/.gitignore +27 -0
  2. data/.travis.yml +9 -0
  3. data/Gemfile +4 -0
  4. data/Guardfile +15 -0
  5. data/LICENSE +202 -0
  6. data/Modulefile +9 -0
  7. data/README.md +330 -0
  8. data/Rakefile +1 -0
  9. data/lib/netdev_stdlib.rb +4 -0
  10. data/lib/netdev_stdlib/version.rb +3 -0
  11. data/lib/puppet/type/domain_name.rb +17 -0
  12. data/lib/puppet/type/name_server.rb +17 -0
  13. data/lib/puppet/type/network_interface.rb +60 -0
  14. data/lib/puppet/type/network_trunk.rb +83 -0
  15. data/lib/puppet/type/network_vlan.rb +53 -0
  16. data/lib/puppet/type/ntp_config.rb +25 -0
  17. data/lib/puppet/type/ntp_server.rb +20 -0
  18. data/lib/puppet/type/port_channel.rb +82 -0
  19. data/lib/puppet/type/radius.rb +20 -0
  20. data/lib/puppet/type/radius_global.rb +40 -0
  21. data/lib/puppet/type/radius_server.rb +95 -0
  22. data/lib/puppet/type/radius_server_group.rb +25 -0
  23. data/lib/puppet/type/search_domain.rb +17 -0
  24. data/lib/puppet/type/snmp_community.rb +29 -0
  25. data/lib/puppet/type/snmp_contact.rb +17 -0
  26. data/lib/puppet/type/snmp_location.rb +17 -0
  27. data/lib/puppet/type/snmp_notification.rb +20 -0
  28. data/lib/puppet/type/snmp_notification_receiver.rb +77 -0
  29. data/lib/puppet/type/snmp_protocol.rb +20 -0
  30. data/lib/puppet/type/snmp_user.rb +77 -0
  31. data/lib/puppet/type/syslog_server.rb +42 -0
  32. data/lib/puppet/type/syslog_settings.rb +25 -0
  33. data/lib/puppet/type/tacacs.rb +20 -0
  34. data/lib/puppet/type/tacacs_global.rb +40 -0
  35. data/lib/puppet/type/tacacs_server.rb +50 -0
  36. data/lib/puppet/type/tacacs_server_group.rb +25 -0
  37. data/netdev_stdlib.gemspec +36 -0
  38. data/spec/spec_helper.rb +15 -0
  39. data/spec/support/shared_examples_for_types.rb +412 -0
  40. data/spec/unit/puppet/type/domain_name_spec.rb +8 -0
  41. data/spec/unit/puppet/type/name_server_spec.rb +8 -0
  42. data/spec/unit/puppet/type/network_interface_spec.rb +44 -0
  43. data/spec/unit/puppet/type/network_trunk_spec.rb +55 -0
  44. data/spec/unit/puppet/type/network_vlan_spec.rb +57 -0
  45. data/spec/unit/puppet/type/ntp_config_spec.rb +8 -0
  46. data/spec/unit/puppet/type/ntp_server_spec.rb +8 -0
  47. data/spec/unit/puppet/type/port_channel_spec.rb +87 -0
  48. data/spec/unit/puppet/type/radius_global_spec.rb +27 -0
  49. data/spec/unit/puppet/type/radius_server_group_spec.rb +12 -0
  50. data/spec/unit/puppet/type/radius_server_spec.rb +51 -0
  51. data/spec/unit/puppet/type/radius_spec.rb +8 -0
  52. data/spec/unit/puppet/type/search_domain_spec.rb +8 -0
  53. data/spec/unit/puppet/type/snmp_community_spec.rb +27 -0
  54. data/spec/unit/puppet/type/snmp_contact_spec.rb +8 -0
  55. data/spec/unit/puppet/type/snmp_location_spec.rb +8 -0
  56. data/spec/unit/puppet/type/snmp_notification_receiver_spec.rb +50 -0
  57. data/spec/unit/puppet/type/snmp_notification_spec.rb +8 -0
  58. data/spec/unit/puppet/type/snmp_protocol_spec.rb +8 -0
  59. data/spec/unit/puppet/type/snmp_user_spec.rb +63 -0
  60. data/spec/unit/puppet/type/syslog_server_spec.rb +20 -0
  61. data/spec/unit/puppet/type/syslog_settings_spec.rb +19 -0
  62. data/spec/unit/puppet/type/tacacs_global_spec.rb +27 -0
  63. data/spec/unit/puppet/type/tacacs_server_group_spec.rb +12 -0
  64. data/spec/unit/puppet/type/tacacs_server_spec.rb +25 -0
  65. data/spec/unit/puppet/type/tacacs_spec.rb +8 -0
  66. metadata +338 -0
@@ -0,0 +1,27 @@
1
+ .rspec
2
+ results
3
+ tags
4
+ .*.sw[op]
5
+ ext/packaging
6
+ pkg
7
+ test.pp
8
+ # YARD generated documentation
9
+ .yardoc
10
+ /doc
11
+ # Now that there is a gemfile, RVM ignores rvmrc in parent directories, so a local one is required
12
+ # to work around that. Which we don't want committed, so we can ignore it here.
13
+ /.rvmrc
14
+ /.bundle
15
+ ext/packaging/
16
+ pkg/
17
+ Gemfile.lock
18
+ Gemfile.local
19
+ .bundle/
20
+ puppet-acceptance/
21
+ /.project
22
+ .idea/
23
+ .ruby-version
24
+ .ruby-gemset
25
+ /tmp/
26
+ /coverage/
27
+ .DS_Store
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ script: bundle exec rspec spec
3
+ bundler_args: --without development
4
+ notifications:
5
+ email: false
6
+ rvm:
7
+ - "1.9.3"
8
+ - "2.1.1"
9
+ - jruby-19mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
3
+ gemspec
4
+ # vim:ft=ruby
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ guard :rspec do
7
+ watch(/^spec\/.+_spec\.rb$/)
8
+ watch(/^lib\/(.+)\.rb$/) { |m| "spec/unit/#{m[1]}_spec.rb" }
9
+ watch('spec/spec_helper.rb') { 'spec' }
10
+ end
11
+
12
+ guard :rubocop do
13
+ watch(/.+\.rb$/)
14
+ watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) }
15
+ end
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2014 Puppet Labs
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,9 @@
1
+ name 'puppetlabs-netdev_stdlib'
2
+ version '0.10.0'
3
+ source 'https://github.com/puppetlabs/netdev_stdlib'
4
+ author 'Puppet Labs'
5
+ license 'Apache 2.0'
6
+ summary 'Type definitions for Networking Device (NetDev) Standard Library'
7
+ description 'NetDev Standard Library provides Puppet types to configure network devices'
8
+
9
+ project_page 'https://github.com/puppetlabs/netdev_stdlib'
@@ -0,0 +1,330 @@
1
+ # Network Device Standard Library
2
+
3
+ [![Build Status][buildstatus]][travis]
4
+
5
+ # Overview
6
+
7
+ This module implements the type specification for the network device support
8
+ program. The goal of this module is to provide the Puppet types for writing
9
+ provider implementations of these types for a specific network device model.
10
+
11
+ # Reference Information
12
+
13
+ The following reference material is useful when developing providers for the
14
+ types implemented in this module.
15
+
16
+ * [Puppet Types and Providers by Dan Bode & Nan Liu][book]
17
+ * [Custom Types Documentation][types doc]
18
+ * [Seriously, What is this Provider Doing?][gary provider] Useful for an
19
+ in-depth explanation of the instances class method for each provider.
20
+
21
+ # Getting Started for Development
22
+
23
+ This section describes how to get started developing providers for the types
24
+ implemented in this module.
25
+
26
+ First, configure a Ruby development environment. There are multiple ways to
27
+ accomplish this task including [rvm][rvm], [rbenv][rbenv], and
28
+ [crossfader][crossfader]. This module has been developed using
29
+ [crossfader][crossfader], a pre-packaged build of multiple Ruby versions
30
+ specifically designed for developing and extending Puppet.
31
+
32
+ ## Install Crossfader
33
+
34
+ Please follow the [Crossfader Quick Start][crossfader quick start] instructions
35
+ to get started with crossfader on Mac OS X.
36
+
37
+ ## Set the ruby environment
38
+
39
+ Once crossfader is installed, select the version of Ruby currently shipping
40
+ with Puppet Enterprise. At the time of writing this is currently Ruby
41
+ 1.9.3-p484. Information on the current version of Ruby shipping with Puppet
42
+ Enterprise is available at [Puppet Enterprise Software Components][pe
43
+ components].
44
+
45
+ $ eval "$(crossfader --ruby 1.9.3-p484 --gemset netdev shellinit)"
46
+
47
+ Once initialized, verify the environment is using the specified version of ruby
48
+ with the `gem env` command.
49
+
50
+ $ gem env
51
+ RubyGems Environment:
52
+ - RUBYGEMS VERSION: 1.8.23
53
+ - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-darwin13.0.0]
54
+ - INSTALLATION DIRECTORY: /opt/crossfader/versions/ruby/1.9.3-p484/gemsets/netdev/ruby/1.9.1
55
+ - RUBY EXECUTABLE: /opt/crossfader/versions/ruby/1.9.3-p484/bin/ruby
56
+ - EXECUTABLE DIRECTORY: /opt/crossfader/versions/ruby/1.9.3-p484/gemsets/netdev/ruby/1.9.1/bin
57
+ - RUBYGEMS PLATFORMS:
58
+ - ruby
59
+ - x86_64-darwin-13
60
+ - GEM PATHS:
61
+ - /opt/crossfader/versions/ruby/1.9.3-p484/gemsets/netdev/ruby/1.9.1
62
+ - /opt/crossfader/versions/ruby/1.9.3-p484/gemsets/global/ruby/1.9.1
63
+ - /opt/crossfader/versions/ruby/1.9.3-p484/lib/ruby/gems/1.9.1
64
+ - /Users/jeff/.gem/ruby/1.9.1
65
+ - GEM CONFIGURATION:
66
+ - :update_sources => true
67
+ - :verbose => true
68
+ - :benchmark => false
69
+ - :backtrace => false
70
+ - :bulk_threshold => 1000
71
+ - REMOTE SOURCES:
72
+ - http://rubygems.org/
73
+
74
+ ## Clone the Repository
75
+
76
+ Clone this repository into your local development workspace.
77
+
78
+ $ git clone https://github.com/puppetlabs/netdev_stdlib
79
+ Cloning into 'netdev_stdlib'...
80
+ remote: Counting objects: 595, done.
81
+ remote: Compressing objects: 100% (172/172), done.
82
+ remote: Total 595 (delta 264), reused 587 (delta 261)
83
+ Receiving objects: 100% (595/595), 76.83 KiB | 0 bytes/s, done.
84
+ Resolving deltas: 100% (264/264), done.
85
+ Checking connectivity... done.
86
+
87
+ ## Install dependencies
88
+
89
+ The types depend primarily on Puppet which itself has a set of dependencies.
90
+ All of these additional software components should be installed using bundler
91
+ when developing the types and providers.
92
+
93
+ $ cd netdev_stdlib/
94
+ $ bundle install --path .bundle/gems/
95
+ Fetching gem metadata from https://rubygems.org/.........
96
+ Resolving dependencies...
97
+ Installing rake (10.1.1)
98
+ Installing CFPropertyList (2.2.8)
99
+ Installing ast (2.0.0)
100
+ Installing slop (3.6.0)
101
+ Installing parser (2.2.0.pre.4)
102
+ Installing astrolabe (1.3.0)
103
+ Installing timers (1.1.0)
104
+ Installing celluloid (0.15.2)
105
+ Installing coderay (1.1.0)
106
+ Installing diff-lcs (1.2.5)
107
+ Installing docile (1.1.5)
108
+ Installing facter (2.2.0)
109
+ Installing ffi (1.9.3)
110
+ Installing formatador (0.2.5)
111
+ Installing rb-fsevent (0.9.4)
112
+ Installing rb-inotify (0.9.5)
113
+ Installing listen (2.7.9)
114
+ Installing lumberjack (1.0.9)
115
+ Installing method_source (0.8.2)
116
+ Installing pry (0.10.1)
117
+ Installing thor (0.19.1)
118
+ Installing guard (2.6.1)
119
+ Installing rspec-core (2.13.1)
120
+ Installing rspec-expectations (2.13.0)
121
+ Installing rspec-mocks (2.13.1)
122
+ Installing rspec (2.13.0)
123
+ Installing guard-rspec (3.1.0)
124
+ Installing powerpack (0.0.9)
125
+ Installing rainbow (2.0.0)
126
+ Installing ruby-progressbar (1.5.1)
127
+ Installing rubocop (0.26.0)
128
+ Installing guard-rubocop (1.1.0)
129
+ Installing json_pure (1.8.1)
130
+ Installing hiera (1.3.4)
131
+ Installing metaclass (0.0.4)
132
+ Installing mocha (1.1.0)
133
+ Installing multi_json (1.10.1)
134
+ Installing yard (0.8.7.4)
135
+ Installing pry-doc (0.6.0)
136
+ Installing rgen (0.6.6)
137
+ Installing puppet (3.6.2)
138
+ Installing puppet-lint (1.0.1)
139
+ Installing puppet-syntax (1.3.0)
140
+ Installing rspec-puppet (1.0.1)
141
+ Installing puppetlabs_spec_helper (0.8.1)
142
+ Installing simplecov-html (0.8.0)
143
+ Installing simplecov (0.9.0)
144
+ Using bundler (1.3.6)
145
+ Your bundle is complete!
146
+ It was installed into ./.bundle/gems
147
+ bundle install --path .bundle/gems/ 7.74s user 1.99s system 45% cpu 21.569 total
148
+
149
+ ## Run the spec tests
150
+
151
+ Before starting development of the types or providers, make sure the current
152
+ branch is known-good by automatically validating expected behavior against
153
+ actual behavior.
154
+
155
+ $ bundle exec rspec spec/
156
+ .........................................
157
+ Finished in 2.43 seconds
158
+ 1213 examples, 0 failures
159
+ Coverage report generated for Unit Tests to /netdev_stdlib/coverage/. 512 / 519 LOC (98.65%) covered.
160
+ bundle exec rspec spec 3.59s user 0.27s system 99% cpu 3.896 total
161
+
162
+ ## Test Driven Development
163
+
164
+ If the types are being changed, the spec tests may be automatically run in
165
+ response to file system change events using guard.
166
+
167
+ $ bundle exec guard
168
+ 16:52:13 - INFO - Guard is using Tmux to send notifications.
169
+ 16:52:13 - INFO - Guard is using TerminalTitle to send notifications.
170
+ 16:52:13 - INFO - Guard::RSpec is running
171
+ 16:52:13 - INFO - Inspecting Ruby code style of all files
172
+ 16:52:16 - INFO - Guard is now watching at '/netdev_stdlib'
173
+ [1] guard(main)>
174
+
175
+ # Implementing a provider
176
+
177
+ For a platform named `foo`, the following section describes how to implement a
178
+ module containing providers for the `netdev_stdlib` types.
179
+
180
+ The basic process for implementing providers for these types are as follows.
181
+ First, create a parent directory for use as the module directory. This parent
182
+ directory will contain the `netdev_stdlib` module and the `netdev_stdlib_foo`
183
+ module. For example, `/workspace/netdev/`.
184
+
185
+ Clone the `netdev_stdlib` into the module directory, for example
186
+ `/workspace/netdev/netdev_stdlib` and install dependencies using bundler as
187
+ described in Getting Started for Development.
188
+
189
+ ## Generate the Provider Module
190
+
191
+ With a current working directory of the type module, generate the provider
192
+ module using `puppet module generate`:
193
+
194
+ $ cd /workspace/netdev/netdev_stdlib/
195
+ $ bundle exec puppet module generate acme-netdev_stdlib_foo
196
+ We need to create a metadata.json file for this module. Please answer the
197
+ following questions; if the question is not applicable to this module, feel free
198
+ to leave it blank.
199
+
200
+ Puppet uses Semantic Versioning (semver.org) to version modules.
201
+ What version is this module? [0.1.0]
202
+ --> 0.1.0
203
+
204
+ Who wrote this module? [acme]
205
+ --> acme
206
+
207
+ What license does this module code fall under? [Apache 2.0]
208
+ -->
209
+
210
+ How would you describe this module in a single sentence?
211
+ --> Acme Foo platform providers for the Network Device Standard Library types
212
+
213
+ Where is this module's source code repository?
214
+ --> https://github.com/acme/netdev_stdlib_foo
215
+
216
+ Where can others go to learn more about this module? [https://github.com/acme/netdev_stdlib_foo]
217
+ -->
218
+
219
+ Where can others go to file issues about this module? [https://github.com/acme/netdev_stdlib_foo/issues]
220
+ -->
221
+
222
+ ----------------------------------------
223
+ {
224
+ "name": "acme-netdev_stdlib_foo",
225
+ "version": "0.1.0",
226
+ "author": "acme",
227
+ "summary": "Acme Foo platform providers for the Network Device Standard Library types",
228
+ "license": "Apache 2.0",
229
+ "source": "https://github.com/acme/netdev_stdlib_foo",
230
+ "project_page": "https://github.com/acme/netdev_stdlib_foo",
231
+ "issues_url": "https://github.com/acme/netdev_stdlib_foo/issues",
232
+ "dependencies": [
233
+ {
234
+ "name": "puppetlabs-stdlib",
235
+ "version_range": ">= 1.0.0"
236
+ }
237
+ ]
238
+ }
239
+ ----------------------------------------
240
+
241
+ About to generate this metadata; continue? [n/Y]
242
+
243
+ Notice: Generating module at /workspace/serious/src/modules/netdev/test/netdev_stdlib/acme-netdev_stdlib_foo...
244
+ Notice: Populating ERB templates...
245
+ Finished; module generated in acme-netdev_stdlib_foo.
246
+ acme-netdev_stdlib_foo/manifests
247
+ acme-netdev_stdlib_foo/manifests/init.pp
248
+ acme-netdev_stdlib_foo/metadata.json
249
+ acme-netdev_stdlib_foo/Rakefile
250
+ acme-netdev_stdlib_foo/README.md
251
+ acme-netdev_stdlib_foo/spec
252
+ acme-netdev_stdlib_foo/spec/classes
253
+ acme-netdev_stdlib_foo/spec/classes/init_spec.rb
254
+ acme-netdev_stdlib_foo/spec/spec_helper.rb
255
+ acme-netdev_stdlib_foo/tests
256
+ acme-netdev_stdlib_foo/tests/init.pp
257
+
258
+ Move the skeleton into the module directory:
259
+
260
+ $ mv acme-netdev_stdlib_foo ../netdev_stdlib_foo
261
+ $ cd ../netdev_stdlib_foo
262
+
263
+ ## Express the dependencies
264
+
265
+ The provider module has the same dependencies as the type module and so it is
266
+ easiest to simply copy the dependency information from the `netdev_stdlib`
267
+ type.
268
+
269
+ $ cp ../netdev_stdlib/{Gem,Guard}file .
270
+
271
+ Install the dependencies:
272
+
273
+ $ bundle install --path .bundle/gems/
274
+
275
+ ## Configure RSpec
276
+
277
+ Puppet Providers are generally tested with RSpec. Copy the spec helper, which
278
+ initializes RSpec for module testing.
279
+
280
+ $ cp ../netdev_stdlib/spec/spec_helper.rb spec/
281
+
282
+ Remove the rspec-puppet generated example for a puppet class.
283
+
284
+ $ rm ./spec/classes/init_spec.rb
285
+
286
+ Test that rspec runs:
287
+
288
+ $ bundle exec rspec spec/
289
+ No examples found.
290
+ Finished in 0.00004 seconds
291
+ 0 examples, 0 failures
292
+
293
+ ## Mocking
294
+
295
+ The device API used by the provider should be modeled as a utility class in
296
+ `PuppetX::NetDev::FooApi` class, located at `lib/puppet_x/net_dev/foo_api.rb`.
297
+ Instance methods of this API class are suitable for mocking network based API
298
+ calls in the spec tests. For REST API's the response data from the resource
299
+ request should be serialized into a fixtures directory. These fixtures are
300
+ therefore able to be updated as API responses are changed or added over time.
301
+
302
+ For more information on rspec, please see https://github.com/rspec/rspec
303
+
304
+ # License
305
+
306
+ Copyright 2014 [Puppet Labs][puppetlabs]
307
+
308
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
309
+ this file except in compliance with the License. You may obtain a copy of the
310
+ License at
311
+
312
+ [http://www.apache.org/licenses/LICENSE-2.0][license]
313
+
314
+ Unless required by applicable law or agreed to in writing, software distributed
315
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
316
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
317
+ specific language governing permissions and limitations under the License.
318
+
319
+ [book]: http://shop.oreilly.com/product/0636920026860.do
320
+ [license]: http://www.apache.org/licenses/LICENSE-2.0
321
+ [travis]: https://travis-ci.org/puppetlabs/netdev_stdlib/builds
322
+ [puppetlabs]: http://puppetlabs.com
323
+ [types doc]: https://docs.puppetlabs.com/guides/custom_types.html
324
+ [gary provider]: http://garylarizza.com/blog/2013/12/15/seriously-what-is-this-provider-doing/
325
+ [crossfader]: http://github.com/puppetlabs/crossfader
326
+ [crossfader quick start]: https://github.com/puppetlabs/crossfader#quick-start-install
327
+ [rvm]: http://rvm.io/
328
+ [rbenv]: https://github.com/sstephenson/rbenv
329
+ [pe components]: https://docs.puppetlabs.com/pe/latest/install_what_and_where.html#puppet-enterprise-software-components
330
+ [buildstatus]: https://travis-ci.org/puppetlabs/netdev_stdlib.svg?branch=master