正在销毁资源
如果您不需要 Spectrum LSF 集群,并且想要销毁其所有关联的 VPC 资源,那么可以从 IBM Cloud® 帐户中除去这些
资源。
重要信息:在执行用于销毁资源的操作之前,必须首先确保 Spectrum LSF 自动缩放功能所创建的工作程序节点仍然存在。 集群中的工作程序节点总数应等于您为 worker_node_min_count指定的值。
1、使用 UI 销毁资源
(1)在 Schematics > 工作空间 页面上的 IBM Cloud 控制台中,选择 操作> 销毁 以删除作为该工作空间一部分部署的所有相关 VPC 资源。
(2)如果选择销毁资源的选项,请决定是否要销毁所有资源。 此操作不可撤销。
(3)通过在文本框中输入工作空间名称来确认操作,然后单击 销毁。
2、使用 CLI 销毁资源
运行以下命令以从工作空间中除去 VPC 资源:
ibmcloud schematics destroy --id <WORKSPACE_ID>
请注意:您可以监视日志文件以查看所有 IBM Cloud 资源的删除进度。
3、使用 Schematics Python API 销毁资源
(1)要使用 IBM Cloud Schematics Python API 销毁资源,请创建 Python 文件并提供您选择的名称,例如 schematics_destroy_resources.py。
(2)将 Destroy resources using Schematics Python API 示例请求复制并粘贴到 Python 文件。
(3)在请求中更改以下参数:
·将 IBM Cloud 密钥替换为 authenticator = IAMAuthenticator('
·根据您希望 Schematics 工作空间驻留的位置 (例如 schematics_service.set_service_url('https://us.schematics.cloud.ibm.com')) ,将 API 端点更改为 API 端点 中提到的端点。
1)在 schematics_service.destroy_workspace_command 函数中,提供以下参数:
·提供在 创建工作空间 任务中生成的工作空间标识,例如 us-south.workspace.Terraform-Schematics-Python-Workspace.b3bbc9f5。
·使用以下命令导出 IBM Cloud API 密钥:
export IBMCLOUD_API_KEY =”<ibm-cloud-api-key>”
·运行以下 curl 命令以创建刷新令牌:
curl -X POST "https://iam.cloud.ibm.com/identity/token" -H
"Content-Type: application/x-www-form-urlencoded" -d
"grant_type=urn:ibm:params:oauth:grant-
type:apikey&apikey=$IBMCLOUD_API_KEY" -u bx:bx
# Destroy resources using Schematics Python APIimport json, loggingfrom ibm_cloud_sdk_core.authenticators import IAMAuthenticatorfrom ibm_schematics.schematics_v1 import SchematicsV1
logging.basicConfig()
logging.root.setLevel(logging.NOTSET)
logging.basicConfig(level=logging.NOTSET)
authenticator = IAMAuthenticator('<ibmcloud-api-key>')
schematics_service = SchematicsV1(authenticator = authenticator)
schematics_service.set_service_url('https://us.schematics.cloud.ibm.com')
logging.info("Started Deletion of Schematic Resources")
workspace_activity_destroy_result = schematics_service.destroy_workspace_command(
w_id='<workspace-id>',
refresh_token='<refresh-token>').get_result()print(json.dumps(workspace_activity_destroy_result, indent=2))
logging.info("Completed Deletion of Schematic Resources")
INFO:root:Started Deletion of Schematic Resources
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): iam.cloud.ibm.com:443
DEBUG:urllib3.connectionpool:https://iam.cloud.ibm.com:443 "POST /identity/token HTTP/1.1" 200 985
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): us.schematics.cloud.ibm.com:443
DEBUG:urllib3.connectionpool:https://us.schematics.cloud.ibm.com:443 "PUT /v1/workspaces/us-south.workspace.Schematic-Sunil-Test-Workspace.5a4cbf11/destroy HTTP/1.1" 202 49
{
"activityid": "4bc90aac48f7cf9850bddf1ba9407eb5"
}
INFO:root:Completed Deletion of Schem