Skip to content

Commit

Permalink
Merge pull request #2888 from phillxnet/2886-Rock-on-install-wizard-o…
Browse files Browse the repository at this point in the history
…bfuscates-share-container-info

Rock-on install wizard obfuscates share container info #2886
  • Loading branch information
phillxnet authored Aug 19, 2024
2 parents 3bb32e0 + 9e46bbc commit 22614e7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
17 changes: 13 additions & 4 deletions src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,13 @@ RockonShareChoice = RockstorWizardPage.extend({
this.validator.showErrors();
return $.Deferred().reject();
}

var share_map = {};
var volumes = this.volumes.filter(function(volume) {
share_map[this.$('#' + volume.id).val()] = volume.get('dest_dir');
co_id = volume.get('container');
if(share_map[co_id] === undefined ) {
share_map[co_id] = {};
}
share_map[co_id][this.$('#' + volume.id).val()] = volume.get('dest_dir');
return volume;
}, this);
this.model.set('share_map', share_map);
Expand Down Expand Up @@ -838,14 +841,20 @@ RockonInstallSummary = RockstorWizardPage.extend({

render: function() {
RockstorWizardPage.prototype.render.apply(this, arguments);
var container_env_map = {}
var container_env_map = {};
for (const [container, container_envs] of Object.entries(this.env_map)) {
for (const [env, value] of Object.entries(container_envs)) {
container_env_map[`${env}:container-id:${container}`] = value
}
}
var container_share_map = {};
for (const [container, container_shares] of Object.entries(this.share_map)) {
for (const [share, value] of Object.entries(container_shares)) {
container_share_map[`${share}:container-id:${container}`] = value
}
}
this.$('#ph-summary-table').html(this.table_template({
share_map: this.share_map,
share_map: container_share_map,
port_map: this.port_map,
cc_map: this.cc_map,
dev_map: this.dev_map,
Expand Down
31 changes: 18 additions & 13 deletions src/rockstor/storageadmin/views/rockon_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,23 @@ def post(self, request, rid, command):
containers = DContainer.objects.filter(rockon=rockon)
for co in containers:
co_id = str(co.id)
for sname in share_map.keys():
dest_dir = share_map[sname]
if not Share.objects.filter(name=sname).exists():
e_msg = "Invalid share ({}).".format(sname)
handle_exception(Exception(e_msg), request)
if DVolume.objects.filter(
container=co, dest_dir=dest_dir
).exists():
so = Share.objects.get(name=sname)
vo = DVolume.objects.get(container=co, dest_dir=dest_dir)
vo.share = so
vo.save()
# {'host_port' : 'container_port', ... }
# share_map={'2': {'share-name1': '/etc/bareos'}, '3': {'share-name2': '/etc/bareos'}
if co_id in share_map:
for sname in share_map[co_id].keys():
dest_dir = share_map[co_id][sname]
if not Share.objects.filter(name=sname).exists():
e_msg = "Invalid share ({}).".format(sname)
handle_exception(Exception(e_msg), request)
if DVolume.objects.filter(
container=co, dest_dir=dest_dir
).exists():
so = Share.objects.get(name=sname)
vo = DVolume.objects.get(
container=co, dest_dir=dest_dir
)
vo.share = so
vo.save()
# port_map={'host_port': 'container_port', ... }
for p in port_map.keys():
if DPort.objects.filter(hostp=p).exists():
dup_po = DPort.objects.get(hostp=p)
Expand Down Expand Up @@ -178,6 +182,7 @@ def post(self, request, rid, command):
cco = DCustomConfig.objects.get(rockon=rockon, key=c)
cco.val = cc_map[c]
cco.save()
# env_map={'85': {'PASSWORD': '***'}, '86': {'DB_ADMIN_PASSWORD': '+++', ...}, ...}
if co_id in env_map:
for e in env_map[co_id].keys():
if not DContainerEnv.objects.filter(
Expand Down

0 comments on commit 22614e7

Please sign in to comment.