web UI - init work on using docker-socket-proxy
This commit is contained in:
@@ -2,8 +2,8 @@ import docker
|
||||
|
||||
class Docker :
|
||||
|
||||
def __init__(self) :
|
||||
self.__client = docker.DockerClient(base_url='unix:///var/run/docker.sock')
|
||||
def __init__(self, docker_host) :
|
||||
self.__client = docker.DockerClient(base_url=docker_host)
|
||||
|
||||
def get_instances(self) :
|
||||
return self.__client.containers.list(all=True, filters={"label" : "bunkerized-nginx.UI"})
|
||||
|
||||
@@ -11,8 +11,11 @@ app = Flask(__name__, static_url_path="/", static_folder="static", template_fold
|
||||
ABSOLUTE_URI = ""
|
||||
if "ABSOLUTE_URI" in os.environ :
|
||||
ABSOLUTE_URI = os.environ["ABSOLUTE_URI"]
|
||||
DOCKER_HOST = "unix:///var/run/docker.sock"
|
||||
if "DOCKER_HOST" in os.environ :
|
||||
DOCKER_HOST = os.environ["DOCKER_HOST"]
|
||||
app.config["ABSOLUTE_URI"] = ABSOLUTE_URI
|
||||
app.config["DOCKER"] = Docker()
|
||||
app.config["DOCKER"] = Docker(DOCKER_HOST)
|
||||
app.config["CONFIG"] = Config()
|
||||
app.jinja_env.globals.update(env_to_summary_class=utils.env_to_summary_class)
|
||||
app.jinja_env.globals.update(form_service_gen=utils.form_service_gen)
|
||||
@@ -46,15 +49,15 @@ def instances() :
|
||||
|
||||
# Do the operation
|
||||
if request.form["operation"] == "reload" :
|
||||
operation = app.config["DOCKER"].reload(request_form["INSTANCE_ID"])
|
||||
operation = app.config["DOCKER"].reload_instance(request.form["INSTANCE_ID"])
|
||||
elif request.form["operation"] == "start" :
|
||||
operation = app.config["DOCKER"].start(request_form["INSTANCE_ID"])
|
||||
operation = app.config["DOCKER"].start_instance(request.form["INSTANCE_ID"])
|
||||
elif request.form["operation"] == "stop" :
|
||||
operation = app.config["DOCKER"].stop(request_form["INSTANCE_ID"])
|
||||
operation = app.config["DOCKER"].stop_instance(request.form["INSTANCE_ID"])
|
||||
elif request.form["operation"] == "restart" :
|
||||
operation = app.config["DOCKER"].restart(request_form["INSTANCE_ID"])
|
||||
operation = app.config["DOCKER"].restart_instance(request.form["INSTANCE_ID"])
|
||||
elif request.form["operation"] == "delete" :
|
||||
operation = app.config["DOCKER"].delete(request_form["INSTANCE_ID"])
|
||||
operation = app.config["DOCKER"].delete_instance(request.form["INSTANCE_ID"])
|
||||
|
||||
# Display instances
|
||||
instances = app.config["DOCKER"].get_instances()
|
||||
|
||||
Reference in New Issue
Block a user