Выполнить Curl на удаленной машине - PullRequest
0 голосов
/ 01 июня 2018

Я выполняю приведенную ниже команду curl локально в системе, и она отлично работает,

curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm

Я хочу выполнить это на удаленной машине через ssh, при этом я получаю отказ в соединении.

ssh root@x.x.x.x $(curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed connect to localhost:9000; Connection refused
Last login: Fri Jun  1 09:38:01 2018 from 10.1.35.28

Выполнение команды Curl привело к ошибке на удаленном хосте

# ssh root@x.x.x.x curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: application; Unknown error
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: ipAddress; Unknown error
{"timestamp":1527844486340,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"100   291    0   251  100    40   2533    403 --:--:-- --:--:-- --:--:--  2533aintenance/vm"}

=====================

a='curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm'
# ssh root@x.x.x.x ${a}
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: ipAddress:10.1.35.38; Unknown error
{"timestamp":1527847037512,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read document: Unrecognized token 'maintainanceMode': was expecting ('true', 'false' or 'null')\n at [Source: java.io.PushbackInputStream@339ead3; line: 1, column: 18]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'maintainanceMode': was expecting ('true', 'false' o100   633    0   593  100    40   5847    394 --:--:-- --:--:-- --:--:--  584718]","path":"/netconf/vnfm/maintenance/vm"}

Любая помощь будет оценена.!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...