Closed dbclkh closed 5 years ago
Thanks for your issue. I can not reproduce the error using your frontend
configurations via the following code. Could you please run nosetests -sv
to take a test in your local environment and see the results, as well as your pyhaproxy
version?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pyhaproxy.parse as parse
class TestParse(object):
@classmethod
def setup_class(cls):
pass
@classmethod
def teardown_class(cls):
pass
def setup(self):
filestring = r"""
frontend http
bind 0.0.0.0:80
acl test_site1 hdr(host) -i test_site1.local
use_backend test_site1_back if test_site1
frontend https
bind 0.0.0.0:443 ssl crt /etc/ssl/private
option forwardfor
reqadd X-Forwarded-Proto:\ https
acl test_site1 hdr(host) -i test_site1.local
use_backend test_site1_back if test_site1
"""
self.parser = parse.Parser(filestring=filestring)
self.configration = self.parser.build_configuration()
def teardown(self):
pass
def test_parse_frontend_section(self):
for frontend in self.configration.frontends:
print '-' * 15
print frontend.name, frontend.host, frontend.port
for acl in frontend.acls():
print acl
Hi Joey,
The version I'm using is 1.7.5-2 2017/05/17. I'll have a look at the nosetests and then get back to you.
Regards, Lars Hansen
Hi Joey,
larshansen@<comp-name> Downloads $ python3 /usr/local/bin/nosetests -sv --all-modules testpyha.py
testpyha.TestParse.test_parse_frontend_section ... ---------------
http 0.0.0.0 80
<acl_line: acl test_site1 hdr(host) -i test_site1.local>
---------------
https 0.0.0.0 443
<acl_line: acl test_site1 hdr(host) -i test_site1.local>
ok
----------------------------------------------------------------------
Ran 1 test in 0.002s
OK
That seems okay to me?
Hi, yes and the passed test means that the two frontend
sections could be parsed correctly. Would you mind providing all the configurations? Thanks.
BTW: I noticed that the python verions is 3
. While to be honest, this library has not been well tested in Python 3 yet. Could you please run it in Python 2 and see the results instead? Apologize for the inconvenience.
Hi Joey, I've tested it on another machine here at my company - it works fine there. It must be something on the first machine then.
So glad to hear that. 😄
Hi,
I'm having a small problem with my pyhaproxy script, and I'm hoping that you can lead me in the correct direction.
My haproxy.cfg contains two frontends...
The haproxy works just fine - no problem there.
Part of my clean up script looks like this:
It gives the following error message: [line 287 is configuration = parser.build_configuration()]
What am I doing wrong or missing?
Regards - Lars