Merge pull request #6532 from sermilrod/Allowing-fixed-port-in-forwarding-rules

Cloudstack builder: adding public_ssh_port flag to use a fixed port in the forwarding rules
This commit is contained in:
Rickard von Essen 2018-08-22 14:27:38 +02:00 committed by GitHub
commit 057a635cab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -38,6 +38,7 @@ type Config struct {
Network string `mapstructure:"network"`
Project string `mapstructure:"project"`
PublicIPAddress string `mapstructure:"public_ip_address"`
PublicPort int `mapstructure:"public_port"`
SecurityGroups []string `mapstructure:"security_groups"`
ServiceOffering string `mapstructure:"service_offering"`
PreventFirewallChanges bool `mapstructure:"prevent_firewall_changes"`

View File

@ -31,9 +31,13 @@ func (s *stepSetupNetworking) Run(_ context.Context, state multistep.StateBag) m
return multistep.ActionContinue
}
// Generate a random public port used to configure our port forward.
rand.Seed(time.Now().UnixNano())
s.publicPort = 50000 + rand.Intn(10000)
if config.PublicPort != 0 {
s.publicPort = config.PublicPort
} else {
// Generate a random public port used to configure our port forward.
rand.Seed(time.Now().UnixNano())
s.publicPort = 50000 + rand.Intn(10000)
}
state.Put("commPort", s.publicPort)
// Set the currently configured port to be the private port.

View File

@ -126,6 +126,10 @@ builder.
connecting any provisioners to. If not provided, a temporary public IP
address will be associated and released during the Packer run.
- `public_port` (number) - The fixed port you want to configure in the port
forwarding rule. Set this attribute if you do not want to use the a random
public port.
- `security_groups` (array of strings) - A list of security group IDs or names
to associate the instance with.