在 PAYG 和 BYOS 之间切换


您可以通过替换许可参考或代码,在随用随付 (PAYG) 和自带订阅 (BYOS) 结算模式之间切换。Red Hat Enterprise Linux (RHEL)、RHEL for SAP、SUSE Linux Enterprise Server (SLES) 和 SLES for SAP 支持在 BYOS 和 PAYG 之间切换。 如需详细了解许可代码以及如何确定允许的许可修改,请参阅许可变更和限制

准备工作

  • 如果您尚未设置身份验证,请进行设置。身份验证用于验证您的身份,以便访问 Google Cloud 服务和 API。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 Compute Engine 进行身份验证:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. 安装 Google Cloud CLI。 安装完成后,运行以下命令来初始化 Google Cloud CLI:

      gcloud init

      如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI

    2. Set a default region and zone.

将 BYOS 许可更改为 PAYG 许可

如需 BYOS 替换为 PAYG 许可,请使用 Google Cloud CLI 或 Compute Engine API。

gcloud

如需将磁盘的许可替换为许可引用或代码,请使用 gcloud compute disks update 命令

gcloud compute disks update DISK_NAME \
    --replace-license=PREVIOUS_LICENSE,NEW_LICENSE

替换以下内容:

  • DISK_NAME:要替换的磁盘的名称。
  • PREVIOUS_LICENSE:要替换的之前的许可参考,例如 "rhel-7-byos""rhel-8-byos"
  • NEW_LICENSE:新的许可参考,例如 "rhel-7-server""rhel-8-server"

REST

如需替换磁盘的许可,请将新许可添加到请求正文中,并省略之前的许可。调用以下 disks.update v1 方法

PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks/DISK_NAME?paths=licenses --data '{"name":"DISK_NAME", "licenses":["https://www.googleapis.com/compute/v1/NEW_LICENSE"]}'

替换以下内容:

  • PROJECT:项目的名称
  • ZONE:包含虚拟机的可用区
  • DISK_NAME:磁盘的名称
  • NEW_LICENSE:新的许可参考,例如 "rhel-6-byos""rhel-7-byos"许可代码,例如 "4720191914037931587""1492188837615955530"