github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/provider/rackspace/provider_configurator.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package rackspace
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  	"github.com/juju/schema"
     9  	"gopkg.in/goose.v1/nova"
    10  
    11  	"github.com/juju/juju/cloudconfig/cloudinit"
    12  	"github.com/juju/juju/environs"
    13  )
    14  
    15  type rackspaceConfigurator struct {
    16  }
    17  
    18  // ModifyRunServerOptions implements ProviderConfigurator interface.
    19  func (c *rackspaceConfigurator) ModifyRunServerOptions(options *nova.RunServerOpts) {
    20  	// More on how ConfigDrive option is used on rackspace:
    21  	// http://docs.rackspace.com/servers/api/v2/cs-devguide/content/config_drive_ext.html
    22  	options.ConfigDrive = true
    23  }
    24  
    25  // GetCloudConfig implements ProviderConfigurator interface.
    26  func (c *rackspaceConfigurator) GetCloudConfig(args environs.StartInstanceParams) (cloudinit.CloudConfig, error) {
    27  	cloudcfg, err := cloudinit.New(args.Tools.OneSeries())
    28  	if err != nil {
    29  		return nil, errors.Trace(err)
    30  	}
    31  	// Additional package required for sshInstanceConfigurator, to save
    32  	// iptables state between restarts.
    33  	cloudcfg.AddPackage("iptables-persistent")
    34  	return cloudcfg, nil
    35  }
    36  
    37  // GetConfigDefaults implements ProviderConfigurator interface.
    38  func (c *rackspaceConfigurator) GetConfigDefaults() schema.Defaults {
    39  	return schema.Defaults{
    40  		"use-floating-ip":      false,
    41  		"use-default-secgroup": false,
    42  		"network":              "",
    43  	}
    44  }