-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from AdaptiveScale/lxdui-2.0
Lxdui 2.0
- Loading branch information
Showing
118 changed files
with
6,205 additions
and
2,378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.idea/* | ||
conf/lxdui.conf | ||
*.pyc | ||
venv | ||
lxdui.egg-info | ||
build | ||
dist/ | ||
LXDUI.egg-info |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
recursive-include lxdui/app_metadata * | ||
recursive-include lxdui/helpers * | ||
recursive-include lxdui/conf * | ||
recursive-include lxdui/static * | ||
recursive-include lxdui/templates * | ||
recursive-include conf *.conf | ||
recursive-include logs * | ||
recursive-include app/ui/static * | ||
recursive-include app/ui/templates * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
APP_NAME = 'LXDUI' | ||
APP_CLI_CMD = 'lui' | ||
VERSION = '2.0-beta' | ||
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 = '[email protected]' | ||
KEYWORDS = 'lxc lxc-containers lxd' | ||
|
||
''' | ||
The following section is for the default configuration | ||
that will be written to the lxdui.conf file if the file | ||
does not already exist. | ||
''' | ||
AUTO_LOAD_CONFIG = True | ||
DEFAULT_CONFIG_FORMAT = 'ini' | ||
__default_config__ = """ | ||
[LXDUI] | ||
lxdui.port = 15151 | ||
lxdui.token.expiration = 1200 | ||
lxdui.admin.user = admin | ||
lxdui.conf.dir = {{app_root}}/conf | ||
lxdui.conf.file = ${lxdui.conf.dir}/lxdui.conf | ||
lxdui.auth.conf = ${lxdui.conf.dir}/auth.conf | ||
lxdui.ssl.cert = ${lxdui.conf.dir}/client.crt | ||
lxdui.ssl.key = ${lxdui.conf.dir}/client.key | ||
lxdui.log.dir = {{app_root}}/logs | ||
lxdui.log.file = ${lxdui.log.dir}/lxdui.log | ||
#lxdui.log.rotate = true | ||
#lxdui.log.max = 10M | ||
#lxdui.log.keep.generations = 5 | ||
lxdui.profiles = ${lxdui.conf.dir}/profiles | ||
lxdui.zfs.pool.name = lxdpool | ||
lxdui.app.alias = LXDUI | ||
lxdui.cli = lui | ||
[LXDUI_CERT] | ||
lxdui.cert.country = US | ||
lxdui.cert.state = Texas | ||
lxdui.cert.locale = Dallas | ||
lxdui.cert.org = AdaptiveScale, Inc. | ||
lxdui.cert.ou = OU=AdaptiveScale, DN=com | ||
[LXD] | ||
lxd.bridge.enabled = true | ||
lxd.bridge.name = lxdbr0 | ||
lxd.dns.conf.file = | ||
lxd.dns.domain = lxd | ||
lxd.ipv4.addr = 10.5.5.1 | ||
lxd.ipv4.netmask = 255.255.255.0 | ||
lxd.ipv4.network = 10.5.5.0/24 | ||
lxd.ipv4.dhcp.range = 253 | ||
lxd.ipv4.dhcp.max = 10.5.5.2,10.5.5.254 | ||
lxd.ipv4.nat = true | ||
lxd.ipv6.addr = 2001:470:b368:4242::1 | ||
lxd.ipv6.mask = 255.255.255.0 | ||
lxd.ipv6.network = 2001:470:b368:4242::/64 | ||
lxd.ipv6.nat = false | ||
lxd.ipv6.proxy = false | ||
""" | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
from flask import Blueprint, request | ||
from flask_jwt import jwt_required | ||
from app.api.schemas.container_schema import doValidate, doValidateCloneMove, doValidateImageExport | ||
|
||
from app.api.models.LXCContainer import LXCContainer | ||
from app.api.models.LXDModule import LXDModule | ||
from app.api.utils import response | ||
|
||
container_api = Blueprint('container_api', __name__) | ||
|
||
@container_api.route('/') | ||
@jwt_required() | ||
def containers(): | ||
client = LXDModule() | ||
result = [] | ||
containers = client.listContainers() | ||
for container in containers: | ||
c = LXCContainer({'name': container.get('name')}) | ||
result.append(c.info()) | ||
return response.reply(result) | ||
|
||
|
||
@container_api.route('/<string:name>') | ||
@jwt_required() | ||
def getContainer(name): | ||
try: | ||
container = LXCContainer({'name': name}) | ||
return response.replySuccess(container.info()) | ||
except ValueError as e: | ||
return response.replyFailed(message=e.__str__()) | ||
|
||
|
||
|
||
@container_api.route('/', methods=['POST']) | ||
@jwt_required() | ||
def createContainer(): | ||
input = request.get_json(silent=True) | ||
validation = doValidate(input) | ||
if validation: | ||
return response.reply(message=validation.message, status=403) | ||
|
||
input = [input] if not isinstance(input, list) else input | ||
|
||
try: | ||
result = [] | ||
for container in input: | ||
client = LXCContainer(container) | ||
result.append(client.create()) | ||
return response.reply(result) | ||
except ValueError as ex: | ||
return response.reply(message=ex.__str__(), status=403) | ||
|
||
@container_api.route('/', methods=['PUT']) | ||
@jwt_required() | ||
def updateContainer(): | ||
input = request.get_json(silent=True) | ||
validation = doValidate(input) | ||
if validation: | ||
return response.reply(message=validation.message, status=403) | ||
|
||
try: | ||
client = LXCContainer(input) | ||
return response.reply(client.update()) | ||
except ValueError as ex: | ||
return response.reply(message=ex.__str__(), status=403) | ||
|
||
|
||
@container_api.route('/<string:name>', methods=['DELETE']) | ||
@jwt_required() | ||
def deleteContainer(name): | ||
input = request.get_json(silent=True) | ||
force = False if input == None else input.get('force') | ||
try: | ||
container = LXCContainer({'name': name}) | ||
container.delete(force) | ||
return response.reply(None) | ||
except ValueError as ex: | ||
return response.replyFailed(message=ex.__str__()) | ||
|
||
|
||
@container_api.route('/start/<string:name>', methods=['PUT']) | ||
@jwt_required() | ||
def startContainer(name): | ||
try: | ||
container = LXCContainer({'name': name}) | ||
container.start() | ||
return response.replySuccess(container.info()) | ||
except ValueError as e: | ||
return response.replyFailed(message=e.__str__()) | ||
|
||
|
||
@container_api.route('/stop/<string:name>', methods=['PUT']) | ||
@jwt_required() | ||
def stopContainer(name): | ||
try: | ||
container = LXCContainer({'name': name}) | ||
ephemeral = container.info()['ephemeral'] | ||
container.stop() | ||
if ephemeral: | ||
return response.replySuccess(data={}, message='success') | ||
return response.replySuccess(container.info()) | ||
except ValueError as e: | ||
return response.replyFailed(message=e.__str__()) | ||
|
||
|
||
@container_api.route('/restart/<string:name>', methods=['PUT']) | ||
@jwt_required() | ||
def restartContainer(name): | ||
try: | ||
container = LXCContainer({'name': name}) | ||
container.restart() | ||
return response.replySuccess(container.info()) | ||
except ValueError as e: | ||
return response.replyFailed(message=e.__str__()) | ||
|
||
@container_api.route('/clone/<string:name>', methods=['POST']) | ||
@jwt_required() | ||
def cloneContainer(name): | ||
input = request.get_json(silent=True) | ||
validation = doValidateCloneMove(input) | ||
if validation: | ||
return response.reply(message=validation.message, status=403) | ||
|
||
input['name'] = name | ||
try: | ||
container = LXCContainer(input) | ||
return response.replySuccess(container.clone()) | ||
except ValueError as e: | ||
return response.replyFailed(message=e.__str__()) | ||
|
||
@container_api.route('/move/<string:name>', methods=['POST']) | ||
@jwt_required() | ||
def moveContainer(name): | ||
input = request.get_json(silent=True) | ||
validation = doValidateCloneMove(input) | ||
if validation: | ||
return response.reply(message=validation.message, status=403) | ||
|
||
input['name'] = name | ||
try: | ||
container = LXCContainer(input) | ||
return response.replySuccess(container.move()) | ||
except ValueError as e: | ||
return response.replyFailed(message=e.__str__()) | ||
|
||
|
||
@container_api.route('/export/<string:name>', methods=['POST']) | ||
@jwt_required() | ||
def exportContainer(name): | ||
input = request.get_json(silent=True) | ||
validation = doValidateImageExport(input) | ||
if validation: | ||
return response.reply(message=validation.message, status=403) | ||
|
||
force = False if input.get('force') == None else input.get('force') | ||
input['name'] = name | ||
try: | ||
container = LXCContainer(input) | ||
return response.replySuccess(container.export(force)) | ||
except ValueError as e: | ||
return response.replyFailed(message=e.__str__()) |
Oops, something went wrong.