Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds subnet_id to launch method. #169

Merged
merged 2 commits into from Oct 26, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions bioblend/cloudman/launch.py
Expand Up @@ -110,7 +110,7 @@ def __repr__(self):

def launch(self, cluster_name, image_id, instance_type, password,
kernel_id=None, ramdisk_id=None, key_name='cloudman_key_pair',
security_groups=['CloudMan'], placement='', **kwargs):
security_groups=['CloudMan'], placement='',subnet_id=None, **kwargs):
"""
Check all the prerequisites (key pair and security groups) for
launching a CloudMan instance, compose the user data based on the
Expand All @@ -132,11 +132,13 @@ def launch(self, cluster_name, image_id, instance_type, password,
``error`` containing an error message if there was one.
"""
ret = {'sg_names': [],
'sg_ids': [],
'kp_name': '',
'kp_material': '',
'rs': None,
'instance_id': '',
'error': None}
security_group_ids = []
# First satisfy the prerequisites
for sg in security_groups:
cmsg = self.create_cm_security_group(sg)
Expand All @@ -145,6 +147,8 @@ def launch(self, cluster_name, image_id, instance_type, password,
return ret
if cmsg['name']:
ret['sg_names'].append(cmsg['name'])
ret['sg_ids'].append(cmsg['sg_id'])
security_group_ids.append(cmsg['sg_id'])
kp_info = self.create_key_pair(key_name)
ret['error'] = kp_info['error']
if ret['error']:
Expand All @@ -169,10 +173,12 @@ def launch(self, cluster_name, image_id, instance_type, password,
rs = self.ec2_conn.run_instances(image_id=image_id,
instance_type=instance_type,
key_name=key_name,
security_groups=security_groups,
#security_groups=security_groups,
security_group_ids=security_group_ids,
user_data=ud,
kernel_id=kernel_id,
ramdisk_id=ramdisk_id,
subnet_id=subnet_id,
placement=placement)
ret['rs'] = rs
except EC2ResponseError as e:
Expand Down Expand Up @@ -226,6 +232,7 @@ def create_cm_security_group(self, sg_name='CloudMan'):
('9600', '9700'), # HTCondor
('30000', '30100')) # FTP transfer
progress = {'name': None,
'sg_id': None,
'error': None,
'ports': ports}
cmsg = None
Expand Down Expand Up @@ -253,13 +260,14 @@ def create_cm_security_group(self, sg_name='CloudMan'):
cmsg = self.ec2_conn.create_security_group(sg_name, 'A security '
'group for CloudMan')
except EC2ResponseError as e:
err_msg = "Problem creating security group '{0}': {1} (code {2}; " \
err_msg = "Problem creaInvalid value 'null' for protocol. VPC security group rules must specify protocols explicitlyting security group '{0}': {1} (code {2}; " \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creaInvalid... explicitlyting: I think you pasted in the wrong place!

"status {3})" \
.format(sg_name, e.message, e.error_code, e.status)
bioblend.log.exception(err_msg)
progress['error'] = err_msg
if cmsg:
progress['name'] = cmsg.name
progress['sg_id'] = cmsg.id
# Add appropriate authorization rules
# If these rules already exist, nothing will be changed in the SG
for port in ports:
Expand Down Expand Up @@ -297,7 +305,7 @@ def create_cm_security_group(self, sg_name='CloudMan'):
break
if not g_rule_exists:
try:
cmsg.authorize(src_group=cmsg)
cmsg.authorize(src_group=cmsg,ip_protocol='tcp', from_port=0, to_port=65535)
except EC2ResponseError as e:
err_msg = "A problem with security group authorization: {0} " \
"(code {1}; status {2})" \
Expand Down