Skip to content

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.

1 participant