1#
2# Permission is hereby granted, free of charge, to any person obtaining a
3# copy of this software and associated documentation files (the
4# "Software"), to deal in the Software without restriction, including
5# without limitation the rights to use, copy, modify, merge, publish, dis-
6# tribute, sublicense, and/or sell copies of the Software, and to permit
7# persons to whom the Software is furnished to do so, subject to the fol-
8# lowing conditions:
9#
10# The above copyright notice and this permission notice shall be included
11# in all copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
15# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
16# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19# IN THE SOFTWARE.
20
21
22class InstanceGroup(object):
23    def __init__(self, num_instances, role, type, market, name, bidprice=None):
24        self.num_instances = num_instances
25        self.role = role
26        self.type = type
27        self.market = market
28        self.name = name
29        if market == 'SPOT':
30            if not bidprice:
31                raise ValueError('bidprice must be specified if market == SPOT')
32            self.bidprice = str(bidprice)
33
34    def __repr__(self):
35        if self.market == 'SPOT':
36            return '%s.%s(name=%r, num_instances=%r, role=%r, type=%r, market = %r, bidprice = %r)' % (
37                self.__class__.__module__, self.__class__.__name__,
38                self.name, self.num_instances, self.role, self.type, self.market,
39                self.bidprice)
40        else:
41            return '%s.%s(name=%r, num_instances=%r, role=%r, type=%r, market = %r)' % (
42                self.__class__.__module__, self.__class__.__name__,
43                self.name, self.num_instances, self.role, self.type, self.market)
44