swift-get-nodes: move --path-as-is to end of curl commands

--path-as-is is not supported by older versions of curl (prior to
7.42.0) so the curl commands printed by swift-get-nodes must cut,
pasted *and then edited* before they can be run with older
curl. Moving the option to the end of the command line makes it
possible to just cut (omitting the last option) and paste the
commands.

Note: the --path-as-is option is not dropped altogether based on
testing the curl version available because the host on which
swift-get-nodes is executed might have a different curl version to the
host on which the curl command is to be executed. The presence of the
option also serves as a reminder that it (and newer curl) might be
needed with some paths.

Change-Id: Ifaf3cf97e6410d4b8818042a5082177418d6c6a2
This commit is contained in:
Alistair Coles 2021-05-12 12:41:20 +01:00
parent 6167dbf7ba
commit 6e56209441
2 changed files with 7 additions and 5 deletions

View File

@ -93,11 +93,12 @@ def curl_head_command(ip, port, device, part, target, policy_index):
else:
formatted_ip = ip
cmd = 'curl --path-as-is -g -I -XHEAD "http://%s:%s/%s/%s/%s"' % (
cmd = 'curl -g -I -XHEAD "http://%s:%s/%s/%s/%s"' % (
formatted_ip, port, device, part, urllib.parse.quote(target))
if policy_index is not None:
cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index',
policy_index)
cmd += ' --path-as-is'
return cmd

View File

@ -1277,9 +1277,9 @@ class TestPrintObjFullMeta(TestCliInfoBase):
os.chdir(cwd)
exp_curl = (
'curl --path-as-is -g -I -XHEAD '
'curl -g -I -XHEAD '
'"http://{host}:{port}/{device}/{part}/AUTH_admin/c/obj" '
'-H "X-Backend-Storage-Policy-Index: 2"').format(
'-H "X-Backend-Storage-Policy-Index: 2" --path-as-is').format(
host=node['ip'],
port=node['port'],
device=node['device'],
@ -1318,9 +1318,10 @@ class TestPrintObjFullMeta(TestCliInfoBase):
os.chdir(cwd)
exp_curl = (
'curl --path-as-is -g -I -XHEAD '
'curl -g -I -XHEAD '
'"http://[{host}]:{port}'
'/{device}/{part}/AUTH_admin/c/obj" ').format(
'/{device}/{part}/AUTH_admin/c/obj" '
'-H "X-Backend-Storage-Policy-Index: 3" --path-as-is').format(
host=node['ip'],
port=node['port'],
device=node['device'],