이 제품의 최신 릴리즈를 사용할 수 있습니다.
본 한국어 번역은 사용자 편의를 위해 제공되는 기계 번역입니다. 영어 버전과 한국어 버전이 서로 어긋나는 경우에는 언제나 영어 버전이 우선합니다.
클러스터를 삭제하는 스크립트입니다
기여자
변경 제안
다음 CLI 스크립트를 사용하여 기존 클러스터를 삭제할 수 있습니다.
#!/usr/bin/env python
##--------------------------------------------------------------------
#
# File: delete_cluster.py
#
# (C) Copyright 2019 NetApp, Inc.
#
# This sample code is provided AS IS, with no support or warranties of
# any kind, including but not limited for warranties of merchantability
# or fitness of any kind, expressed or implied. Permission to use,
# reproduce, modify and create derivatives of the sample code is granted
# solely for the purpose of researching, designing, developing and
# testing a software application product for use with NetApp products,
# provided that the above copyright notice appears in all copies and
# that the software application product is distributed pursuant to terms
# no less restrictive than those set forth herein.
#
##--------------------------------------------------------------------
import argparse
import json
import logging
from deploy_requests import DeployRequests
def find_cluster(deploy, cluster_name):
return deploy.find_resource('/clusters', 'name', cluster_name)
def offline_cluster(deploy, cluster_id):
# Test that the cluster is online, otherwise do nothing
response = deploy.get('/clusters/{}?fields=state'.format(cluster_id))
cluster_data = response.json()['record']
if cluster_data['state'] == 'powered_on':
log_info("Found the cluster to be online, modifying it to be powered_off.")
deploy.patch('/clusters/{}'.format(cluster_id), {'availability': 'powered_off'}, True)
def delete_cluster(deploy, cluster_id):
log_info("Deleting the cluster({}).".format(cluster_id))
deploy.delete('/clusters/{}'.format(cluster_id), True)
pass
def log_info(msg):
logging.getLogger('deploy').info(msg)
def configure_logging():
FORMAT = '%(asctime)-15s:%(levelname)s:%(name)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=FORMAT)
logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARNING)
def main(args):
configure_logging()
deploy = DeployRequests(args.deploy, args.password)
with open(args.config_file) as json_data:
config = json.load(json_data)
cluster_id = find_cluster(deploy, config['cluster']['name'])
log_info("Found the cluster {} with id: {}.".format(config['cluster']['name'], cluster_id))
offline_cluster(deploy, cluster_id)
delete_cluster(deploy, cluster_id)
def parseArgs():
parser = argparse.ArgumentParser(description='Uses the ONTAP Select Deploy API to delete a cluster')
parser.add_argument('-d', '--deploy', required=True, type=str, help='Hostname or IP address of Deploy server')
parser.add_argument('-p', '--password', required=True, type=str, help='Admin password of Deploy server')
parser.add_argument('-c', '--config_file', required=True, type=str, help='Filename of the cluster json config')
return parser.parse_args()
if __name__ == '__main__':
args = parseArgs()
main(args)