Support source_image_name in OpenStack builder
As gophercloud supports source_image_name let's allow that in builder configuration also. This an alternative way of providing source_image.
This commit is contained in:
parent
8484c2e2a0
commit
cbb2b538bd
|
@ -83,6 +83,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&StepRunSourceServer{
|
||||
Name: b.config.ImageName,
|
||||
SourceImage: b.config.SourceImage,
|
||||
SourceImageName: b.config.SourceImageName,
|
||||
SecurityGroups: b.config.SecurityGroups,
|
||||
Networks: b.config.Networks,
|
||||
AvailabilityZone: b.config.AvailabilityZone,
|
||||
|
|
|
@ -15,6 +15,7 @@ type RunConfig struct {
|
|||
SSHInterface string `mapstructure:"ssh_interface"`
|
||||
|
||||
SourceImage string `mapstructure:"source_image"`
|
||||
SourceImageName string `mapstructure:"source_image_name"`
|
||||
Flavor string `mapstructure:"flavor"`
|
||||
AvailabilityZone string `mapstructure:"availability_zone"`
|
||||
RackconnectWait bool `mapstructure:"rackconnect_wait"`
|
||||
|
@ -42,8 +43,10 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
|
||||
// Validation
|
||||
errs := c.Comm.Prepare(ctx)
|
||||
if c.SourceImage == "" {
|
||||
errs = append(errs, errors.New("A source_image must be specified"))
|
||||
if c.SourceImage == "" && c.SourceImageName == "" {
|
||||
errs = append(errs, errors.New("Either a source_image or a source_image_name must be specified"))
|
||||
} else if len(c.SourceImage) > 0 && len(c.SourceImageName) > 0 {
|
||||
errs = append(errs, errors.New("Only a source_image or a source_image_name can be specified, not both."))
|
||||
}
|
||||
|
||||
if c.Flavor == "" {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
type StepRunSourceServer struct {
|
||||
Name string
|
||||
SourceImage string
|
||||
SourceImageName string
|
||||
SecurityGroups []string
|
||||
Networks []string
|
||||
AvailabilityZone string
|
||||
|
@ -57,6 +58,7 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
|
|||
CreateOptsBuilder: servers.CreateOpts{
|
||||
Name: s.Name,
|
||||
ImageRef: s.SourceImage,
|
||||
ImageName: s.SourceImageName,
|
||||
FlavorRef: flavor,
|
||||
SecurityGroups: s.SecurityGroups,
|
||||
Networks: networks,
|
||||
|
|
|
@ -48,6 +48,10 @@ builder.
|
|||
Unless you specify completely custom SSH settings, the source image must
|
||||
have `cloud-init` installed so that the keypair gets assigned properly.
|
||||
|
||||
- `source_image_name` (string) - The name of the base image to use. This
|
||||
is an alternative way of providig `source_image` and only either of them
|
||||
can be specified.
|
||||
|
||||
- `username` (string) - The username used to connect to the OpenStack service.
|
||||
If not specified, Packer will use the environment variable `OS_USERNAME`,
|
||||
if set.
|
||||
|
|
Loading…
Reference in New Issue