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)

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.

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)