imjoey / pyhaproxy

Python library to parse haproxy configurations
MIT License
54 stars 21 forks source link

More examples #6

Closed eurodomenii closed 7 years ago

eurodomenii commented 7 years ago

Modify existing value example

# Find the specified ACL
acl_instance = the_fe_section.acl(the_acl_name)   # return config.Acl
acl_instance.value = "hdr(host) -i modified.example.com"

Delete acl record example

# Get all the ACLs defined in the frontend section
acls = the_fe_section.acls()   # return list(config.Acl)
# Find the specified ACL
acl_instance = the_fe_section.acl(the_acl_name)   # return config.Acl
acls.remove(acl_instance)

Append example failure

the_fe_section.acls().append(config.ACL(acl_name, acl_value)) # append the ACL into the frontend section fails with NameError: name 'config' is not defined

Finally , a small observation

for usebe in usebackends:
    # Get the using backend name, operator, condition
    print usebe.backend_name, usebe.operator, backend_condition

Should be _usebe.backendcondition

Btw, nice piece of software!

imjoey commented 7 years ago

@eurodomenii Thanks for your issue, I fix the bugs and add the examples as you mentioned. It's recommended that you could submit a PR to add your codes. ^_^

eurodomenii commented 7 years ago

Thanks for the fix @imjoey . My contribution is limited to several examples... In the future, if I have something substantial, I'll commit.