# Path: app/lib/conf.py
# APP = meta.APP_NAME
# class MetaConf(object):
# class Config(object):
#     def __init__(self):
#     def resolveMacros(self):
#     def getConfRoot(self):
#     def getSnapPath(self):
#     def getConfPaths(self):
#     def __init__(self, **kwargs):
#     def load(self, conf_type, *file_path):
#     def get(self, section, key):
#     def set(self, section, key, value):
#     def show(self):
#     def save(self):
#     def envGet():
#     def envGet2(key):
#     def envSet(self, **kwargs):
#     def envShow(self):
#     def getConfig(self, file):
#     def parseConfig(file):
# 
# Path: app/lib/auth.py
# class User(object):
#     def __init__(self):
#     def load(self):
#     def save(self, data):
#     def get(self, username):
#     def sha_password(cls, password):
#     def bcrypt_password(cls, password):
#     def show(self):
#     def add(self, username, password):
#     def delete(self, username):
#     def update(self, username, password):
#     def authenticate(self, username, password):
# 
# Path: app/lib/cert.py
# class Certificate(object):
#     def __init__(self):
#     def create(self):
#     def save(file, data):
# 
# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


from app.lib import conf, auth, cert
from pathlib import Path
from app import __metadata__ as meta
import shutil
import os
import logging
        Create config file with:
        a) user provided path to the desired config file
            - use the config settings from that file
        b) default config settings from conf file

    3) Create Auth File

        If there is no auth file create it with the provided admin user password:
        a) If there is an auth file from a previous configuration, prompt the user that
          it will be overwritten
        b) The admin username is specified in the conf file

    4) Create Client Certs

        If this is the first time LXDUI is run then there should be no client certificates
        a) Check if there are certs from a previous config
        b) Generate the client certificates is they don't exist and prompt the user to
          overwrite if they do exit

    """

    APP = meta.APP_NAME

    def __init__(self, password):
        c = conf.Config()
        self.password = auth.User.bcrypt_password(password)
        self.username = c.get(self.APP, '{}.admin.user'.format(self.APP.lower()))
        self.auth_file = c.get(self.APP, '{}.auth.conf'.format(self.APP.lower()))
        self.cert_file = c.get(self.APP, '{}.ssl.cert'.format(self.APP.lower()))
        self.key_file = c.get(self.APP, '{}.ssl.key'.format(self.APP.lower()))

# Path: app/lib/conf.py
# APP = meta.APP_NAME
# class MetaConf(object):
# class Config(object):
#     def __init__(self):
#     def resolveMacros(self):
#     def getConfRoot(self):
#     def getSnapPath(self):
#     def getConfPaths(self):
#     def __init__(self, **kwargs):
#     def load(self, conf_type, *file_path):
#     def get(self, section, key):
#     def set(self, section, key, value):
#     def show(self):
#     def save(self):
#     def envGet():
#     def envGet2(key):
#     def envSet(self, **kwargs):
#     def envShow(self):
#     def getConfig(self, file):
#     def parseConfig(file):
# 
# Path: app/lib/auth.py
# class User(object):
#     def __init__(self):
#     def load(self):
#     def save(self, data):
#     def get(self, username):
#     def sha_password(cls, password):
#     def bcrypt_password(cls, password):
#     def show(self):
#     def add(self, username, password):
#     def delete(self, username):
#     def update(self, username, password):
#     def authenticate(self, username, password):
# 
# Path: app/lib/cert.py
# class Certificate(object):
#     def __init__(self):
#     def create(self):
#     def save(file, data):
# 
# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


# Path: app/cli/init.py
from app.lib import conf, auth, cert
from pathlib import Path
from app import __metadata__ as meta
import shutil
import os
import logging

        Create config file with:
        a) user provided path to the desired config file
            - use the config settings from that file
        b) default config settings from conf file

    3) Create Auth File

        If there is no auth file create it with the provided admin user password:
        a) If there is an auth file from a previous configuration, prompt the user that
          it will be overwritten
        b) The admin username is specified in the conf file

    4) Create Client Certs

        If this is the first time LXDUI is run then there should be no client certificates
        a) Check if there are certs from a previous config
        b) Generate the client certificates is they don't exist and prompt the user to
          overwrite if they do exit

    """

    APP = meta.APP_NAME

    def __init__(self, password):
        c = conf.Config()
        self.password = auth.User.bcrypt_password(password)
        self.username = c.get(self.APP, '{}.admin.user'.format(self.APP.lower()))
        self.auth_file = c.get(self.APP, '{}.auth.conf'.format(self.APP.lower()))
        self.cert_file = c.get(self.APP, '{}.ssl.cert'.format(self.APP.lower()))
        self.key_file = c.get(self.APP, '{}.ssl.key'.format(self.APP.lower()))

        self.key, self.cert = cert.Certificate().create()