diff options
Diffstat (limited to 'moon_forming')
-rw-r--r-- | moon_forming/Dockerfile | 11 | ||||
-rw-r--r-- | moon_forming/README.md | 44 | ||||
-rw-r--r-- | moon_forming/conf2consul.py | 102 | ||||
-rw-r--r-- | moon_forming/run.sh | 43 |
4 files changed, 0 insertions, 200 deletions
diff --git a/moon_forming/Dockerfile b/moon_forming/Dockerfile deleted file mode 100644 index ca0eba76..00000000 --- a/moon_forming/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM python:3 - -WORKDIR /usr/src/app -RUN pip install --no-cache-dir --upgrade requests pyyaml python_moonutilities python_moondb python_moonclient - -ENV POPULATE_ARGS "-v" - -ADD . /root -WORKDIR /root - -CMD sh /root/run.sh ${POPULATE_ARGS}
\ No newline at end of file diff --git a/moon_forming/README.md b/moon_forming/README.md deleted file mode 100644 index cc08f676..00000000 --- a/moon_forming/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Moon Forming -moon_forming is a container to automatize the configuration of the Moon platform - -## Run -```bash -docker run wukongsun/moon_forming:latest -``` - -## Consul -The Moon platform is already configured after the installation. -If you want to see or modify the configuration, go with a web browser -to the following page: `http://localhost:30006`. - -With the consul server, you can update the configuration in the `KEY/VALUE` tab. -There are some configuration items, lots of them are only read when a new K8S pod is started -and not during its life cycle. - -**WARNING: some confidential information are put here in clear text. -This is a known security issue.** - -### Keystone -If you have your own Keystone server, you can point Moon to your Keystone in the -`openstack/keystone` element: `http://localhost:30005/ui/#/dc1/kv/openstack/keystone/edit`. -This configuration element is read every time Moon need it, specially when adding users. - -### Database -The database can also be modified through: `http://localhost:30005/ui/#/dc1/kv/database/edit`. - -**WARNING: the password is in clear text, this is a known security issue.** - -If you want to use your own database server, change the configuration: - - {"url": "mysql+pymysql://my_user:my_secret_password@my_server/moon", "driver": "sql"} - -Then you have to rebuild the database before using it. -This can be done with the following commands: -```bash -kubectl delete -f $MOON_HOME/tools/moon_kubernetes/templates/moon_forming.yaml -kubectl create -f $MOON_HOME/tools/moon_kubernetes/templates/moon_forming.yaml -``` - - - - diff --git a/moon_forming/conf2consul.py b/moon_forming/conf2consul.py deleted file mode 100644 index 148bf923..00000000 --- a/moon_forming/conf2consul.py +++ /dev/null @@ -1,102 +0,0 @@ -import os -import sys -import requests -import yaml -import logging -import json -import base64 - -logging.basicConfig(level=logging.INFO) -log = logging.getLogger("moon.conf2consul") -requests_log = logging.getLogger("requests.packages.urllib3") -requests_log.setLevel(logging.WARNING) -requests_log.propagate = True - -if len(sys.argv) == 2: - if os.path.isfile(sys.argv[1]): - CONF_FILENAME = sys.argv[1] - CONSUL_HOST = "consul" - else: - CONF_FILENAME = "moon.conf" - CONSUL_HOST = sys.argv[1] - CONSUL_PORT = 8500 -else: - CONSUL_HOST = sys.argv[1] if len(sys.argv) > 1 else "consul" - CONSUL_PORT = sys.argv[2] if len(sys.argv) > 2 else 8500 - CONF_FILENAME = sys.argv[3] if len(sys.argv) > 3 else "moon.conf" -HEADERS = {"content-type": "application/json"} - - -def search_config_file(): - data_config = None - for _file in ( - CONF_FILENAME, - "conf/moon.conf", - "../moon.conf", - "../conf/moon.conf", - "/etc/moon/moon.conf", - ): - try: - data_config = yaml.safe_load(open(_file)) - except FileNotFoundError: - data_config = None - continue - else: - break - if not data_config: - raise Exception("Configuration file not found...") - return data_config - - -def put(key, value): - url = "http://{host}:{port}/v1/kv/{key}".format(host=CONSUL_HOST, port=CONSUL_PORT, key=key) - log.info(url) - req = requests.put( - url, - headers=HEADERS, - json=value - ) - if req.status_code != 200: - raise Exception("Error connecting to Consul ({}, {})".format(req.status_code, req.text)) - - -def get(key): - url = "http://{host}:{port}/v1/kv/{key}".format(host=CONSUL_HOST, port=CONSUL_PORT, key=key) - req = requests.get(url) - data = req.json() - for item in data: - log.info("{} {} -> {}".format( - req.status_code, - item["Key"], - json.loads(base64.b64decode(item["Value"]).decode("utf-8")) - )) - yield json.loads(base64.b64decode(item["Value"]).decode("utf-8")) - - -def main(): - data_config = search_config_file() - req = requests.head("http://{}:{}/ui/".format(CONSUL_HOST, CONSUL_PORT)) - if req.status_code != 200: - log.critical("Consul is down...") - log.critical("request info: {}/{}".format(req, req.text)) - sys.exit(1) - - put("database", data_config["database"]) - # put("messenger", data_config["messenger"]) - # put("slave", data_config["slave"]) - # put("docker", data_config["docker"]) - put("logging", data_config["logging"]) - # put("components_port_start", data_config["components"]["port_start"]) - - for _key, _value in data_config["components"].items(): - put("components/{}".format(_key), data_config["components"][_key]) - - # for _key, _value in data_config["plugins"].items(): - # put("plugins/{}".format(_key), data_config["plugins"][_key]) - - for _key, _value in data_config["openstack"].items(): - put("openstack/{}".format(_key), data_config["openstack"][_key]) - - -main() - diff --git a/moon_forming/run.sh b/moon_forming/run.sh deleted file mode 100644 index d731cb17..00000000 --- a/moon_forming/run.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -populate_args=$* - -echo "Waiting for Consul (http://consul:8500)" -while ! python -c "import requests; req = requests.get('http://consul:8500')" 2>/dev/null ; do - sleep 5 ; - echo -n "." -done -echo "." -echo "Consul (http://consul:8500) is up." - -python3 /root/conf2consul.py /etc/moon/moon.conf - -echo "Waiting for DB (tcp://db:3306)" -while ! python -c "import socket, sys; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.connect(('db', 3306)); sys.exit(0)" 2>/dev/null ; do - sleep 5 ; - echo -n "." -done -echo "." -echo "Database (http://db:3306) is up." - -moon_db_manager upgrade - -echo "Waiting for Keystone (http://keystone:5000)" -while ! python -c "import requests; req = requests.get('http://keystone:5000')" 2>/dev/null ; do - sleep 5 ; - echo -n "." -done -echo "." -echo "Keystone (http://keystone:5000) is up." - -echo "Waiting for Manager (http://manager:8082)" -while ! python -c "import requests; req = requests.get('http://manager:8082')" 2>/dev/null ; do - sleep 5 ; - echo -n "." -done -echo "." -echo "Manager (http://manager:8082) is up." - -#for i in /data/*.py ; do -# moon_populate_values $populate_args --consul-host=consul --consul-port=8500 $i -#done |