Addressed all the comments

This commit is contained in:
jasminSPC 2016-08-31 13:55:11 +02:00
parent 1ef326ad68
commit 5caa54acd7
6 changed files with 51 additions and 22 deletions

View File

@ -29,9 +29,9 @@ const testBuilderAccBasic = `
{
"builders": [{
"image": "Ubuntu-16.04",
"password": "password",
"username": "username",
"snapshot_name": "packer",
"pbpassword": "password",
"pbusername": "username",
"servername": "packer",
"type": "profitbricks"
}]
}

View File

@ -9,9 +9,9 @@ import (
func testConfig() map[string]interface{} {
return map[string]interface{}{
"image": "Ubuntu-16.04",
"password": "password",
"username": "username",
"snapshot_name": "packer",
"pbpassword": "password",
"pbusername": "username",
"servername": "packer",
"type": "profitbricks",
}
}
@ -53,4 +53,34 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
if err == nil {
t.Fatal("should have error")
}
}
}
func TestBuilderPrepare_Servername(t *testing.T) {
var b Builder
config := testConfig()
delete(config, "servername")
warnings, err := b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err == nil {
t.Fatalf("should error")
}
expected := "packer"
config["servername"] = expected
b = Builder{}
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.SnapshotName != expected {
t.Errorf("found %s, expected %s", b.config.SnapshotName, expected)
}
}

View File

@ -130,7 +130,7 @@ func (s *stepCreateServer) Cleanup(state multistep.StateBag) {
func (d *stepCreateServer) waitTillProvisioned(path string, config Config) error {
d.setPB(config.PBUsername, config.PBPassword, config.PBUrl)
waitCount := 50
waitCount := 120
if config.Timeout > 0 {
waitCount = config.Timeout
}
@ -142,7 +142,7 @@ func (d *stepCreateServer) waitTillProvisioned(path string, config Config) error
if request.Metadata.Status == "FAILED" {
return errors.New(request.Metadata.Message)
}
time.Sleep(10 * time.Second)
time.Sleep(1 * time.Second)
i++
}
return nil

View File

@ -11,7 +11,7 @@ Type: `profitbricks`
The ProfitBricks Builder is able to create virtual machines for [ProfitBricks](https://www.profitbricks.com).
-> **Note:** This builder is not supported by HashiCorp. Please visit [ProfitBricks DevOps Central](https://devops.profitbricks.com/) for support. You may file issues on [GitHub](https://github.com/profitbricks/docker-machine-driver-profitbricks/issues).
-> **Note:** This builder is not supported by HashiCorp. Please visit [ProfitBricks DevOps Central](https://devops.profitbricks.com/) for support. You may file issues on [GitHub](https://github.com/profitbricks/packer-builder-profitbricks/issues).
## Configuration Reference
@ -25,33 +25,32 @@ builder.
### Required
- `username` (string) - ProfitBricks username. This can be specified via environment variable `PROFITBRICKS_USERNAME', if provided. The value definded in the config has precedence over environemnt variable.
- `image` (string) - ProfitBricks volume image
- `password` (string) - ProfitBrucks password. This can be specified via environment variable `PROFITBRICKS_PASSWORD', if provided. The value definded in the config has precedence over environemnt variable.
- `image` (string) - ProfitBricks volume image
- `username` (string) - ProfitBricks username. This can be specified via environment variable `PROFITBRICKS_USERNAME', if provided. The value definded in the config has precedence over environemnt variable.
### Optional
- `cores` (int) - Amount of CPU cores to use for this build. Defaults to `4`.
- `cores` (integer) - Amount of CPU cores to use for this build. Defaults to "4".
- `disk_size` (string) - Amount of disk space for this image. Defaults to `50gb`
- `disk_size` (string) - Amount of disk space for this image. Defaults to "50gb"
- `disktype` (string) - Type of disk to use for this image. Defaults to `HDD`.
- `disk_type` (string) - Type of disk to use for this image. Defaults to "HDD".
- `ram` (int) - Amount of RAM to use for this image. Defalts to `2048`.
- `location` (string) - Defaults to "us/las".
- `location` (string) - Defaults to `us/las`.
- `ram` (integer) - Amount of RAM to use for this image. Defalts to "2048".
- `snapshot_name` (string) - If snapshot name is not provided Packer will generate it
- `snapshot_password` (string) - ????
- `snapshot_password` (string) - Password for the snapshot.
- `ssh_key_path` (string) - Path to private SSHkey. If no path to the key is provided Packer will create one under the name [snapshot_name]
- `timeout` (string) - An approximate limit on how long Packer will continue making status requests while waiting for the build to complete. Default value 120 seconds.
- `url` (string) - Endpoint for the ProfitBricks REST API
- `timeout` (string) - An approximate limit on how long packer will continue making status requests while waiting for the build to complete. Set this to an integer where 1 equals 10 seconds. Default value 50.
- `url` (string) - Endpoint for the ProfitBricks REST API. Default URL "https://api.profitbricks.com/rest/v2"
## Example