Skip to content

Commit 3d39f34

Browse files
committed
Default to instances in correct zone when creating and resizing EBS volumens.
1 parent c017d13 commit 3d39f34

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

starcluster/commands/createvolume.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# along with StarCluster. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import os
19+
import re
1920

2021
from starcluster import node
2122
from starcluster import volume
@@ -141,6 +142,9 @@ def execute(self, args):
141142
kwargs = self.specified_options_dict
142143
kwargs.update(dict(keypair=keypair, key_location=key_location,
143144
host_instance=host_instance))
145+
if 'image_id' not in kwargs.keys():
146+
zone_short = re.match(".+-.+-[1-9]+", zone).group()
147+
kwargs['image_id'] = static.BASE_AMI_64[zone_short]
144148
vc = volume.VolumeCreator(self.ec2, **kwargs)
145149
if host_instance:
146150
vc._validate_host_instance(host_instance, zone)

starcluster/commands/resizevolume.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with StarCluster. If not, see <http://www.gnu.org/licenses/>.
1717

18+
import re
19+
1820
from starcluster import node
1921
from starcluster import volume
2022
from starcluster import static
@@ -96,6 +98,9 @@ def execute(self, args):
9698
kwargs = self.specified_options_dict
9799
kwargs.update(dict(keypair=keypair, key_location=key_location,
98100
host_instance=host_instance))
101+
if 'image_id' not in kwargs.keys():
102+
zone_short = re.match(".+-.+-[1-9]+", zone).group()
103+
kwargs['image_id'] = static.BASE_AMI_64[zone_short]
99104
vc = volume.VolumeCreator(self.ec2, **kwargs)
100105
if host_instance:
101106
vc._validate_host_instance(host_instance, zone)

starcluster/static.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ def create_sc_config_dirs():
8181
CRASH_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'crash-report-%d.txt' % PID)
8282

8383
# StarCluster BASE AMIs (us-east-1)
84-
BASE_AMI_32 = "ami-9bf9c9f2"
85-
BASE_AMI_64 = "ami-3393a45a"
86-
BASE_AMI_HVM = "ami-6b211202"
84+
BASE_AMI_32 = {'us-east-1': "ami-9bf9c9f2", 'us-west-1': "ami-52112317",
85+
'us-west-2': "ami-b2badb82"}
86+
BASE_AMI_64 = {'us-east-1': "ami-3393a45a", 'us-west-1': "ami-56172513",
87+
'us-west-2': "ami-04bedf34"}
88+
BASE_AMI_HVM = {'us-east-1': "ami-6b211202", 'us-west-1': "ami-06172543",
89+
'us-west-2': "ami-80bedfb0"}
90+
8791

8892
SECURITY_GROUP_PREFIX = "@sc-"
8993
SECURITY_GROUP_TEMPLATE = SECURITY_GROUP_PREFIX + "%s"

starcluster/templates/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@
349349
# [plugin xvfb]
350350
# SETUP_CLASS = starcluster.plugins.xvfb.XvfbSetup
351351
""" % {
352-
'x86_ami': static.BASE_AMI_32,
353-
'x86_64_ami': static.BASE_AMI_64,
354-
'hvm_ami': static.BASE_AMI_HVM,
352+
'x86_ami': static.BASE_AMI_32['us-east-1'],
353+
'x86_64_ami': static.BASE_AMI_64['us-east-1'],
354+
'hvm_ami': static.BASE_AMI_HVM['us-east-1'],
355355
'instance_types': ', '.join(static.INSTANCE_TYPES.keys()),
356356
'shells': ', '.join(static.AVAILABLE_SHELLS.keys()),
357357
}

starcluster/volume.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ class VolumeCreator(cluster.Cluster):
4343
"""
4444
def __init__(self, ec2_conn, spot_bid=None, keypair=None,
4545
key_location=None, host_instance=None, device='/dev/sdz',
46-
image_id=static.BASE_AMI_32, instance_type="t1.micro",
46+
image_id=static.BASE_AMI_32['us-east-1'], instance_type="t1.micro",
4747
shutdown_instance=False, detach_vol=False,
4848
mkfs_cmd='mkfs.ext3 -F', resizefs_cmd='resize2fs', **kwargs):
4949
self._host_instance = host_instance
5050
self._instance = None
5151
self._volume = None
5252
self._aws_block_device = device or '/dev/sdz'
5353
self._real_device = None
54-
self._image_id = image_id or static.BASE_AMI_32
54+
self._image_id = image_id or static.BASE_AMI_32['us-east-1']
5555
self._instance_type = instance_type or 'm1.small'
5656
self._shutdown = shutdown_instance
5757
self._detach_vol = detach_vol

0 commit comments

Comments
 (0)