Is the xe utility open source?
-
I am a huge fan of PowerShell and there is a PowerShell module for managing XenServer/XCP-ng, however it requires connecting to the Xen system with a username/password before using it even if the PowerShell module is installed on XCP-ng itself.
I noticed that the version of xe that I install on my workstation needs to make a connection (of course), but the xe utility on XCP-ng host does not need to do this. It seems there is some way of interacting with the XCP-ng server that doesn't require auth if running on the server as root.
I was hoping I could figure out a way to replicate this with with PowerShell, so that if I am logged into XCP-ng as root, I can immediate run Get-XenVM without needing to run Connect-XenServer first.
-
@Byte0 Oh, I may have just found it. It's written on ocaml? Uh oh. Might be well out of my ability to make this happen.
-
@Byte0 When
xe
utility is running on a XenServer/XCP-ng host itself, without any additional connection related command line parameters, it defaults to using XenAPI Unix socket:# ls -la /var/xapi/xapi srwxr-xr-x 1 root root 0 feb 18 11:07 /var/xapi/xapi
Since this socket is owned by
root
user and writable only byroot
user and only accessible from inside the dom0 system, then it is assumed to be safe andxe
does not require any kind of authentication.xe
can freely send API requests trough the socket.So can PowerShell module do the same? Possibly, but PowerShell is way less documented than, let's say, Python modules, so I can't tell without looking at the code.
To check it yourself, you will first have to install PowerShell modules on XenServer/XCP-ng itself and make it work in standard way (
Connect-XenServer
). Then take a look at PowerShell modules source code to see if there is any trace of support for XenAPI Unix socket. If there is none and you are good with PowerShell, maybe you can add support for Unix socket.For XenAPI Python modules you can use either http/httpd or unix socket connection.
Update:
A few Googles later. It seems that PowerShell does not have support for Unix sockets at all. It requires some kind of TCP to Unix socket proxy like
socat
. So making XenAPI PowerShell modules work over Unix socket could be non trivial undertaking and some considerable hacking would be required. -
We have a powershell SDK planned for XO API this year
-
@bvitnik .Net core supports connecting to Unix sockets (socket types). PowerShell can, but would need to create .Net objects to do it. My goal was to still use the Citrix PowerShell module, but I would need to edit the .Net SDK as well as the PowerShell module code that uses the .Net SDK. The scope might be too large for a noob such as I.
I'm sure I could figure it out eventually, but it would take me forever. I'm a sysadmin that's loves writing code (all basic tools and automations though) and I wish I could do it more, so I could get better at it.
EDIT: Citrix has two editions of the PowerShell module, one written for Windows PowerShell and one written for PowerShell core.
-
@olivierlambert NICE!! I super love PowerShell. I hope Unix socket interaction is part of it. I'd love to help contribute, except I am a super noob when it comes to development. I've written c# tools before, but I am all self taught and there's so much about C# I don't know.
I totally overlooked the "for XO". The Unix socket thing doesn't apply there. It is still really awesome though and wish I could help.