Initial commit
parent
2dccc5d14e
commit
73116d39d5
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
yes '' | lxd init
|
|
@ -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
|
3
main.py
3
main.py
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import paramiko
|
||||
import sshim
|
||||
import pylxd
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@ -12,7 +13,7 @@ def check_auth_none(self, username):
|
|||
|
||||
|
||||
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_FAILED
|
||||
|
||||
|
|
Loading…
Reference in New Issue