siderolabs / talos-vmtoolsd

VMware tools implementation for the Talos Kubernetes platform, using govmomi and Talos' apid
Apache License 2.0
28 stars 14 forks source link

permit sending rpc commands #25

Open clementnuss opened 3 weeks ago

clementnuss commented 3 weeks ago

it would be much appreciated if we were able (from the command line) to issue RPC to VMWare/ESXi. Our use case is something like:

vmtoolsd --cmd="info-get guestinfo.esxhost"

I went through the codebase but am not sure where to implement that. I gave it a shot here but am not sure if that's really the way to go, as I'm not sure if we want/can open a new nanotoolbox.Service or if we should try to reuse the already running vmtoolsd.

Let me know if my code is heading in the right direction, then I'll open a PR and I'll try to build and test it (so far I got some strange error when running make vmtoolsd... related to ARG {TOOLCHAIN} so I put that on hold before your reply.)

jonkerj commented 3 weeks ago

I like this idea!

If I were to implement this, I'd implement subcommands using spf13/cobra, one for the current function (the daemon), one for issueing these commands.

It would require a bit of refactoring in cmd/*:

I'm a bit short on time (and typically over-optimistic when it comes to planning), so don't count on it too much, but we could do this command refactoring in the coming two weeks.

clementnuss commented 3 weeks ago

cool! I've already worked with cobra, I'll try to implement that 👍🏼

one key point for me though: can we have multiple nanotoolbox.Service running ? or should we try to somehow implement an api on the daemon that the rpc-cmd subcommand would then query ?

I have a feeling it should work out-of-the box with another service, I'm just not sure how the underlying communication happens:

  1. is there a socket for the VMWare comm?
  2. and mostly, does it support parallel operations or will it crash if the daemon and the rpc-cmd try to issue an RPC all at the same time?