Modified fork for utilisation in cloud provisioning services.
Goals:
- Update to .NET 5.0
- Add support / demo for VMs
- Add support for container and vm provisioning via cloud-init iso for vms.
SharpLXD is based on LXD.NET and includes the work of https://github.com/autozimu/LXD.NET https://github.com/GnicoJP/LXD.NET with thanks.
The project has been renamed to avoid confusion. This project is not intended to be compatible with LXD.NET going forward.
LXD Server side:
mkdir -p /root/.config/lxc
openssl req -x509 -newkey rsa:2048 -keyout /root/.config/lxc/client.key.secure -out /root/.config/lxc/client.crt -days 3650
openssl rsa -in /root/.config/lxc/client.key.secure -out /root/.config/lxc/client.key
lxc config trust add /root/.config/lxc/client.crt
source: https://gitlab.com/catalyst-it/devtools/vagrant-lxd/-/issues/6
Client Side:
openssl pkcs12 -export -out client.pfx -inkey client.key -in client.crt
LXD client implemented in C#.
using LXD;
Client client = new Client(
apiEndpoint: "https://your-lxd-service:8443",
clientCertificateFilename: "your-client-certificate.p12",
password: "your-client-certificate-password");
Console.WriteLine(client.Trusted); // true
foreach (Domain.Container container in client.Containers) {
Console.WriteLine(container.Name);
}
// alpline
// ubuntu
Domain.Container alpine = client.Containers.First();
foreach (string str in alpine.Exec(new[] {"cat", "/etc/issue"})) {
Console.WriteLine(st);
}
// Welcome to Alpine Linux 3.4
// Kernel \r on an \m (\l)