arista-eos 1.1.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 (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,73 @@
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_stp_interface).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
+ result = node.api('stp').get
47
+ result[:interfaces].map do |(name, attrs)|
48
+ provider_hash = { name: name }
49
+ provider_hash[:portfast] = attrs[:portfast].to_s.to_sym
50
+ provider_hash[:portfast_type] = attrs[:portfast_type].to_sym
51
+ provider_hash[:bpduguard] = attrs[:bpduguard].to_s.to_sym
52
+ new(provider_hash)
53
+ end
54
+ end
55
+
56
+ def portfast=(val)
57
+ value = val == :true
58
+ node.api('stp').interfaces.set_portfast(resource['name'], value: value)
59
+ @property_hash[:portfast] = val
60
+ end
61
+
62
+ def portfast_type=(val)
63
+ value = val.to_s
64
+ node.api('stp').interfaces.set_portfast_type(resource['name'], value: value)
65
+ @property_hash[:portfast_type] = val
66
+ end
67
+
68
+ def bpduguard=(val)
69
+ value = val == :true
70
+ node.api('stp').interfaces.set_bpduguard(resource['name'], value: value)
71
+ @property_hash[:bpduguard] = val
72
+ end
73
+ end
@@ -0,0 +1,100 @@
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_switchport).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
+ switchports = node.api('switchports').getall
50
+ switchports.map do |(name, attrs)|
51
+ provider_hash = { name: name, ensure: :present }
52
+ provider_hash.merge!(attrs)
53
+ provider_hash[:mode] = attrs[:mode].to_sym
54
+ new(provider_hash)
55
+ end
56
+ end
57
+
58
+ def mode=(val)
59
+ node.api('switchports').set_mode(resource[:name], value: val)
60
+ @property_hash[:mode] = val
61
+ end
62
+
63
+ def trunk_allowed_vlans=(val)
64
+ node.api('switchports').set_trunk_allowed_vlans(resource[:name], value: val)
65
+ @property_hash[:trunk_allowed_vlans] = val
66
+ end
67
+
68
+ def trunk_native_vlan=(val)
69
+ node.api('switchports').set_trunk_native_vlan(resource[:name], value: val)
70
+ @property_hash[:trunk_native_vlan] = val
71
+ end
72
+
73
+ def access_vlan=(val)
74
+ node.api('switchports').set_access_vlan(resource[:name], value: val)
75
+ @property_hash[:access_vlan] = val
76
+ end
77
+
78
+ def exists?
79
+ @property_hash[:ensure] == :present
80
+ end
81
+
82
+ def create
83
+ node.api('switchports').create(resource[:name])
84
+ @property_hash = { name: resource[:name], ensure: :present }
85
+ self.mode = resource[:mode] if resource[:mode]
86
+
87
+ self.trunk_allowed_vlans = resource[:trunk_allowed_vlans] \
88
+ if resource[:trunk_allowed_vlans]
89
+
90
+ self.trunk_native_vlan = resource[:trunk_native_vlan] \
91
+ if resource[:trunk_native_vlan]
92
+
93
+ self.access_vlan = resource[:access_vlan] if resource[:access_vlan]
94
+ end
95
+
96
+ def destroy
97
+ node.api('switchports').delete(resource[:name])
98
+ @property_hash = { name: resource[:name], ensure: :absent }
99
+ end
100
+ end
@@ -0,0 +1,63 @@
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_system).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('system').get
50
+ provider_hash = { name: 'settings', ensure: :present,
51
+ hostname: result[:hostname] }
52
+ [new(provider_hash)]
53
+ end
54
+
55
+ def exists?
56
+ @property_hash[:ensure] == :present
57
+ end
58
+
59
+ def hostname=(val)
60
+ node.api('system').set_hostname(value: val)
61
+ @property_hash[:hostname] = val
62
+ end
63
+ end
@@ -0,0 +1,93 @@
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_vlan).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
+ vlans = node.api('vlans').getall
50
+ vlans.map do |name, attrs|
51
+ provider_hash = { name: name, vlanid: name, ensure: :present }
52
+ provider_hash[:vlan_name] = attrs[:name]
53
+ provider_hash[:enable] = attrs[:state] == 'active' ? :true : :false
54
+ provider_hash[:trunk_groups] = attrs[:trunk_groups]
55
+ new(provider_hash)
56
+ end
57
+ end
58
+
59
+ def enable=(value)
60
+ val = value == :true ? 'active' : 'suspend'
61
+ node.api('vlans').set_state(resource[:vlanid], value: val)
62
+ @property_hash[:enable] = value
63
+ end
64
+
65
+ def vlan_name=(value)
66
+ node.api('vlans').set_name(resource[:vlanid], value: value)
67
+ @property_hash[:vlan_name] = value
68
+ end
69
+
70
+ def trunk_groups=(value)
71
+ node.api('vlans').set_trunk_group(resource[:vlanid], value: value)
72
+ @property_hash[:trunk_groups] = value
73
+ end
74
+
75
+ def exists?
76
+ @property_hash[:ensure] == :present
77
+ end
78
+
79
+ def create
80
+ node.api('vlans').create(resource[:name])
81
+ @property_hash = { name: resource[:name], vlanid: resource[:vlanid],
82
+ ensure: :present }
83
+
84
+ self.enable = resource[:enable] if resource[:enable]
85
+ self.vlan_name = resource[:vlan_name] if resource[:vlan_name]
86
+ self.trunk_groups = resource[:trunk_groups] if resource[:trunk_groups]
87
+ end
88
+
89
+ def destroy
90
+ node.api('vlans').delete(resource[:vlanid])
91
+ @property_hash = { vlanid: resource[:vlanid], ensure: :absent }
92
+ end
93
+ end
@@ -0,0 +1,104 @@
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_vxlan).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] == 'vxlan'
52
+ provider_hash = { name: name, ensure: :present }
53
+ provider_hash.merge!(attrs)
54
+ provider_hash[:enable] = attrs[:shutdown] ? :false : :true
55
+ arry << new(provider_hash)
56
+ end
57
+ end
58
+
59
+ def source_interface=(val)
60
+ node.api('interfaces').set_source_interface(resource[:name], value: val)
61
+ @property_hash[:source_interface] = val
62
+ end
63
+
64
+ def multicast_group=(val)
65
+ node.api('interfaces').set_multicast_group(resource[:name], value: val)
66
+ @property_hash[:multicast_group] = val
67
+ end
68
+
69
+ def udp_port=(val)
70
+ node.api('interfaces').set_udp_port(resource[:name], value: val)
71
+ @property_hash[:udp_port] = val
72
+ end
73
+
74
+ def enable=(val)
75
+ node.api('interfaces').set_shutdown(resource[:name], value: val == :false)
76
+ @property_hash[:enable] = val
77
+ end
78
+
79
+ def description=(val)
80
+ node.api('interfaces').set_description(resource[:name], value: val)
81
+ @property_hash[:description] = val
82
+ end
83
+
84
+ def exists?
85
+ @property_hash[:ensure] == :present
86
+ end
87
+
88
+ def create
89
+ node.api('interfaces').create(resource[:name])
90
+ @property_hash = { name: resource[:name], ensure: :present }
91
+ self.enable = resource[:enable] if resource[:enable]
92
+ self.description = resource[:description] if resource[:description]
93
+ self.udp_port = resource[:udp_port] if resource[:udp_port]
94
+ self.source_interface = resource[:source_interface] \
95
+ if resource[:source_interface]
96
+ self.multicast_group = resource[:multicast_group] \
97
+ if resource[:multicast_group]
98
+ end
99
+
100
+ def destroy
101
+ node.api('interfaces').delete(resource[:name])
102
+ @property_hash = { name: resource[:name], ensure: :absent }
103
+ end
104
+ 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_vxlan_vlan).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
+ resources = node.api('interfaces').get('Vxlan1')
50
+ resources[:vlans].map do |(vlan, attrs)|
51
+ provider_hash = { name: vlan, ensure: :present, vni: attrs[:vni] }
52
+ new(provider_hash)
53
+ end
54
+ end
55
+
56
+ def initialize(resource = {})
57
+ super(resource)
58
+ @property_flush = {}
59
+ end
60
+
61
+ def vni=(val)
62
+ @property_flush[:vni] = val
63
+ end
64
+
65
+ def exists?
66
+ @property_hash[:ensure] == :present
67
+ end
68
+
69
+ def create
70
+ @property_flush = resource.to_hash
71
+ end
72
+
73
+ def destroy
74
+ @property_flush = resource.to_hash
75
+ end
76
+
77
+ def flush
78
+ api = node.api('interfaces')
79
+ desired_state = @property_hash.merge!(@property_flush)
80
+ validate([:vni], desired_state)
81
+ case desired_state[:ensure]
82
+ when :present
83
+ api.update_vlan('Vxlan1', desired_state[:name], desired_state[:vni])
84
+ when :absent
85
+ api.remove_vlan('Vxlan1', desired_state[:name])
86
+ end
87
+ @property_hash = desired_state
88
+ end
89
+ end