New name is Puppet::Type.property_names

Signed-off-by: Luke Kanies <[email protected]>
---
Local-branch: refactor/master/8233-refactor_parameter_management
 .../provider/macauthorization/macauthorization.rb  |    2 +-
 lib/puppet/provider/nameservice.rb                 |    4 ++--
 .../provider/nameservice/directoryservice.rb       |   12 ++++++------
 lib/puppet/provider/network_device.rb              |    2 +-
 lib/puppet/provider/parsedfile.rb                  |    2 +-
 lib/puppet/provider/user/pw.rb                     |    2 +-
 lib/puppet/provider/user/user_role_add.rb          |    2 +-
 lib/puppet/provider/user/useradd.rb                |    2 +-
 lib/puppet/provider/zfs/solaris.rb                 |    2 +-
 lib/puppet/provider/zone/solaris.rb                |    2 +-
 lib/puppet/reference/type.rb                       |    2 +-
 lib/puppet/type.rb                                 |   17 ++++-------------
 lib/puppet/type/yumrepo.rb                         |    2 +-
 spec/unit/provider/ldap_spec.rb                    |    2 +-
 spec/unit/provider/network_device_spec.rb          |    4 ++--
 spec/unit/type/mount_spec.rb                       |    2 +-
 spec/unit/type_spec.rb                             |    7 +++++++
 test/language/snippets.rb                          |    2 +-
 test/lib/puppettest/fakes.rb                       |    4 ++--
 test/ral/manager/type.rb                           |    4 ++--
 test/ral/providers/group.rb                        |    2 +-
 test/ral/providers/parsedfile.rb                   |    2 +-
 test/ral/providers/user.rb                         |    6 +++---
 23 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/lib/puppet/provider/macauthorization/macauthorization.rb 
b/lib/puppet/provider/macauthorization/macauthorization.rb
index fdf9fd1..dfcb3ce 100644
--- a/lib/puppet/provider/macauthorization/macauthorization.rb
+++ b/lib/puppet/provider/macauthorization/macauthorization.rb
@@ -86,7 +86,7 @@ Puppet::Type.type(:macauthorization).provide 
:macauthorization, :parent => Puppe
     # we just fill the @property_hash in here and let the flush method
     # deal with it rather than repeating code.
     new_values = {}
-    validprops = Puppet::Type.type(resource.class.name).validproperties
+    validprops = Puppet::Type.type(resource.class.name).property_names
     validprops.each do |prop|
       next if prop == :ensure
       if value = resource.should(prop) and value != ""
diff --git a/lib/puppet/provider/nameservice.rb 
b/lib/puppet/provider/nameservice.rb
index d57052b..5f7d78a 100644
--- a/lib/puppet/provider/nameservice.rb
+++ b/lib/puppet/provider/nameservice.rb
@@ -66,7 +66,7 @@ class Puppet::Provider::NameService < Puppet::Provider
 
     def resource_type=(resource_type)
       super
-      @resource_type.validproperties.each do |prop|
+      @resource_type.property_names.each do |prop|
         next if prop == :ensure
         define_method(prop) { get(prop) || :absent} unless 
public_method_defined?(prop)
         define_method(prop.to_s + "=") { |*vals| set(prop, *vals) } unless 
public_method_defined?(prop.to_s + "=")
@@ -248,7 +248,7 @@ class Puppet::Provider::NameService < Puppet::Provider
   # Convert the Etc struct into a hash.
   def info2hash(info)
     hash = {}
-    self.class.resource_type.validproperties.each do |param|
+    self.class.resource_type.property_names.each do |param|
       method = posixmethod(param)
       hash[param] = info.send(posixmethod(param)) if info.respond_to? method
     end
diff --git a/lib/puppet/provider/nameservice/directoryservice.rb 
b/lib/puppet/provider/nameservice/directoryservice.rb
index 35ac8d7..f1e8aad 100644
--- a/lib/puppet/provider/nameservice/directoryservice.rb
+++ b/lib/puppet/provider/nameservice/directoryservice.rb
@@ -65,7 +65,7 @@ class DirectoryService < Puppet::Provider::NameService
     # JJM Class method that provides an array of instance objects of this
     #     type.
     # JJM: Properties are dependent on the Puppet::Type we're managine.
-    type_property_array = [:name] + @resource_type.validproperties
+    type_property_array = [:name] + @resource_type.property_names
 
     # Create a new instance of this Puppet::Type for each object present
     #    on the system.
@@ -193,7 +193,7 @@ class DirectoryService < Puppet::Provider::NameService
     # stored in the user record. It is stored at a path that involves the
     # UUID of the user record for non-Mobile local acccounts.
     # Mobile Accounts are out of scope for this provider for now
-    attribute_hash[:password] = self.get_password(attribute_hash[:guid]) if 
@resource_type.validproperties.include?(:password) and Puppet.features.root?
+    attribute_hash[:password] = self.get_password(attribute_hash[:guid]) if 
@resource_type.property_names.include?(:password) and Puppet.features.root?
     attribute_hash
   end
 
@@ -341,7 +341,7 @@ class DirectoryService < Puppet::Provider::NameService
     # managing and call the method which sets that property value
     # dscl can't create everything at once unfortunately.
     if ensure_value == :present
-      @resource.class.validproperties.each do |name|
+      @resource.class.property_names.each do |name|
         next if name == :ensure
         # LAK: We use property.sync here rather than directly calling
         # the settor method because the properties might do some kind
@@ -434,7 +434,7 @@ class DirectoryService < Puppet::Provider::NameService
     end
 
     # Now we create all the standard properties
-    Puppet::Type.type(@resource.class.name).validproperties.each do |property|
+    Puppet::Type.type(@resource.class.name).property_names.each do |property|
       next if property == :ensure
       value = @resource.should(property)
       if property == :gid and value.nil?
@@ -514,7 +514,7 @@ class DirectoryService < Puppet::Provider::NameService
       # self.class.resource_type is a reference to the Puppet::Type class,
       # probably Puppet::Type::User or Puppet::Type::Group, etc...
       #
-      # self.class.resource_type.validproperties is a class method,
+      # self.class.resource_type.property_names is a class method,
       # returning an Array of the valid properties of that specific
       # Puppet::Type.
       #
@@ -523,7 +523,7 @@ class DirectoryService < Puppet::Provider::NameService
       #
       # Ultimately, we add :name to the list, delete :ensure from the
       # list, then report on the remaining list. Pretty whacky, ehh?
-      type_properties = [:name] + self.class.resource_type.validproperties
+      type_properties = [:name] + self.class.resource_type.property_names
       type_properties.delete(:ensure) if type_properties.include? :ensure
       type_properties << :guid  # append GeneratedUID so we just get the 
report here
       @property_value_cache_hash = self.class.single_report(@resource[:name], 
*type_properties)
diff --git a/lib/puppet/provider/network_device.rb 
b/lib/puppet/provider/network_device.rb
index 46be279..93af863 100644
--- a/lib/puppet/provider/network_device.rb
+++ b/lib/puppet/provider/network_device.rb
@@ -40,7 +40,7 @@ class Puppet::Provider::NetworkDevice < Puppet::Provider
 
   def create
     @property_hash[:ensure] = :present
-    self.class.resource_type.validproperties.each do |property|
+    self.class.resource_type.property_names.each do |property|
       if val = resource.should(property)
         @property_hash[property] = val
       end
diff --git a/lib/puppet/provider/parsedfile.rb 
b/lib/puppet/provider/parsedfile.rb
index 009ad1f..00ef61f 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -304,7 +304,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
   end
 
   def create
-    @resource.class.validproperties.each do |property|
+    @resource.class.property_names.each do |property|
       if value = @resource.should(property)
         @property_hash[property] = value
       end
diff --git a/lib/puppet/provider/user/pw.rb b/lib/puppet/provider/user/pw.rb
index a5988ca..792deee 100644
--- a/lib/puppet/provider/user/pw.rb
+++ b/lib/puppet/provider/user/pw.rb
@@ -22,7 +22,7 @@ Puppet::Type.type(:user).provide :pw, :parent => 
Puppet::Provider::NameService::
 
   def addcmd
     cmd = [command(:pw), "useradd", @resource[:name]]
-    @resource.class.validproperties.each do |property|
+    @resource.class.property_names.each do |property|
       next if property == :ensure
       # the value needs to be quoted, mostly because -c might
       # have spaces in it
diff --git a/lib/puppet/provider/user/user_role_add.rb 
b/lib/puppet/provider/user/user_role_add.rb
index 2377f9e..ea31152 100644
--- a/lib/puppet/provider/user/user_role_add.rb
+++ b/lib/puppet/provider/user/user_role_add.rb
@@ -29,7 +29,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => 
:useradd, :source =>
   #must override this to hand the keyvalue pairs
   def add_properties
     cmd = []
-    Puppet::Type.type(:user).validproperties.each do |property|
+    Puppet::Type.type(:user).property_names.each do |property|
       #skip the password because we can't create it with the solaris useradd
       next if [:ensure, :password, :password_min_age, 
:password_max_age].include?(property)
       # 1680 Now you can set the hashed passwords on 
solaris:lib/puppet/provider/user/user_role_add.rb
diff --git a/lib/puppet/provider/user/useradd.rb 
b/lib/puppet/provider/user/useradd.rb
index b879717..4d0c804 100644
--- a/lib/puppet/provider/user/useradd.rb
+++ b/lib/puppet/provider/user/useradd.rb
@@ -52,7 +52,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => 
Puppet::Provider::NameServ
 
   def add_properties
     cmd = []
-    Puppet::Type.type(:user).validproperties.each do |property|
+    Puppet::Type.type(:user).property_names.each do |property|
       next if property == :ensure
       next if property.to_s =~ /password_.+_age/
       # the value needs to be quoted, mostly because -c might
diff --git a/lib/puppet/provider/zfs/solaris.rb 
b/lib/puppet/provider/zfs/solaris.rb
index b783f9e..32dcbcf 100644
--- a/lib/puppet/provider/zfs/solaris.rb
+++ b/lib/puppet/provider/zfs/solaris.rb
@@ -6,7 +6,7 @@ Puppet::Type.type(:zfs).provide(:solaris) do
 
   def add_properties
     properties = []
-    Puppet::Type.type(:zfs).validproperties.each do |property|
+    Puppet::Type.type(:zfs).property_names.each do |property|
       next if property == :ensure
       if value = @resource[property] and value != ""
         properties << "-o" << "#{property}=#{value}"
diff --git a/lib/puppet/provider/zone/solaris.rb 
b/lib/puppet/provider/zone/solaris.rb
index 194af50..b729b9c 100644
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@ -77,7 +77,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
       if @property_hash.empty?
         @property_hash[:ensure] = :absent
       else
-        @resource.class.validproperties.each do |name|
+        @resource.class.property_names.each do |name|
           @property_hash[name] ||= :absent
         end
       end
diff --git a/lib/puppet/reference/type.rb b/lib/puppet/reference/type.rb
index dbd8278..455b1ee 100644
--- a/lib/puppet/reference/type.rb
+++ b/lib/puppet/reference/type.rb
@@ -70,7 +70,7 @@ type = Puppet::Util::Reference.newreference :type, :doc => 
"All Puppet resource
     end
 
     docs = {}
-    type.validproperties.sort { |a,b|
+    type.property_names.sort { |a,b|
       a.to_s <=> b.to_s
     }.reject { |sname|
       property = type.parameter(sname)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 96a069d..462d741 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -245,6 +245,10 @@ class Type
     parameters.find_all { |p| p.property? }
   end
 
+  def self.property_names
+    properties.collect { |p| p.name }
+  end
+
   # Is the provided name a valid parameter?
   # This method is used in both Puppet::Type and Puppet::Resource.
   def self.valid_parameter?(name)
@@ -270,19 +274,6 @@ class Type
   # All new code in this block
   #############################
 
-  #############################
-  # This code should probably all be removed
-  # All parameters, in the appropriate order.  The key_attributes come first, 
then
-  # the provider, then the properties, and finally the params and metaparams
-  # in the order they were specified in the files.
-  # does the name reflect a valid property?
-  # Return the list of validproperties
-  def self.validproperties
-    parameters.find_all { |p| p.property? }.collect { |p| p.name }
-  end
-  # end of code likely to be removed
-  ##############################
-
   # Create the 'ensure' class.  This is a separate method so other types
   # can easily call it and create their own 'ensure' values.
   def self.ensurable(&block)
diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb
index 9b4c794..6047437 100644
--- a/lib/puppet/type/yumrepo.rb
+++ b/lib/puppet/type/yumrepo.rb
@@ -82,7 +82,7 @@ module Puppet
 
     def self.instances
       l = []
-      check = validproperties
+      check = property_names
       clear
       inifile.each_section do |s|
         next if s.name == "main"
diff --git a/spec/unit/provider/ldap_spec.rb b/spec/unit/provider/ldap_spec.rb
index 44c9dc9..79de56b 100755
--- a/spec/unit/provider/ldap_spec.rb
+++ b/spec/unit/provider/ldap_spec.rb
@@ -216,7 +216,7 @@ describe Puppet::Provider::Ldap do
     describe "is being created" do
       before do
         @rclass = mock 'resource_class'
-        @rclass.stubs(:validproperties).returns([:one, :two])
+        @rclass.stubs(:property_names).returns([:one, :two])
         @resource = mock 'resource'
         @resource.stubs(:class).returns @rclass
         @resource.stubs(:[]).returns nil
diff --git a/spec/unit/provider/network_device_spec.rb 
b/spec/unit/provider/network_device_spec.rb
index ae8627f..6878a01 100755
--- a/spec/unit/provider/network_device_spec.rb
+++ b/spec/unit/provider/network_device_spec.rb
@@ -89,7 +89,7 @@ describe provider_class do
       @instance = provider_class.new(:device)
 
       @property_class = stub 'property_class', :array_matching => :all, 
:superclass => Puppet::Property
-      @resource_class = stub 'resource_class', :parameter => @property_class, 
:valid_parameter? => true, :validproperties => [:description]
+      @resource_class = stub 'resource_class', :parameter => @property_class, 
:valid_parameter? => true, :property_names => [:description]
       provider_class.stubs(:resource_type).returns @resource_class
     end
 
@@ -122,7 +122,7 @@ describe provider_class do
     describe "is being created" do
       before do
         @rclass = mock 'resource_class'
-        @rclass.stubs(:validproperties).returns([:description])
+        @rclass.stubs(:property_names).returns([:description])
         @resource = stub_everything 'resource'
         @resource.stubs(:class).returns @rclass
         @resource.stubs(:should).returns nil
diff --git a/spec/unit/type/mount_spec.rb b/spec/unit/type/mount_spec.rb
index 3be3e3c..1fbc38b 100755
--- a/spec/unit/type/mount_spec.rb
+++ b/spec/unit/type/mount_spec.rb
@@ -73,7 +73,7 @@ describe Puppet::Type.type(:mount)::Ensure do
   end
 
   def mount_stub(params)
-    Puppet::Type.type(:mount).validproperties.each do |prop|
+    Puppet::Type.type(:mount).property_names.each do |prop|
       unless params[prop]
         params[prop] = :absent
         @mount[prop] = :absent
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index eb7e595..4c5c176 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -276,6 +276,13 @@ describe Puppet::Type do
 
       @type.properties.should == [foo, bar]
     end
+
+    it "should be able to return all known property names" do
+      foo = @type.newproperty(:foo)
+      bar = @type.newproperty(:bar)
+
+      @type.property_names.should == [:foo, :bar]
+    end
   end
 
   describe "when creating an event" do
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 5ac69c1..bdd7783 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -99,7 +99,7 @@ class TestSnippets < Test::Unit::TestCase
   end
 
   def properties(type)
-    properties = type.validproperties
+    properties = type.property_names
   end
 
   def metaparams(type)
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index 91d5da2..5006cc5 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -85,7 +85,7 @@ module PuppetTest
 
     # Set up methods to fake things
     def self.apimethods(*ary)
-      @resource_type.validproperties.each do |property|
+      @resource_type.property_names.each do |property|
         ary << property unless ary.include? property
       end
       attr_accessor(*ary)
@@ -124,7 +124,7 @@ module PuppetTest
     end
 
     def properties
-      self.class.resource_type.validproperties.inject({}) do |props, name|
+      self.class.resource_type.property_names.inject({}) do |props, name|
         props[name] = self.send(name) || :absent
         props
       end
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index d8995e2..8d96841 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -26,7 +26,7 @@ class TestType < Test::Unit::TestCase
       )
 
       # Skip types with no parameters or valid properties
-      #unless ! type.parameters.empty? or ! type.validproperties.empty?
+      #unless ! type.parameters.empty? or ! type.property_names.empty?
       #    next
       #end
 
@@ -42,7 +42,7 @@ class TestType < Test::Unit::TestCase
 
               assert_not_nil(
                 
-          type.validproperties,
+          type.property_names,
         
           "Valid properties for #{name} are nil"
         )
diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb
index 4259be3..900c29c 100755
--- a/test/ral/providers/group.rb
+++ b/test/ral/providers/group.rb
@@ -186,7 +186,7 @@ class TestGroupProvider < Test::Unit::TestCase
       }
       assert(!missing?(name), "Group #{name} is missing")
 
-      tests = Puppet::Type.type(:group).validproperties
+      tests = Puppet::Type.type(:group).property_names
 
       tests.each { |test|
         if self.respond_to?("attrtest_#{test}")
diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb
index b9e33e5..71d0ccb 100755
--- a/test/ral/providers/parsedfile.rb
+++ b/test/ral/providers/parsedfile.rb
@@ -500,7 +500,7 @@ class TestParsedFile < Test::Unit::TestCase
     assert_nothing_raised { notdisk.provider.create }
 
     # Now make sure all of the data is copied over correctly.
-    notdisk.class.validproperties.each do |property|
+    notdisk.class.property_names.each do |property|
       assert_equal(notdisk.should(property), 
notdisk.provider.property_hash[property],
         "#{property} was not copied over during creation")
     end
diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb
index ebf2ab7..96f4c10 100755
--- a/test/ral/providers/user.rb
+++ b/test/ral/providers/user.rb
@@ -91,7 +91,7 @@ class TestUserProvider < Test::Unit::TestCase
 
 
   def eachproperty
-    Puppet::Type.type(:user).validproperties.each do |property|
+    Puppet::Type.type(:user).property_names.each do |property|
       yield property
     end
   end
@@ -175,7 +175,7 @@ class TestUserProvider < Test::Unit::TestCase
     }
     assert(user, "Could not create user provider")
 
-    Puppet::Type.type(:user).validproperties.each do |property|
+    Puppet::Type.type(:user).property_names.each do |property|
       next if property == :ensure
       # This is mostly in place for the 'password' stuff.
       next unless user.class.supports_parameter?(property) and 
Puppet.features.root?
@@ -482,7 +482,7 @@ class TestUserProvider < Test::Unit::TestCase
       assert_equal("Puppet's Testing User pptest", user.comment,
         "Comment was not set")
 
-      tests = Puppet::Type.type(:user).validproperties
+      tests = Puppet::Type.type(:user).property_names
 
       just = nil
       tests.each { |test|
-- 
1.7.3.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to