Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENSTACK-2894: use utf-8 code for bigip configuration #1616

Open
wants to merge 1 commit into
base: v3.0.11-dev
Choose a base branch
from

Conversation

zhang-shengping
Copy link

No description provided.

@zhang-shengping zhang-shengping force-pushed the v3.0.11-dev-unicode branch 2 times, most recently from 3959cc9 to 769841a Compare October 9, 2023 09:11
@zhang-shengping zhang-shengping marked this pull request as ready for review October 10, 2023 02:11
@zhang-shengping
Copy link
Author

zhang-shengping commented Oct 10, 2023

@zhang-shengping
Copy link
Author

zhang-shengping commented Oct 10, 2023

# -*- coding: utf-8 -*-

from f5_openstack_agent.lbaasv2.drivers.bigip.resource \
    import VirtualServer
from f5.bigip import ManagementRoot
import json

partition = u'Project_6fd06a50b7824ae48386565786e94b38'
name = u'test'

bigip = ManagementRoot(
    "10.110.119.120",
    "admin",
    "xxxxx",
    timeout=10,
    debug=True
)

# this character, the modify PATCH will failed with bigip error.
test = u"退"

# if use this character, the modify PATCH will succeed.
# test = u"哈哈"

vs = VirtualServer()
server = vs.load(bigip, name=name, partition=partition)
server.modify(description=test)

The test is a unicode, when the python Request module send this unicode to bigip server, it uses json parameter, which dumps the request body as json bytestring, and the unicode is escaped. The bigip server cannot correctly decode the json bytestring.

the bigip GUI web displays unreadable messy code as below:

image

To resolve this problem, this patch encodes the request body into utf-8 bytestring and sets the bytestring to the request data parameter.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant