Modify

Ticket #861 (closed enhancement: fixed)

Opened 10 years ago

Last modified 9 years ago

Python block in Genshi bundle causes traceback

Reported by: Bruce Bush <bruce_bush@…> Owned by: solj
Priority: minor Milestone: Bcfg2 1.2.0 Release
Component: bcfg2-server Version: 1.0
Keywords: python block Cc: sol.jerome@…

Description

Using bcfg2 v 1.0.1 on CentOS 5.4 - Genshi bundle containing a python block causes traceback:

This example causes a traceback: <Bundle name='awstats' xmlns:py="http://genshi.edgewall.org/">

<?python

vhosts = $metadata.Probesvhosts?.split(":")

?> <ConfigFile? py:for="vhost in vhosts" name='/etc/bruce/package-${vhost}' altsrc='/etc/testfile' />

</Bundle>

This example works: <Bundle name='awstats' xmlns:py="http://genshi.edgewall.org/"> <py:for each="vhost in metadata.Probes['vhosts'].split(':')" >

<ConfigFile? name='/etc/bruce/package-${vhost}' altsrc='/etc/testfile' />\

</py:for> </Bundle>

Attachments

Change History

comment:1 Changed 10 years ago by solj

  • Owner changed from desai to solj
  • Status changed from new to accepted

comment:2 Changed 10 years ago by solj

  • Status changed from accepted to closed
  • Resolution set to worksforme

This works for me. Here is a simple example:

<!--
vim: ft=xml
-->
<Bundle name='test' xmlns:py="http://genshi.edgewall.org/" lang='en'>
<?python
test = metadata.Probes.keys()
?>
        <Path name='/etc/${test}' altsrc='/foo'/>
</Bundle>

comment:3 follow-up: ↓ 4 Changed 10 years ago by Manush Dodunekov <manush@…>

  • Status changed from closed to reopened
  • Resolution worksforme deleted

I can reproduce this on CentOS 5.4 x86_64. Here is the traceback:

error in BindStructure
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/Bcfg2/Server/Core.py", line 258, in BuildConfiguration
    self.BindStructure(astruct, meta)
  File "/usr/lib/python2.4/site-packages/Bcfg2/Server/Core.py", line 175, in BindStructure
    if entry.tag.startswith("Bound"):
AttributeError: 'builtin_function_or_method' object has no attribute 'startswith'

The problem appears whenever a bundle in Bundler contains a PI or a comment.

comment:4 in reply to: ↑ 3 Changed 10 years ago by solj

Replying to Manush Dodunekov <manush@…>:

I can reproduce this on CentOS 5.4 x86_64. Here is the traceback:

error in BindStructure
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/Bcfg2/Server/Core.py", line 258, in BuildConfiguration
    self.BindStructure(astruct, meta)
  File "/usr/lib/python2.4/site-packages/Bcfg2/Server/Core.py", line 175, in BindStructure
    if entry.tag.startswith("Bound"):
AttributeError: 'builtin_function_or_method' object has no attribute 'startswith'

The problem appears whenever a bundle in Bundler contains a PI or a comment.

I'm unable to reproduce this. Can you paste your bundle please?

comment:5 follow-up: ↓ 6 Changed 10 years ago by solj

  • Cc solj@… added

comment:6 in reply to: ↑ 5 ; follow-up: ↓ 7 Changed 10 years ago by Manush Dodunekov <manush@…>

Replying to solj:

Here is a config that triggers the problem:

Bundler/test-bundle.xml:

<Bundle name="test-bundle" xmlns:py="http://genshi.edgewall.org/">
  <?python
    s = "whatever"
  ?>
  <BoundConfigFile name="/tmp/test.txt" owner="root" group="root" perms="0644">${s}</BoundConfigFile>
</Bundle>

Relevant part of GroupPatterns/config.xml:

<GroupPatterns>
  <GroupPattern>
    <NamePattern>testclient\.domain</NamePattern>
    <Group>test</Group>
  </GroupPattern>
</GroupPatterns>

Relevant part of Metadata/groups.xml:

<Groups version="3.0">
   <Group name="test">
     <Bundle name="test-bundle"/>
   </Group>
</Groups>

comment:7 in reply to: ↑ 6 Changed 10 years ago by solj

Replying to Manush Dodunekov <manush@…>:

This, also, works for me. I'm guessing this must be a CentOS problem. I'll look into it when I get a chance.

comment:8 Changed 10 years ago by Manush Dodunekov <manush@…>

After reading through Plugins/Bundler? one more time, I renamed test-bundle.xml to test-bundle.genshi and things started working as expected.

A suggestion would be to treat any bundle with xmlns:py="http://genshi.edgewall.org/" as a genshi bundle instead of relying on the filename extension.

comment:9 Changed 10 years ago by solj

  • Type changed from defect to enhancement
  • Milestone changed from Bcfg2 1.1.0 Release to Bcfg2 1.2.0 Release

We might be able to do something like this. In the meantime, moving it to the next feature release.

comment:10 Changed 10 years ago by solj

  • Cc sol.jerome@… added; solj@… removed

comment:11 Changed 9 years ago by solj

  • Status changed from reopened to closed
  • Resolution set to fixed

The ability to use genshi templates in files having a .xml extension has been added in 1dcb73e1a06d3a558b498ec5d5a47ff562254b7d.

WARNING! You need to establish a session before you can create or edit tickets. Otherwise the ticket will get treated as spam.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.