Bug/difference in Chef manage vs. knife for data bag IDs?

Hi,

I found that if I use “knife data bag” to create an item in a data bag, the item id can include both upper and lower-case letters, but if I use the web app to try to create a data bag, it doesn’t allow upper-case characters in the item id?

The reason I ran across this is that I have a recipe that uses node[‘hostname’’] to get the hostname which I then use to select the item in the data bag, and in Windows at least, the node[‘hostname’] seems to be returning the (short) hostname in all caps.

In other words, if the hostname is “foo”, then node[‘hostname’] is returning “FOO”, so I need to make the item IDs in the data bag with caps.

Is this a bug in the web app?

Also, is there a way that I can lower-case the node[‘hostname’], something like lowercase(node[‘hostname’])?

Thanks,
Jim

I can’t speak to the issue you’re seeing in Manage, but to convert any String in ruby to lowercase or uppercase, you’d use downcase and upcase, respectively.

node[‘hostname’].downcase
node[‘hostname’].upcase

Cheers,
Dang Nguyen

-----Original Message-----
From: o haya [mailto:ohaya@yahoo.com]
Sent: Thursday, June 25, 2015 8:38 AM
To: chef@lists.opscode.com
Cc: ohaya@yahoo.com
Subject: [chef] Bug/difference in Chef manage vs. knife for data bag IDs?

Hi,

I found that if I use “knife data bag” to create an item in a data bag, the item id can include both upper and lower-case letters, but if I use the web app to try to create a data bag, it doesn’t allow upper-case characters in the item id?

The reason I ran across this is that I have a recipe that uses node[‘hostname’’] to get the hostname which I then use to select the item in the data bag, and in Windows at least, the node[‘hostname’] seems to be returning the (short) hostname in all caps.

In other words, if the hostname is “foo”, then node[‘hostname’] is returning “FOO”, so I need to make the item IDs in the data bag with caps.

Is this a bug in the web app?

Also, is there a way that I can lower-case the node[‘hostname’], something like lowercase(node[‘hostname’])?

Thanks,
Jim