~alexlist/charms/trusty/keystone/mojo-is-swift-ha

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/storage/linux/utils.py

  • Committer: James Page
  • Date: 2014-04-16 08:20:08 UTC
  • mfrom: (52.2.30 keystone)
  • Revision ID: james.page@canonical.com-20140416082008-34w0nyak0y571tfp
[james-page,ivoks,hazmat,yolanda.robla,r=james-page,t=*]

Redux to used charm helpers
Support for Icehouse on 12.04 and 14.04
Support for Active/Active and SSL RabbitMQ
Support for SSL MySQL
Support for SSL endpoints
Support for PostgreSQL

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from os import stat
 
2
from stat import S_ISBLK
 
3
 
 
4
from subprocess import (
 
5
    check_call
 
6
)
 
7
 
 
8
 
 
9
def is_block_device(path):
 
10
    '''
 
11
    Confirm device at path is a valid block device node.
 
12
 
 
13
    :returns: boolean: True if path is a block device, False if not.
 
14
    '''
 
15
    return S_ISBLK(stat(path).st_mode)
 
16
 
 
17
 
 
18
def zap_disk(block_device):
 
19
    '''
 
20
    Clear a block device of partition table. Relies on sgdisk, which is
 
21
    installed as pat of the 'gdisk' package in Ubuntu.
 
22
 
 
23
    :param block_device: str: Full path of block device to clean.
 
24
    '''
 
25
    check_call(['sgdisk', '--zap-all', '--clear',
 
26
                '--mbrtogpt', block_device])