刪除私有雲

私有雲由一或多個 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. 在 Shell 中執行下列指令,設定 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}"
    )