github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/provider/openstack/provider_configurator.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package openstack
     5  
     6  import (
     7  	"github.com/juju/schema"
     8  	"gopkg.in/goose.v1/nova"
     9  
    10  	"github.com/juju/juju/cloudconfig/cloudinit"
    11  	"github.com/juju/juju/environs"
    12  )
    13  
    14  // This interface is added to allow to customize openstack provider behaviour.
    15  // This is used in other providers, that embeds openstack provider.
    16  type ProviderConfigurator interface {
    17  	// GetConfigDefaults sets some configuration default values, if any
    18  	GetConfigDefaults() schema.Defaults
    19  
    20  	// This method allows to adjust defult RunServerOptions, before new server is actually created.
    21  	ModifyRunServerOptions(options *nova.RunServerOpts)
    22  
    23  	// This method provides default cloud config.
    24  	// This config can be different for different providers.
    25  	GetCloudConfig(args environs.StartInstanceParams) (cloudinit.CloudConfig, error)
    26  }
    27  
    28  type defaultConfigurator struct {
    29  }
    30  
    31  // ModifyRunServerOptions implements ProviderConfigurator interface.
    32  func (c *defaultConfigurator) ModifyRunServerOptions(options *nova.RunServerOpts) {
    33  }
    34  
    35  // GetCloudConfig implements ProviderConfigurator interface.
    36  func (c *defaultConfigurator) GetCloudConfig(args environs.StartInstanceParams) (cloudinit.CloudConfig, error) {
    37  	return nil, nil
    38  }
    39  
    40  // GetConfigDefaults implements ProviderConfigurator interface.
    41  func (c *defaultConfigurator) GetConfigDefaults() schema.Defaults {
    42  	return schema.Defaults{
    43  		"use-floating-ip":      false,
    44  		"use-default-secgroup": false,
    45  		"network":              "",
    46  	}
    47  }