Skip to content

Commit

Permalink
Initial support for zfs backing store. Fixes #55
Browse files Browse the repository at this point in the history
Conflicts:
	lwp.py
  • Loading branch information
kylejohnson authored and claudyus committed Apr 22, 2014
1 parent 5029d11 commit f660c39
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
14 changes: 14 additions & 0 deletions lwp.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,20 @@ def create_container():
except subprocess.CalledProcessError:
flash(u'Error!' % name, 'error')

elif storage_method == 'zfs':
zfs = request.form['zpoolname']

if re.match('^[a-zA-Z0-9_-]+$', zfs) and zfs != '':
try:
if lxc.create(name, template=template, storage='zfs --zfsroot %s' % zfs, xargs=command) == 0:
flash(u'Container %s created successfully!' % name, 'success')
else:
flash(u'Failed to create %s!' % name, 'error')
except lxc.ContainerAlreadyExists:
flash(u'The Container %s is already created!' % name, 'error')
except subprocess.CalledProcessError:
flash(u'Error!' % name, 'error')

elif storage_method == 'lvm':
lvname = request.form['lvname']
vgname = request.form['vgname']
Expand Down
9 changes: 8 additions & 1 deletion templates/includes/modal_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h3 id="createCTLabel">Create container</h3>
<option value="default" selected>Default</option>
<option value="directory">Directory</option>
<option value="lvm">LVM</option>
<option value="zfs">ZFS</option>
</select>
</div>
<span class="help-inline"><small>*By default it is 'none', which is a simple directory tree under /var/lib/lxc/&lt;name&gt;/rootfs</small></span>
Expand All @@ -59,6 +60,12 @@ <h3 id="createCTLabel">Create container</h3>
<input type="text" id="inputFSSize" name="fssize" placeholder="500M">
</div>
</div>
<div class="control-group hide zfs">
<div class="controls">
<label class="control-label" for="zpoolname">zpool Name</label>
<input type="text" id="inputZFS" name="zpoolname" placeholder="lxc">
</div>
</div>
</div>
</div>
<div class="modal-footer">
Expand All @@ -74,4 +81,4 @@ <h3 id="createCTLabel">Create container</h3>
</div>
</div>
</form>
</div>
</div>
9 changes: 8 additions & 1 deletion templates/includes/modals.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ <h3 id="createCTLabel">Create container</h3>
<option value="default" selected>Default</option>
<option value="directory">Directory</option>
<option value="lvm">LVM</option>
<option value="zfs">ZFS</option>
</select>
</div>
<span class="help-inline"><small>*By default it is 'none', which is a simple directory tree under /var/lib/lxc/&lt;name&gt;/rootfs</small></span>
Expand All @@ -63,6 +64,12 @@ <h3 id="createCTLabel">Create container</h3>
<input type="text" id="inputFSSize" name="fssize" placeholder="500M">
</div>
</div>
<div class="control-group hide" id="zfs">
<div class="controls">
<label class="control-label" for="zpoolname">zpool Name</label>
<input type="text" id="inputZFS" name="zpoolname" placeholder="lxc">
</div>
</div>
</div>
</div>
<div class="modal-footer">
Expand Down Expand Up @@ -133,4 +140,4 @@ <h3 id="newUserLabel">New user</h3>
</div>
</div>
</form>
</div>
</div>
8 changes: 8 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,23 @@ <h3 style="position: relative; width: 500px;">{{ dist }} ({{ host }})</h3>
$(".backingstore").on('change',function(){
var _val = $(this).val();
var _lvm = $(this).closest('.advanced-wrapper').find('.lvm');
var _zfs = $(this).closest('.advanced-wrapper').find('.zfs');
var _directory = $(this).closest('.advanced-wrapper').find('.directory');

if( _val == 'lvm'){
_lvm.slideDown();
_directory.slideUp();
_zfs.slideUp();
}
else if ( _val == 'directory' ){
_directory.slideDown();
_lvm.slideUp();
_zfs.slideUp();
}
else if ( _val == 'zfs'){
_zfs.slideDown();
_lvm.slideUp();
_directory.slideUp();
}
else{
_directory.slideUp();
Expand Down

0 comments on commit f660c39

Please sign in to comment.