Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

impulsemachines/SharpLXD

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharpLXD by ImpulseMachines

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.

Generating a pfx certificate for use with SharpLXD

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  

Original LXD.NET Documentation

LXD client implemented in C#.

Example

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)

About

Opinionated LXD client implemented in C#. Destined for integration into a cloud provisioning service.

Resources

License

Stars

Watchers

Forks

Languages

  • C# 96.4%
  • Smalltalk 3.6%