Add support for cd_files
in addition to floppy_files
At least the Ubuntu 24.04 server ISO hangs for 5 minutes when booting with a Xen-provided floppy drive. The primary purpose of floppy_files is to provide the autoinstall config files, and cloud-init is happy to find those files on an inserted CD instead. Add the ability for packer-plugin-xenserver to create such a CD.
This commit is contained in:
parent
756f4d7e1a
commit
65ae17abd3
@ -22,6 +22,7 @@ type CommonConfig struct {
|
|||||||
VMDescription string `mapstructure:"vm_description"`
|
VMDescription string `mapstructure:"vm_description"`
|
||||||
SrName string `mapstructure:"sr_name"`
|
SrName string `mapstructure:"sr_name"`
|
||||||
SrISOName string `mapstructure:"sr_iso_name" required:"false"`
|
SrISOName string `mapstructure:"sr_iso_name" required:"false"`
|
||||||
|
CDFiles []string `mapstructure:"cd_files"`
|
||||||
FloppyFiles []string `mapstructure:"floppy_files"`
|
FloppyFiles []string `mapstructure:"floppy_files"`
|
||||||
NetworkNames []string `mapstructure:"network_names"`
|
NetworkNames []string `mapstructure:"network_names"`
|
||||||
ExportNetworkNames []string `mapstructure:"export_network_names"`
|
ExportNetworkNames []string `mapstructure:"export_network_names"`
|
||||||
|
@ -26,6 +26,7 @@ type FlatConfig struct {
|
|||||||
VMDescription *string `mapstructure:"vm_description" cty:"vm_description" hcl:"vm_description"`
|
VMDescription *string `mapstructure:"vm_description" cty:"vm_description" hcl:"vm_description"`
|
||||||
SrName *string `mapstructure:"sr_name" cty:"sr_name" hcl:"sr_name"`
|
SrName *string `mapstructure:"sr_name" cty:"sr_name" hcl:"sr_name"`
|
||||||
SrISOName *string `mapstructure:"sr_iso_name" required:"false" cty:"sr_iso_name" hcl:"sr_iso_name"`
|
SrISOName *string `mapstructure:"sr_iso_name" required:"false" cty:"sr_iso_name" hcl:"sr_iso_name"`
|
||||||
|
CDFiles []string `mapstructure:"cd_files" cty:"cd_files" hcl:"cd_files"`
|
||||||
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files" hcl:"floppy_files"`
|
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files" hcl:"floppy_files"`
|
||||||
NetworkNames []string `mapstructure:"network_names" cty:"network_names" hcl:"network_names"`
|
NetworkNames []string `mapstructure:"network_names" cty:"network_names" hcl:"network_names"`
|
||||||
ExportNetworkNames []string `mapstructure:"export_network_names" cty:"export_network_names" hcl:"export_network_names"`
|
ExportNetworkNames []string `mapstructure:"export_network_names" cty:"export_network_names" hcl:"export_network_names"`
|
||||||
@ -142,6 +143,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"vm_description": &hcldec.AttrSpec{Name: "vm_description", Type: cty.String, Required: false},
|
"vm_description": &hcldec.AttrSpec{Name: "vm_description", Type: cty.String, Required: false},
|
||||||
"sr_name": &hcldec.AttrSpec{Name: "sr_name", Type: cty.String, Required: false},
|
"sr_name": &hcldec.AttrSpec{Name: "sr_name", Type: cty.String, Required: false},
|
||||||
"sr_iso_name": &hcldec.AttrSpec{Name: "sr_iso_name", Type: cty.String, Required: false},
|
"sr_iso_name": &hcldec.AttrSpec{Name: "sr_iso_name", Type: cty.String, Required: false},
|
||||||
|
"cd_files": &hcldec.AttrSpec{Name: "cd_files", Type: cty.List(cty.String), Required: false},
|
||||||
"floppy_files": &hcldec.AttrSpec{Name: "floppy_files", Type: cty.List(cty.String), Required: false},
|
"floppy_files": &hcldec.AttrSpec{Name: "floppy_files", Type: cty.List(cty.String), Required: false},
|
||||||
"network_names": &hcldec.AttrSpec{Name: "network_names", Type: cty.List(cty.String), Required: false},
|
"network_names": &hcldec.AttrSpec{Name: "network_names", Type: cty.List(cty.String), Required: false},
|
||||||
"export_network_names": &hcldec.AttrSpec{Name: "export_network_names", Type: cty.List(cty.String), Required: false},
|
"export_network_names": &hcldec.AttrSpec{Name: "export_network_names", Type: cty.List(cty.String), Required: false},
|
||||||
|
@ -195,6 +195,10 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
Force: self.config.PackerForce,
|
Force: self.config.PackerForce,
|
||||||
Path: self.config.OutputDir,
|
Path: self.config.OutputDir,
|
||||||
},
|
},
|
||||||
|
&commonsteps.StepCreateCD{
|
||||||
|
Files: self.config.CDFiles,
|
||||||
|
Label: "cidata",
|
||||||
|
},
|
||||||
&commonsteps.StepCreateFloppy{
|
&commonsteps.StepCreateFloppy{
|
||||||
Files: self.config.FloppyFiles,
|
Files: self.config.FloppyFiles,
|
||||||
Label: "cidata",
|
Label: "cidata",
|
||||||
@ -202,6 +206,18 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
&xscommon.StepHTTPServer{
|
&xscommon.StepHTTPServer{
|
||||||
Chan: httpReqChan,
|
Chan: httpReqChan,
|
||||||
},
|
},
|
||||||
|
&xscommon.StepUploadVdi{
|
||||||
|
VdiNameFunc: func() string {
|
||||||
|
return "Packer-CD"
|
||||||
|
},
|
||||||
|
ImagePathFunc: func() string {
|
||||||
|
if cdPath, ok := state.GetOk("cd_path"); ok {
|
||||||
|
return cdPath.(string)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
},
|
||||||
|
VdiUuidKey: "cd_vdi_uuid",
|
||||||
|
},
|
||||||
&xscommon.StepUploadVdi{
|
&xscommon.StepUploadVdi{
|
||||||
VdiNameFunc: func() string {
|
VdiNameFunc: func() string {
|
||||||
return "Packer-floppy-disk"
|
return "Packer-floppy-disk"
|
||||||
@ -258,6 +274,10 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
VdiUuidKey: "tools_vdi_uuid",
|
VdiUuidKey: "tools_vdi_uuid",
|
||||||
VdiType: xsclient.VbdTypeCD,
|
VdiType: xsclient.VbdTypeCD,
|
||||||
},
|
},
|
||||||
|
&xscommon.StepAttachVdi{
|
||||||
|
VdiUuidKey: "cd_vdi_uuid",
|
||||||
|
VdiType: xsclient.VbdTypeCD,
|
||||||
|
},
|
||||||
new(xscommon.StepStartVmPaused),
|
new(xscommon.StepStartVmPaused),
|
||||||
new(xscommon.StepSetVmHostSshAddress),
|
new(xscommon.StepSetVmHostSshAddress),
|
||||||
// &xscommon.StepForwardPortOverSSH{
|
// &xscommon.StepForwardPortOverSSH{
|
||||||
@ -307,6 +327,9 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
&xscommon.StepDetachVdi{
|
&xscommon.StepDetachVdi{
|
||||||
VdiUuidKey: "tools_vdi_uuid",
|
VdiUuidKey: "tools_vdi_uuid",
|
||||||
},
|
},
|
||||||
|
&xscommon.StepDetachVdi{
|
||||||
|
VdiUuidKey: "cd_vdi_uuid",
|
||||||
|
},
|
||||||
&xscommon.StepDetachVdi{
|
&xscommon.StepDetachVdi{
|
||||||
VdiUuidKey: "floppy_vdi_uuid",
|
VdiUuidKey: "floppy_vdi_uuid",
|
||||||
},
|
},
|
||||||
|
@ -118,6 +118,10 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
Force: self.config.PackerForce,
|
Force: self.config.PackerForce,
|
||||||
Path: self.config.OutputDir,
|
Path: self.config.OutputDir,
|
||||||
},
|
},
|
||||||
|
&commonsteps.StepCreateCD{
|
||||||
|
Files: self.config.CDFiles,
|
||||||
|
Label: "cidata",
|
||||||
|
},
|
||||||
&commonsteps.StepCreateFloppy{
|
&commonsteps.StepCreateFloppy{
|
||||||
Files: self.config.FloppyFiles,
|
Files: self.config.FloppyFiles,
|
||||||
Label: "cidata",
|
Label: "cidata",
|
||||||
@ -125,6 +129,18 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
&xscommon.StepHTTPServer{
|
&xscommon.StepHTTPServer{
|
||||||
Chan: httpReqChan,
|
Chan: httpReqChan,
|
||||||
},
|
},
|
||||||
|
&xscommon.StepUploadVdi{
|
||||||
|
VdiNameFunc: func() string {
|
||||||
|
return "Packer-CD"
|
||||||
|
},
|
||||||
|
ImagePathFunc: func() string {
|
||||||
|
if cdPath, ok := state.GetOk("cd_path"); ok {
|
||||||
|
return cdPath.(string)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
},
|
||||||
|
VdiUuidKey: "cd_vdi_uuid",
|
||||||
|
},
|
||||||
&xscommon.StepUploadVdi{
|
&xscommon.StepUploadVdi{
|
||||||
VdiNameFunc: func() string {
|
VdiNameFunc: func() string {
|
||||||
return "Packer-floppy-disk"
|
return "Packer-floppy-disk"
|
||||||
@ -153,6 +169,10 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
VdiUuidKey: "tools_vdi_uuid",
|
VdiUuidKey: "tools_vdi_uuid",
|
||||||
VdiType: xsclient.VbdTypeCD,
|
VdiType: xsclient.VbdTypeCD,
|
||||||
},
|
},
|
||||||
|
&xscommon.StepAttachVdi{
|
||||||
|
VdiUuidKey: "cd_vdi_uuid",
|
||||||
|
VdiType: xsclient.VbdTypeCD,
|
||||||
|
},
|
||||||
new(xscommon.StepStartVmPaused),
|
new(xscommon.StepStartVmPaused),
|
||||||
new(xscommon.StepSetVmHostSshAddress),
|
new(xscommon.StepSetVmHostSshAddress),
|
||||||
new(xscommon.StepBootWait),
|
new(xscommon.StepBootWait),
|
||||||
@ -182,6 +202,9 @@ func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (p
|
|||||||
&xscommon.StepDetachVdi{
|
&xscommon.StepDetachVdi{
|
||||||
VdiUuidKey: "tools_vdi_uuid",
|
VdiUuidKey: "tools_vdi_uuid",
|
||||||
},
|
},
|
||||||
|
&xscommon.StepDetachVdi{
|
||||||
|
VdiUuidKey: "cd_vdi_uuid",
|
||||||
|
},
|
||||||
&xscommon.StepDetachVdi{
|
&xscommon.StepDetachVdi{
|
||||||
VdiUuidKey: "floppy_vdi_uuid",
|
VdiUuidKey: "floppy_vdi_uuid",
|
||||||
},
|
},
|
||||||
|
@ -83,6 +83,16 @@ each category, the available options are alphabetized and described.
|
|||||||
five seconds and one minute 30 seconds, respectively. If this isn't specified,
|
five seconds and one minute 30 seconds, respectively. If this isn't specified,
|
||||||
the default is 10 seconds.
|
the default is 10 seconds.
|
||||||
|
|
||||||
|
* `cd_files` (array of strings) - A list of files to place onto a CD
|
||||||
|
that is attached when the VM is booted. This is most useful
|
||||||
|
for unattended Windows installs, which look for an `Autounattend.xml` file
|
||||||
|
on removable media. By default, no CD will be attached. All files
|
||||||
|
listed in this setting get placed into the root directory of the CD
|
||||||
|
and the CD is attached as the first CD device. Currently, no
|
||||||
|
support exists for creating sub-directories on the CD. Wildcard
|
||||||
|
characters (\*, ?, and []) are allowed. Directory names are also allowed,
|
||||||
|
which will add all the files found in the directory to the CD.
|
||||||
|
|
||||||
* `clone_template` (string) - The template to clone. Defaults to "Other install
|
* `clone_template` (string) - The template to clone. Defaults to "Other install
|
||||||
media", this is "other", but you can get _dramatic_ performance improvements
|
media", this is "other", but you can get _dramatic_ performance improvements
|
||||||
by setting this to the proper value. To view all available values for this
|
by setting this to the proper value. To view all available values for this
|
||||||
|
Loading…
Reference in New Issue
Block a user