resolveSSHCreds returns the SSH username, keyfile path, and jump-host config to use for the node that hosts vm, preferring the guest's source profile when available.
(vm *api.VM)
| 353 | // resolveSSHCreds returns the SSH username, keyfile path, and jump-host config |
| 354 | // to use for the node that hosts vm, preferring the guest's source profile when available. |
| 355 | func (s *cliSession) resolveSSHCreds(vm *api.VM) (sshUser string, sshKeyfile string, jumpHost config.SSHJumpHost) { |
| 356 | if vm != nil && vm.SourceProfile != "" { |
| 357 | if p, ok := s.cfg.Profiles[vm.SourceProfile]; ok { |
| 358 | if p.SSHUser != "" { |
| 359 | sshUser = p.SSHUser |
| 360 | } |
| 361 | if p.SSHKeyfile != "" { |
| 362 | sshKeyfile = p.SSHKeyfile |
| 363 | } |
| 364 | if p.SSHJumpHost.Addr != "" { |
| 365 | jumpHost = p.SSHJumpHost |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | if sshUser == "" { |
| 371 | sshUser = s.cfg.SSHUser |
| 372 | } |
| 373 | if sshKeyfile == "" { |
| 374 | sshKeyfile = s.cfg.SSHKeyfile |
| 375 | } |
| 376 | if jumpHost.Addr == "" { |
| 377 | jumpHost = s.cfg.SSHJumpHost |
| 378 | } |
| 379 | |
| 380 | return sshUser, sshKeyfile, jumpHost |
| 381 | } |
| 382 | |
| 383 | // execLXC executes cmdParts inside an LXC container via SSH to its host node |
| 384 | // using pct exec. Returns stdout, stderr, exit code, and any transport error. |
no outgoing calls
no test coverage detected