Skip to content

Instantly share code, notes, and snippets.

@gowatana
Last active August 30, 2020 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/cd115fe400d300bb71e367ab2c98caf3 to your computer and use it in GitHub Desktop.
Save gowatana/cd115fe400d300bb71e367ab2c98caf3 to your computer and use it in GitHub Desktop.
Nutanix のヘルスチェック一覧を取得する。
import sys
import json
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
args = sys.argv
conf_file = args[1]
def main():
with open(conf_file, "r") as file:
conf = file.read()
conf = json.loads(conf)
prism_addr = conf["prism_address"]
prism_user = conf["user_name"]
prism_pass = conf["password"]
base_url = 'https://' + prism_addr + ':9440/PrismGateway/services/rest/v2.0/'
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
s = requests.Session()
s.auth = (prism_user, prism_pass)
s.headers.update({'Content-Type': 'application/json; charset=utf-8'})
data = s.get(base_url + 'health_checks', verify=False).json()
for e in data['entities']:
print(e['id'] + ',' + e['name'])
if __name__ == '__main__':
main()
@gowatana
Copy link
Author

下記のように Prism への接続情報を記載した JSON を作成しておく。

$ cat prism-config.json
{
    "prism_address": "Prism の VIP アドレス",
    "user_name": "admin",
    "password": "パスワード"
}

スクリプトを実行する。

$ python list_nutanix-health_checks.py prism-config.json > nutanix-health-check.csv

@gowatana
Copy link
Author

下記の投稿むけ。

Nutanix CE の Health Check 項目の一覧を取得してみる。(Python 編)
https://blog.ntnx.jp/entry/2020/07/19/165100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment