Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fetching the VM IP using prlctl #434

Merged
merged 2 commits into from
Mar 22, 2023
Merged

Support fetching the VM IP using prlctl #434

merged 2 commits into from
Mar 22, 2023

Conversation

bineesh-n
Copy link
Contributor

Adding support for 'vagrant ssh' for pvm and macvm.

Requirements : public key should be present in the guest, if using - key authentication. Also, host should be providing the private key with box / with default identity.

Currently 'vagrant up' will fail to configure some shared directories - using ssh (After launching the VM). But 'vagrant ssh' will work perfectly.

@legal90
Copy link
Collaborator

legal90 commented Mar 20, 2023

Hi @bineesh-n ,
Could you please elaborate, which exact issue are you facing and how this change solves it?
Steps to reproduce would be great. Thank you!

@bineesh-n
Copy link
Contributor Author

@legal90 SSH was not working in MacOS vms in M-Series chips, is the main problem. I changed the mechanism of getting the ip from "DHCP leases" to "Guest Tools", which will be more accurate. So I changed the IP detection mechanism for both type of VMs.

Copy link
Collaborator

@legal90 legal90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current implementation with relying on the DHCP and "Shared" network has been done that way intentionally. The VMs not always have guest tools installed, or they could be out of date. Also, I'm not sure, in which version of Parallels Desktop the property ip_configured became available and what are the requirements for it to be set (compatibility with guest tools).

Using the DHCP lease for detecting the VM IP on the early stage is a way more reliable way than using the host <-> guest integration via prlctl.
Unfortunately, switching from the DHCP lease to prlctl output can brake the plugin for a various use-cases. That's why I don't think it's a right track for fixing this issue.

I would rather suggest to fix the SSH via Shared network & DHCP for all use cases, including yours on M-Series chips.
I'm ready to help with that, but I don't have a possibility to test it on M-Series hardware.

Could you please file a new issue here with the details, describing the failure with the latest official provider version (v2.2.6)? Please also include this info:

  1. Does /Library/Preferences/Parallels/parallels_dhcp_leases exist on your mac?
  2. Which IP vagrant tries to use? (It should be shown in vagrant up or vagrant ssh-config output)
  3. Which IP do you see in the output prlctl list -f <uuid> --json ?

@bineesh-n
Copy link
Contributor Author

@legal90 I've created the issue here. As you asked, prlctl does not require guest tools since PD16 actually (only for macvms guest tools required). Also, "ip_configured" is available since PD9 at least.

@legal90
Copy link
Collaborator

legal90 commented Mar 20, 2023

Thank you, @bineesh-n! Now I have a better understanding of the issue.

Let's see if we will find any other ways to determine the IP of .macvms. If there will be no other options, I think we can still use both solutions at the same time, e.q.:

  1. Try read_guest_ip(), as it is now.
  2. If it returned an empty string (no IP in the lease) - try the method with prlctl list -f <uuid> --json

The wrapper function ssh_ip() is getting called in a loop, so vagrant with retry it again until it gets the IP from any of these 2 sources. In this case we wont break the compatibility for existing cases relying on DHCP lease.

Requirements : public key should be present in the guest, if using -
key authentication. Also, host should be providing the private key with box / with default identity.

Currently 'vagrant up' will fail to configure some shared directories -
using ssh (After launching the VM). But 'vagrant ssh' will work perfectly.
@bineesh-n
Copy link
Contributor Author

@legal90 Thanks for your suggestion. I've updated this pull request as per your suggestions.

@bineesh-n bineesh-n linked an issue Mar 20, 2023 that may be closed by this pull request
@legal90
Copy link
Collaborator

legal90 commented Mar 21, 2023

@bineesh-n Thank you! I'll check it later today 👍

@legal90 legal90 merged commit eb92ec5 into master Mar 22, 2023
@legal90 legal90 changed the title Reimplement 'vagrant ssh' using guest-tools Support fetching the VM IP using prlctl Mar 22, 2023
@legal90
Copy link
Collaborator

legal90 commented Mar 22, 2023

@bineesh-n I will run acceptance tests and release a new version of vagrant-parallels today.

@legal90 legal90 deleted the wip-vagrant-ssh branch March 22, 2023 09:16
@legal90
Copy link
Collaborator

legal90 commented Mar 22, 2023

@bineesh-n I released a new version , v2.3.0
Could you please verify if it fixed this issue with .macvms ?

@bineesh-n
Copy link
Contributor Author

@legal90 No, it's not working.
read_guest_ip_dhcp || read_guest_ip_prlctl is returning "" for macvm. read_guest_ip_prlctl is never executed (read_guest_ip_dhcp is not nil anytime ? ).

@legal90
Copy link
Collaborator

legal90 commented Mar 23, 2023

@bineesh-n Oh, sorry about that! My bad - I didn't test it properly.
Here is the fix: #440 Could you please review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'vagrant ssh' fails with macvm boxes
2 participants