Created
February 27, 2013 13:03
-
-
Save DavidS/5047755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newproperty(:mode) do | |
desc "Set trunking mode of the interface." | |
defaultto(:undef) | |
newvalues(:undef, :access, :dot1q, :dynamic, :private, :trunk) | |
end | |
newproperty(:trunk_native_vlan) do | |
desc "Set native VLAN when interface is in trunking mode" | |
defaultto(:undef) | |
newvalues(:undef, /^\d+$/) | |
validate do |value| | |
if resource.value(:mode) == :trunk and value == :undef | |
raise ArgumentError, "Must set native vlan if mode is trunk" | |
elsif resource.value(:mode) != :trunk and value != :undef | |
raise ArgumentError, "May only be set if mode is trunk" | |
end | |
self.class.value_collection.validate(value) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment