charmhelpers.contrib.storage.linux package¶
charmhelpers.contrib.storage.linux.ceph module¶
-
class
charmhelpers.contrib.storage.linux.ceph.
CephBrokerRq
(api_version=1)¶ Bases:
object
Ceph broker request.
Multiple operations can be added to a request and sent to the Ceph broker to be executed.
Request is json-encoded for sending over the wire.
The API is versioned and defaults to version 1.
-
add_op_create_pool
(name, replica_count=3)¶
-
request
¶
-
-
class
charmhelpers.contrib.storage.linux.ceph.
CephBrokerRsp
(encoded_rsp)¶ Bases:
object
Ceph broker response.
Response is json-decoded and contents provided as methods/properties.
The API is versioned and defaults to version 1.
-
exit_code
¶
-
exit_msg
¶
-
-
charmhelpers.contrib.storage.linux.ceph.
ceph_version
()¶ Retrieve the local version of ceph.
-
charmhelpers.contrib.storage.linux.ceph.
configure
(service, key, auth, use_syslog)¶ Perform basic configuration of Ceph.
-
charmhelpers.contrib.storage.linux.ceph.
copy_files
(src, dst, symlinks=False, ignore=None)¶ Copy files from src to dst.
-
charmhelpers.contrib.storage.linux.ceph.
create_key_file
(service, key)¶ Create a file containing key.
-
charmhelpers.contrib.storage.linux.ceph.
create_keyring
(service, key)¶ Create a new Ceph keyring containing key.
-
charmhelpers.contrib.storage.linux.ceph.
create_pool
(service, name, replicas=3)¶ Create a new RADOS pool.
-
charmhelpers.contrib.storage.linux.ceph.
create_rbd_image
(service, pool, image, sizemb)¶ Create a new RADOS block device.
-
charmhelpers.contrib.storage.linux.ceph.
delete_keyring
(service)¶ Delete an existing Ceph keyring.
-
charmhelpers.contrib.storage.linux.ceph.
delete_pool
(service, name)¶ Delete a RADOS pool from ceph.
-
charmhelpers.contrib.storage.linux.ceph.
ensure_ceph_keyring
(service, user=None, group=None)¶ Ensures a ceph keyring is created for a named service and optionally ensures user and group ownership.
Returns False if no ceph key is available in relation state.
-
charmhelpers.contrib.storage.linux.ceph.
ensure_ceph_storage
(service, pool, rbd_img, sizemb, mount_point, blk_device, fstype, system_services=[], replicas=3)¶ NOTE: This function must only be called from a single service unit for the same rbd_img otherwise data loss will occur.
Ensures given pool and RBD image exists, is mapped to a block device, and the device is formatted and mounted at the given mount_point.
If formatting a device for the first time, data existing at mount_point will be migrated to the RBD device before being re-mounted.
All services listed in system_services will be stopped prior to data migration and restarted when complete.
-
charmhelpers.contrib.storage.linux.ceph.
filesystem_mounted
(fs)¶ Determine whether a filesytems is already mounted.
-
charmhelpers.contrib.storage.linux.ceph.
get_ceph_nodes
()¶ Query named relation ‘ceph’ to determine current nodes.
-
charmhelpers.contrib.storage.linux.ceph.
get_osds
(service)¶ Return a list of all Ceph Object Storage Daemons currently in the cluster.
-
charmhelpers.contrib.storage.linux.ceph.
image_mapped
(name)¶ Determine whether a RADOS block device is mapped locally.
-
charmhelpers.contrib.storage.linux.ceph.
install
()¶ Basic Ceph client installation.
-
charmhelpers.contrib.storage.linux.ceph.
make_filesystem
(blk_device, fstype='ext4', timeout=10)¶ Make a new filesystem on the specified block device.
-
charmhelpers.contrib.storage.linux.ceph.
map_block_storage
(service, pool, image)¶ Map a RADOS block device for local use.
-
charmhelpers.contrib.storage.linux.ceph.
modprobe
(module)¶ Load a kernel module and configure for auto-load on reboot.
-
charmhelpers.contrib.storage.linux.ceph.
place_data_on_block_device
(blk_device, data_src_dst)¶ Migrate data in data_src_dst to blk_device and then remount.
-
charmhelpers.contrib.storage.linux.ceph.
pool_exists
(service, name)¶ Check to see if a RADOS pool already exists.
-
charmhelpers.contrib.storage.linux.ceph.
rbd_exists
(service, pool, rbd_img)¶ Check to see if a RADOS block device exists.
charmhelpers.contrib.storage.linux.loopback module¶
-
charmhelpers.contrib.storage.linux.loopback.
create_loopback
(file_path)¶ Create a loopback device for a given backing file.
Returns: str: Full path to new loopback device (eg, /dev/loop0)
-
charmhelpers.contrib.storage.linux.loopback.
ensure_loopback_device
(path, size)¶ Ensure a loopback device exists for a given backing file path and size. If it a loopback device is not mapped to file, a new one will be created.
TODO: Confirm size of found loopback device.
Returns: str: Full path to the ensured loopback device (eg, /dev/loop0)
-
charmhelpers.contrib.storage.linux.loopback.
loopback_devices
()¶ Parse through ‘losetup -a’ output to determine currently mapped loopback devices. Output is expected to look like:
/dev/loop0: [0807]:961814 (/tmp/my.img)Returns: dict: a dict mapping {loopback_dev: backing_file}
charmhelpers.contrib.storage.linux.lvm module¶
-
charmhelpers.contrib.storage.linux.lvm.
create_lvm_physical_volume
(block_device)¶ Initialize a block device as an LVM physical volume.
Parameters: block_device – str: Full path of block device to initialize.
-
charmhelpers.contrib.storage.linux.lvm.
create_lvm_volume_group
(volume_group, block_device)¶ Create an LVM volume group backed by a given block device.
Assumes block device has already been initialized as an LVM PV.
Parameters: volume_group – str: Name of volume group to create. Block_device: str: Full path of PV-initialized block device.
-
charmhelpers.contrib.storage.linux.lvm.
deactivate_lvm_volume_group
(block_device)¶ Deactivate any volume gruop associated with an LVM physical volume.
Parameters: block_device – str: Full path to LVM physical volume
-
charmhelpers.contrib.storage.linux.lvm.
is_lvm_physical_volume
(block_device)¶ Determine whether a block device is initialized as an LVM PV.
Parameters: block_device – str: Full path of block device to inspect. Returns: boolean: True if block device is a PV, False if not.
-
charmhelpers.contrib.storage.linux.lvm.
list_lvm_volume_group
(block_device)¶ List LVM volume group associated with a given block device.
Assumes block device is a valid LVM PV.
Parameters: block_device – str: Full path of block device to inspect. Returns: str: Name of volume group associated with block device or None
-
charmhelpers.contrib.storage.linux.lvm.
remove_lvm_physical_volume
(block_device)¶ Remove LVM PV signatures from a given block device.
Parameters: block_device – str: Full path of block device to scrub.
charmhelpers.contrib.storage.linux.utils module¶
-
charmhelpers.contrib.storage.linux.utils.
is_block_device
(path)¶ Confirm device at path is a valid block device node.
Returns: boolean: True if path is a block device, False if not.
-
charmhelpers.contrib.storage.linux.utils.
is_device_mounted
(device)¶ Given a device path, return True if that device is mounted, and False if it isn’t.
Parameters: device – str: Full path of the device to check. Returns: boolean: True if the path represents a mounted device, False if it doesn’t.
-
charmhelpers.contrib.storage.linux.utils.
zap_disk
(block_device)¶ Clear a block device of partition table. Relies on sgdisk, which is installed as pat of the ‘gdisk’ package in Ubuntu.
Parameters: block_device – str: Full path of block device to clean.