Merge pull request #1261 from lflux/openstack-networks-support
Add ability to configure networks for openstack
This commit is contained in:
commit
a0caa635fa
|
@ -92,6 +92,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
Flavor: b.config.Flavor,
|
Flavor: b.config.Flavor,
|
||||||
SourceImage: b.config.SourceImage,
|
SourceImage: b.config.SourceImage,
|
||||||
SecurityGroups: b.config.SecurityGroups,
|
SecurityGroups: b.config.SecurityGroups,
|
||||||
|
Networks: b.config.Networks,
|
||||||
},
|
},
|
||||||
&StepAllocateIp{
|
&StepAllocateIp{
|
||||||
FloatingIpPool: b.config.FloatingIpPool,
|
FloatingIpPool: b.config.FloatingIpPool,
|
||||||
|
|
|
@ -20,6 +20,7 @@ type RunConfig struct {
|
||||||
FloatingIpPool string `mapstructure:"floating_ip_pool"`
|
FloatingIpPool string `mapstructure:"floating_ip_pool"`
|
||||||
FloatingIp string `mapstructure:"floating_ip"`
|
FloatingIp string `mapstructure:"floating_ip"`
|
||||||
SecurityGroups []string `mapstructure:"security_groups"`
|
SecurityGroups []string `mapstructure:"security_groups"`
|
||||||
|
Networks []string `mapstructure:"networks"`
|
||||||
|
|
||||||
// Unexported fields that are calculated from others
|
// Unexported fields that are calculated from others
|
||||||
sshTimeout time.Duration
|
sshTimeout time.Duration
|
||||||
|
|
|
@ -13,6 +13,7 @@ type StepRunSourceServer struct {
|
||||||
Name string
|
Name string
|
||||||
SourceImage string
|
SourceImage string
|
||||||
SecurityGroups []string
|
SecurityGroups []string
|
||||||
|
Networks []string
|
||||||
|
|
||||||
server *gophercloud.Server
|
server *gophercloud.Server
|
||||||
}
|
}
|
||||||
|
@ -30,12 +31,18 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
|
||||||
securityGroups[i]["name"] = groupName
|
securityGroups[i]["name"] = groupName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networks := make([]gophercloud.NetworkConfig, len(s.Networks))
|
||||||
|
for i, networkUuid := range s.Networks {
|
||||||
|
networks[i].Uuid = networkUuid
|
||||||
|
}
|
||||||
|
|
||||||
server := gophercloud.NewServer{
|
server := gophercloud.NewServer{
|
||||||
Name: s.Name,
|
Name: s.Name,
|
||||||
ImageRef: s.SourceImage,
|
ImageRef: s.SourceImage,
|
||||||
FlavorRef: s.Flavor,
|
FlavorRef: s.Flavor,
|
||||||
KeyPairName: keyName,
|
KeyPairName: keyName,
|
||||||
SecurityGroup: securityGroups,
|
SecurityGroup: securityGroups,
|
||||||
|
Networks: networks,
|
||||||
}
|
}
|
||||||
|
|
||||||
serverResp, err := csp.CreateServer(server)
|
serverResp, err := csp.CreateServer(server)
|
||||||
|
|
|
@ -69,6 +69,9 @@ each category, the available configuration keys are alphabetized.
|
||||||
* `insecure` (boolean) - Whether or not the connection to OpenStack can be done
|
* `insecure` (boolean) - Whether or not the connection to OpenStack can be done
|
||||||
over an insecure connection. By default this is false.
|
over an insecure connection. By default this is false.
|
||||||
|
|
||||||
|
* `networks` (array of strings) - A list of networks by UUID to attach
|
||||||
|
to this instance.
|
||||||
|
|
||||||
* `openstack_provider` (string)
|
* `openstack_provider` (string)
|
||||||
<!---
|
<!---
|
||||||
@todo document me
|
@todo document me
|
||||||
|
@ -89,7 +92,6 @@ each category, the available configuration keys are alphabetized.
|
||||||
<!---
|
<!---
|
||||||
@todo document me
|
@todo document me
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `security_groups` (array of strings) - A list of security groups by name
|
* `security_groups` (array of strings) - A list of security groups by name
|
||||||
to add to this instance.
|
to add to this instance.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue