|
|
|
|
@ -7,46 +7,44 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
|
"github.com/mitchellh/packer/common"
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
|
"log"
|
|
|
|
|
|
|
|
|
|
"github.com/mitchellh/gophercloud-fork-40444fb"
|
|
|
|
|
"github.com/mitchellh/packer/helper/config"
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
|
"github.com/mitchellh/packer/template/interpolate"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// The unique ID for this builder
|
|
|
|
|
const BuilderId = "mitchellh.openstack"
|
|
|
|
|
|
|
|
|
|
type config struct {
|
|
|
|
|
type Config struct {
|
|
|
|
|
common.PackerConfig `mapstructure:",squash"`
|
|
|
|
|
AccessConfig `mapstructure:",squash"`
|
|
|
|
|
ImageConfig `mapstructure:",squash"`
|
|
|
|
|
RunConfig `mapstructure:",squash"`
|
|
|
|
|
|
|
|
|
|
tpl *packer.ConfigTemplate
|
|
|
|
|
ctx interpolate.Context
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Builder struct {
|
|
|
|
|
config config
|
|
|
|
|
config Config
|
|
|
|
|
runner multistep.Runner
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|
|
|
|
md, err := common.DecodeConfig(&b.config, raws...)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b.config.tpl, err = packer.NewConfigTemplate()
|
|
|
|
|
err := config.Decode(&b.config, &config.DecodeOpts{
|
|
|
|
|
Interpolate: true,
|
|
|
|
|
}, raws...)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
b.config.tpl.UserVars = b.config.PackerUserVars
|
|
|
|
|
|
|
|
|
|
// Accumulate any errors
|
|
|
|
|
errs := common.CheckUnusedConfig(md)
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(b.config.tpl)...)
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(b.config.tpl)...)
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(b.config.tpl)...)
|
|
|
|
|
var errs *packer.MultiError
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...)
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
|
|
|
|
|
|
|
|
|
|
if errs != nil && len(errs.Errors) > 0 {
|
|
|
|
|
return nil, errs
|
|
|
|
|
@ -96,7 +94,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
Networks: b.config.Networks,
|
|
|
|
|
},
|
|
|
|
|
&StepWaitForRackConnect{
|
|
|
|
|
Wait: b.config.RackconnectWait,
|
|
|
|
|
Wait: b.config.RackconnectWait,
|
|
|
|
|
},
|
|
|
|
|
&StepAllocateIp{
|
|
|
|
|
FloatingIpPool: b.config.FloatingIpPool,
|
|
|
|
|
|