Using OpenStack Shared File Systems

Using OpenStack Shared File Systems

Before working with the Shared File System service, you’ll need to create a connection to your OpenStack cloud by following the Connect user guide. This will provide you with the conn variable used in the examples below.

List Availability Zones

A Shared File System service availability zone is a failure domain for your shared file systems. You may create a shared file system (referred to simply as shares) in a given availability zone, and create replicas of the share in other availability zones.

def list_availability_zones(conn):
    print("List Shared File System Availability Zones:")
    for az in conn.share.availability_zones():
        print(az)

Share Instances

Administrators can list, show information for, explicitly set the state of, and force-delete share instances.

def share_instances(conn, **query):
    print('List all share instances:')
    for si in conn.share.share_instances(**query):
        print(si)

Get Share Instance

Shows details for a single share instance.

def get_share_instance(conn, share_instance_id):
    print('Get share instance with given Id:')
    share_instance = conn.share.get_share_instance(share_instance_id)
    print(share_instance)

Reset Share Instance Status

Explicitly updates the state of a share instance.

def reset_share_instance_status(conn, share_instance_id, status):
    print(
        'Reset the status of the share instance with the given '
        'share_instance_id to the given status'
    )
    conn.share.reset_share_instance_status(share_instance_id, status)

Delete Share Instance

Force-deletes a share instance.

def delete_share_instance(conn, share_instance_id):
    print('Force-delete the share instance with the given share_instance_id')
    conn.share.delete_share_instance(share_instance_id)

Resize Share

Shared File System shares can be resized (extended or shrunk) to a given size. For details on resizing shares, refer to the Manila docs.

def resize_share(conn, share_id, share_size):
    # Be explicit about not wanting to use force if the share
    # will be extended.
    use_force = False
    print('Resize the share to the given size:')
    conn.share.resize_share(share_id, share_size, use_force)
def resize_shares_without_shrink(conn, min_size):
    # Sometimes, extending shares without shrinking
    # them (effectively setting a min size) is desirable.

    # Get list of shares from the connection.
    shares = conn.share.shares()

    # Loop over the shares:
    for share in shares:
        # Extend shares smaller than min_size to min_size,
        # but don't shrink shares larger than min_size.
        conn.share.resize_share(share.id, min_size, no_shrink=True)

List Share Group Snapshots

A share group snapshot is a point-in-time, read-only copy of the data that is contained in a share group. You can list all share group snapshots

def list_share_group_snapshots(conn, **query):
    print("List all share group snapshots:")
    share_group_snapshots = conn.share.share_group_snapshots(**query)
    for share_group_snapshot in share_group_snapshots:
        print(share_group_snapshot)

Get Share Group Snapshot

Show share group snapshot details

def get_share_group_snapshot(conn, group_snapshot_id):
    print("Show share group snapshot with given Id:")
    share_group_snapshot = conn.share.get_share_group_snapshots(
        group_snapshot_id
    )
    print(share_group_snapshot)

List Share Group Snapshot Members

Lists all share group snapshots members.

def share_group_snapshot_members(conn, group_snapshot_id):
    print("Show share group snapshot members with given Id:")
    members = conn.share.share_group_snapshot_members(group_snapshot_id)
    for member in members:
        print(member)

Create Share Group Snapshot

Creates a snapshot from a share group.

def create_share_group_snapshot(conn, share_group_id, **attrs):
    print("Creating a share group snapshot from given attributes:")
    share_group_snapshot = conn.share.create_share_group_snapshot(
        share_group_id, **attrs
    )
    print(share_group_snapshot)

Reset Share Group Snapshot

Reset share group snapshot state.

def reset_share_group_snapshot_status(conn, group_snapshot_id, status):
    print("Reseting the share group snapshot status:")
    conn.share.reset_share_group_snapshot_status(group_snapshot_id, status)

Update Share Group Snapshot

Updates a share group snapshot.

def update_share_group_snapshot(conn, group_snapshot_id, **attrs):
    print("Updating a share group snapshot with given Id:")
    share_group_snapshot = conn.share.update_share_group_snapshot(
        group_snapshot_id, **attrs
    )
    print(share_group_snapshot)

Delete Share Group Snapshot

Deletes a share group snapshot.

def delete_share_group_snapshot(conn, group_snapshot_id):
    print("Deleting a share group snapshot with given Id:")
    conn.share.delete_share_group_snapshot(group_snapshot_id)
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.