Added method to OpenStackHeatStack to return OpenStackFlavor objects.
[snaps.git] / snaps / domain / flavor.py
1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 #                    and others.  All rights reserved.
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 implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16
17 class Flavor:
18     """
19     SNAPS domain object for Flavors. Should contain attributes that
20     are shared amongst cloud providers
21     """
22     def __init__(self, **kwargs):
23         """
24         Constructor
25         :param name: the flavor's name
26         :param flavor_id or id: the flavor's id
27         :param ram: the flavor's RAM in MB
28         :param disk: the flavor's disk size in GB
29         :param vcpus: the flavor's number of virtual CPUs
30         :param ephemeral: the flavor's ephemeral disk in GB
31         :param swap: the flavor's swap space in MB
32         :param rxtx_factor: the flavor's RX/TX factor integer value
33         :param is_public: denotes if flavor can be used by other projects
34         """
35         self.name = kwargs.get('name')
36         self.id = kwargs.get('flavor_id', kwargs.get('id'))
37         self.ram = kwargs.get('ram')
38         self.disk = kwargs.get('disk')
39         self.vcpus = kwargs.get('vcpus')
40         self.ephemeral = kwargs.get('ephemeral')
41
42         if kwargs.get('swap'):
43             self.swap = int(kwargs.get('swap'))
44         else:
45             self.swap = None
46
47         self.rxtx_factor = kwargs.get('rxtx_factor')
48         self.is_public = kwargs.get('is_public')