[Nailgun] NetworkTemplate behaves incorrectly

Bug #1500869 reported by Ihor Kalnytskyi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Released
Medium
Ihor Kalnytskyi

Bug Description

Current implementation of `NetworkTemplate` class is based on built-in `string.Template`. Unfortunately, the `string.Template` fits poorly our needs, since it's focuses on delimeter-based approach first when we need a braced one. Moreover, the `string.Template` has bugs in its implementation prior Python 2.7.10, and our `NetworkTemplate` behaves wrongly. Just check out this test -

   https://github.com/stackforge/fuel-web/blob/5aed5a7e9683e8b259c4437db413606125ec2ecd/nailgun/nailgun/test/unit/test_network_template.py#L53-L57

(we lost closes brace)

In order to make this class work properly on all Python interpreters, and reduce number of potential bugs (due to delimeter-based approach) let's reimplement it.

Changed in fuel:
milestone: none → 8.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-web (master)

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

Changed in fuel:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-web (master)

Reviewed: https://review.openstack.org/229011
Committed: https://git.openstack.org/cgit/stackforge/fuel-web/commit/?id=180a39eae65300144a8f0a41e335b0845570d88b
Submitter: Jenkins
Branch: master

commit 180a39eae65300144a8f0a41e335b0845570d88b
Author: Igor Kalnitsky <email address hidden>
Date: Tue Sep 29 18:15:05 2015 +0300

    Re-implement NetworkTemplate to use regex directly

    NetworkTemplate behaves wrong way in case we don't pass a substituation
    value or when closing pattern doesn't fit '%>' (check fixed tests). The
    main reason is that `string.Template` is designed to match delimeter
    based patterns, not braced ones. By some accident, the `string.Template`
    implementation is broken in both Python 2.6 and Python 2.7.6, and it's
    fixed for sure in Python 2.7.10 (because tests start to fail).

    Let's re-write our NetworkImplementation in order to have proper
    behaviour, and make tests to pass on various Py2 versions regardless of
    minor versions.

    Closes-Bug: #1500869

    Change-Id: I3f6e1cb7fb50ab9d3a47256b3e7e718b4f01e153
    Signed-off-by: Igor Kalnitsky <email address hidden>

Changed in fuel:
status: In Progress → Fix Committed
Dmitry Pyzhov (dpyzhov)
tags: added: area-python
Revision history for this message
Dmitry Belyaninov (dbelyaninov) wrote :

Verified by unit tests.

Changed in fuel:
status: Fix Committed → Fix Released
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.