Commit c0069699 authored by Ian Delahorne's avatar Ian Delahorne

Add ability to configure networks for openstack

Add configuration option `networks`, a list of network UUIDs, to attach to the
source instance.

In some openstack installs, no default network will be attached or the network
with the ability to attach a public floating IP will need to be specified.
parent be56b5a6
......@@ -92,6 +92,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Flavor: b.config.Flavor,
SourceImage: b.config.SourceImage,
SecurityGroups: b.config.SecurityGroups,
Networks: b.config.Networks,
},
&StepAllocateIp{
FloatingIpPool: b.config.FloatingIpPool,
......
......@@ -20,6 +20,7 @@ type RunConfig struct {
FloatingIpPool string `mapstructure:"floating_ip_pool"`
FloatingIp string `mapstructure:"floating_ip"`
SecurityGroups []string `mapstructure:"security_groups"`
Networks []string `mapstructure:"networks"`
// Unexported fields that are calculated from others
sshTimeout time.Duration
......
......@@ -13,6 +13,7 @@ type StepRunSourceServer struct {
Name string
SourceImage string
SecurityGroups []string
Networks []string
server *gophercloud.Server
}
......@@ -30,12 +31,18 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
securityGroups[i]["name"] = groupName
}
networks := make([]gophercloud.NetworkConfig, len(s.Networks))
for i, networkUuid := range s.Networks {
networks[i].Uuid = networkUuid
}
server := gophercloud.NewServer{
Name: s.Name,
ImageRef: s.SourceImage,
FlavorRef: s.Flavor,
KeyPairName: keyName,
SecurityGroup: securityGroups,
Networks: networks,
}
serverResp, err := csp.CreateServer(server)
......
......@@ -89,6 +89,8 @@ each category, the available configuration keys are alphabetized.
<!---
@todo document me
-->
* `networks` (array of strings) - A list of networks by UUID to attach
to this instance.
* `security_groups` (array of strings) - A list of security groups by name
to add to this instance.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment