Skip to content

Commit

Permalink
refactor providers
Browse files Browse the repository at this point in the history
 - refactor prefatch method
  • Loading branch information
rwaffen committed Sep 3, 2015
1 parent b0d642a commit 0f3e7f0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 22 deletions.
5 changes: 2 additions & 3 deletions lib/puppet/provider/onecluster/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ def self.instances
def self.prefetch(resources)
clusters = instances
resources.keys.each do |name|
if provider = clusters.find{ |cluster| cluster.name == name }
resources[name].provider = provider
end
provider = clusters.find{ |cluster| cluster.name == name }
resources[name].provider = provider unless provider.nil?
end
end

Expand Down
5 changes: 2 additions & 3 deletions lib/puppet/provider/onedatastore/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ def self.instances
def self.prefetch(resources)
datastores = instances
resources.keys.each do |name|
if provider = datastores.find{ |datastore| datastore.name == name }
resources[name].provider = provider
end
provider = datastores.find{ |datastore| datastore.name == name }
resources[name].provider = provider unless provider.nil?
end
end

Expand Down
5 changes: 2 additions & 3 deletions lib/puppet/provider/onehost/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def self.instances
def self.prefetch(resources)
hosts = instances
resources.keys.each do |name|
if provider = hosts.find{ |host| host.name == name }
resources[name].provider = provider
end
provider = hosts.find{ |host| host.name == name }
resources[name].provider = provider unless provider.nil?
end
end

Expand Down
5 changes: 2 additions & 3 deletions lib/puppet/provider/oneimage/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ def self.instances
def self.prefetch(resources)
images = instances
resources.keys.each do |name|
if provider = images.find{ |image| image.name == name }
resources[name].provider = provider
end
provider = images.find{ |image| image.name == name }
resources[name].provider = provider unless provider.nil?
end
end

Expand Down
5 changes: 2 additions & 3 deletions lib/puppet/provider/onesecgroup/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ def self.instances
def self.prefetch(resources)
secgroups = instances
resources.keys.each do |name|
if provider = secgroups.find{ |secgroup| secgroup.name == name }
resources[name].provider = provider
end
provider = secgroups.find{ |secgroup| secgroup.name == name }
resources[name].provider = provider unless provider.nil?
end
end

Expand Down
7 changes: 3 additions & 4 deletions lib/puppet/provider/onevm/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ def self.instances
def self.prefetch(resources)
vms = instances
resources.keys.each do |name|
if provider = vms.find{ |vm| vm.name == name }
resources[name].provider = provider
end
provider = vms.find{ |vm| vm.name == name }
resources[name].provider = provider unless provider.nil?
end
end

# setters
def template=(value)
raise "Can not modify a VM template"
raise 'Can not modify a VM template'
end
end
5 changes: 2 additions & 3 deletions lib/puppet/provider/onevnet_addressrange/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ def self.instances
def self.prefetch(resources)
vnets = instances
resources.keys.each do |name|
if provider = vnets.find{ |vnet| vnet.name == name }
resources[name].provider = provider
end
provider = vnets.find{ |vnet| vnet.name == name }
resources[name].provider = provider unless provider.nil?
end
end

Expand Down

0 comments on commit 0f3e7f0

Please sign in to comment.