Action as array vers string


#1

Hi,

I am a bit confused about how I should compare action variable. The action in recipe can be a string or array:

route “something” do
gateway "gateway"
device "eth0"
action :add

action [ :add ]

end

The route.rb provider includes this code:

def generate_config

        if resource.action == :add

This condition doesn’t work for me because resource.action is always an array no matter how I specify my action in recipe.

Is this know bug of Chef 10.12.0?

Thank you, Jan

DISCLAIMER
WOOD & Company Financial Services, a.s. and its branches are authorized and regulated by the CNB as Home State regulator and in Poland by the KNF, in Romania by the CNVM, in Slovakia by the NBS and in the UK by the FSA as Host State regulators. For further information about WOOD & Co., its investment services, financial instruments and associated risks, safeguard client assets (incl. compensation schemes) and contractual relationship please see our website at www.wood.cz under section Corporate Governance.

Unless otherwise stated, this transmission is neither an offer nor the solicitation of an offer to sell or purchase any investment. All estimates, opinions and other information contained herein are subject to change without notice and are provided in good faith but without legal responsibility or liability. Opinion may be personal to the author and may not reflect the opinions of WOOD & Co. Communications from sales persons, sales traders or traders should not be regarded as investment research and may contain opinions or trading ideas which are different from WOOD & Co. investment research opinions.

This e-mail and any attachments are confidential and may be privileged or otherwise protected from disclosure. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail and any of its attachments. Please notify the sender that you have received this email by mistake by replying to the email, and then delete the email and any copies of it. Although WOOD & Co. routinely screens e-mails for viruses, addressees should scan this e-mail and any attachments for viruses. WOOD & Co. makes no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our server(s).


#2

On Wednesday, November 28, 2012 at 1:20 AM, Jan Bares wrote:

Hi,

I am a bit confused about how I should compare action variable. The action in recipe can be a string or array:

route “something” do
gateway "gateway"
device "eth0"
action :add

action [ :add ]

end

The route.rb provider includes this code:

def generate_config

if resource.action == :add

This condition doesn’t work for me because resource.action is always an array no matter how I specify my action in recipe.

Is this know bug of Chef 10.12.0?

Thank you, Jan
I don’t see a bug reported, but looking at the current code, it doesn’t seem like this should be a problem now. Do you see any issues using Chef 10.16.2?


Daniel DeLeo


#3

Hello Jan,

On Wed, 28 Nov 2012 09:20:31 +0000
Jan Bares jan.bares@wood.cz wrote:

I am a bit confused about how I should compare action variable. The
action in recipe can be a string or array:

route “something” do
gateway "gateway"
device "eth0"
action :add

action [ :add ]

end

The route.rb provider includes this code:

def generate_config

        if resource.action == :add

This condition doesn’t work for me because resource.action is always
an array no matter how I specify my action in recipe.

Is this know bug of Chef 10.12.0?

Yes. Your are right. There seems to be a bug in the “route” provider.
I will try to solve it in this ticket:

http://tickets.opscode.com/browse/CHEF-3332

In theory “action” method should work both with an array and with a
symbol.

Meanwhile it should work if you remove the line “action :add” from
your route resource (anyway “add” is the default action).


Xabier de Zuazo Oteiza
IT System Administrator - Onddo Labs S.L.
t: (+34) 946.569.935
onddo.com


#4

Thanks Xabier for your fix, I will wait for the official Chef version. Your suggested workaround doesn’t help.

Kind regards, Jan

-----Original Message-----
From: Xabier de Zuazo [mailto:xabier@zuazo.org]
Sent: Thursday, November 29, 2012 11:42 AM
To: chef@lists.opscode.com
Subject: [chef] Re: action as array vers string

Hello Jan,

On Wed, 28 Nov 2012 09:20:31 +0000
Jan Bares jan.bares@wood.cz wrote:

I am a bit confused about how I should compare action variable. The
action in recipe can be a string or array:

route “something” do
gateway "gateway"
device "eth0"
action :add

action [ :add ]

end

The route.rb provider includes this code:

def generate_config

        if resource.action == :add

This condition doesn’t work for me because resource.action is always
an array no matter how I specify my action in recipe.

Is this know bug of Chef 10.12.0?

Yes. Your are right. There seems to be a bug in the “route” provider.
I will try to solve it in this ticket:

http://tickets.opscode.com/browse/CHEF-3332

In theory “action” method should work both with an array and with a
symbol.

Meanwhile it should work if you remove the line “action :add” from
your route resource (anyway “add” is the default action).


Xabier de Zuazo Oteiza
IT System Administrator - Onddo Labs S.L.
t: (+34) 946.569.935
onddo.com

DISCLAIMER
WOOD & Company Financial Services, a.s. and its branches are authorized and regulated by the CNB as Home State regulator and in Poland by the KNF, in Romania by the CNVM, in Slovakia by the NBS and in the UK by the FSA as Host State regulators. For further information about WOOD & Co., its investment services, financial instruments and associated risks, safeguard client assets (incl. compensation schemes) and contractual relationship please see our website at www.wood.cz under section Corporate Governance.

Unless otherwise stated, this transmission is neither an offer nor the solicitation of an offer to sell or purchase any investment. All estimates, opinions and other information contained herein are subject to change without notice and are provided in good faith but without legal responsibility or liability. Opinion may be personal to the author and may not reflect the opinions of WOOD & Co. Communications from sales persons, sales traders or traders should not be regarded as investment research and may contain opinions or trading ideas which are different from WOOD & Co. investment research opinions.

This e-mail and any attachments are confidential and may be privileged or otherwise protected from disclosure. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail and any of its attachments. Please notify the sender that you have received this email by mistake by replying to the email, and then delete the email and any copies of it. Although WOOD & Co. routinely screens e-mails for viruses, addressees should scan this e-mail and any attachments for viruses. WOOD & Co. makes no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our server(s).