{"id":3616,"date":"2018-03-23T18:37:00","date_gmt":"2018-03-23T09:37:00","guid":{"rendered":"https:\/\/blog.claris.cloud\/?p=153"},"modified":"2021-06-16T16:25:58","modified_gmt":"2021-06-16T07:25:58","slug":"acli-%e3%81%ae%e7%b5%90%e6%9e%9c%e3%82%92-json-%e3%81%a7%e5%87%ba%e5%8a%9b%e3%81%97%e3%81%a6-jq-%e3%81%a7%e5%bf%85%e8%a6%81%e3%81%aa%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%8f%96%e3%82%8a%e5%87%ba","status":"publish","type":"post","link":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/acli-%e3%81%ae%e7%b5%90%e6%9e%9c%e3%82%92-json-%e3%81%a7%e5%87%ba%e5%8a%9b%e3%81%97%e3%81%a6-jq-%e3%81%a7%e5%bf%85%e8%a6%81%e3%81%aa%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%8f%96%e3%82%8a%e5%87%ba\/","title":{"rendered":"acli \u306e\u7d50\u679c\u3092 json \u3067\u51fa\u529b\u3057\u3066 jq \u3067\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002\u30af\u30e9\u30e9\u306e\u5409\u6751\u3067\u3059\u3002<\/p>\n<p>\u4eca\u65e5\u306f\u3001acli \u3092 json \u3067\u51fa\u529b\u3057\u3066\u3001\u3055\u3089\u306b jq \u3067\u64cd\u4f5c\u3059\u308b\u3068\u3053\u308d\u3092\u3084\u308a\u307e\u3059\u3002<\/p>\n<h3 class=\"style3a\">\u3084\u308a\u305f\u3044\u4e8b<\/h3>\n<p>Prism \u304b\u3089 \u4eee\u60f3\u30de\u30b7\u30f3\u3084\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u60c5\u5831\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u304c\u3001\u3084\u306f\u308aLinux\u3067\u30b5\u30af\u30c3\u3068\u78ba\u8a8d\u3057\u305f\u3044\u3068\u3044\u3046\u6642\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>AWS\u306a\u3069\u306b\u30d1\u30d6\u30ea\u30c3\u30af\u30af\u30e9\u30a6\u30c9\u306b\u6163\u308c\u3066\u3044\u308b\u3068\u7279\u306b\u305d\u3046\u611f\u3058\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u4eca\u56de\u306f\u305d\u306e\u3088\u3046\u306a\u74b0\u5883\u3092\u6574\u3048\u308b\u307e\u3067\u306e\u624b\u9806\u3067\u3059\u3002<\/p>\n<h3 class=\"style3a\">acli \u306e\u51fa\u529b\u3092 json \u306b\u3059\u308b<\/h3>\n<p>acli \u3092\u64cd\u4f5c\u3059\u308b\u3068\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>[bash]<\/p>\n<p>$ acli net.list<br \/>\nNetwork name Network UUID Type Identifier Subnet<br \/>\nManagement f489f2cf-45e7-4afa-93b1-7a2982cc7742 kBridged 0<br \/>\nnetwork_test 9b4c9c30-ad14-4664-9daf-969f2e9476ae kBridged 755 xxx.xxx.xxx.xxx.\/24<br \/>\nnetwork_test_local 62008052-4685-4351-b1bb-621ae13edd96 kBridged 737 xxx.xxx.xxx.xxx.\/24<br \/>\nnutanix-global 7c760a59-4823-4e8c-9e54-a30a105a7bfc kBridged 737<br \/>\ntest-900 c44c305e-28d7-452f-a268-224eff2acc10 kBridged 900 10.0.10.0\/24<\/p>\n<p>[\/bash]<\/p>\n<p>\u4e00\u89a7\u6027\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u6a5f\u80fd\u7684\u3067\u306f\u306a\u3044\u611f\u3058\u3067\u3059\u306d\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u305d\u3053\u3067\u3001\u3053\u3061\u3089\u3092 json \u5f62\u5f0f\u3067\u51fa\u529b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3084\u308a\u65b9\u306f\u7c21\u5358\u3067\u3001acli \u306e\u3059\u3050\u5f8c\u306b\u3001-o json \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre>$ acli -o json net.list\r\n{\"status\": 0, \"data\": [{\"id\": 0, \"subnet\": null, \"type\": \"kBridged\", \"name\": \"Management\", \"uuid\": \"f489f2cf-45e7-4afa-93b1-7a2982cc7742\"}, {\"id\": 755, \"subnet\": \"xxx.xxx.xxx.xxx\/24\", \"type\": \"kBridged\", \"name\": \"network_test\", \"uuid\": \"9b4c9c30-ad14-4664-9daf-969f2e9476ae\"}, {\"id\": 737, \"subnet\": \"xxx.xxx.xxx.xxx\/24\", \"type\": \"kBridged\", \"name\": \"network_test_local\", \"uuid\": \"62008052-4685-4351-b1bb-621ae13edd96\"}, {\"id\": 737, \"subnet\": null, \"type\": \"kBridged\", \"name\": \"nutanix-global\", \"uuid\": \"7c760a59-4823-4e8c-9e54-a30a105a7bfc\"}, {\"id\": 900, \"subnet\": \"10.0.10.0\/24\", \"type\": \"kBridged\", \"name\": \"test-900\", \"uuid\": \"c44c305e-28d7-452f-a268-224eff2acc10\"}], \"error\": null}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>json \u5f62\u5f0f\u3067\u51fa\u529b\u3055\u308c\u307e\u3057\u305f\u304c\u3001\u51fa\u307e\u3057\u305f\u6a2a\u9577\u3002<\/p>\n<h3 class=\"style3a\">json\u3092\u6574\u5f62\u3057\u3088\u3046<\/h3>\n<p>\u4e0a\u8a18\u306e\u901a\u308a\u3001\u3053\u306e\u307e\u307e\u3067\u306f\u8996\u8a8d\u6027\u304c\u826f\u304f\u306a\u3044\u306e\u3067\u3001\u898b\u3084\u3059\u304f\u6574\u5f62\u3057\u307e\u3059\u3002<\/p>\n<p>CVM\u306b\u306f\u3001json_reformat\u3000\u30b3\u30de\u30f3\u30c9\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u3067\u3001\u3053\u3061\u3089\u3067\u3082\u6574\u5f62\u306f\u3067\u304d\u308b\u307f\u305f\u3044\u3067\u3059\u304c\u3001\u3084\u306f\u308a jq \u30b3\u30de\u30f3\u30c9\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3053\u3061\u3089\u306e\u65b9\u304c\u30cd\u30c3\u30c8\u306b\u3044\u3063\u3071\u3044\u60c5\u5831\u6709\u308a\u307e\u3059\u3057\u3001aws cli \u306a\u3069\u3067\u4f7f\u3044\u6163\u308c\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u203b nutanix \u30b5\u30dd\u30fc\u30c8\u3067\u306f\u3001CVM\u306b\u3044\u304b\u306a\u308b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3082\u8a31\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u81ea\u5df1\u8cac\u4efb\u3067\u304a\u9858\u3044\u3057\u307e\u3059\u3002<\/strong><\/span><\/p>\n<p>[bash]<\/p>\n<p>## PATH\u3092\u78ba\u8a8d<\/p>\n<pre>$ echo $PATH\r\n\/home\/nutanix\/ncc\/panacea\/bin:\/usr\/lib\/jvm\/jre\r\n1.8.0\/bin:\/home\/nutanix\/ncc\/bin:\/home\/nutanix\/kvm\/bin:\/home\/nutanix\/prism\/cli:\/usr\/local\/nutanix\/cluster\/lib\/sg3utils\/bin:\/usr\/local\/nutanix\/minerva\/bin:\/usr\/local\/nutanix\/cluster\/bin:\/usr\/local\/nutanix\/zookeeper\/bin:\/usr\/local\/nutanix\/apache-cassandra\/bin:\/usr\/local\/nutanix\/bin:\/usr\/local\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin\r\n<\/pre>\n<p>## \u3044\u3063\u3071\u3044\u51fa\u3066\u304d\u307e\u3059\u304c\u3001\u7121\u96e3\u306b \/usr\/local\/bin\/ \u306b\u3057\u307e\u3059\u3002<br \/>\n$ cd \/usr\/local\/bin<\/p>\n<p>## jq \u30b3\u30de\u30f3\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<br \/>\n## CVM \u3067 yum \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3057\u306a\u3044\u3067\u3059<br \/>\n$ wget http:\/\/stedolan.github.io\/jq\/download\/linux64\/jq<br \/>\n$ chmod +x jq<\/p>\n<p>## PATH \u304c\u901a\u3063\u3066\u3044\u308b\u304b\u78ba\u8a8d<br \/>\n$ which jq<br \/>\n\/usr\/local\/bin\/jq<\/p>\n<p>[\/bash]<\/p>\n<p>&nbsp;<\/p>\n<p>\u3053\u308c\u3067\u6e96\u5099\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5148\u307b\u3069\u306e\u7d50\u679c\u3092\u6574\u5f62\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"well2\">$ acli -o json net.list | jq '.'\r\n{\r\n \"status\": 0,\r\n \"data\": [\r\n {\r\n \"id\": 0,\r\n \"subnet\": null,\r\n \"type\": \"kBridged\",\r\n \"name\": \"Management\",\r\n \"uuid\": \"f489f2cf-45e7-4afa-93b1-7a2982cc7742\"\r\n },\r\n {\r\n \"id\": 755,\r\n \"subnet\": \"xxx.xxx.xxx.xxx\/24\",\r\n \"type\": \"kBridged\",\r\n \"name\": \"network_test\",\r\n \"uuid\": \"9b4c9c30-ad14-4664-9daf-969f2e9476ae\"\r\n },\r\n {\r\n \"id\": 737,\r\n \"subnet\": \"xxx.xxx.xxx.xxx\/24\",\r\n \"type\": \"kBridged\",\r\n \"name\": \"network_test_local\",\r\n \"uuid\": \"62008052-4685-4351-b1bb-621ae13edd96\"\r\n },\r\n {\r\n \"id\": 737,\r\n \"subnet\": null,\r\n \"type\": \"kBridged\",\r\n \"name\": \"nutanix-global\",\r\n \"uuid\": \"7c760a59-4823-4e8c-9e54-a30a105a7bfc\"\r\n },\r\n {\r\n \"id\": 900,\r\n \"subnet\": \"10.0.10.0\/24\",\r\n \"type\": \"kBridged\",\r\n \"name\": \"test-900\",\r\n \"uuid\": \"c44c305e-28d7-452f-a268-224eff2acc10\"\r\n }\r\n ],\r\n \"error\": null\r\n}<\/pre>\n<p>\u826f\u304f\u306a\u308a\u307e\u3057\u305f\u306d\u3002<\/p>\n<p>\u3067\u306f\u3001\u3082\u3046\u3061\u3087\u3063\u3068\u8e0f\u307f\u8fbc\u3093\u3067\u3001jq \u3092\u4f7f\u3063\u3066\u4efb\u610f\u306e\u30c7\u30fc\u30bf\u306e\u307f\u3092\u62bd\u51fa\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre>## \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u4e00\u89a7\u304b\u3089\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d\u306e\u307f\u3092\u62bd\u51fa\r\n$ acli -o json net.list | jq '.data[].name'\r\n\"Management\"\r\n\"network_test\"\r\n\"network_test_local\"\r\n\"nutanix-global\"\r\n\"test-900\"\r\n\r\n## \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d nutanix-global \u306b\u5c5e\u3057\u3066\u3044\u308bVM\u540d\u4e00\u89a7\u3092\u8868\u793a\r\n$ acli -o json net.list_vms nutanix-global | jq '.'\r\n{\r\n \"status\": 0,\r\n \"data\": [\r\n {\r\n \"macAddress\": \"50:6b:8d:3d:cb:8f\",\r\n \"ipAddress\": null,\r\n \"uuid\": \"9721d49f-d7da-47cd-92af-d43cfc64123a\",\r\n \"name\": \"for-ntnx-clara\"\r\n },\r\n {\r\n \"macAddress\": \"50:6b:8d:05:97:27\",\r\n \"ipAddress\": null,\r\n \"uuid\": \"34520b97-8fb7-4a14-b602-d26d6c6eaca2\",\r\n \"name\": \"test_clara01\"\r\n }\r\n ],\r\n \"error\": null\r\n}\r\n\r\n## \u4e0a\u8a18\u306eVM\u4e00\u89a7\u7d50\u679c\u304b\u3089 VM\u540d\u306e\u307f\u3092\u62bd\u51fa\r\n$ acli -o json net.list_vms nutanix-global | jq '.data[].name'\r\n\"for-ntnx-clara\"\r\n\"test_clara01\"<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067json\u3092\u6574\u5f62\u3059\u308c\u3070\u3001\u3044\u308d\u3044\u308d\u4f5c\u696d\u304c\u6357\u308a\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u4ee5\u4e0a\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002\u30af\u30e9\u30e9\u306e\u5409\u6751\u3067\u3059\u3002 \u4eca\u65e5\u306f\u3001acli \u3092 json \u3067\u51fa\u529b\u3057\u3066\u3001\u3055\u3089\u306b jq \u3067\u64cd\u4f5c\u3059\u308b\u3068\u3053\u308d\u3092\u3084\u308a\u307e\u3059\u3002 \u3084\u308a\u305f\u3044\u4e8b Prism \u304b\u3089 \u4eee\u60f3\u30de\u30b7\u30f3\u3084\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u60c5\u5831\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u304c\u3001\u3084\u306f\u308aLinux\u3067\u30b5\u30af\u30c3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8006,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[94,96],"tags":[43],"class_list":["post-3616","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nutanix","category-tech","tag-acli"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/posts\/3616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/comments?post=3616"}],"version-history":[{"count":3,"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/posts\/3616\/revisions"}],"predecessor-version":[{"id":8005,"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/posts\/3616\/revisions\/8005"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/media\/8006"}],"wp:attachment":[{"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/media?parent=3616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/categories?post=3616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ci.clara.jp\/solution\/clara-cloud\/wp-json\/wp\/v2\/tags?post=3616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}