Initial commit

os-repl
root 2022-11-23 18:55:06 +00:00
parent 2dccc5d14e
commit 73116d39d5
3 changed files with 27 additions and 1 deletions

3
lxd-init.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
yes '' | lxd init

22
lxd_interface.py Normal file
View File

@ -0,0 +1,22 @@
import pylxd
lxd_client = pylxd.client.Client()
def create_instance(container_name: str):
config = {'name': container_name, 'source':
{'type': 'image', "mode": "pull", "server": "https://cloud-images.ubuntu.com/daily", "protocol": "simplestreams",
'alias': 'lts/amd64'}, 'security.nesting': 'true'}
instance = lxd_client.instances.create(config, wait=True)
instance.start()
return True
def destroy_instance(container_name: str):
instance = lxd_client.instances.get(container_name)
instance.stop(wait=True)
instance.delete(wait=True)
return True

View File

@ -1,6 +1,7 @@
import logging import logging
import paramiko import paramiko
import sshim import sshim
import pylxd
import os import os
import re import re
@ -12,7 +13,7 @@ def check_auth_none(self, username):
def check_auth_password(self, username, password): def check_auth_password(self, username, password):
if password == os.environ["ssh-password"]: if username == os.environ["ssh-username"] and password == os.environ["ssh-password"]:
return paramiko.AUTH_SUCCESSFUL return paramiko.AUTH_SUCCESSFUL
return paramiko.AUTH_FAILED return paramiko.AUTH_FAILED