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{
|
&StepRunSourceServer{
|
||||||
Name: b.config.ImageName,
|
Name: b.config.ImageName,
|
||||||
SourceImage: b.config.SourceImage,
|
SourceImage: b.config.SourceImage,
|
||||||
|
SourceImageName: b.config.SourceImageName,
|
||||||
SecurityGroups: b.config.SecurityGroups,
|
SecurityGroups: b.config.SecurityGroups,
|
||||||
Networks: b.config.Networks,
|
Networks: b.config.Networks,
|
||||||
AvailabilityZone: b.config.AvailabilityZone,
|
AvailabilityZone: b.config.AvailabilityZone,
|
||||||
|
|
|
@ -15,6 +15,7 @@ type RunConfig struct {
|
||||||
SSHInterface string `mapstructure:"ssh_interface"`
|
SSHInterface string `mapstructure:"ssh_interface"`
|
||||||
|
|
||||||
SourceImage string `mapstructure:"source_image"`
|
SourceImage string `mapstructure:"source_image"`
|
||||||
|
SourceImageName string `mapstructure:"source_image_name"`
|
||||||
Flavor string `mapstructure:"flavor"`
|
Flavor string `mapstructure:"flavor"`
|
||||||
AvailabilityZone string `mapstructure:"availability_zone"`
|
AvailabilityZone string `mapstructure:"availability_zone"`
|
||||||
RackconnectWait bool `mapstructure:"rackconnect_wait"`
|
RackconnectWait bool `mapstructure:"rackconnect_wait"`
|
||||||
|
@ -42,8 +43,10 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
errs := c.Comm.Prepare(ctx)
|
errs := c.Comm.Prepare(ctx)
|
||||||
if c.SourceImage == "" {
|
if c.SourceImage == "" && c.SourceImageName == "" {
|
||||||
errs = append(errs, errors.New("A source_image must be specified"))
|
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 == "" {
|
if c.Flavor == "" {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
type StepRunSourceServer struct {
|
type StepRunSourceServer struct {
|
||||||
Name string
|
Name string
|
||||||
SourceImage string
|
SourceImage string
|
||||||
|
SourceImageName string
|
||||||
SecurityGroups []string
|
SecurityGroups []string
|
||||||
Networks []string
|
Networks []string
|
||||||
AvailabilityZone string
|
AvailabilityZone string
|
||||||
|
@ -57,6 +58,7 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
|
||||||
CreateOptsBuilder: servers.CreateOpts{
|
CreateOptsBuilder: servers.CreateOpts{
|
||||||
Name: s.Name,
|
Name: s.Name,
|
||||||
ImageRef: s.SourceImage,
|
ImageRef: s.SourceImage,
|
||||||
|
ImageName: s.SourceImageName,
|
||||||
FlavorRef: flavor,
|
FlavorRef: flavor,
|
||||||
SecurityGroups: s.SecurityGroups,
|
SecurityGroups: s.SecurityGroups,
|
||||||
Networks: networks,
|
Networks: networks,
|
||||||
|
|
|
@ -48,6 +48,10 @@ builder.
|
||||||
Unless you specify completely custom SSH settings, the source image must
|
Unless you specify completely custom SSH settings, the source image must
|
||||||
have `cloud-init` installed so that the keypair gets assigned properly.
|
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.
|
- `username` (string) - The username used to connect to the OpenStack service.
|
||||||
If not specified, Packer will use the environment variable `OS_USERNAME`,
|
If not specified, Packer will use the environment variable `OS_USERNAME`,
|
||||||
if set.
|
if set.
|
||||||
|
|
Loading…
Reference in New Issue