Skip to content

Instantly share code, notes, and snippets.

@DavidS
Created February 27, 2013 13:03
Show Gist options
  • Save DavidS/5047755 to your computer and use it in GitHub Desktop.
Save DavidS/5047755 to your computer and use it in GitHub Desktop.
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