Coverage for watcher/decision_engine/model/element/volume.py: 100%
20 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-17 12:22 +0000
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-17 12:22 +0000
1# -*- encoding: utf-8 -*-
2# Copyright 2017 NEC Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
17import enum
19from watcher.decision_engine.model.element import storage_resource
20from watcher.objects import base
21from watcher.objects import fields as wfields
24class VolumeState(enum.Enum):
25 # https://docs.openstack.org/api-ref/block-storage/v3/#volumes-volumes
27 CREATING = 'creating'
28 AVAILABLE = 'available'
29 ATTACHING = 'attaching'
30 IN_USE = 'in-use'
31 DELETING = 'deleting'
32 ERROR = 'error'
33 ERROR_DELETING = 'error_deleting'
34 BACKING_UP = 'backing-up'
35 RESTORING_BACKUP = 'restoring-backup'
36 ERROR_RESTORING = 'error_restoring'
37 ERROR_EXTENDING = 'error_extending'
40@base.WatcherObjectRegistry.register_if(False)
41class Volume(storage_resource.StorageResource):
43 fields = {
44 "size": wfields.NonNegativeIntegerField(),
45 "status": wfields.StringField(default=VolumeState.AVAILABLE.value),
46 "attachments": wfields.FlexibleListOfDictField(),
47 "name": wfields.StringField(),
48 "multiattach": wfields.BooleanField(),
49 "snapshot_id": wfields.UUIDField(nullable=True),
50 "project_id": wfields.UUIDField(),
51 "metadata": wfields.JsonField(),
52 "bootable": wfields.BooleanField()
53 }
55 def accept(self, visitor):
56 raise NotImplementedError()