components/ruby/puppet/files/solaris/lib/puppet/provider/address_properties/solaris.rb
changeset 2109 ed516b43cefc
parent 2081 1f1144fb0e4e
equal deleted inserted replaced
2108:6145b31310ca 2109:ed516b43cefc
    71     def properties
    71     def properties
    72         @property_hash[:properties]
    72         @property_hash[:properties]
    73     end
    73     end
    74 
    74 
    75     def properties=(value)
    75     def properties=(value)
    76         ipadm("set-addrprop", add_properties(value), @resource[:name])
    76         value.each do |key, value|
    77     end
    77             ipadm("set-addrprop", "-p", "#{key}=#{value}", @resource[:name])
    78 
       
    79     def add_properties(props)
       
    80         a = []
       
    81         props.each do |key, value|
       
    82             a << "#{key}=#{value}"
       
    83         end
    78         end
    84         properties = Array["-p", a.join(",")]
       
    85     end
    79     end
    86 
    80 
    87     def exists?
    81     def exists?
    88         if @resource[:properties] == nil
    82         if @resource[:properties] == nil
    89             return :false
    83             return :false
   105 
    99 
   106         return @addrprops.empty?
   100         return @addrprops.empty?
   107     end
   101     end
   108 
   102 
   109     def create
   103     def create
   110         ipadm("set-addrprop", add_properties(@addrprops), @resource[:address])
   104         @addrprops.each do |key, value|
       
   105             ipadm("set-addrprop", "-p", "#{key}=#{value}", @resource[:address])
       
   106         end
   111     end
   107     end
   112 
   108 
   113     def exec_cmd(*cmd)
   109     def exec_cmd(*cmd)
   114         output = Puppet::Util::Execution.execute(cmd, :failonfail => false)
   110         output = Puppet::Util::Execution.execute(cmd, :failonfail => false)
   115         {:out => output, :exit => $CHILD_STATUS.exitstatus}
   111         {:out => output, :exit => $CHILD_STATUS.exitstatus}