opentelekomcloud / otc-tools

(Deprecated) Simple bash/curl/jq based command line tool using the OpenStack and OTC specific REST APIs.
Creative Commons Attribution Share Alike 4.0 International
27 stars 17 forks source link

process response body in docurl and not the complete response with headers #40

Closed gtema closed 6 years ago

gtema commented 6 years ago

without a previous token in tmp (receiver with ver < 0.8.11) it's not possible to login, since docurl is invoked through curlpost with "-i" argument what includes headers in the response. In the docurl function jq is invoked on the curl response, what of course fails (when headers are present). So it is required to strip those headers off and analyse pure response body. Unfortunately it is only possible to do this in bash based on 1st empty string, but it should be ok here.

For some reason my editor silently purified some line endings, so there are a bit more changes

garloff commented 6 years ago

Artem, Thanks for the analysis and patch! Comments and requests:

  1. I could not reproduce a problem - can you describe what I need to do? (Just deleting all cached tokens and then doing e.g. otc.sh vm list does work just fine with plan 0.8.10 and 11.)
  2. Your patch nevertheless looks like a worthwhile improvement, so I'm willing to merge it.
  3. Can you split out functional changes and formatting cleanup into two commits? This avoids conflicts... Thanks!
gtema commented 6 years ago

The PR is updated - formatting changes removed Yes Kurt, this is exactly what is not working - ensure you are trying correct 0.8.11 (happened to me as well) ` [linux@ag-bastion ~]$ wget https://raw.githubusercontent.com/OpenTelekomCloud/otc-tools/master/otc.sh --2018-02-11 09:26:42-- https://raw.githubusercontent.com/OpenTelekomCloud/otc-tools/master/otc.sh Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.64.133, 151.101.128.133, 151.101.0.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.64.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 51368 (50K) [text/plain] Saving to: ‘otc.sh’

otc.sh 100%[========================================================================================================================================>] 50.16K --.-KB/s in 0.04s

2018-02-11 09:26:42 (1.32 MB/s) - ‘otc.sh’ saved [229593]

[linux@ag-bastion ~]$ chmod u+x ./otc.sh [linux@ag-bastion ~]$ grep "VERSION=0.8" ./otc.sh VERSION=0.8.11 [linux@ag-bastion ~]$ rm -rf ./tmp/* [linux@ag-bastion ~]$ wget https://raw.githubusercontent.com/OpenTelekomCloud/otc-tools/master/otc.sh^C [linux@ag-bastion ~]$ ./otc.sh vm list

Note: Reading environment from /home/linux/.ostackrc ...

ERROR: Authentication call failed `

garloff commented 6 years ago

OK, I can reproduce now. This was indeed introduced recently. I need to tolerate empty ECODE ...