Fix setters in puppet providers

Bug #1366009 reported by Andrey Danin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
Medium
Dmitry Ilyin

Bug Description

We found an issue with Ruby (see bug https://bugs.launchpad.net/fuel/+bug/1365449) in Puppet about setters for Puppet resource properties. It seems we should rewrite a usage of setters in our custom Puppet resource providers (at least in l23network) from code like this:
  def attr=(value)
  end
  def some_func (value)
    attr = value
  end
To (look at 'self' before 'attr'):
 def attr=(value)
  end
  def some_func (value)
    self.attr = (value)
  end

Changed in fuel:
importance: Undecided → Medium
assignee: nobody → Fuel Library Team (fuel-library)
Changed in fuel:
status: New → Confirmed
Revision history for this message
Eugene Korekin (ekorekin) wrote :

It should be 'self.attr=(value)' (without spaces, cause setter function defined as 'attr=')

Revision history for this message
Dmitry Ilyin (idv1985) wrote :

Actually it's a very funny Ruby problem

In ruby classes you can define setters and getters for a attributes:

def attr
  puts 'get attr'
  @attr
end

def attr=(value)
  puts 'set attr'
  @attr = value
end

then you can set and get this attr

put myclass.attr
myclass.attr = 1

Ok, then setter method is named 'attr=' what if i want to call if from within the class

attr = 1 -> it will not work. set local variable attr to 1
attr= 1 -> same
attr=(1) -> same

in this case we have to use self like in Python

self.attr = 1 -> ok using getter magic
self.attr= 1 -> ok calling directly
self.attr=(1) -> same

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-library (master)

Fix proposed to branch: master
Review: https://review.openstack.org/119387

Changed in fuel:
assignee: Fuel Library Team (fuel-library) → Dmitry Ilyin (idv1985)
status: Confirmed → In Progress
Revision history for this message
Dmitry Ilyin (idv1985) wrote :
Revision history for this message
Sergey Vasilenko (xenolog) wrote :

It affects l23network

Changed in fuel:
milestone: next → 6.0
Revision history for this message
Dmitry Ilyin (idv1985) wrote :

But comment is not entirely correct

tags: added: l23 networking
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on fuel-library (master)

Change abandoned by Dmitry Ilyin (<email address hidden>) on branch: master
Review: https://review.openstack.org/119387
Reason: 1

description: updated
Revision history for this message
Dmitry Borodaenko (angdraug) wrote :
Changed in fuel:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.