lxd/patches.go
func patchRenameCustomVolumeLVs(name string, d *Daemon) error {
	// Ignore the error since it will also fail if there are no pools.
	pools, _ := d.cluster.StoragePools()

	for _, poolName := range pools {
		poolID, pool, err := d.cluster.StoragePoolGet(poolName)
		if err != nil {
			return err
		}

		sType, err := storageStringToType(pool.Driver)
		if err != nil {
			return err
		}

		if sType != storageTypeLvm {
			continue
		}

		volumes, err := d.cluster.StoragePoolNodeVolumesGetType(storagePoolVolumeTypeCustom, poolID)
		if err != nil {
			return err
		}

		vgName := poolName
		if pool.Config["lvm.vg_name"] != "" {
			vgName = pool.Config["lvm.vg_name"]
		}

		for _, volume := range volumes {
			oldName := fmt.Sprintf("%s/custom_%s", vgName, volume)
			newName := fmt.Sprintf("%s/custom_%s", vgName, containerNameToLVName(volume))

			exists, err := storageLVExists(newName)
			if err != nil {
				return err
			}

			if exists || oldName == newName {
				continue
			}

			err = lvmLVRename(vgName, oldName, newName)
			if err != nil {
				return err
			}

			logger.Info("Successfully renamed LV", log.Ctx{"old_name": oldName, "new_name": newName})
		}
	}

	return nil
}
func patchRenameCustomVolumeLVs(name string, d *Daemon) error {
	// Ignore the error since it will also fail if there are no pools.
	pools, _ := d.cluster.StoragePools()

	for _, poolName := range pools {
		poolID, pool, err := d.cluster.StoragePoolGet(poolName)
		if err != nil {
			return err
		}

		sType, err := storageStringToType(pool.Driver)
		if err != nil {
			return err
		}

		if sType != storageTypeLvm {
			continue
		}

		volumes, err := d.cluster.StoragePoolNodeVolumesGetType(storagePoolVolumeTypeCustom, poolID)
		if err != nil {
			return err
		}

		vgName := poolName
		if pool.Config["lvm.vg_name"] != "" {
			vgName = pool.Config["lvm.vg_name"]
		}

		for _, volume := range volumes {
			oldName := fmt.Sprintf("%s/custom_%s", vgName, volume)
			newName := fmt.Sprintf("%s/custom_%s", vgName, containerNameToLVName(volume))

			exists, err := storageLVExists(newName)
			if err != nil {
				return err
			}

			if exists || oldName == newName {
				continue
			}

			err = lvmLVRename(vgName, oldName, newName)
			if err != nil {
				return err
			}

			logger.Info("Successfully renamed LV", log.Ctx{"old_name": oldName, "new_name": newName})
		}
	}

	return nil
}
func patchRenameCustomVolumeLVs ( name string , d * Daemon ) error { // Ignore the error since it will also fail if there are no pools. pools , _ := d . cluster . StoragePools ( ) for _ , poolName := range pools { poolID , pool , err := d . cluster . StoragePoolGet ( poolName ) if err != nil { return err } sType , err := storageStringToType ( pool . Driver ) if err != nil { return err } if sType != storageTypeLvm { continue } volumes , err := d . cluster . StoragePoolNodeVolumesGetType ( storagePoolVolumeTypeCustom , poolID ) if err != nil { return err } vgName := poolName if pool . Config [ " " ] != " " { vgName = pool . Config [ " " ] } for _ , volume := range volumes { oldName := fmt . Sprintf ( " " , vgName , volume ) newName := fmt . Sprintf ( " " , vgName , containerNameToLVName ( volume ) ) exists , err := storageLVExists ( newName ) if err != nil { return err } if exists || oldName == newName { continue } err = lvmLVRename ( vgName , oldName , newName ) if err != nil { return err } logger . Info ( " " , log . Ctx { " " : oldName , " " : newName } ) } } return nil }
// Patches begin here
Patches begin here