WIP to fix a suspected issue with packer-sdc validate

This commit is contained in:
Dom Del Nano 2023-04-23 05:40:46 -07:00
parent bea09bb3ed
commit 434a5868e1
7 changed files with 13 additions and 13 deletions

View File

@ -13,9 +13,9 @@ import (
) )
type CommonConfig struct { type CommonConfig struct {
Username string `mapstructure:"remote_username"` XSUsername string `mapstructure:"remote_username"`
Password string `mapstructure:"remote_password"` XSPassword string `mapstructure:"remote_password"`
HostIp string `mapstructure:"remote_host"` HostIp string `mapstructure:"remote_host"`
VMName string `mapstructure:"vm_name"` VMName string `mapstructure:"vm_name"`
VMDescription string `mapstructure:"vm_description"` VMDescription string `mapstructure:"vm_description"`
@ -136,11 +136,11 @@ func (c *CommonConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig
// Validation // Validation
if c.Username == "" { if c.XSUsername == "" {
errs = append(errs, errors.New("remote_username must be specified.")) errs = append(errs, errors.New("remote_username must be specified."))
} }
if c.Password == "" { if c.XSPassword == "" {
errs = append(errs, errors.New("remote_password must be specified.")) errs = append(errs, errors.New("remote_password must be specified."))
} }

View File

@ -12,7 +12,7 @@ import (
type Config struct { type Config struct {
common.PackerConfig `mapstructure:",squash"` common.PackerConfig `mapstructure:",squash"`
CommonConfig `mapstructure:",squash"` CommonConfig `mapstructure:",squash"`
Comm communicator.Config `mapstructure:",squash"` communicator.Config `mapstructure:",squash"`
VCPUsMax uint `mapstructure:"vcpus_max"` VCPUsMax uint `mapstructure:"vcpus_max"`
VCPUsAtStartup uint `mapstructure:"vcpus_atstartup"` VCPUsAtStartup uint `mapstructure:"vcpus_atstartup"`

View File

@ -18,8 +18,8 @@ type FlatConfig struct {
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
Username *string `mapstructure:"remote_username" cty:"remote_username" hcl:"remote_username"` XSUsername *string `mapstructure:"remote_username" cty:"remote_username" hcl:"remote_username"`
Password *string `mapstructure:"remote_password" cty:"remote_password" hcl:"remote_password"` XSPassword *string `mapstructure:"remote_password" cty:"remote_password" hcl:"remote_password"`
HostIp *string `mapstructure:"remote_host" cty:"remote_host" hcl:"remote_host"` HostIp *string `mapstructure:"remote_host" cty:"remote_host" hcl:"remote_host"`
VMName *string `mapstructure:"vm_name" cty:"vm_name" hcl:"vm_name"` VMName *string `mapstructure:"vm_name" cty:"vm_name" hcl:"vm_name"`
VMDescription *string `mapstructure:"vm_description" cty:"vm_description" hcl:"vm_description"` VMDescription *string `mapstructure:"vm_description" cty:"vm_description" hcl:"vm_description"`

View File

@ -91,9 +91,9 @@ func ExecuteHostSSHCmd(state multistep.StateBag, cmd string) (stdout string, err
sshAddress, _ := SSHAddress(state) sshAddress, _ := SSHAddress(state)
// Setup connection config // Setup connection config
sshConfig := &gossh.ClientConfig{ sshConfig := &gossh.ClientConfig{
User: config.Username, User: config.XSUsername,
Auth: []gossh.AuthMethod{ Auth: []gossh.AuthMethod{
gossh.Password(config.Password), gossh.Password(config.XSPassword),
}, },
HostKeyCallback: gossh.InsecureIgnoreHostKey(), HostKeyCallback: gossh.InsecureIgnoreHostKey(),
} }

View File

@ -38,7 +38,7 @@ func (self *StepForwardPortOverSSH) Run(ctx context.Context, state multistep.Sta
remotePort, _ := self.RemotePort(state) remotePort, _ := self.RemotePort(state)
remoteDest, _ := self.RemoteDest(state) remoteDest, _ := self.RemoteDest(state)
go ssh_port_forward(l, remotePort, remoteDest, hostAddress, config.Username, config.Password) go ssh_port_forward(l, remotePort, remoteDest, hostAddress, config.XSUsername, config.XSPassword)
ui.Say(fmt.Sprintf("Port forward setup. %d ---> %s:%d on %s", sshHostPort, remoteDest, remotePort, hostAddress)) ui.Say(fmt.Sprintf("Port forward setup. %d ---> %s:%d on %s", sshHostPort, remoteDest, remotePort, hostAddress))
// Provide the local port to future steps. // Provide the local port to future steps.

View File

@ -158,7 +158,7 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, warns []stri
} }
func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
c, err := xscommon.NewXenAPIClient(self.config.HostIp, self.config.Username, self.config.Password) c, err := xscommon.NewXenAPIClient(self.config.HostIp, self.config.XSUsername, self.config.XSPassword)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -92,7 +92,7 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, warns []stri
func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { func (self *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
//Setup XAPI client //Setup XAPI client
c, err := xscommon.NewXenAPIClient(self.config.HostIp, self.config.Username, self.config.Password) c, err := xscommon.NewXenAPIClient(self.config.HostIp, self.config.XSUsername, self.config.XSPassword)
if err != nil { if err != nil {
return nil, err return nil, err