arista-eos 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.gitignore +41 -0
  2. data/.rubocop.yml +21 -0
  3. data/Gemfile +57 -0
  4. data/Guardfile +21 -0
  5. data/LICENSE +28 -0
  6. data/README.md +178 -0
  7. data/Rakefile +46 -0
  8. data/eos.gemspec +36 -0
  9. data/guide/.gitignore +2 -0
  10. data/guide/Makefile +177 -0
  11. data/guide/_static/arista_logo_jpg-11.jpg +0 -0
  12. data/guide/_static/favicon.ico +0 -0
  13. data/guide/conf.py +282 -0
  14. data/guide/cookbook.rst +135 -0
  15. data/guide/developing.rst +55 -0
  16. data/guide/faq.rst +30 -0
  17. data/guide/index.rst +25 -0
  18. data/guide/installation.rst +174 -0
  19. data/guide/license.rst +5 -0
  20. data/guide/overview.rst +35 -0
  21. data/guide/quickstart.rst +184 -0
  22. data/guide/release-notes-1.0.rst +37 -0
  23. data/guide/release-notes-1.1.rst +25 -0
  24. data/guide/release-notes.rst +10 -0
  25. data/guide/testing.rst +8 -0
  26. data/guide/troubleshooting.rst +26 -0
  27. data/guide/typedoc.rst +928 -0
  28. data/guide/types.rst +44 -0
  29. data/lib/eos.rb +8 -0
  30. data/lib/eos/version.rb +5 -0
  31. data/lib/puppet/provider/eos_acl_entry/default.rb +122 -0
  32. data/lib/puppet/provider/eos_command/default.rb +61 -0
  33. data/lib/puppet/provider/eos_ethernet/default.rb +96 -0
  34. data/lib/puppet/provider/eos_interface/default.rb +89 -0
  35. data/lib/puppet/provider/eos_ipinterface/default.rb +89 -0
  36. data/lib/puppet/provider/eos_mlag/default.rb +86 -0
  37. data/lib/puppet/provider/eos_mlag_interface/default.rb +90 -0
  38. data/lib/puppet/provider/eos_ntp_config/default.rb +68 -0
  39. data/lib/puppet/provider/eos_ntp_server/default.rb +69 -0
  40. data/lib/puppet/provider/eos_portchannel/default.rb +117 -0
  41. data/lib/puppet/provider/eos_snmp/default.rb +77 -0
  42. data/lib/puppet/provider/eos_stp_interface/default.rb +73 -0
  43. data/lib/puppet/provider/eos_switchport/default.rb +100 -0
  44. data/lib/puppet/provider/eos_system/default.rb +63 -0
  45. data/lib/puppet/provider/eos_vlan/default.rb +93 -0
  46. data/lib/puppet/provider/eos_vxlan/default.rb +104 -0
  47. data/lib/puppet/provider/eos_vxlan_vlan/default.rb +89 -0
  48. data/lib/puppet/provider/eos_vxlan_vtep/default.rb +70 -0
  49. data/lib/puppet/type/eos_acl_entry.rb +126 -0
  50. data/lib/puppet/type/eos_command.rb +75 -0
  51. data/lib/puppet/type/eos_ethernet.rb +101 -0
  52. data/lib/puppet/type/eos_interface.rb +79 -0
  53. data/lib/puppet/type/eos_ipinterface.rb +116 -0
  54. data/lib/puppet/type/eos_mlag.rb +133 -0
  55. data/lib/puppet/type/eos_mlag_interface.rb +85 -0
  56. data/lib/puppet/type/eos_ntp_config.rb +70 -0
  57. data/lib/puppet/type/eos_ntp_server.rb +52 -0
  58. data/lib/puppet/type/eos_portchannel.rb +189 -0
  59. data/lib/puppet/type/eos_snmp.rb +127 -0
  60. data/lib/puppet/type/eos_stp_interface.rb +94 -0
  61. data/lib/puppet/type/eos_switchport.rb +150 -0
  62. data/lib/puppet/type/eos_system.rb +69 -0
  63. data/lib/puppet/type/eos_vlan.rb +130 -0
  64. data/lib/puppet/type/eos_vxlan.rb +150 -0
  65. data/lib/puppet/type/eos_vxlan_vlan.rb +78 -0
  66. data/lib/puppet/type/eos_vxlan_vtep.rb +62 -0
  67. data/lib/puppet_x/eos/provider.rb +86 -0
  68. data/lib/puppet_x/eos/utils/helpers.rb +34 -0
  69. data/metadata.json +20 -0
  70. data/spec/fixtures/README +61 -0
  71. data/spec/fixtures/ethernet.json +9 -0
  72. data/spec/fixtures/fixture_stp.yaml +11 -0
  73. data/spec/fixtures/fixture_vxlan_get.yaml +11 -0
  74. data/spec/fixtures/ospf.json +13 -0
  75. data/spec/fixtures/snmp.json +6 -0
  76. data/spec/fixtures/varp.json +11 -0
  77. data/spec/spec_helper.rb +27 -0
  78. data/spec/support/fixtures.rb +74 -0
  79. data/spec/support/shared_examples_for_providers.rb +7 -0
  80. data/spec/support/shared_examples_for_types.rb +451 -0
  81. data/spec/unit/puppet/provider/eos_acl_entry/default_spec.rb +226 -0
  82. data/spec/unit/puppet/provider/eos_acl_entry/fixture_acl_entry.yaml +20 -0
  83. data/spec/unit/puppet/provider/eos_ethernet/default_spec.rb +226 -0
  84. data/spec/unit/puppet/provider/eos_ethernet/fixture_ethernet.yaml +8 -0
  85. data/spec/unit/puppet/provider/eos_interface/default_spec.rb +176 -0
  86. data/spec/unit/puppet/provider/eos_interface/fixture_interfaces.yaml +5 -0
  87. data/spec/unit/puppet/provider/eos_ipinterface/default_spec.rb +223 -0
  88. data/spec/unit/puppet/provider/eos_ipinterface/fixture_ipinterfaces.yaml +5 -0
  89. data/spec/unit/puppet/provider/eos_mlag/default_spec.rb +203 -0
  90. data/spec/unit/puppet/provider/eos_mlag/fixture_mlag.yaml +11 -0
  91. data/spec/unit/puppet/provider/eos_mlag_interface/default_spec.rb +177 -0
  92. data/spec/unit/puppet/provider/eos_mlag_interface/fixture_mlag.yaml +11 -0
  93. data/spec/unit/puppet/provider/eos_ntp_config/default_spec.rb +150 -0
  94. data/spec/unit/puppet/provider/eos_ntp_config/fixture_ntp.yaml +3 -0
  95. data/spec/unit/puppet/provider/eos_ntp_server/default_spec.rb +152 -0
  96. data/spec/unit/puppet/provider/eos_ntp_server/fixture_ntp.yaml +3 -0
  97. data/spec/unit/puppet/provider/eos_portchannel/default_spec.rb +271 -0
  98. data/spec/unit/puppet/provider/eos_portchannel/fixture_portchannels.yaml +10 -0
  99. data/spec/unit/puppet/provider/eos_snmp/default_spec.rb +193 -0
  100. data/spec/unit/puppet/provider/eos_snmp/fixture_snmp.yaml +6 -0
  101. data/spec/unit/puppet/provider/eos_stp_interface/default_spec.rb +138 -0
  102. data/spec/unit/puppet/provider/eos_switchport/default_spec.rb +250 -0
  103. data/spec/unit/puppet/provider/eos_switchport/fixture_switchports.yaml +7 -0
  104. data/spec/unit/puppet/provider/eos_system/default_spec.rb +129 -0
  105. data/spec/unit/puppet/provider/eos_system/fixture_system.yaml +2 -0
  106. data/spec/unit/puppet/provider/eos_vlan/default_spec.rb +228 -0
  107. data/spec/unit/puppet/provider/eos_vlan/fixture_vlans.yaml +6 -0
  108. data/spec/unit/puppet/provider/eos_vxlan/default_spec.rb +229 -0
  109. data/spec/unit/puppet/provider/eos_vxlan/fixture_vxlan.yaml +9 -0
  110. data/spec/unit/puppet/provider/eos_vxlan_vlan/default_spec.rb +148 -0
  111. data/spec/unit/puppet/provider/eos_vxlan_vtep/default_spec.rb +140 -0
  112. data/spec/unit/puppet/type/eos_acl_entry_spec.rb +103 -0
  113. data/spec/unit/puppet/type/eos_command_spec.rb +67 -0
  114. data/spec/unit/puppet/type/eos_ethernet_spec.rb +87 -0
  115. data/spec/unit/puppet/type/eos_interface_spec.rb +67 -0
  116. data/spec/unit/puppet/type/eos_ipinterface_spec.rb +84 -0
  117. data/spec/unit/puppet/type/eos_mlag_interface_spec.rb +62 -0
  118. data/spec/unit/puppet/type/eos_mlag_spec.rb +98 -0
  119. data/spec/unit/puppet/type/eos_ntp_config_spec.rb +58 -0
  120. data/spec/unit/puppet/type/eos_ntp_server_spec.rb +51 -0
  121. data/spec/unit/puppet/type/eos_portchannel_spec.rb +99 -0
  122. data/spec/unit/puppet/type/eos_snmp_spec.rb +87 -0
  123. data/spec/unit/puppet/type/eos_stp_interface_spec.rb +77 -0
  124. data/spec/unit/puppet/type/eos_switchport_spec.rb +88 -0
  125. data/spec/unit/puppet/type/eos_system_spec.rb +57 -0
  126. data/spec/unit/puppet/type/eos_vlan_spec.rb +86 -0
  127. data/spec/unit/puppet/type/eos_vxlan_spec.rb +100 -0
  128. data/spec/unit/puppet/type/eos_vxlan_vlan_spec.rb +73 -0
  129. data/spec/unit/puppet/type/eos_vxlan_vtep_spec.rb +52 -0
  130. data/tests/init.pp +12 -0
  131. metadata +437 -0
@@ -0,0 +1,44 @@
1
+ .. comment
2
+ # Generate typedoc.rst from the repo-root with the following commands:
3
+ bundle exec puppet doc -r type \
4
+ | awk '/This page/{flag=1}/augeas/{flag=0}/eos_/{flag=1}/ exec/{flag=0}/\*This page/{flag=1}flag' \
5
+ | pandoc --from=markdown --to=rst --output=- \
6
+ > guide/typedoc.rst
7
+
8
+ Types
9
+ =====
10
+
11
+ .. contents::
12
+ :local:
13
+ :depth: 2
14
+
15
+ Getting to know the Types
16
+ -------------------------
17
+
18
+ There are a number of ways to browse the available EOS types::
19
+
20
+ $ puppet resource --types | grep eos
21
+ $ puppet describe eos_vlan
22
+
23
+ Display the current state of a type:
24
+
25
+ .. code-block:: puppet
26
+
27
+ Arista#bash sudo puppet resource eos_vlan
28
+ eos_vlan { '1':
29
+ ensure => 'present',
30
+ enable => 'true',
31
+ vlan_name => 'default',
32
+ }
33
+ eos_vlan { '123':
34
+ ensure => 'present',
35
+ enable => 'true',
36
+ vlan_name => 'VLAN0123',
37
+ }
38
+ eos_vlan { '300':
39
+ ensure => 'present',
40
+ enable => 'true',
41
+ vlan_name => 'ztp_bootstrap',
42
+ }
43
+
44
+ .. include:: typedoc.rst
@@ -0,0 +1,8 @@
1
+ require 'puppet_x/eos/version'
2
+ require 'puppet_x/eos/autoload'
3
+ require 'puppet_x/eos/eapi'
4
+
5
+ ##
6
+ # eos namespace
7
+ module Eos
8
+ end
@@ -0,0 +1,5 @@
1
+ ##
2
+ # eos version
3
+ module Eos
4
+ VERSION = '1.1.0'
5
+ end
@@ -0,0 +1,122 @@
1
+ #
2
+ # Copyright (c) 2015, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'puppet/type'
33
+ require 'pathname'
34
+
35
+ module_lib = Pathname.new(__FILE__).parent.parent.parent.parent
36
+ require File.join module_lib, 'puppet_x/eos/provider'
37
+
38
+ Puppet::Type.type(:eos_acl_entry).provide(:eos) do
39
+ # Create methods that set the @property_hash for the #flush method
40
+ mk_resource_methods
41
+
42
+ # Mix in the api as instance methods
43
+ include PuppetX::Eos::EapiProviderMixin
44
+
45
+ # Mix in the api as class methods
46
+ extend PuppetX::Eos::EapiProviderMixin
47
+
48
+ def self.instances
49
+ acls = node.api('acl').getall
50
+ acls.each_with_object([]) do |(name, entries), arry|
51
+ entries.each_with_object([]) do |(seqno, attrs), _hsh|
52
+ provider_hash = { name: namevar(name, seqno), ensure: :present }
53
+ acltype = attrs[:acltype]
54
+ provider_hash[:acltype] = acltype ? acltype.to_sym : :standard
55
+ action = attrs[:action]
56
+ provider_hash[:action] = action ? action.to_sym : :deny
57
+ provider_hash[:srcaddr] = attrs[:srcaddr]
58
+ provider_hash[:srcprefixlen] = attrs[:srcprefixlen]
59
+ provider_hash[:log] = attrs[:log] ? :true : :false
60
+ arry << new(provider_hash)
61
+ end
62
+ end
63
+ end
64
+
65
+ def initialize(resource = {})
66
+ super(resource)
67
+ @property_flush = {}
68
+ end
69
+
70
+ def acltype=(value)
71
+ @property_flush[:acltype] = value
72
+ end
73
+
74
+ def action=(value)
75
+ @property_flush[:action] = value
76
+ end
77
+
78
+ def srcaddr=(value)
79
+ @property_flush[:srcaddr] = value
80
+ end
81
+
82
+ def srcprefixlen=(value)
83
+ @property_flush[:srcprefixlen] = value
84
+ end
85
+
86
+ def log=(value)
87
+ @property_flush[:log] = value
88
+ end
89
+
90
+ def exists?
91
+ @property_hash[:ensure] == :present
92
+ end
93
+
94
+ def create
95
+ @property_flush = resource.to_hash
96
+ end
97
+
98
+ def destroy
99
+ @property_flush = resource.to_hash
100
+ end
101
+
102
+ def flush
103
+ desired_state = @property_hash.merge!(@property_flush)
104
+ # Extract the acl name and seqno from the name
105
+ comp = desired_state[:name].split(':')
106
+ acl_name = comp[0]
107
+ desired_state[:seqno] = comp[1].to_i
108
+
109
+ api = node.api('acl')
110
+ case desired_state[:ensure]
111
+ when :present
112
+ api.update_entry(acl_name, desired_state)
113
+ when :absent
114
+ api.remove_entry(acl_name, desired_state[:seqno])
115
+ end
116
+ @property_hash = desired_state
117
+ end
118
+
119
+ def self.namevar(name, seqno)
120
+ "#{name}:#{seqno}"
121
+ end
122
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # Copyright (c) 2014, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'puppet/type'
33
+ require 'puppet_x/eos/provider'
34
+
35
+ Puppet::Type.type(:eos_command).provide(:eos) do
36
+ # Create methods that set the @property_hash for the #flush method
37
+ mk_resource_methods
38
+
39
+ # Mix in the api as instance methods
40
+ include PuppetX::Eos::EapiProviderMixin
41
+
42
+ # Mix in the api as class methods
43
+ extend PuppetX::Eos::EapiProviderMixin
44
+
45
+ def self.instances
46
+ []
47
+ end
48
+
49
+ def initialize(resource = {})
50
+ super(resource)
51
+ @property_flush = {}
52
+ end
53
+
54
+ def flush
55
+ if resource[:mode] == :config
56
+ node.config(resource[:commands])
57
+ else
58
+ node.enable(resource[:commands])
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,96 @@
1
+ #
2
+ # Copyright (c) 2014, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'puppet/type'
33
+ require 'pathname'
34
+
35
+ module_lib = Pathname.new(__FILE__).parent.parent.parent.parent
36
+ require File.join module_lib, 'puppet_x/eos/provider'
37
+
38
+ Puppet::Type.type(:eos_ethernet).provide(:eos) do
39
+ # Create methods that set the @property_hash for the #flush method
40
+ mk_resource_methods
41
+
42
+ # Mix in the api as instance methods
43
+ include PuppetX::Eos::EapiProviderMixin
44
+
45
+ # Mix in the api as class methods
46
+ extend PuppetX::Eos::EapiProviderMixin
47
+
48
+ def self.instances
49
+ interfaces = node.api('interfaces').getall
50
+ interfaces.each_with_object([]) do |(name, attrs), arry|
51
+ next unless attrs[:type] == 'ethernet'
52
+ provider_hash = { name: name }
53
+ provider_hash[:enable] = attrs[:shutdown] ? :false : :true
54
+ provider_hash[:description] = attrs[:description]
55
+ provider_hash[:flowcontrol_send] = attrs[:flowcontrol_send].to_sym
56
+ provider_hash[:flowcontrol_receive] = attrs[:flowcontrol_receive].to_sym
57
+ arry << new(provider_hash)
58
+ end
59
+ end
60
+
61
+ def create
62
+ node.api('interfaces').create(resource[:name])
63
+ @property_hash = { name: resource[:name], ensure: :present }
64
+ self.enable = resource[:enable] if resource[:enable]
65
+ self.description = resource[:description] if resource[:description]
66
+ self.flowcontrol_send = resource[:flowcontrol_send] \
67
+ if resource[:flowcontrol_send]
68
+ self.flowcontrol_receive = resource[:flowcontrol_receive] \
69
+ if resource[:flowcontrol_receive]
70
+ end
71
+
72
+ def destroy
73
+ node.api('interfaces').delete(resource[:name])
74
+ @property_hash = { name: resource[:name], ensure: :absent }
75
+ end
76
+
77
+ def enable=(val)
78
+ node.api('interfaces').set_shutdown(resource[:name], value: val == :false)
79
+ @property_hash[:enable] = val
80
+ end
81
+
82
+ def description=(val)
83
+ node.api('interfaces').set_description(resource[:name], value: val)
84
+ @property_hash[:description] = val
85
+ end
86
+
87
+ def flowcontrol_send=(val)
88
+ node.api('interfaces').set_flowcontrol_send(resource[:name], value: val)
89
+ @property_hash[:flowcontrol_send] = val
90
+ end
91
+
92
+ def flowcontrol_receive=(val)
93
+ node.api('interfaces').set_flowcontrol_receive(resource[:name], value: val)
94
+ @property_hash[:flowcontrol_receive] = val
95
+ end
96
+ end
@@ -0,0 +1,89 @@
1
+ #
2
+ # Copyright (c) 2014, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'puppet/type'
33
+ require 'pathname'
34
+
35
+ module_lib = Pathname.new(__FILE__).parent.parent.parent.parent
36
+ require File.join module_lib, 'puppet_x/eos/provider'
37
+
38
+ Puppet::Type.type(:eos_interface).provide(:eos) do
39
+ # Create methods that set the @property_hash for the #flush method
40
+ mk_resource_methods
41
+
42
+ # Mix in the api as instance methods
43
+ include PuppetX::Eos::EapiProviderMixin
44
+
45
+ # Mix in the api as class methods
46
+ extend PuppetX::Eos::EapiProviderMixin
47
+
48
+ def self.instances
49
+ interfaces = node.api('interfaces').getall
50
+ interfaces.map do |(name, attrs)|
51
+ provider_hash = { name: name, ensure: :present }
52
+ provider_hash.merge!(attrs)
53
+ provider_hash[:enable] = attrs[:shutdown] ? :false : :true
54
+ new(provider_hash)
55
+ end
56
+ end
57
+
58
+ def enable=(val)
59
+ node.api('interfaces').set_shutdown(resource[:name], value: val == :false)
60
+ @property_hash[:enable] = val
61
+ end
62
+
63
+ def description=(val)
64
+ node.api('interfaces').set_description(resource[:name], value: val)
65
+ @property_hash[:description] = val
66
+ end
67
+
68
+ def exists?
69
+ @property_hash[:ensure] == :present
70
+ end
71
+
72
+ def create
73
+ if resource[:name] =~ /^[Et|Ma]/
74
+ fail 'Creating physical interfaces is not supported'
75
+ end
76
+ node.api('interfaces').create(resource[:name])
77
+ @property_hash = { name: resource[:name], ensure: :present }
78
+ self.enable = resource[:enable] if resource[:enable]
79
+ self.description = resource[:description] if resource[:description]
80
+ end
81
+
82
+ def destroy
83
+ if resource[:name] =~ /^[Et|Ma]/
84
+ fail 'Destroying physical interfaces is not supported'
85
+ end
86
+ node.api('interfaces').delete(resource[:name])
87
+ @property_hash = { name: resource[:name], ensure: :absent }
88
+ end
89
+ end
@@ -0,0 +1,89 @@
1
+ #
2
+ # Copyright (c) 2014, Arista Networks, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are
7
+ # met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # Neither the name of Arista Networks nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS
24
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ require 'puppet/type'
33
+ require 'pathname'
34
+
35
+ module_lib = Pathname.new(__FILE__).parent.parent.parent.parent
36
+ require File.join module_lib, 'puppet_x/eos/provider'
37
+
38
+ Puppet::Type.type(:eos_ipinterface).provide(:eos) do
39
+ # Create methods that set the @property_hash for the #flush method
40
+ mk_resource_methods
41
+
42
+ # Mix in the api as instance methods
43
+ include PuppetX::Eos::EapiProviderMixin
44
+
45
+ # Mix in the api as class methods
46
+ extend PuppetX::Eos::EapiProviderMixin
47
+
48
+ def self.instances
49
+ result = node.api('ipinterfaces').getall
50
+ result.map do |name, attrs|
51
+ provider_hash = { name: name, ensure: :present }
52
+ provider_hash.merge!(attrs)
53
+ new(provider_hash)
54
+ end
55
+ end
56
+
57
+ def address=(val)
58
+ node.api('ipinterfaces').set_address(resource['name'], value: val)
59
+ @property_hash[:address] = val
60
+ end
61
+
62
+ def helper_addresses=(val)
63
+ node.api('ipinterfaces').set_helper_addresses(resource['name'], value: val)
64
+ @property_hash[:helper_addresses] = val
65
+ end
66
+
67
+ def mtu=(val)
68
+ node.api('ipinterfaces').set_mtu(resource['name'], value: val)
69
+ @property_hash[:mtu] = val
70
+ end
71
+
72
+ def exists?
73
+ @property_hash[:ensure] == :present
74
+ end
75
+
76
+ def create
77
+ node.api('ipinterfaces').create(resource[:name])
78
+ @property_hash = { name: resource[:name], ensure: :present }
79
+ self.address = resource[:address] if resource[:address]
80
+ self.mtu = resource[:mtu] if resource[:mtu]
81
+ self.helper_addresses = resource[:helper_addresses] \
82
+ if resource[:helper_addresses]
83
+ end
84
+
85
+ def destroy
86
+ node.api('ipinterfaces').delete(resource[:name])
87
+ @property_hash = { name: resource[:name], ensure: :absent }
88
+ end
89
+ end