-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance.py
More file actions
34 lines (28 loc) · 1.05 KB
/
Copy pathinstance.py
File metadata and controls
34 lines (28 loc) · 1.05 KB
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
"""
Instance details
"""
class Instance:
""" Instance represents a Xen VM comprised of memory, cpu, and disk.
Keyword Arguments:
name
"""
INSTANCE_TYPES = {
'level1': dict(memory=512, vcpus=1, storage_gb=10),
'level2': dict(memory=1024, vcpus=1, storage_gb=20),
'level3': dict(memory=2048, vcpus=2, storage_gb=40),
}
def __init__(self, **kwargs):
self._name = kwargs.get('name', None)
self._memory = kwargs.get('memory', None)
self._vcpus = kwargs.get('vcpus', None)
self._storage_gb = kwargs.get('storage_gb', None)
self._state = kwargs.get('state', None)
self._instance_type = kwargs.get('instance_type', None)
self._init_instance()
def _init_instance(self):
if not self._instance_type:
return
self._instance_type = self.INSTANCE_TYPES[self._instance_type]
self._memory = self._instance_type['memory']
self._vcpus = self._instance_type['vcpus']
self._storage_gb = self._instance_type['storage_gb']