Result: Status 200. '\' is removed from the metadata value and stored value will be testkey=aktnagrawal ('\' is removed).
Analysis: '\' is a special character in python which is escaped by "sys.argv".
The correct ways to add new line using python-glanceclient
a) $ glance image-update ce33c155-91bc-4b85-b9d0-a8735b35536f --property testkey=akt\\nagrawal -- (with '\\n')
b) $ glance image-update ce33c155-91bc-4b85-b9d0-a8735b35536f --property testkey='akt\nagrawal'
c) $ glance image-update ce33c155-91bc-4b85-b9d0-a8735b35536f --property testkey="akt\nagrawal"
Result: Status 200. All the characters after (including) '\n' is removed from the metadata value.
Data is being lost when calling "self.session.request()" method from "_request" method of python-glanceclient/glanceclient/common/http.py module.
self.session is an object of requests.Session() which is a third party library, so IMO this issue can not be handled from glance or glance-client.
The correct way to add new line in metadata is to send with "\\n".
Hi, I tested this issue with latest code and found following points
1. Call glance api update image using curl command (with metadata 'tesinsg\nisssue') 10.69.4. 178:9292/ v1/images/ ce33c155- 91bc-4b85- b9d0-a8735b3553 6f' -X PUT -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'User-Agent: python- glanceclient' -H 'x-glance- registry- purge-props: false' -H 'Content-Type: application/ octet-stream' -H 'X-Auth-Token: 5552cacaade544c eade9489317b4d4 46' -H 'x-image- meta-property- test: tesinsg\nisssue'
$ curl -i 'http://
Result: Status 200. There is no issue and metadata value is saved as it is (with containing '\n').
2. Update image using python-glanceclient 91bc-4b85- b9d0-a8735b3553 6f --property testkey= akt\nagrawal
$ glance image-update ce33c155-
Result: Status 200. '\' is removed from the metadata value and stored value will be testkey=aktnagrawal ('\' is removed).
Analysis: '\' is a special character in python which is escaped by "sys.argv".
The correct ways to add new line using python-glanceclient 91bc-4b85- b9d0-a8735b3553 6f --property testkey= akt\\nagrawal -- (with '\\n') 91bc-4b85- b9d0-a8735b3553 6f --property testkey= 'akt\nagrawal' 91bc-4b85- b9d0-a8735b3553 6f --property testkey= "akt\nagrawal"
a) $ glance image-update ce33c155-
b) $ glance image-update ce33c155-
c) $ glance image-update ce33c155-
3. Call nova api update image using curl command 10.69.4. 178:8774/ v2/8327f833d88c 42d693d9b38d340 0565c/images/ ce33c155- 91bc-4b85- b9d0-a8735b3553 6f/metadata' -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-novaclient" -H "X-Auth-Project-Id: admin" -H "X-Auth-Token: 5552cacaade544c eade9489317b4d4 46" -d '{"metadata": {"key1": "firstline\ nsecondline" , "application_ version" : "1"}}'
$ curl -i 'http://
Result: Status 200. All the characters after (including) '\n' is removed from the metadata value.
Data is being lost when calling "self.session. request( )" method from "_request" method of python- glanceclient/ glanceclient/ common/ http.py module.
self.session is an object of requests.Session() which is a third party library, so IMO this issue can not be handled from glance or glance-client.
The correct way to add new line in metadata is to send with "\\n".