F5 BIG IP update VIP using REST API cause code:400, message:0107028c:3 - f5

I am trying to call my F5 Big IP REST API to update some VIP configurations, for example I want to update the VIP description using this command:
curl -s -k --tlsv1.2 -u admin:password -H "Content-Type: application/json" -X PUT https://ManagmentIP/mgmt/tm/ltm/virtual/~MyPool~MyVIP_887 {"description":"THIS IS JUST A TEST"}
I am getting this error:
{"code":400,"message":"0107028c:3: The source (::%10) and destination (10.62.185.3%10) addresses for virtual server (/MyPool/MyVIP_887) must be be the same type (IPv4 or IPv6).","errorStack":[],"apiError":3}
My F5 Big IP version: BIG-IP 12.1.3 Build 0.0.378 Final
Am I missing something?

The answer is taken from F5 DevCentral:
You have to use -d 'data' = The JSON data to send. Note that you need to quote the entire json blob, and each "name":"value" pairs must be quoted. When you have nested quotes, make sure you escape () them.
Refer the cookbook if it helps.
So something like,
curl -sku admin -H "Content-Type: application/json" -X PATCH
https:///mgmt/tm/ltm/virtual/ -d
'{"description": "Hello World!"}'

Related

Docker API push to private registry error

I can't manage to push an image to a private registry using the docker API. I have read everything I found everywhere and tried everything with no luck...
I tried :
curl -X POST -H "X-Registry-Auth:XXXXXXXXXXXXXXX" http://dockerapiurl:2375/images/registryurl/python/push?tag=6
OR
curl -X POST -H 'X-Registry-Auth:{"username": "xxxxxx","password": "xxxxx", "serveraddress": "xxxx.url.net", "auth": ""}' http://dockerapiurl:2375/images/registryurl/python/push?tag=6
I always get the same error :
{"errorDetail":{"message":"errors:\ndenied: requested access to the resource is denied\nunauthorized: authentication required\n"},"error":"errors:\ndenied: requested access to the resource is denied\nunauthorized: authentication required\n"}
If I use docker push in CLI mode everything works, what am I doing wrong?
Thanks!!
it needs to be encoded in base 64, try this
XRA=`echo "{ \"username\": \"xxxxxx\", \"password\": \"xxxxxx\", \"email\": \"youmail#example.org\", \"serveraddress\": \"xxxxxx\" }" | base64 --wrap=0`
curl -X POST -d "" -H "X-Registry-Auth: $XRA" http://dockerapiurl:2375/images/registryurl/python/push?tag=6
end result should look like this
curl -X POST -d "" -H "X-Registry-Auth: eyAidXNlcm5hbWUiOiAieHh4eHh4IiwgInBhc3N3b3JkIjogInh4eHh4eCIsICJlbWFpbCI6ICJ5b3VtYWlsQGV4YW1wbGUub3JnIiB9Cg==" http://dockerapiurl:2375/images/registryurl/python/push?tag=6

curl: (6) Could not resolve host: http while running the jenkins job from terminal

I tried to run the Jenkins job using "CURL" command but getting the below error
C:\Users\gd\Downloads\curl-7.66.0_2-win64-mingw\curl-7.66.0-win64-mingw\bin>
curl -X POST http://slack:11cf86296e48e9c5c3a8570aa1ccfc57a8#10.204.211.118:8080/job/test-job/build
curl: (6) Could not resolve host: http
curl -X POST http://slack:11cf86296e48e9c5c3a8570aa1ccfc57a8#10.204.211.118:8080/job/test-job/build
when we hit that command from the command prompt, immediately Jenkins job should run in the Jenkins
enter image description here
You can use any one of the below to trigger the pipeline:-
curl -X POST slack:11cf86296e48e9c5c3a8570aa1ccfc57a8#<Jenkinshost>:8080/job/test-slack/build
curl -X POST http://slack:11cf86296e48e9c5c3a8570aa1ccfc57a8#<Jenkinshost>:8080/job/test-slack/build
For could not resolve POST: make sure to use -X, not -x
curl -X POST ...
You seem to have an extra http:// in the middle of your URL:
http://slack:11cf86296e48e9c5c3a8570aa1ccfc57a8#http:///:8080/job/test-slack/build
^^^^^^^
Try instead to use "<ipaddress>" (to be replace by the actual Jenkins IP address)
http://slack:11cf86296e48e9c5c3a8570aa1ccfc57a8#<ipaddress>:8080/job/test-slack/build
Using a fully qualified named instead of an IP address would be preferable, but both should work.

FORBIDDEN/12/index read-only / allow delete (api) problem

When importing items into my Rails app I keep getting the above error being raised by SearchKick on behalf of Elasticsearch.
I'm running Elasticsearch in a Docker. I start my app by running docker-compose up. I've tried running the command recommended above but i just get "No such file or directory" returned. Any ideas?
I do have port 9200 exposed to outside but nothing seems to help. Any ideas?
Indeed, running curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}' as suggested by #Nishant Saini resolves the very similar issue I ran just into.
I hit disk watermarks limits on my machine.
Use the following command in linux:
curl -s -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/_all/_settings?pretty' -d ' {
"index":{
"blocks" : {"read_only_allow_delete":"false"}
}
}'
the same command in Kibana's DEV TOOL format :
PUT _all/_settings
{
"index":{
"blocks" : {"read_only_allow_delete":"false"}
}
}

Icinga: How to enable maintenance mode through remote api or tool?

I am using Icinga Version 2.4.2 to monitor services on several hosts. I would like to be able to place certain hosts in maintenance mode for a set amount of time using a cli tool or rest API instead of the Web UI.
Is this possible and if so what tool/api should I use?
If I cannot do this through a remote tool/api what command should I use on the server or client to place clients in maintenance mode?
Update: It seems like the rest api has a solution. This set of permissions works:
object ApiUser "root" {
password = "foobar"
permissions = [ "console", "objects/query/Host", "objects/query/Service", "actions/schedule-downtime", "actions/remove-downtime"]
}
Then the following allows me to make and remove downtimes:
curl -k -s -u root:foobar -H 'Accept: application/json' -X POST "https://localhost:5665/v1/actions/schedule-downtime?filter=host.name==%22${TARGET}%22&type=Host" -d '{ "start_time": "1528239116", "end_time": "1528325561", "duration": 1000, "author": "root", "comment": "downtime on $TARGET" }' | jq .
curl -k -s -u root:foobar -H 'Accept: application/json' -X POST "https://localhost:5665/v1/actions/remove-downtime?filter=host.name==%22${TARGET}%22&type=Host" | jq .
Right now the only issue with this I am having is how to pass in variables for the start and stop dates. Attempting this keeps resulting in the following error:
{
"status": "Invalid request body: Error: lexical error: invalid char in json text.\n { \"start_time\": $current_time,\n (right here) ------^\n\n",
"error": 400
}

Deleting array of objects server side from restkit

I'm trying to delete several playlists objects from my server at once, but I can't find a way to do this with restkit. I'm basically trying to recreate this curl function:
curl -H "Content-Type:application/json" -H "Accept:application/json" -H "X-HTTP-Method-Override: DELETE" -d "{\"playlists\":{\"array\":[ {\"id\":\"25\"}, {\"id\":\"26\"},{\"id\":\"22\"},{\"id\":\"23\"},{\"id\":\"24\"}]}}" http://localhost:3000/api/v1/users/5/playlists
Is this possible with restkit?

Resources