github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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 "github.com/juju/juju/provider/openstack" 14 ) 15 16 type rackspaceConfigurator struct { 17 } 18 19 // ModifyRunServerOptions implements ProviderConfigurator interface. 20 func (c *rackspaceConfigurator) ModifyRunServerOptions(options *nova.RunServerOpts) { 21 // More on how ConfigDrive option is used on rackspace: 22 // http://docs.rackspace.com/servers/api/v2/cs-devguide/content/config_drive_ext.html 23 options.ConfigDrive = true 24 } 25 26 // GetCloudConfig implements ProviderConfigurator interface. 27 func (c *rackspaceConfigurator) GetCloudConfig(args environs.StartInstanceParams) (cloudinit.CloudConfig, error) { 28 cloudcfg, err := cloudinit.New(args.Tools.OneSeries()) 29 if err != nil { 30 return nil, errors.Trace(err) 31 } 32 // Additional package required for sshInstanceConfigurator, to save 33 // iptables state between restarts. 34 cloudcfg.AddPackage("iptables-persistent") 35 return cloudcfg, nil 36 } 37 38 // GetConfigDefaults implements ProviderConfigurator interface. 39 func (c *rackspaceConfigurator) GetConfigDefaults() schema.Defaults { 40 return schema.Defaults{ 41 "username": "", 42 "password": "", 43 "tenant-name": "", 44 "auth-url": "https://identity.api.rackspacecloud.com/v2.0", 45 "auth-mode": string(openstack.AuthUserPass), 46 "access-key": "", 47 "secret-key": "", 48 "region": "", 49 "use-floating-ip": false, 50 "use-default-secgroup": false, 51 "network": "", 52 } 53 }