Skip to content

Commit

Permalink
Merge pull request #711 from schakrava/697_owncloud
Browse files Browse the repository at this point in the history
697 owncloud
  • Loading branch information
schakrava committed Jul 5, 2015
2 parents 101ee47 + 9c8a382 commit dc7134d
Show file tree
Hide file tree
Showing 30 changed files with 1,434 additions and 416 deletions.
1 change: 0 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ extends = base-buildout.cfg

parts =
stop-servers
rpm-deps
django
scripts
postgres-setup
Expand Down
15 changes: 14 additions & 1 deletion src/rockstor/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,10 @@ def remove_share(pool, pool_device, share_name):
subvol_mnt_pt = root_pool_mnt + '/' + share_name
if (not is_subvol(subvol_mnt_pt)):
return
qgroup = ('0/%s' % share_id(pool, pool_device, share_name))
delete_cmd = [BTRFS, 'subvolume', 'delete', subvol_mnt_pt]
run_command(delete_cmd)
return qgroup_destroy(qgroup, root_pool_mnt)


def remove_snap(pool, pool_device, share_name, snap_name):
Expand All @@ -360,7 +362,9 @@ def remove_snap(pool, pool_device, share_name, snap_name):
if (is_mounted(snap_path)):
umount_root(snap_path)
if (is_subvol(snap_path)):
return run_command([BTRFS, 'subvolume', 'delete', snap_path])
qgroup = ('0/%s' % share_id(pool, pool_device, snap_name))
run_command([BTRFS, 'subvolume', 'delete', snap_path])
return qgroup_destroy(qgroup, root_mnt)
else:
o, e, rc = run_command([BTRFS, 'subvolume', 'list', '-s', root_mnt])
snap = None
Expand Down Expand Up @@ -460,6 +464,15 @@ def qgroup_id(pool, disk_name, share_name):
return '0/' + sid


def qgroup_destroy(qid, mnt_pt):
o, e, rc = run_command([BTRFS, 'qgroup', 'show', mnt_pt])
for l in o:
if (re.match(qid, l) is not None and
l.split()[0] == qid):
return run_command([BTRFS, 'qgroup', 'destroy', qid, mnt_pt])
return False


def update_quota(pool, pool_device, qgroup, size_bytes):
pool_device = '/dev/' + pool_device
root_pool_mnt = mount_root(pool, pool_device)
Expand Down
53 changes: 53 additions & 0 deletions src/rockstor/qgroup_clean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
Copyright (c) 2012-2015 RockStor, Inc. <http://rockstor.com>
This file is part of RockStor.
RockStor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
RockStor is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

BTRFS = '/usr/sbin/btrfs'


import re
from django.conf import settings
from storageadmin.models import Pool
from system.osi import run_command


def main():
for p in Pool.objects.all():
mnt_pt = '%s%s' % (settings.MNT_PT, p.name)
o, e, rc = run_command([BTRFS, 'subvol', 'list', mnt_pt])
subvol_ids = []
for l in o:
if (re.match('ID ', l) is not None):
subvol_ids.append(l.split()[1])

o, e, rc = run_command([BTRFS, 'qgroup', 'show', mnt_pt])
qgroup_ids = []
for l in o:
if (re.match('0/', l) is not None):
q = l.split()[0].split('/')[1]
if (q == '5'):
continue
qgroup_ids.append(l.split()[0].split('/')[1])

for q in qgroup_ids:
if (q not in subvol_ids):
print ('qgroup %s not in use. deleting' % q)
run_command([BTRFS, 'qgroup', 'destroy', '0/%s' % q, mnt_pt])


if __name__ == '__main__':
main()

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/rockstor/storageadmin/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from pool_balance import PoolBalance
from tls_certificate import TLSCertificate
from rockon import (RockOn, DImage, DContainer, DPort, DVolume,
ContainerOption, DCustomConfig)
ContainerOption, DCustomConfig, DContainerLink)
from smart import (SMARTAttribute, SMARTCapability, SMARTErrorLog,
SMARTErrorLogSummary, SMARTTestLog, SMARTTestLogDetail,
SMARTIdentity, SMARTInfo)
36 changes: 34 additions & 2 deletions src/rockstor/storageadmin/models/rockon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ class RockOn(models.Model):
status = models.CharField(max_length=2048)
link = models.CharField(max_length=1024, null=True)
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 All @@ -46,18 +61,31 @@ class DContainer(models.Model):
rockon = models.ForeignKey(RockOn)
dimage = models.ForeignKey(DImage)
name = models.CharField(max_length=1024, unique=True)
link = models.ForeignKey('self', null=True)
launch_order = models.IntegerField(default=1)

class Meta:
app_label = 'storageadmin'


class DContainerLink(models.Model):
source = models.OneToOneField(DContainer)
destination = models.ForeignKey(DContainer, related_name='destination_container')
name = models.CharField(max_length=64, null=True)

class Meta:
unique_together = ('destination', 'name')
app_label = 'storageadmin'


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()
container = models.ForeignKey(DContainer)
protocol = models.CharField(max_length=32, null=True)
uiport = models.BooleanField(default=False)
label = models.CharField(max_length=1024, null=True)

class Meta:
unique_together = ('container', 'containerp',)
Expand All @@ -69,6 +97,9 @@ class DVolume(models.Model):
share = models.ForeignKey(Share, null=True)
dest_dir = models.CharField(max_length=1024)
uservol = models.BooleanField(default=False)
description = models.CharField(max_length=1024, null=True)
min_size = models.IntegerField(null=True)
label = models.CharField(max_length=1024, null=True)

@property
def share_name(self):
Expand All @@ -84,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 All @@ -95,6 +126,7 @@ class DCustomConfig(models.Model):
key = models.CharField(max_length=1024)
val = models.CharField(max_length=1024, null=True)
description = models.CharField(max_length=2048, null=True)
label = models.CharField(max_length=64, null=True)

class Meta:
unique_together = ('rockon', 'key',)
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
20 changes: 20 additions & 0 deletions src/rockstor/storageadmin/static/storageadmin/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2526,4 +2526,24 @@ This file is generated by `grunt build`, do not edit it by hand.

.shorten-input {
width: 50%;
}

.overlay {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background-color:rgba(0, 0, 0, 0.57);
background: url(data:;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABl0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuNUmK/OAAAAATSURBVBhXY2RgYNgHxGAAYuwDAA78AjwwRoQYAAAAAElFTkSuQmCC) repeat scroll transparent\9; /* ie fallback png background image */
z-index:9999;
color:white;
}

.overlay-text {
display: inline-block;
vertical-align: middle;
padding: 10px 15px;
position:relative;
font-weight:bold;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
<label class="control-label"></label>

<div class="form-box">
<form id="custom-choice-form" name="aform" >
<form id="custom-choice-form" name="aform" class="form-horizontal">
<div class="messages"></div>
<% cc.each(function(cci, index) { %>
<div class="form-group">
<% cc.each(function(cci, index) { %>
<label class="control-label" for="cc"><%= cci.get('key')%><span class="required"> *</span></label!>
<label class="col-sm-3 control-label" for="cc"><%= cci.get('label')%><span class="required"> *</span></label>
<div class="controls">
<input type="text" id="<%= cci.id %>" name="<%= cci.id %>" value="<%= cci.get('val')%>">
&nbsp;&nbsp<i class="fa fa-exclamation-circle" title="<%= cci.get('description') %>" rel="tooltip"></i>
<div class="col-sm-6">
<input class="form-control" type="text" id="<%= cci.id %>" name="<%= cci.id %>" value="<%= cci.get('val')%>">
</div>
&nbsp;&nbsp<i class="fa fa-info-circle fa-lg" title="<%= cci.get('description') %>" rel="tooltip"></i>
</div>
<% }); %>
</div>
<% }); %>
</form>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<div id="breadcrumb">
<div>Shares</div>
<div>Ports</div>
<div>Config</div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 75%;">
<span class="sr-only">60% Complete</span>
</div>
</div>
<br>
<h3>Additional configuration needed for this Rock-on.</h3>
<br>
<div class="alert alert-warning">
<p>Additional configuration is needed for this Rock-on. Make sure to read tooltips for specific information before making your selection.</p>
</div>

<div id="ph-cc-form"></div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="breadcrumb">
<div>Shares</div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 25%;"></div>
</div>
<div class="alert alert-warning">
<p>Shares provide storage to the Rock-on. Make sure to read tooltips for specific information before making a selection. We strongly recommend creating dedicated Share assignments. If a Share is assigned to more than one Rock-On, it could cause strange behavior.</p>
</div>
<br>
<h4>Assign Share(s) to the Rock-on. For proper functionality, make sure to assign new/empty and dedicated Shares.</h4>
<br>
<div id="ph-vols-table"></div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="alert alert-success">
<h3>Installation is in progress.<br>It can take a while depending on the type of Rock-on, network speed and other factors.<br> You can monitor the Rock-ons page which refreshes periodically during the installation.</h3>
<p>Installation is in progress.<br>It can take a while depending on the type of Rock-on, network speed and other factors.<br> You can monitor the Rock-ons page which refreshes periodically during the installation.</p>
</div>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div id="breadcrumb">
<div>Shares</div>
<div>Ports</div>
<div>Config</div>
<div>Summary</div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 100%;">
<span class="sr-only">60% Complete</span>
</div>
</div>
<br>
<h4>Click submit to start the installation.</h4>
<br>
<div class="alert alert-warning">
<p>Please verify your input and click submit to start the installation.</p>
</div>

<div id="ph-summary-table"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= rockon.get('more_info') %>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div id="breadcrumb">
<div>Shares</div>
<div>Ports</div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 50%;">
</div>
</div>
<div class="alert alert-warning">
<p>Ports provide network access to the Rock-on. Preferred default values are provided for convenience. Read tooltips for more information.</p>
</div>
<br>
<h4>Assign appropriate ports to the Rock-on. If unsure, go with default values provided.</h4>
<br>
<div id="ph-ports-form"></div>
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
<div class="row">
<div class="col-md-8">
<div class="col-md-10">
<label class="control-label"></label>

<div class="form-box">
<form id="port-select-form" name="aform" >

<form id="port-select-form" name="aform" class="form-horizontal">
<div class="messages"></div>

<% ports.each(function(port, index) { %>
<div class="form-group">
<% ports.each(function(port, index) { %>
<label class="control-label" for="ports">Port(<%= port.get('containerp')%>)<span class="required"> *</span></label>
<div class="">
<input type="text" id="<%= port.id %>" name="<%= port.id %>" value="<%= port.get('containerp')%>" title="host port to map to the Rock-on port">
<label class="control-label col-sm-3" for="ports"><%= port.get('label') %><span class="required">*</span></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="<%= port.id %>" name="<%= port.id %>" value="<%= port.get('hostp')%>">
</div>
<% }); %>
<i class="fa fa-info-circle fa-lg" title="<%= port.get('description') %>"></i>
</div>

<% }); %>
</form>
</div>

</div>

</div>
Loading

0 comments on commit dc7134d

Please sign in to comment.