From 89b9b4c456a59124a4e0f46789e0779ca0b39e1a Mon Sep 17 00:00:00 2001 From: Rickard von Essen Date: Fri, 14 Jul 2017 07:50:54 +0200 Subject: [PATCH] cloudstack: Add default cidr_list [ 0.0.0.0/0 ] --- builder/cloudstack/config.go | 8 ++++---- builder/cloudstack/config_test.go | 2 +- website/source/docs/builders/cloudstack.html.md | 11 +++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/builder/cloudstack/config.go b/builder/cloudstack/config.go index a7193adf2..c662a4571 100644 --- a/builder/cloudstack/config.go +++ b/builder/cloudstack/config.go @@ -83,6 +83,10 @@ func NewConfig(raws ...interface{}) (*Config, error) { c.AsyncTimeout = 30 * time.Minute } + if len(c.CIDRList) == 0 && !c.UseLocalIPAddress { + c.CIDRList = []string{"0.0.0.0/0"} + } + if c.InstanceName == "" { c.InstanceName = fmt.Sprintf("packer-%s", uuid.TimeOrderedUUID()) } @@ -114,10 +118,6 @@ func NewConfig(raws ...interface{}) (*Config, error) { errs = packer.MultiErrorAppend(errs, errors.New("a secret_key must be specified")) } - if len(c.CIDRList) == 0 && !c.UseLocalIPAddress { - errs = packer.MultiErrorAppend(errs, errors.New("a cidr_list must be specified")) - } - if c.Network == "" { errs = packer.MultiErrorAppend(errs, errors.New("a network must be specified")) } diff --git a/builder/cloudstack/config_test.go b/builder/cloudstack/config_test.go index ea98ad70d..54fb3248a 100644 --- a/builder/cloudstack/config_test.go +++ b/builder/cloudstack/config_test.go @@ -38,7 +38,7 @@ func TestNewConfig(t *testing.T) { "source_template": "d31e6af5-94a8-4756-abf3-6493c38db7e5", }, Nullify: "cidr_list", - Err: true, + Err: false, }, "no_cidr_list_with_use_local_ip_address": { Config: map[string]interface{}{ diff --git a/website/source/docs/builders/cloudstack.html.md b/website/source/docs/builders/cloudstack.html.md index f6a5fa9dd..eeba7e3c9 100644 --- a/website/source/docs/builders/cloudstack.html.md +++ b/website/source/docs/builders/cloudstack.html.md @@ -37,11 +37,6 @@ builder. - `api_key` (string) - The API key used to sign all API requests. -- `cidr_list` (array) - List of CIDR's that will have access to the new - instance. This is needed in order for any provisioners to be able to - connect to the instance. Usually this will be the NAT address of your - current location. Only required when `use_local_ip_address` is `false`. - - `instance_name` (string) - The name of the instance. Defaults to "packer-UUID" where UUID is dynamically generated. @@ -76,6 +71,11 @@ builder. - `async_timeout` (int) - The time duration to wait for async calls to finish. Defaults to 30m. +- `cidr_list` (array) - List of CIDR's that will have access to the new + instance. This is needed in order for any provisioners to be able to + connect to the instance. Defaults to `[ "0.0.0.0/0" ]`. Only required + when `use_local_ip_address` is `false`. + - `disk_offering` (string) - The name or ID of the disk offering used for the instance. This option is only available (and also required) when using `source_iso`. @@ -161,7 +161,6 @@ Here is a basic example. "secret_key": "YOUR_SECRET_KEY", "disk_offering": "Small - 20GB", - "cidr_list": ["0.0.0.0/0"], "hypervisor": "KVM", "network": "management", "service_offering": "small",