Merge pull request #5932 from hashicorp/add_configurable_snapshot_timeout
add configurable snapshot timeout to oracle-classic builder
This commit is contained in:
commit
9e8e376d6c
|
@ -6,6 +6,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/common"
|
"github.com/hashicorp/packer/common"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
|
@ -27,10 +28,11 @@ type Config struct {
|
||||||
apiEndpointURL *url.URL
|
apiEndpointURL *url.URL
|
||||||
|
|
||||||
// Image
|
// Image
|
||||||
ImageName string `mapstructure:"image_name"`
|
ImageName string `mapstructure:"image_name"`
|
||||||
Shape string `mapstructure:"shape"`
|
Shape string `mapstructure:"shape"`
|
||||||
SourceImageList string `mapstructure:"source_image_list"`
|
SourceImageList string `mapstructure:"source_image_list"`
|
||||||
DestImageList string `mapstructure:"dest_image_list"`
|
SnapshotTimeout time.Duration `mapstructure:"snapshot_timeout"`
|
||||||
|
DestImageList string `mapstructure:"dest_image_list"`
|
||||||
// Attributes and Atributes file are both optional and mutually exclusive.
|
// Attributes and Atributes file are both optional and mutually exclusive.
|
||||||
Attributes string `mapstructure:"attributes"`
|
Attributes string `mapstructure:"attributes"`
|
||||||
AttributesFile string `mapstructure:"attributes_file"`
|
AttributesFile string `mapstructure:"attributes_file"`
|
||||||
|
@ -71,6 +73,10 @@ func NewConfig(raws ...interface{}) (*Config, error) {
|
||||||
c.Comm.SSHUsername = "opc"
|
c.Comm.SSHUsername = "opc"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.SnapshotTimeout == 0 {
|
||||||
|
c.SnapshotTimeout = 20 * time.Minute
|
||||||
|
}
|
||||||
|
|
||||||
// Validate that all required fields are present
|
// Validate that all required fields are present
|
||||||
var errs *packer.MultiError
|
var errs *packer.MultiError
|
||||||
required := map[string]string{
|
required := map[string]string{
|
||||||
|
|
|
@ -3,7 +3,6 @@ package classic
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/hashicorp/go-oracle-terraform/compute"
|
"github.com/hashicorp/go-oracle-terraform/compute"
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
|
@ -30,7 +29,7 @@ func (s *stepSnapshot) Run(_ context.Context, state multistep.StateBag) multiste
|
||||||
snapshotInput := &compute.CreateSnapshotInput{
|
snapshotInput := &compute.CreateSnapshotInput{
|
||||||
Instance: fmt.Sprintf("%s/%s", config.ImageName, instanceID),
|
Instance: fmt.Sprintf("%s/%s", config.ImageName, instanceID),
|
||||||
MachineImage: config.ImageName,
|
MachineImage: config.ImageName,
|
||||||
Timeout: time.Minute * 20,
|
Timeout: config.SnapshotTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
snap, err := snapshotClient.CreateSnapshot(snapshotInput)
|
snap, err := snapshotClient.CreateSnapshot(snapshotInput)
|
||||||
|
|
|
@ -309,12 +309,14 @@ func (d *VmwareDriver) GuestIP(state multistep.StateBag) (string, error) {
|
||||||
|
|
||||||
// grab network mapper
|
// grab network mapper
|
||||||
netmap, err := d.NetworkMapper()
|
netmap, err := d.NetworkMapper()
|
||||||
|
log.Printf("MEGAN: NEtworkMapper is %#v", netmap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert the stashed network to a device
|
// convert the stashed network to a device
|
||||||
network := state.Get("vmnetwork").(string)
|
network := state.Get("vmnetwork").(string)
|
||||||
|
log.Printf("MEGAN: network is %#v", network)
|
||||||
device, err := netmap.NameIntoDevice(network)
|
device, err := netmap.NameIntoDevice(network)
|
||||||
|
|
||||||
// we were unable to find the device, maybe it's a custom one...
|
// we were unable to find the device, maybe it's a custom one...
|
||||||
|
@ -337,6 +339,7 @@ func (d *VmwareDriver) GuestIP(state multistep.StateBag) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
log.Printf("MEGAN mac address is %s", MACAddress)
|
||||||
|
|
||||||
// figure out the correct dhcp leases
|
// figure out the correct dhcp leases
|
||||||
dhcpLeasesPath := d.DhcpLeasesPath(device)
|
dhcpLeasesPath := d.DhcpLeasesPath(device)
|
||||||
|
|
|
@ -84,6 +84,14 @@ This builder currently only works with the SSH communicator.
|
||||||
|
|
||||||
- `image_name` (string) - The name to assign to the resulting custom image.
|
- `image_name` (string) - The name to assign to the resulting custom image.
|
||||||
|
|
||||||
|
- `snapshot_timeout` (string) - How long to wait for a snapshot to be
|
||||||
|
created. Expects a positive golang Time.Duration string, which is
|
||||||
|
a sequence of decimal numbers and a unit suffix; valid suffixes are `ns`
|
||||||
|
(nanoseconds), `us` (microseconds), `ms` (milliseconds), `s` (seconds), `m`
|
||||||
|
(minutes), and `h` (hours). Examples of valid inputs: `100ms`, `250ms`, `1s`,
|
||||||
|
`2.5s`, `2.5m`, `1m30s`.
|
||||||
|
Example: `"snapshot_timeout": "15m"`. Default: `20m`.
|
||||||
|
|
||||||
## Basic Example
|
## Basic Example
|
||||||
|
|
||||||
Here is a basic example. Note that account specific configuration has been
|
Here is a basic example. Note that account specific configuration has been
|
||||||
|
|
Loading…
Reference in New Issue