To manage a SCSI disk, you must specify and know its SCSI controller and logical unit number (LUN). For a vSphere disk object, you can use Automation Assembler to assign both values in the cloud template.

The ability to use different SCSI controllers is important for performance and is required for some deployment types, such as Oracle Real Application Clusters (RAC).

SCSI controller and LUN disk properties

To assign a SCSI controller and LUN, add the following cloud template properties:

SCSIController

unitNumber

You also have the option to omit the properties, in which case assignment follows a predictable default. Automation Assembler no longer deploys SCSI disks in random order, which made them difficult to manage.

SCSI controllers and disks are numbered in order, with zero being first. Each SCSI controller can support SCSI disks of unit numbers 0–15.

Option 1: Set both SCSI controller and unit number

You may fully specify both properties as shown in the following example. If so, assignment of the SCSI controller and unit number match the values that you enter.

resources:
  Cloud_vSphere_Machine_1:
    type: Cloud.vSphere.Machine
    properties:
      image: centos
      cpuCount: 1
      totalMemoryMB: 1024
      attachedDisks:
        - source: '${resource.Cloud_vSphere_Disk_1.id}'
        - source: '${resource.Cloud_vSphere_Disk_2.id}'
        - source: '${resource.Cloud_vSphere_Disk_3.id}'
  Cloud_vSphere_Disk_1:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
      SCSIController: SCSI_Controller_2
      unitNumber: 0
  Cloud_vSphere_Disk_2:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
      SCSIController: SCSI_Controller_2
      unitNumber: 1
  Cloud_vSphere_Disk_3:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
      SCSIController: SCSI_Controller_3
      unitNumber: 4

Option 2: Set only the SCSI controller

You may specify the SCSI controller and omit the unit number. In this case, assignment of the SCSI controller matches the value you enter. The unit number is set to the first available unit number under that controller.

resources:
  Cloud_vSphere_Machine_1:
    type: Cloud.vSphere.Machine
    properties:
      image: centos
      cpuCount: 1
      totalMemoryMB: 1024
      attachedDisks:
        - source: '${resource.Cloud_vSphere_Disk_1.id}'
        - source: '${resource.Cloud_vSphere_Disk_2.id}'
        - source: '${resource.Cloud_vSphere_Disk_3.id}'
  Cloud_vSphere_Disk_1:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
      SCSIController: SCSI_Controller_0
  Cloud_vSphere_Disk_2:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
      SCSIController: SCSI_Controller_0
  Cloud_vSphere_Disk_3:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
      SCSIController: SCSI_Controller_1

Option 3: Omit both properties

You may omit the SCSI controller and unit number. In this case, assignment is set to the first available SCSI controller, and the first available unit number under that controller.

resources:
  Cloud_vSphere_Machine_1:
    type: Cloud.vSphere.Machine
    properties:
      image: centos
      cpuCount: 1
      totalMemoryMB: 1024
      attachedDisks:
        - source: '${resource.Cloud_vSphere_Disk_1.id}'
        - source: '${resource.Cloud_vSphere_Disk_2.id}'
        - source: '${resource.Cloud_vSphere_Disk_3.id}'
  Cloud_vSphere_Disk_1:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
  Cloud_vSphere_Disk_2:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1
  Cloud_vSphere_Disk_3:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 1

Not an option: LUN only

You cannot omit the SCSI controller and specify only a unit number. Doing so might result in a deployment where multiple SCSI controllers have a disk of that number but, for management purposes, you won't know which disk is which.

Using inputs to set the SCSI controller and LUN

To make the design more dynamic, use inputs so that the user may specify which SCSI controller and unit number at request or update time.

inputs:
  diskProperties:
    type: array
    minItems: 1
    maxItems: 10
    items:
      type: object
      properties:
        size:
          type: integer
        SCSIController:
          type: string
          title: SCSI Controller
          enum:
            - SCSI_Controller_0
            - SCSI_Controller_1
            - SCSI_Controller_2
            - SCSI_Controller_3
        unitNumber:
          type: integer
          title: Unit Number
          
resources:
  app:
    type: Cloud.vSphere.Machine
    allocatePerInstance: true
    properties:
      flavor: small
      image: centos
      attachedDisks: '${map_to_object(slice(resource.disk[*].id, 0, 4), ''source'')}'
  disk:
    type: Cloud.vSphere.Disk
    allocatePerInstance: true
    properties:
      capacityGb: '${input.diskProperties[count.index].size}'
      SCSIController: '${input.diskProperties[count.index].SCSIController}'
      unitNumber: '${input.diskProperties[count.index].unitNumber}'
      count: ${length(input.diskProperties)}
Terraform CLI URL