File: volume.py

package info (click to toggle)
python-openstacksdk 0.9.5-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,264 kB
  • ctags: 5,542
  • sloc: python: 20,419; makefile: 133; sh: 46
file content (99 lines) | stat: -rw-r--r-- 4,245 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# 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.

from openstack.block_store import block_store_service
from openstack import format
from openstack import resource


class Volume(resource.Resource):
    resource_key = "volume"
    resources_key = "volumes"
    base_path = "/volumes"
    service = block_store_service.BlockStoreService()

    # capabilities
    allow_retrieve = True
    allow_create = True
    allow_delete = True
    allow_update = True

    # Properties
    #: A ID representing this volume.
    id = resource.prop("id")
    #: The name of this volume.
    name = resource.prop("name")
    #: A list of links associated with this volume. *Type: list*
    links = resource.prop("links", type=list)

    #: The availability zone.
    availability_zone = resource.prop("availability_zone")
    #: To create a volume from an existing volume, specify the ID of
    #: the existing volume. If specified, the volume is created with
    #: same size of the source volume.
    source_volume_id = resource.prop("source_volid")
    #: The volume description.
    description = resource.prop("description")
    #: To create a volume from an existing snapshot, specify the ID of
    #: the existing volume snapshot. If specified, the volume is created
    #: in same availability zone and with same size of the snapshot.
    snapshot_id = resource.prop("snapshot_id")
    #: The size of the volume, in GBs. *Type: int*
    size = resource.prop("size", type=int)
    #: The ID of the image from which you want to create the volume.
    #: Required to create a bootable volume.
    image_id = resource.prop("imageRef")
    #: The name of the associated volume type.
    volume_type = resource.prop("volume_type")
    #: Enables or disables the bootable attribute. You can boot an
    #: instance from a bootable volume. *Type: bool*
    is_bootable = resource.prop("bootable", type=format.BoolStr)
    #: One or more metadata key and value pairs to associate with the volume.
    metadata = resource.prop("metadata")

    #: One of the following values: creating, available, attaching, in-use
    #: deleting, error, error_deleting, backing-up, restoring-backup,
    #: error_restoring. For details on these statuses, see the
    #: Block Storage API documentation.
    status = resource.prop("status")
    #: TODO(briancurtin): This is currently undocumented in the API.
    attachments = resource.prop("attachments")
    #: The timestamp of this volume creation.
    created_at = resource.prop("created_at")


class VolumeDetail(Volume):

    base_path = "/volumes/detail"

    #: The volume's current back-end.
    host = resource.prop("os-vol-host-attr:host")
    #: The project ID associated with current back-end.
    project_id = resource.prop("os-vol-tenant-attr:tenant_id")
    #: The status of this volume's migration (None means that a migration
    #: is not currently in progress).
    migration_status = resource.prop("os-vol-mig-status-attr:migstat")
    #: The volume ID that this volume's name on the back-end is based on.
    migration_id = resource.prop("os-vol-mig-status-attr:name_id")
    #: Status of replication on this volume.
    replication_status = resource.prop("replication_status")
    #: Extended replication status on this volume.
    extended_replication_status = resource.prop(
        "os-volume-replication:extended_status")
    #: ID of the consistency group.
    consistency_group_id = resource.prop("consistencygroup_id")
    #: Data set by the replication driver
    replication_driver_data = resource.prop(
        "os-volume-replication:driver_data")
    #: ``True`` if this volume is encrypted, ``False`` if not.
    #: *Type: bool*
    is_encrypted = resource.prop("encrypted", type=format.BoolStr)