Coverage for watcher/decision_engine/model/element/instance.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 (c) 2015 b<>com
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 compute_resource
20from watcher.objects import base
21from watcher.objects import fields as wfields
24class InstanceState(enum.Enum):
25 ACTIVE = 'active' # Instance is running
26 BUILDING = 'building' # Instance only exists in DB
27 PAUSED = 'paused'
28 SUSPENDED = 'suspended' # Instance is suspended to disk.
29 STOPPED = 'stopped' # Instance is shut off, the disk image is still there.
30 RESCUED = 'rescued' # A rescue image is running with the original image
31 # attached.
32 RESIZED = 'resized' # an Instance with the new size is active.
33 SHELVED = 'shelved'
35 SOFT_DELETED = 'soft-delete'
36 # still available to restore.
37 DELETED = 'deleted' # Instance is permanently deleted.
39 ERROR = 'error'
42@base.WatcherObjectRegistry.register_if(False)
43class Instance(compute_resource.ComputeResource):
45 fields = {
46 # If the resource is excluded by the scope,
47 # 'watcher_exclude' property will be set True.
48 "watcher_exclude": wfields.BooleanField(default=False),
49 "name": wfields.StringField(),
50 "state": wfields.StringField(default=InstanceState.ACTIVE.value),
51 "memory": wfields.NonNegativeIntegerField(),
52 "disk": wfields.NonNegativeIntegerField(),
53 "vcpus": wfields.NonNegativeIntegerField(),
54 "metadata": wfields.JsonField(),
55 "project_id": wfields.UUIDField(),
56 "locked": wfields.BooleanField(default=False),
57 }
59 def accept(self, visitor):
60 raise NotImplementedError()