Advertisement
fatmcgav

Untitled

Nov 13th, 2012
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.88 KB | None | 0 0
  1. -- Provider
  2. require 'puppet/provider/netapp'
  3.  
  4. Puppet::Type.type(:netapp_volume_options).provide(:netapp_volume_options, :parent => Puppet::Provider::Netapp) do
  5.   @doc = "Manage Netapp Volume option modification and deletion for existing volumes."
  6.  
  7.   confine :feature => :posix
  8.   defaultfor :feature => :posix
  9.  
  10.   def create
  11.     Puppet.debug("Puppet::Provider::netapp_volume_options: setting Netapp Volume options against volume #{@resource[:name]}.")
  12.     Puppet.debug("Puppet::Provider::netapp_volume_options: Options: #{@resource[:options]}")
  13.     options = @resource[:options]
  14.     options.each do |option|
  15.         Puppet.debug("Puppet::Provider::netapp_volume_options: Option: #{option}")
  16.         value = split(option, '=')
  17.         value.each do |val|
  18.                 Puppet.debug("Puppet::Provider::netapp_volume_options: Val = #{val}")
  19.         end
  20.   end
  21.  
  22.   def destroy
  23.     Puppet.debug("Puppet::Provider::netapp_volume_options: destroying Netapp Volume #{@resource[:name]}")
  24.   end
  25.  
  26.   def exists?
  27.     Puppet.debug("Puppet::Provider::netapp_volume_options: checking value of Netapp Volume option on Volume #{@resource[:name]}")
  28.   return false
  29.   end
  30. end
  31.  
  32. -- Type
  33. Puppet::Type.newtype(:netapp_volume_options) do
  34.   @doc = "Manage Netapp Volume Option modification."
  35.  
  36.   apply_to_device
  37.  
  38.   ensurable do
  39.     desc "Netapp Volume resource state. Valid values are: present, absent."
  40.  
  41.     defaultto(:present)
  42.  
  43.     newvalue(:present) do
  44.       provider.create
  45.     end
  46.  
  47.     newvalue(:absent) do
  48.       provider.destroy
  49.     end
  50.   end
  51.  
  52.   newparam(:name) do
  53.     desc "The volume name to set options against."
  54.     isnamevar
  55.   end
  56.  
  57.   newparam(:options, :array_matching => :all) do
  58.     desc "Array of options to be applied to this volume."
  59.  
  60.   end
  61. end
  62.  
  63. -- Node config
  64.         netapp_volume_options { 'v_puppet_test12111508':
  65.                 options => ['x=a', 'y=b']
  66.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement