作为云管理员,您可以在 Automation Assembler 中创建和管理基于插件的 Google Cloud Platform (GCP) 磁盘快照。

如果需要创建磁盘备份,可以在云模板中使用快照资源。可以将快照资源附加到任何类型的磁盘。还可以使用快照创建新的 实例或磁盘。创建快照后,可以登录到 Google Cloud 控制台,查看快照。

以下部分包含一些使用快照的示例云模板。

创建引导磁盘的快照

以下云模板展示了如何为附加到实例的引导磁盘生成快照。在此示例中,将使用计算帮助程序、网络帮助程序、映像帮助程序以及特定实例帮助程序。
formatVersion: 1
inputs: {}
resources:
  Allocations_Image_1:
    type: Allocations.Image
    properties:
      image: ubuntu
  Allocations_Network_1:
    type: Allocations.Network
    properties:
      networkType: existing
  Allocations_Compute_1:
    type: Allocations.Compute
    properties:
      accountType: gcp
  Allocations_Flavor_1:
    type: Allocations.Flavor
    properties:
      flavor: small
  mysql:
    type: Idem.GCP.COMPUTE.INSTANCE
    properties:
      name: mysql
      zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      project: ${resource.Allocations_Compute_1.selectedCloudAccount.additionalProperties.gcp.project}
      network_interfaces:
        - name: nic0
          stack_type: IPV4_ONLY
          subnetwork: ${'/projects/' + resource.Allocations_Compute_1.selectedCloudAccount.additionalProperties.gcp.project + '/regions/' + resource.Allocations_Compute_1.selectedRegion.id + '/subnetworks/' + resource.Allocations_Network_1.selectedSubnet.name}
      disks:
        - device_name: ${resource.mysql-boot-disk.name}
          source: ${resource.mysql-boot-disk.resource_id}
          boot: true
        - boot: false
          device_name: ${resource.mssql-attached-disk.name}
          source: ${resource.mssql-attached-disk.resource_id}
      machine_type: ${'/projects/' + resource.Allocations_Flavor_1.selectedCloudAccount.additionalProperties.gcp.project + '/zones/' + resource.Allocations_Compute_1.selectedPlacementCompute.id + '/machineTypes/' + resource.Allocations_Flavor_1.selectedInstanceTypeName}
  mssql-attached-disk:
    type: Idem.GCP.COMPUTE.DISK
    properties:
      name: attached-disk
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      size_gb: 1
      project: ${resource.Allocations_Flavor_1.selectedCloudAccount.additionalProperties.gcp.project}
      zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.name}
      type: ${'/projects/' + resource.Allocations_Flavor_1.selectedCloudAccount.additionalProperties.gcp.project + '/zones/' + resource.Allocations_Compute_1.selectedPlacementCompute.id + '/diskTypes/pd-extreme'}
  mysql-boot-disk:
    type: Idem.GCP.COMPUTE.DISK
    properties:
      name: mysql-boot-disk
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      size_gb: 12
      project: ${resource.Allocations_Flavor_1.selectedCloudAccount.additionalProperties.gcp.project}
      zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.name}
      type: ${'/projects/' + resource.Allocations_Flavor_1.selectedCloudAccount.additionalProperties.gcp.project + '/zones/' + resource.Allocations_Compute_1.selectedPlacementCompute.id + '/diskTypes/pd-balanced'}
  mysql-disk-snapshot:
    type: Idem.GCP.COMPUTE.SNAPSHOT
    dependsOn: ''
    properties:
      name: mysql-boot-disk-snapshot
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      source_disk: ${resource.mysql-boot-disk.resource_id}

使用绑定将 mysql-boot-diskresource_id 传递到快照资源。

从快照创建新实例

以下云模板显示了如何从快照创建新实例。在此示例中,还使用计算帮助程序、映像帮助程序、网络帮助程序以及特定实例帮助程序。
atVersion: 1
inputs:
  disk-snapshot-Id:
    type: string
    title: Disk Snapshot Link id
resources:
  Allocations_Image_1:
    type: Allocations.Image
    properties:
      image: ubuntu
  Allocations_Network_1:
    type: Allocations.Network
    properties:
      networkType: existing
  Allocations_Compute_1:
    type: Allocations.Compute
    properties:
      accountType: gcp
  Allocations_Flavor_1:
    type: Allocations.Flavor
    properties:
      flavor: small
  mysql:
    type: Idem.GCP.COMPUTE.INSTANCE
    properties:
      name: mysql-from-snapshot
      zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      project: ${resource.Allocations_Compute_1.selectedCloudAccount.additionalProperties.gcp.project}
      network_interfaces:
        - name: nic0
          stack_type: IPV4_ONLY
          subnetwork: ${'/projects/' + resource.Allocations_Compute_1.selectedCloudAccount.additionalProperties.gcp.project + '/regions/' + resource.Allocations_Compute_1.selectedRegion.id + '/subnetworks/' + resource.Allocations_Network_1.selectedSubnet.name}
      disks:
        - device_name: ${resource.restored-disk.name}
          source: ${resource.restored-disk.resource_id}
          boot: true
      machine_type: ${'/projects/' + resource.Allocations_Flavor_1.selectedCloudAccount.additionalProperties.gcp.project + '/zones/' + resource.Allocations_Compute_1.selectedPlacementCompute.id + '/machineTypes/' + resource.Allocations_Flavor_1.selectedInstanceTypeName}
  restored-disk:
    type: Idem.GCP.COMPUTE.DISK
    properties:
      name: restored
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      disk_name: restored-boot
      zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id}
      source_snapshot: ${input.disk-snapshot-Id}
      boot: true

使用输入参数,以允许用户输入要用于引导磁盘的快照的 snapshot-Id