miscellaneous qemu cleanup. Fix generator strings; generate code
fix diskimage logic linting fix tests
This commit is contained in:
parent
3577c4a283
commit
83ee4e7d13
|
@ -1,6 +1,3 @@
|
|||
//go:generate struct-markdown
|
||||
//go:generate mapstructure-to-hcl2 -type Config
|
||||
|
||||
package qemu
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
//go:generate struct-markdown
|
||||
//go:generate mapstructure-to-hcl2 -type Config
|
||||
|
||||
package qemu
|
||||
|
||||
import (
|
||||
|
|
|
@ -519,9 +519,15 @@ func TestBuilderPrepare_SSHPrivateKey(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test good contents
|
||||
tf.Seek(0, 0)
|
||||
tf.Truncate(0)
|
||||
tf.Write([]byte(testPem))
|
||||
if _, err := tf.Seek(0, 0); err != nil {
|
||||
t.Fatalf("errorf getting key")
|
||||
}
|
||||
if err := tf.Truncate(0); err != nil {
|
||||
t.Fatalf("errorf getting key")
|
||||
}
|
||||
if _, err := tf.Write([]byte(testPem)); err != nil {
|
||||
t.Fatalf("errorf getting key")
|
||||
}
|
||||
config["ssh_private_key_file"] = tf.Name()
|
||||
c = Config{}
|
||||
warns, err = c.Prepare(config)
|
||||
|
|
|
@ -35,7 +35,7 @@ func (s *stepRun) Run(ctx context.Context, state multistep.StateBag) multistep.S
|
|||
// installation CD or a pre-baked image
|
||||
bootDrive := "once=d"
|
||||
message := "Starting VM, booting from CD-ROM"
|
||||
if !s.DiskImage {
|
||||
if s.DiskImage {
|
||||
bootDrive = "c"
|
||||
message = "Starting VM, booting disk image"
|
||||
}
|
||||
|
|
|
@ -76,9 +76,11 @@ func Test_CDFilesPath(t *testing.T) {
|
|||
"-machine", "type=,accel=",
|
||||
"-device", ",netdev=user.0",
|
||||
"-drive", "file=/path/to/test.iso,index=0,media=cdrom",
|
||||
"-drive", "file=fake_cd_path.iso,index=1,media=cdrom ",
|
||||
"-drive", "file=fake_cd_path.iso,index=1,media=cdrom",
|
||||
}
|
||||
|
||||
assert.ElementsMatch(t, args, expected, fmt.Sprintf("unexpected generated args: %#v", args))
|
||||
|
||||
// cd_path is set and DiskImage is true
|
||||
config := &Config{
|
||||
DiskImage: true,
|
||||
|
|
|
@ -21,15 +21,15 @@ import (
|
|||
type stepWaitGuestAddress struct {
|
||||
CommunicatorType string
|
||||
NetBridge string
|
||||
timeout time.Duration
|
||||
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func (s *stepWaitGuestAddress) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
config := state.Get("config").(*Config)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
if s.CommunicatorType == "none" {
|
||||
ui.Message("Not using a communicator -- skipping StepWaitGuestAddress")
|
||||
ui.Message("No communicator is configured -- skipping StepWaitGuestAddress")
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
if s.NetBridge == "" {
|
||||
|
@ -41,9 +41,9 @@ func (s *stepWaitGuestAddress) Run(ctx context.Context, state multistep.StateBag
|
|||
ctx, cancel := context.WithTimeout(ctx, s.timeout)
|
||||
defer cancel()
|
||||
|
||||
ui.Say(fmt.Sprintf("Waiting for the guest address to become available in the %s network bridge...", config.NetBridge))
|
||||
ui.Say(fmt.Sprintf("Waiting for the guest address to become available in the %s network bridge...", s.NetBridge))
|
||||
for {
|
||||
guestAddress := getGuestAddress(qmpMonitor, config.NetBridge, "user.0")
|
||||
guestAddress := getGuestAddress(qmpMonitor, s.NetBridge, "user.0")
|
||||
if guestAddress != "" {
|
||||
log.Printf("Found guest address %s", guestAddress)
|
||||
state.Put("guestAddress", guestAddress)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!-- Code generated from the comments of the Config struct in builder/qemu/builder.go; DO NOT EDIT MANUALLY -->
|
||||
<!-- Code generated from the comments of the Config struct in builder/qemu/config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `iso_skip_cache` (bool) - Use iso from provided url. Qemu must support
|
||||
curl block device. This defaults to `false`.
|
||||
|
|
Loading…
Reference in New Issue