Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

honour tag element within rock-on json. Fixes #2014 #2016

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions src/rockstor/storageadmin/views/rockon_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def rockon_status(name):


def rm_container(name):
o, e, rc = run_command([DOCKER, 'stop', name], throw=False)
o, e, rc = run_command([DOCKER, 'rm', name], throw=False)
o, e, rc = run_command([DOCKER, 'stop', name], throw=False, log=True)
o, e, rc = run_command([DOCKER, 'rm', name], throw=False, log=True)
return logger.debug(('Attempted to remove a container ({}). Out: {} '
'Err: {} rc: {}.').format(name, o, e, rc))

Expand All @@ -75,7 +75,7 @@ def generic_start(rockon):
try:
for c in DContainer.objects.filter(
rockon=rockon).order_by('launch_order'):
run_command([DOCKER, 'start', c.name])
run_command([DOCKER, 'start', c.name], log=True)
except Exception as e:
logger.error(('Exception while starting the '
'rockon ({}).').format(rockon.name))
Expand All @@ -98,7 +98,7 @@ def generic_stop(rockon):
try:
for c in DContainer.objects.filter(
rockon=rockon).order_by('-launch_order'):
run_command([DOCKER, 'stop', c.name])
run_command([DOCKER, 'stop', c.name], log=True)
except Exception as e:
logger.debug(('Exception while stopping the '
'rockon ({}).').format(rockon.name))
Expand Down Expand Up @@ -235,7 +235,8 @@ def generic_install(rockon):
for c in DContainer.objects.filter(rockon=rockon).order_by('launch_order'):
rm_container(c.name)
# pull image explicitly so we get updates on re-installs.
run_command([DOCKER, 'pull', c.dimage.name])
image_name_plus_tag = c.dimage.name + ':' + c.dimage.tag
run_command([DOCKER, 'pull', image_name_plus_tag], log=True)
cmd = list(DCMD2) + ['--name', c.name, ]
cmd.extend(vol_ops(c))
# Add '--device' flag
Expand All @@ -251,35 +252,47 @@ def generic_install(rockon):
cmd.extend(container_ops(c))
cmd.extend(envars(c))
cmd.extend(labels_ops(c))
cmd.append(c.dimage.name)
cmd.append(image_name_plus_tag)
cmd.extend(cargs(c))
run_command(cmd)
run_command(cmd, log=True)


def openvpn_install(rockon):
"""
Custom config for the openvpn Rock-on install.
:param rockon:
:return:
"""
# volume container
vol_co = DContainer.objects.get(rockon=rockon, launch_order=1)
volc_cmd = list(DCMD) + ['--name', vol_co.name, ]
volc_cmd.extend(container_ops(vol_co))
volc_cmd.append(vol_co.dimage.name)
run_command(volc_cmd)
image_name_plus_tag = vol_co.dimage.name + ':' + vol_co.dimage.tag
phillxnet marked this conversation as resolved.
Show resolved Hide resolved
volc_cmd.append(image_name_plus_tag)
run_command(volc_cmd, log=True)
# initialize vol container data
cco = DCustomConfig.objects.get(rockon=rockon)
oc = DContainer.objects.get(rockon=rockon, launch_order=2)
dinit_cmd = list(DCMD) + ['--rm', ]
dinit_cmd.extend(container_ops(oc))
dinit_cmd.extend([oc.dimage.name, 'ovpn_genconfig', '-u',
image_name_plus_tag = oc.dimage.name + ':' + oc.dimage.tag
dinit_cmd.extend([image_name_plus_tag, 'ovpn_genconfig', '-u',
'udp://%s' % cco.val, ])
run_command(dinit_cmd)
run_command(dinit_cmd, log=True)
# start the server
server_cmd = list(DCMD2) + ['--name', oc.name, ]
server_cmd.extend(container_ops(oc))
server_cmd.extend(port_ops(oc))
server_cmd.append(oc.dimage.name)
run_command(server_cmd)
run_command(server_cmd, log=True)


def owncloud_install(rockon):
"""
Custom config for the owncloud Rock-on install.
:param rockon:
:return:
"""
for c in DContainer.objects.filter(rockon=rockon).order_by('launch_order'):
rm_container(c.name)
cmd = list(DCMD2) + ['--name', c.name, ]
Expand All @@ -302,7 +315,8 @@ def owncloud_install(rockon):
'-e', 'HTTPS_ENABLED=true'])
cmd.extend(['-e', 'DB_USER=%s' % db_user, '-e',
'DB_PASS=%s' % db_pw, ])
cmd.append(c.dimage.name)
image_name_plus_tag = c.dimage.name + ':' + c.dimage.tag
phillxnet marked this conversation as resolved.
Show resolved Hide resolved
cmd.append(image_name_plus_tag)
logger.debug('Docker cmd = ({}).'.format(cmd))
run_command(cmd)
if (c.dimage.name == 'postgres'):
Expand Down