Exemple #1
0
func cdrom_tf_to_vix(d *schema.ResourceData, vm *vix.VM) error {
	cdromCount := d.Get("cdrom.#").(int)
	vm.CDDVDDrives = make([]*govix.CDDVDDrive, 0, cdromCount)

	for i := 0; i < cdromCount; i++ {
		prefix := fmt.Sprintf("cdrom.%d.", i)
		cdrom := new(govix.CDDVDDrive)

		if attr, ok := d.Get(prefix + "bus_type").(string); ok && attr != "" {
			cdrom.Bus = vmx.BusType(attr)
		}

		if attr, ok := d.Get(prefix + "image").(string); ok && attr != "" {
			cdrom.Filename = attr
		}
		vm.CDDVDDrives = append(vm.CDDVDDrives, cdrom)
	}

	return nil
}