Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #406 from deNBI/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dweinholz authored Jul 21, 2020
2 parents 56deb31 + 7c225fc commit c02a97e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8.3-buster
FROM python:3.8.4-buster
RUN apt-get update -y
RUN apt-get install -y build-essential
WORKDIR /code
Expand Down
13 changes: 6 additions & 7 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,13 +1128,12 @@ def create_and_deploy_playbook(
port = self.get_vm_ports(openstack_id=openstack_id)
key = self.redis.hget(openstack_id, "key").decode("utf-8")
playbook = Playbook(
self.GATEWAY_IP,
port["port"],
playbooks_information,
key,
public_key,
self.logger,
self.pool,
ip=self.GATEWAY_IP,
port=port["port"],
playbooks_information=playbooks_information,
osi_private_key=key,
public_key=public_key,
pool=self.pool,
)
self.redis.hset(openstack_id, "status", self.BUILD_PLAYBOOK)
playbook.run_it()
Expand Down
24 changes: 13 additions & 11 deletions VirtualMachineService/ancon/Playbook.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import logging
import shlex
import shutil
from tempfile import NamedTemporaryFile, TemporaryDirectory
import ruamel.yaml
import subprocess
from tempfile import NamedTemporaryFile, TemporaryDirectory

import redis
import ruamel.yaml

BIOCONDA = "bioconda"
THEIA = "theiaide"
Expand All @@ -15,21 +17,21 @@

ALL_TEMPLATES = [BIOCONDA, THEIA, RSTUDIO, GUACAMOLE, JUPYTERNOTEBOOK]

LOG = logging.getLogger(__name__)

class Playbook(object):

ACTIVE = "ACTIVE"
PLAYBOOK_FAILED = "PLAYBOOK_FAILED"

def __init__(
self, ip, port, playbooks_information, osi_private_key, public_key, logger, pool
self, ip, port, playbooks_information, osi_private_key, public_key, pool
):
self.redis = redis.Redis(connection_pool=pool) # redis connection
self.yaml_exec = ruamel.yaml.YAML() # yaml writer/reader
self.vars_files = [] # _vars_file.yml to read
self.tasks = [] # task list
self.always_tasks = []
self.logger = logger
self.process = (
None # init process, returncode, standard output, standard error output
)
Expand Down Expand Up @@ -160,15 +162,15 @@ def load_vars():
self.yaml_exec.dump(data, variables)
self.add_to_playbook_lists(playbook_name)
except shutil.Error as e:
self.logger.exception(e)
LOG.exception(e)
self.add_tasks_only(playbook_name)
except IOError as e:
self.logger.exception(e)
LOG.exception(e)
self.add_tasks_only(playbook_name)
except shutil.Error as e:
self.logger.exception(e)
LOG.exception(e)
except IOError as e:
self.logger.exception(e)
LOG.exception(e)

def add_to_playbook_lists(self, playbook_name):
self.vars_files.append(playbook_name + "_vars_file.yml")
Expand Down Expand Up @@ -219,20 +221,20 @@ def run_it(self):
def check_status(self, openstack_id):
done = self.process.poll()
if done is None:
self.logger.info(
LOG.info(
"Playbook for (openstack_id) {0} still in progress.".format(
openstack_id
)
)
elif done != 0:
self.logger.info(
LOG.info(
"Playbook for (openstack_id) {0} has failed.".format(openstack_id)
)
self.redis.hset(openstack_id, "status", self.PLAYBOOK_FAILED)
self.returncode = self.process.returncode
self.process.wait()
else:
self.logger.info(
LOG.info(
"Playbook for (openstack_id) {0} is successful.".format(openstack_id)
)
self.redis.hset(openstack_id, "status", self.ACTIVE)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setuptools==49.1.0
setuptools==49.2.0
thrift >= 0.11.0,<0.20.0
python-keystoneclient
openstacksdk ==0.48.0
Expand Down

0 comments on commit c02a97e

Please sign in to comment.