刪除私有雲

私有雲由一或多個 vSphere 叢集組成。刪除私有雲會一併刪除整個私有雲。私有雲的所有元件都會刪除,包括所有私有雲節點。

私有雲的元件包括:

  • 節點
  • 虛擬機器
  • 管理 VLAN 和子網路
  • 工作負載子網路
  • 儲存在私有雲的所有使用者資料
  • 所有外部存取規則

刪除私有雲的程序分為兩個階段:虛刪除和永久刪除。每個階段的流程如下:

  1. 虛刪除:私有雲會進入七天的虛刪除狀態。 在這個階段,會發生下列情況:
    • 系統會立即停止計費。
    • 與 NSX 區隔和工作負載的所有連線都會中斷。
    • 私有雲的使用者介面和 API 存取權會遭到停用。
    • 外部 IP 位址已停用。
    • 私有雲的設定和資料會保留,VM 也會繼續執行。
    • 您可以將私有雲還原至先前的狀態。
  2. 永久刪除:七天後,系統會永久刪除私有雲及其資源。如要永久刪除處於軟刪除狀態的私有雲,請與支援團隊聯絡。

事前準備

如要保留任何資料,請將資料備份至其他私有雲、Google Cloud 儲存空間、地端儲存空間或其他儲存空間。

gcloud 和 API 需求

如要使用 gcloud 指令列工具或 API 管理 VMware Engine 資源,建議按照下列說明設定工具。

gcloud

  1. 設定預設專案 ID:

    gcloud config set project PROJECT_ID
    
  2. 設定預設地區和區域:

    gcloud config set compute/region REGION
    
    gcloud config set compute/zone ZONE
    

如要進一步瞭解 gcloud vmware 工具,請參閱 Cloud SDK 參考文件

API

本文件集中的 API 範例會使用 cURL 指令列工具查詢 API。您必須在cURL要求中提供有效的存取權杖。取得有效存取權杖的方法有很多,以下步驟使用 gcloud 工具產生存取權杖:

  1. 登入 Google Cloud:

    gcloud auth login
    
  2. 產生存取權杖並匯出至 TOKEN:

    export TOKEN=`gcloud auth print-access-token`
    
  3. 確認 TOKEN 設定正確:

    echo $TOKEN
    

現在,您可以在 API 要求中使用授權權杖。例如:

curl -X GET -H "Authorization: Bearer \"$TOKEN\"" -H "Content-Type: application/json; charset=utf-8" https://vmwareengine.googleapis.com/v1/projects/PROJECT_ID/locations

Python

本說明文件中的 Python 程式碼範例會使用 VMware Engine 程式庫與 API 通訊。如要使用這種方法,必須先安裝程式庫,並設定應用程式預設憑證

  1. 下載並安裝 Python 程式庫:

    pip install google-cloud-vmwareengine
    
  2. 在殼層中執行這些指令,設定 ADC 資訊:

    gcloud auth application-default login
    

    或者,使用服務帳戶金鑰檔案:

    export GOOGLE_APPLICATION_CREDENTIALS="FILE_PATH"
    

如要進一步瞭解程式庫,請造訪參考頁面或查看 GitHub 上的程式碼範例

刪除私有雲

如要立即使用工作負載網路 IP CIDR,請先關閉私有雲中的所有 VM,再開始刪除私有雲。

主控台

  1. 前往 Google Cloud 控制台的「Private clouds」頁面。

    前往 Private Cloud

  2. 按一下「選取專案」,然後選取要刪除私有雲的機構、資料夾或專案。

  3. 選取要刪除的私有雲。

  4. 在摘要頁面中,按一下「Delete this Private Cloud」(刪除這個私有雲)

  5. 在確認頁面中,系統會提示您驗證刪除動作的所有結果。請仔細閱讀這些資訊,並在確認接受結果後,再繼續刪除。準備好接受結果時,請選取所有核取方塊。

  6. 輸入刪除作業的等候時數 (1 到 8 小時)。在該期間內,您可以點選「取消」來取消刪除。

  7. 為確認您知道要刪除哪個私有雲,請輸入要刪除的私有雲名稱。

  8. 按一下「刪除」,將私有雲標示為待刪除。

刪除程序會在指定延遲時間 (以小時為單位) 過後開始執行,直到完成為止。

gcloud

如要使用 Google Cloud CLI 刪除私有雲,請使用 gcloud vmware private-clouds delete 指令

  gcloud vmware private-clouds delete PRIVATE_CLOUD_ID \
     --location=ZONE [--delay-hours=HOURS]

更改下列內容:

+   `PRIVATE_CLOUD_ID`: the private cloud ID for
    this request
+   `ZONE`: the zone for this private cloud
+   `HOURS`: the numbers of hours to delay this
    request. By default, this is set to 3 hours, but you can set this
    from 0 to 8 hours. Setting this value to 0 means the deletion
    request will start immediately.

API

如要使用 VMware Engine API 刪除私有雲,請發出 DELETE 要求:

curl -X DELETE -H "Authorization: Bearer TOKEN"  -H "Content-Type: application/json; charset=utf-8" https://vmwareengine.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/privateClouds?privateCloudId=PRIVATE_CLOUD_ID&mps;delayHours=HOUR

更改下列內容:

+   `TOKEN`: the authorization token for this
    request.
+   `PROJECT_ID`: the project for this request
+   `ZONE`: the zone for the private cloud
+   `PRIVATE_CLOUD_ID`: the private cloud ID for
    the private cloud
+   `HOUR`: the number of hours to delay this
    request; the default is 3. You can set an hour between 0 to 8.
    Setting this value to 0 starts the deletion request immediately.

Python

與使用 Google Cloud 控制台相比,使用 VMWare Engine 程式庫刪除私有雲的程序只有一個步驟。呼叫私有雲刪除方法時,請務必小心謹慎。

from google.api_core import operation
from google.cloud import vmwareengine_v1


def delete_private_cloud_by_full_name(cloud_name: str) -> operation.Operation:
    """
    Deletes VMware Private Cloud.

    Args:
        cloud_name: identifier of the Private Cloud you want to delete.
            Expected format:
            projects/{project_name}/locations/{zone}/privateClouds/{cloud}

    Returns:
        An Operation object related to started private cloud deletion operation.
    """
    client = vmwareengine_v1.VmwareEngineClient()
    request = vmwareengine_v1.DeletePrivateCloudRequest()
    request.force = True
    request.delay_hours = 3
    request.name = cloud_name
    return client.delete_private_cloud(request)


def delete_private_cloud(
    project_id: str, zone: str, cloud_name: str
) -> operation.Operation:
    """
    Deletes VMWare Private Cloud.

    Args:
        project_id: name of the project hosting the private cloud.
        zone: zone in which the private cloud is located in.
        cloud_name: name of the private cloud to be deleted.

    Returns:
        An Operation object related to started private cloud deletion operation.
    """
    return delete_private_cloud_by_full_name(
        f"projects/{project_id}/locations/{zone}/privateClouds/{cloud_name}"
    )

取消刪除私有雲

您可以在軟刪除期間取消刪除私有雲。 請按照下列步驟操作。

主控台

  1. 前往 Google Cloud 控制台的「Private clouds」頁面。

前往 Private Cloud

  1. 選取已標示為要刪除的私有雲。
  2. 在摘要頁面中,按一下「取消刪除」,即可取消刪除私有雲。

gcloud

如要使用 Google Cloud CLI 取消刪除私有雲,請使用 gcloud vmware private-clouds undelete 指令

  gcloud vmware private-clouds undelete PRIVATE_CLOUD_ID \
     --location=ZONE

更改下列內容:

+   `PRIVATE_CLOUD_ID`: the private cloud ID for
    this request
+   `ZONE`: the zone for this private cloud

API

如要使用 VMware Engine API 取消刪除私有雲,請發出 POST 要求:

curl -X POST -H "Authorization: Bearer TOKEN"  -H "Content-Type: application/json; charset=utf-8" https://vmwareengine.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/privateClouds?privateCloudId=PRIVATE_CLOUD_ID:undelete

更改下列內容:

+   `TOKEN`: the authorization token for this
    request.
+   `PROJECT_ID`: the project ID for this request
            +   `ZONE`: the zone for the private
                cloud
+   `PRIVATE_CLOUD_ID`: the private cloud ID for
    this request

Python

from google.api_core import operation
from google.cloud import vmwareengine_v1


def cancel_private_cloud_deletion_by_full_name(cloud_name: str) -> operation.Operation:
    """
    Cancels in progress deletion of VMware Private Cloud.

    Args:
        cloud_name: identifier of the Private Cloud you want to cancel deletion for.
            Expected format:
            projects/{project_name}/locations/{zone}/privateClouds/{cloud}

    Returns:
        An Operation object related to canceling private cloud deletion operation.
    """
    client = vmwareengine_v1.VmwareEngineClient()
    request = vmwareengine_v1.UndeletePrivateCloudRequest()
    request.name = cloud_name
    return client.undelete_private_cloud(request)


def cancel_private_cloud_deletion(
    project_id: str, zone: str, cloud_name: str
) -> operation.Operation:
    """
    Cancels in progress deletion of VMWare Private Cloud.

    Args:
        project_id: name of the project hosting the private cloud.
        zone: zone in which the private cloud is located in.
        cloud_name: name of the private cloud to cancel deletion for.

    Returns:
        An Operation object related to canceling private cloud deletion operation.
    """
    return cancel_private_cloud_deletion_by_full_name(
        f"projects/{project_id}/locations/{zone}/privateClouds/{cloud_name}"
    )