github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/provider/lxd/environ_policy.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package lxd
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  
     9  	"github.com/juju/juju/core/constraints"
    10  	"github.com/juju/juju/environs"
    11  	"github.com/juju/juju/environs/context"
    12  )
    13  
    14  // PrecheckInstance verifies that the provided series and constraints
    15  // are valid for use in creating an instance in this environment.
    16  func (env *environ) PrecheckInstance(ctx context.ProviderCallContext, args environs.PrecheckInstanceParams) error {
    17  	_, err := env.parsePlacement(ctx, args.Placement)
    18  	return errors.Trace(err)
    19  }
    20  
    21  var unsupportedConstraints = []string{
    22  	constraints.CpuPower,
    23  	constraints.Tags,
    24  	constraints.VirtType,
    25  	constraints.Container,
    26  }
    27  
    28  // ConstraintsValidator returns a Validator value which is used to
    29  // validate and merge constraints.
    30  func (env *environ) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error) {
    31  	validator := constraints.NewValidator()
    32  
    33  	validator.RegisterUnsupported(unsupportedConstraints)
    34  	validator.RegisterVocabulary(constraints.Arch, []string{env.server.HostArch()})
    35  
    36  	return validator, nil
    37  }
    38  
    39  // ShouldApplyControllerConstraints returns if bootstrapping logic should use
    40  // default constraints
    41  func (env *environ) ShouldApplyControllerConstraints() bool {
    42  	return false
    43  }
    44  
    45  // SupportNetworks returns whether the environment has support to
    46  // specify networks for applications and machines.
    47  func (env *environ) SupportNetworks(ctx context.ProviderCallContext) bool {
    48  	return false
    49  }