github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/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  		"username":             "",
    44  		"password":             "",
    45  		"tenant-name":          "",
    46  		"auth-url":             "",
    47  		"auth-mode":            string(AuthUserPass),
    48  		"access-key":           "",
    49  		"secret-key":           "",
    50  		"region":               "",
    51  		"use-floating-ip":      false,
    52  		"use-default-secgroup": false,
    53  		"network":              "",
    54  	}
    55  }