blockdevice

package module
v0.0.0-...-07bbb5b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

This package is a general abstraction on top of the official rbd/rados libraries in order to make the creation of blockdevices simpler.

Index

Constants

View Source
const (
	DefaultPoolName       = "rbd"
	DefaultFileSystemType = "xfs"
)

Variables

This section is empty.

Functions

func RunCommand

func RunCommand(name string, args ...string) (string, error)

This is a helper method for running a command and returning the output.

Types

type Connection

type Connection struct {
	*rados.Conn
	// contains filtered or unexported fields
}

This struct represents a connection to the ceph cluster

func NewConnection

func NewConnection(username string, pool string, cluster string, configFile string) (*Connection, error)

Creates a new connection to a Ceph cluster, this connection could be shutdown by defering the `Shutdown` method.

func (*Connection) GetImageByName

func (c *Connection) GetImageByName(name string) (*Image, error)

This method retrieves an image from the pool given the `name`

func (*Connection) GetMappedDevices

func (c *Connection) GetMappedDevices() (map[string]string, error)

This method lists all the mapped devices available on the system as seen by the output of the 'rbd showmapped' command

func (*Connection) GetOrCreateImage

func (c *Connection) GetOrCreateImage(name string, size uint64) (*Image, error)

This method tries to fetch the given `name` from the ceph pool, if is not found it creates a new one using the given `size` parameter.

func (*Connection) Shutdown

func (c *Connection) Shutdown()

This method destroys the connection context and the connection itself.

type Device

type Device struct {
	// contains filtered or unexported fields
}

This structure represents a local device mapped on the system.

func NewDevice

func NewDevice(image *Image, fsType string, mountPoint string) (*Device, error)

This method is a contructor for `Device` Objects.

func (*Device) Format

func (d *Device) Format() error

This method formats a given device with the specific filesystem type

func (*Device) GetFileSystemType

func (d *Device) GetFileSystemType() (string, error)

This method returns the filesystem type using blkid of a given device.

func (*Device) GetMountPoint

func (d *Device) GetMountPoint() string

Getter method for mountpoint

func (*Device) GetPath

func (d *Device) GetPath() string

Getter method for path

func (*Device) IsAlreadyFormatted

func (d *Device) IsAlreadyFormatted() bool

This method checks if the current filesystem for a given device matches the expected fileSystemType.

func (*Device) Mount

func (d *Device) Mount(mountPoint string) (string, error)

This method mounts a `Device` on the given Mountpoint, it returns and error if is already mounted or has been already formatted.

func (*Device) UnMap

func (d *Device) UnMap() error

This method unmaps a device using the 'rbd unmap' command

func (*Device) UnMount

func (d *Device) UnMount() error

This method unmounts the device from the current mounting path.

type Image

type Image struct {
	*rbd.Image
	*rbd.ImageInfo
	*Connection
	// contains filtered or unexported fields
}

This struct represents a RBD Image

func NewImage

func NewImage(image *rbd.Image, connection *Connection, name string) (*Image, error)

This is a constructor for `Image`, this also opens an image descriptor, and performs an Stat on it.

func (*Image) IsAlreadyMapped

func (i *Image) IsAlreadyMapped() string

This methods returns the current device path of a given device is if mapped, otherwise it returns an empty string

func (*Image) MapToDevice

func (i *Image) MapToDevice(fsType string, mountPoint string) (*Device, error)

This method creates a new rados device (if available on the system), formats it on the given `fsType` and mount it on the given `mountPoint`

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL