Originally posted by: @AAB
jq running successfully on AIX7.1
1. donwload jq from jq site : https://stedolan.github.io/jq/
2. Make copy on my work directory /opt/freeware/src/packages/SOURCES/
cd /opt/freeware/src/packages/SOURCES/jq-1.5
tar -xvf jq-1.5.tar; cd jq-1.5
3. Modify jv.h and builtin.c files as recommanded on https://github.com/stedolan/jq/issues/1335
--- jv_orig.h 2015-07-27 01:32:03.000000000 +0200
+++ jv.h 2017-02-28 11:21:28.000000000 +0100
@@ -99,6 +99,9 @@
__attribute__ ((__format__( __printf__, fmt_arg_num, args_num)))
#define JV_VPRINTF_LIKE(fmt_arg_num) \
__attribute__ ((__format__( __printf__, fmt_arg_num, 0)))
+ #else
+ #define JV_PRINTF_LIKE(fmt_arg_num, args_num)
+ #define JV_VPRINTF_LIKE(fmt_arg_num)
#endif
--- builtin_orig.c 2015-08-16 06:38:10.000000000 +0200
+++ builtin.c 2017-02-28 13:47:26.000000000 +0100
@@ -1,6 +1,10 @@
#define _BSD_SOURCE
#define _GNU_SOURCE
+ #if defined(_AIX) /* AIX */
+ #define _XOPEN_SOURCE 700
+ #elif
#define _XOPEN_SOURCE
+ #endif /* _AIX */
#include <sys/time.h>
#include <stdlib.h>
#include <stddef.h>
4. Compilation with cc succeeded :
export PATH=/opt/freeware/bin:$PATH
export CC=cc
./configure --disable-maintainer-mode
make
make install
5. Test it, by extract some informations from JSON file :
root@XXXXXXXXX:/root# export PATH=/usr/local/bin:$PATH
root@XXXXXXXXX:/root# uname
AIX
root@XXXXXXXXX:/root# oslevel -s
7100-05-01-1731
root@XXXXXXXXX:/root# cat /tmp/VM_AIX.json | jq '.servers | .[] | [.name, .max_memory_mb, .cpus, .["OS-EXT-AZ:availability_zone"], .operating_system]'
[
"xxxxx",
9472,
1,
"XXXY",
"AIX 6.1 6100-08-03-1339"
]
[
"xxxxxxxxxxxx",
9216,
1,
"XXXY",
"AIX 6.1 6100-08-03-1339"
]
[
"wwwwwwwwww",
16384,
4,
"XXXY",
"AIX 6.1 6100-09-07-1614"
]
...
root@XXXXXXXXX:/root# echo $?
0
6. PowerVC Use case and validate JSON file before send API request :
root@XXXXXXXXX:/root# jq '.' /tmp/auth.json
{
"auth": {
"scope": {
"project": {
"name": "ibm-default",
"domain": {
"name": "Default"
}
}
},
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"domain": {
"name": "Default"
},
"name": "root",
"password": "xxxxxx"
}
}
}
}
}
# request a token by API
root@XXXXXXXXX:/root# curl -l -k -i -X POST https://MyPowerVCIP:5000/v3/auth/tokens -H "Accept: application/json" -H "Content-Type: application/json" -d @/tmp/auth.json
curl -l -k -i -X POST https://MyPowerVCIP:5000/v3/auth/tokens -H "Accept: application/json" -H "Content-Type: application/json" -d @/tmp/auth.json
HTTP/1.1 201 Created
Date: Wed, 29 Aug 2018 16:47:37 GMT
Server: Apache
X-Subject-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Vary: X-Auth-Token
x-openstack-request-id: rxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Length: 8388
Content-Type: application/json
...
...
Very useful, thank you so much for every one IBMers !