File: share_metadata.py

package info (click to toggle)
python-openstacksdk 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,352 kB
  • sloc: python: 122,960; sh: 153; makefile: 23
file content (61 lines) | stat: -rw-r--r-- 2,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


def list_share_metadata(conn, share_id):
    # Method returns the entire share with the metadata inside it.
    returned_share = conn.get_share_metadata(share_id)

    # Access metadata of share
    metadata = returned_share['metadata']

    print("List All Share Metadata:")
    for meta_key in metadata:
        print(f"{meta_key}={metadata[meta_key]}")


def get_share_metadata_item(conn, share_id, key):
    # Method returns the entire share with the metadata inside it.
    returned_share = conn.get_share_metadata_item(share_id, key)

    # Access metadata of share
    metadata = returned_share['metadata']

    print("Get share metadata item given item key and share id:")
    print(metadata[key])


def create_share_metadata(conn, share_id, metadata):
    # Method returns the entire share with the metadata inside it.
    created_share = conn.create_share_metadata(share_id, metadata)

    # Access metadata of share
    metadata = created_share['metadata']

    print("Metadata created for given share:")
    print(metadata)


def update_share_metadata(conn, share_id, metadata):
    # Method returns the entire share with the metadata inside it.
    updated_share = conn.update_share_metadata(share_id, metadata, True)

    # Access metadata of share
    metadata = updated_share['metadata']

    print("Updated metadata for given share:")
    print(metadata)


def delete_share_metadata(conn, share_id, keys):
    # Method doesn't return anything.
    conn.delete_share_metadata(share_id, keys)