Skip to content

Commit

Permalink
move wipe_disk() from fs/btrfs to system/osi rockstor#1320
Browse files Browse the repository at this point in the history
Not directly related to btrfs so moving to more general location.
Added docstrings and did minor variable name refactoring.
  • Loading branch information
phillxnet committed Jun 2, 2016
1 parent e8f8667 commit c4680a9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
7 changes: 0 additions & 7 deletions src/rockstor/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
DD = '/bin/dd'
DEFAULT_MNT_DIR = '/mnt2/'
RMDIR = '/bin/rmdir'
WIPEFS = '/usr/sbin/wipefs'
QID = '2015'


Expand Down Expand Up @@ -1103,12 +1102,6 @@ def scan_disks(min_size):
return disks


def wipe_disk(disk):
# todo candidate for move to system/osi as not btrfs related
disk = ('/dev/disk/by-id/%s' % disk)
return run_command([WIPEFS, '-a', disk])


def blink_disk(disk, total_exec, read, sleep):
# todo candidate for move to system/osi as not btrfs related
DD_CMD = [DD, 'if=/dev/disk/by-id/%s' % disk, 'of=/dev/null', 'bs=512',
Expand Down
4 changes: 2 additions & 2 deletions src/rockstor/storageadmin/views/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from rest_framework.response import Response
from django.db import transaction
from storageadmin.models import (Disk, Pool, Share)
from fs.btrfs import (scan_disks, wipe_disk, blink_disk, enable_quota,
from fs.btrfs import (scan_disks, blink_disk, enable_quota,
btrfs_uuid, pool_usage, mount_root, get_pool_info,
pool_raid, enable_quota)
from storageadmin.serializers import DiskInfoSerializer
Expand All @@ -31,7 +31,7 @@
import rest_framework_custom as rfc
from system import smart
from system.osi import set_disk_spindown, enter_standby, get_dev_byid_name, \
get_devname
wipe_disk
from copy import deepcopy
import uuid
import json
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/storageadmin/views/disk_smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
SMARTCapability, SMARTErrorLog,
SMARTErrorLogSummary, SMARTTestLog,
SMARTTestLogDetail, SMARTIdentity)
from fs.btrfs import (scan_disks, wipe_disk, blink_disk, btrfs_uuid,
from fs.btrfs import (scan_disks, blink_disk, btrfs_uuid,
pool_usage, mount_root)
from storageadmin.serializers import SMARTInfoSerializer
from storageadmin.util import handle_exception
Expand Down
12 changes: 12 additions & 0 deletions src/rockstor/system/osi.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
LSBLK = '/usr/bin/lsblk'
HDPARM = '/usr/sbin/hdparm'
SYSTEMCTL_BIN = '/usr/bin/systemctl'
WIPEFS = '/usr/sbin/wipefs'


def inplace_replace(of, nf, regex, nl):
Expand Down Expand Up @@ -388,6 +389,17 @@ def remount(mnt_pt, mnt_options):
return True


def wipe_disk(disk_byid):
"""
Simple run_command wrapper to execute "wipefs -a disk_byid"
:param disk_byid: by-id type name without path as found in db Disks.name.
:return: o, e, rc tuple returned by the run_command wrapper running the
locally generated wipefs command.
"""
disk_byid_withpath = ('/dev/disk/by-id/%s' % disk_byid)
return run_command([WIPEFS, '-a', disk_byid_withpath])


def convert_to_kib(size):
"""
Attempts to convert a size string that is initially expected to have 3
Expand Down

0 comments on commit c4680a9

Please sign in to comment.