Skip to content

Commit

Permalink
Default to instances in correct zone when creating and resizing EBS v…
Browse files Browse the repository at this point in the history
…olumens.
  • Loading branch information
nfoti committed Nov 20, 2015
1 parent c017d13 commit 3d39f34
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions starcluster/commands/createvolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with StarCluster. If not, see <http://www.gnu.org/licenses/>.

import os
import re

from starcluster import node
from starcluster import volume
Expand Down Expand Up @@ -141,6 +142,9 @@ def execute(self, args):
kwargs = self.specified_options_dict
kwargs.update(dict(keypair=keypair, key_location=key_location,
host_instance=host_instance))
if 'image_id' not in kwargs.keys():
zone_short = re.match(".+-.+-[1-9]+", zone).group()
kwargs['image_id'] = static.BASE_AMI_64[zone_short]
vc = volume.VolumeCreator(self.ec2, **kwargs)
if host_instance:
vc._validate_host_instance(host_instance, zone)
Expand Down
5 changes: 5 additions & 0 deletions starcluster/commands/resizevolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with StarCluster. If not, see <http://www.gnu.org/licenses/>.

import re

from starcluster import node
from starcluster import volume
from starcluster import static
Expand Down Expand Up @@ -96,6 +98,9 @@ def execute(self, args):
kwargs = self.specified_options_dict
kwargs.update(dict(keypair=keypair, key_location=key_location,
host_instance=host_instance))
if 'image_id' not in kwargs.keys():
zone_short = re.match(".+-.+-[1-9]+", zone).group()
kwargs['image_id'] = static.BASE_AMI_64[zone_short]
vc = volume.VolumeCreator(self.ec2, **kwargs)
if host_instance:
vc._validate_host_instance(host_instance, zone)
Expand Down
10 changes: 7 additions & 3 deletions starcluster/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ def create_sc_config_dirs():
CRASH_FILE = os.path.join(STARCLUSTER_LOG_DIR, 'crash-report-%d.txt' % PID)

# StarCluster BASE AMIs (us-east-1)
BASE_AMI_32 = "ami-9bf9c9f2"
BASE_AMI_64 = "ami-3393a45a"
BASE_AMI_HVM = "ami-6b211202"
BASE_AMI_32 = {'us-east-1': "ami-9bf9c9f2", 'us-west-1': "ami-52112317",
'us-west-2': "ami-b2badb82"}
BASE_AMI_64 = {'us-east-1': "ami-3393a45a", 'us-west-1': "ami-56172513",
'us-west-2': "ami-04bedf34"}
BASE_AMI_HVM = {'us-east-1': "ami-6b211202", 'us-west-1': "ami-06172543",
'us-west-2': "ami-80bedfb0"}


SECURITY_GROUP_PREFIX = "@sc-"
SECURITY_GROUP_TEMPLATE = SECURITY_GROUP_PREFIX + "%s"
Expand Down
6 changes: 3 additions & 3 deletions starcluster/templates/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@
# [plugin xvfb]
# SETUP_CLASS = starcluster.plugins.xvfb.XvfbSetup
""" % {
'x86_ami': static.BASE_AMI_32,
'x86_64_ami': static.BASE_AMI_64,
'hvm_ami': static.BASE_AMI_HVM,
'x86_ami': static.BASE_AMI_32['us-east-1'],
'x86_64_ami': static.BASE_AMI_64['us-east-1'],
'hvm_ami': static.BASE_AMI_HVM['us-east-1'],
'instance_types': ', '.join(static.INSTANCE_TYPES.keys()),
'shells': ', '.join(static.AVAILABLE_SHELLS.keys()),
}
Expand Down
4 changes: 2 additions & 2 deletions starcluster/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ class VolumeCreator(cluster.Cluster):
"""
def __init__(self, ec2_conn, spot_bid=None, keypair=None,
key_location=None, host_instance=None, device='/dev/sdz',
image_id=static.BASE_AMI_32, instance_type="t1.micro",
image_id=static.BASE_AMI_32['us-east-1'], instance_type="t1.micro",
shutdown_instance=False, detach_vol=False,
mkfs_cmd='mkfs.ext3 -F', resizefs_cmd='resize2fs', **kwargs):
self._host_instance = host_instance
self._instance = None
self._volume = None
self._aws_block_device = device or '/dev/sdz'
self._real_device = None
self._image_id = image_id or static.BASE_AMI_32
self._image_id = image_id or static.BASE_AMI_32['us-east-1']
self._instance_type = instance_type or 'm1.small'
self._shutdown = shutdown_instance
self._detach_vol = detach_vol
Expand Down

0 comments on commit 3d39f34

Please sign in to comment.