func addCoreFilersWithBalancedQuota()

in src/terraform/providers/terraform-provider-avere/resource_vfxt.go [1673:1730]


func addCoreFilersWithBalancedQuota(corefilers []*CoreFiler, averevfxt *AvereVfxt) error {
	log.Printf("[INFO] [addCoreFilerWithBalancedQuota")
	defer log.Printf("[INFO] addCoreFilerWithBalancedQuota]")

	var lastCoreFiler *CoreFiler
	lastIndex := len(corefilers)

	// There is an undesired behavior in Avere vFXT where the first core filer is added and
	// it receives all the quota space.  To speed up balancing, add the last core filer, and
	// then delete it after added the other core filers.  This releases the space.
	if QuotaSpeedUpDeleteFirstFiler {
		lastIndex = lastIndex - 1
		lastCoreFiler = corefilers[lastIndex]
		log.Printf("[INFO] add last core filer '%s', without fixed quota", lastCoreFiler.Name)
		if err := averevfxt.CreateCoreFiler(lastCoreFiler); err != nil {
			return err
		}
	}

	// increase speed of dynamic block allocation
	if err := startFixedQuotaPercent(corefilers, averevfxt); err != nil {
		return fmt.Errorf("error encountered while starting setting of fixed quota: %v", err)
	}

	// add the core filer and quota percent first (not adding last core filer if used for quota speedup)
	for i := 0; i < lastIndex; i++ {
		if err := createCoreFilerWithFixedQuota(corefilers[i], averevfxt); err != nil {
			return err
		}
	}

	// remove and add the last core filer and quota percent, to release the space, and speed allocation
	if QuotaSpeedUpDeleteFirstFiler {
		log.Printf("[INFO] remove last core filer '%s'", lastCoreFiler.Name)
		if err := averevfxt.DeleteFiler(lastCoreFiler.Name); err != nil {
			return err
		}

		log.Printf("[INFO] add last core filer '%s', with fixed quota", lastCoreFiler.Name)
		if err := createCoreFilerWithFixedQuota(lastCoreFiler, averevfxt); err != nil {
			return err
		}
	}

	// add the custom settings, after core filers and fixed quota percent has been added
	// the custom settings are added after all core filers are added because they are slow to add,
	// and could slow down the rebalancing
	if err := addCustomSettings(corefilers, averevfxt); err != nil {
		return err
	}

	// restore speed of dynamic block allocation and remove all cpolicyActive settings
	if err := finishFixedQuotaPercent(corefilers, averevfxt); err != nil {
		return fmt.Errorf("error encountered while starting setting of fixed quota: %v", err)
	}

	return nil
}