Skip to content

Commit

Permalink
bunch of improvements for more testing. rockstor#697
Browse files Browse the repository at this point in the history
  • Loading branch information
schakrava committed Jul 4, 2015
1 parent eea554b commit 4808d85
Show file tree
Hide file tree
Showing 11 changed files with 2,687 additions and 122 deletions.
500 changes: 500 additions & 0 deletions src/rockstor/storageadmin/migrations/0031_auto__add_field_rockon_ui.py

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions src/rockstor/storageadmin/models/rockon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ class RockOn(models.Model):
website = models.CharField(max_length=2048, null=True)
https = models.BooleanField(default=False)
icon = models.URLField(max_length=1024, null=True)
ui = models.BooleanField(default=False)
volume_add_support = models.BooleanField(default=False)
more_info = models.CharField(max_length=4096, null=True)

@property
def ui_port(self):
if (not self.ui):
return None
for co in self.dcontainer_set.all():
for po in co.dport_set.all():
if (po.uiport):
return po.hostp
return None

class Meta:
app_label = 'storageadmin'
Expand Down Expand Up @@ -67,8 +80,8 @@ class Meta:
class DPort(models.Model):
description = models.CharField(max_length=1024, null=True)
hostp = models.IntegerField(unique=True)
hostp_default = models.IntegerField(null=True)
containerp = models.IntegerField()
containerp_default = models.IntegerField(null=True)
container = models.ForeignKey(DContainer)
protocol = models.CharField(max_length=32, null=True)
uiport = models.BooleanField(default=False)
Expand All @@ -85,7 +98,7 @@ class DVolume(models.Model):
dest_dir = models.CharField(max_length=1024)
uservol = models.BooleanField(default=False)
description = models.CharField(max_length=1024, null=True)
min_size = models.IntegerField(default=0)
min_size = models.IntegerField(null=True)
label = models.CharField(max_length=1024, null=True)

@property
Expand All @@ -102,7 +115,7 @@ class Meta:
class ContainerOption(models.Model):
container = models.ForeignKey(DContainer)
name = models.CharField(max_length=1024)
val = models.CharField(max_length=1024)
val = models.CharField(max_length=1024, blank=True)

class Meta:
app_label = 'storageadmin'
Expand Down
1 change: 1 addition & 0 deletions src/rockstor/storageadmin/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Meta:


class RockOnSerializer(serializers.ModelSerializer):
ui_port = serializers.IntegerField()

class Meta:
model = RockOn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ RockonInstallComplete = RockstorWizardPage.extend({
RockonSettingsWizardView = WizardView.extend({
initialize: function() {
WizardView.prototype.initialize.apply(this, arguments);
this.pages = [];
this.pages = [RockonSettingsSummary,];
this.rockon = this.model.get('rockon');
this.volumes = new RockOnVolumeCollection(null, {rid: this.rockon.id});
this.ports = new RockOnPortCollection(null, {rid: this.rockon.id});
Expand Down Expand Up @@ -640,9 +640,11 @@ RockonSettingsWizardView = WizardView.extend({
},

addPages: function() {
this.pages.push.apply(this.pages,
[RockonSettingsSummary, RockonAddShare,
RockonSettingsSummary, RockonSettingsComplete]);
if (this.rockon.get('volume_add_support')) {
this.pages.push.apply(this.pages,
[RockonAddShare, RockonSettingsSummary,
RockonSettingsComplete]);
}
WizardView.prototype.render.apply(this, arguments);
return this;
},
Expand All @@ -659,7 +661,7 @@ RockonSettingsWizardView = WizardView.extend({
if (this.currentPageNum == 0) {
this.$('#prev-page').hide();
this.$('#next-page').html('Add a Share');
if (this.volumes.length == 0) {
if (!this.rockon.get('volume_add_support')) {
this.$('#next-page').hide();
}
} else if (this.currentPageNum == (this.pages.length - 2)) {
Expand Down
21 changes: 12 additions & 9 deletions src/rockstor/storageadmin/views/rockon.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,21 @@ def post(self, request, command=None):
continue
ro.description = r_d['description']
ro.website = r_d['website']
ro.icon = r_d['icon']
ro.volume_add_support = r_d['volume_add_support']
ro.more_info = r_d['more_info']
else:
ro = RockOn(name=name,
description=r_d['description'],
version='1.0', state='available',
status='stopped', website=r_d['website'],
icon=r_d['icon'], volume_add_support=r_d['volume_add_support'],
more_info=r_d['more_info'])
status='stopped', website=r_d['website'])
if ('ui' in r_d):
ui_d = r_d['ui']
ro.link = ui_d['slug']
ro.https = ui_d['https']
if ('icon' in r_d):
ro.icon = r_d['icon']
if ('volume_add_support' in r_d):
ro.volume_add_support = r_d['volume_add_support']
if ('more_info' in r_d):
ro.more_info = r_d['more_info']
ro.save()
containers = r_d['containers']
for c in containers.keys():
Expand Down Expand Up @@ -167,16 +168,18 @@ def post(self, request, command=None):
v_d = c_d['volumes']
for v in v_d.keys():
cv_d = v_d[v]
vo = None
if (DVolume.objects.filter(dest_dir=v, container=co).exists()):
vo = DVolume.objects.get(dest_dir=v, container=co)
vo.description = cv_d['description']
vo.label = cv_d['label']
vo.min_size = cv_d['min_size']
vo.save()
else:
vo = DVolume(container=co, dest_dir=v, description=cv_d['description'],
min_size=cv_d['min_size'], label=cv_d['label'])
vo.save()
label=cv_d['label'])
if ('min_size' in cv_d):
vo.min_size = cv_d['min_size']
vo.save()

for vo in DVolume.objects.filter(container=co):
if (vo.dest_dir not in v_d):
Expand Down
23 changes: 10 additions & 13 deletions src/rockstor/storageadmin/views/rockon_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,17 @@ def btsync_install(rockon):
run_command(cmd)


def generic_install(rockon):
for c in DContainer.objects.filter(rockon=rockon).order_by('launch_order'):
cmd = [DOCKER, 'run', '-d', '--name', c.name,]
cmd.extend(vol_ops(c))
cmd.extend(port_ops(c))
cmd.append(c.dimage.name)
run_command(cmd)


def syncthing_install(rockon):
rm_container(rockon.name)
cmd = [DOCKER, 'run', '-d', '--name', rockon.name,]
c = DContainer.objects.get(rockon=rockon)
image = c.dimage.name
run_command([DOCKER, 'pull', image])
for v in DVolume.objects.filter(container=c):
share_mnt = '%s%s' % (settings.MNT_PT, v.share.name)
mount_share(v.share.name, share_mnt)
cmd.extend(['-v', '%s:%s' % (share_mnt, v.dest_dir), ])
for p in DPort.objects.filter(container=c):
cmd.extend(['-p', '%d:%d' % (p.hostp, p.containerp), ])
cmd.append(image)
run_command(cmd)
return generic_install(rockon)


def pull_images(rockon):
Expand Down
Loading

0 comments on commit 4808d85

Please sign in to comment.