Skip to content

Commit

Permalink
Merge pull request #120 from whole-tale/stata
Browse files Browse the repository at this point in the history
Stata support
  • Loading branch information
Xarthisius authored Jan 20, 2021
2 parents e56123e + e3dc3d3 commit 9a5da5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions gwvolman/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ def remove_volume(self, instanceId):
logging.info("Unmounting %s", dest)
subprocess.call("umount %s" % dest, shell=True)

logging.info("Unmounting licenses")
subprocess.call("umount /licenses", shell=True)

try:
self.girder_client.delete('/dm/session/{sessionId}'.format(**instance))
except Exception as e:
Expand Down
27 changes: 23 additions & 4 deletions gwvolman/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import uuid
import logging
import docker
import datetime
import dateutil.relativedelta as rel

from .constants import LICENSE_PATH, MOUNTPOINTS, REPO2DOCKER_VERSION

Expand Down Expand Up @@ -234,10 +236,27 @@ def _launch_container(volumeName, nodeId, container_config, tale_id='', instance
)
host = 'tmp-{}'.format(new_user(12).lower())

# Add licences mount for STATA and Matlab support
mounts.append(
docker.types.Mount(type="bind", source=LICENSE_PATH, target="/licenses")
)
if container_config.buildpack:
# Mount the MATLAB and Stata runtime licenses
if container_config.buildpack == "MatlabBuildPack":
mounts.append(
docker.types.Mount(type='bind',
source=LICENSE_PATH,
target="/licenses")
)
elif container_config.buildpack == "StataBuildPack":
# Weekly license expires each Sunday and is provided
# in the format stata.YYYYMMDD.lic where YYYYMMDD is the
# license expiration date.
license_date = datetime.date.today() + rel.relativedelta(days=1, weekday=rel.SU)
source_path = os.path.join(
LICENSE_PATH, "stata", f"stata.{license_date.strftime('%Y%m%d')}.lic"
)
mounts.append(
docker.types.Mount(
type='bind', source=source_path, target="/usr/local/stata/stata.lic"
)
)

# https://github.com/containous/traefik/issues/2582#issuecomment-354107053
endpoint_spec = docker.types.EndpointSpec(mode="vip")
Expand Down

0 comments on commit 9a5da5d

Please # to comment.