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