def create(role): _setup_iam_connection() validate(validator, role) _create_instance_profile(role['name'], role['path']) _create_role(role['name'], role['path']) \ or _delete_role_policies(role['name']) _set_role_policy(role['name'], role['policy']) # That's instance profile, role: iam.add_role_to_instance_profile(role['name'], role['name'])
def launch(instance): hc2002.plugin.apply_for_resource(__name__, instance) validate(validator, instance) if 'auto-scaling-group' in instance \ and instance['auto-scaling-group']: return _launch_auto_scaling_group(instance) elif 'spot-price' in instance \ and instance['spot-price']: return _launch_spot_instance(instance) else: return _launch_instance(instance)
def _validate_manifests(instance): if 'user-data' not in instance: return if isinstance(instance['user-data'], basestring): instance['user-data'] = [instance['user-data']] for i, entry in enumerate(instance['user-data']): if not isinstance(entry, basestring): continue scope = 'user-data[%i]' % i #FIXME: Should either move file inlining earlier or validation # later. Should NOT read the file twice. Live as plugin of a # user-data plugin? :-) if entry.startswith('file:'): scope += ':%s:' % entry[5:] entry = open(entry[5:], 'rb').read() if entry.startswith('#manifest\n'): logger.debug("Validating manifest %s:\n", entry) validate(hc2002.manifest, yaml.safe_load(entry), scope)
def _validate_manifests(instance): if 'user-data' not in instance: return if isinstance(instance['user-data'], basestring): instance['user-data'] = [ instance['user-data'] ] for i, entry in enumerate(instance['user-data']): if not isinstance(entry, basestring): continue scope = 'user-data[%i]' % i #FIXME: Should either move file inlining earlier or validation # later. Should NOT read the file twice. Live as plugin of a # user-data plugin? :-) if entry.startswith('file:'): scope += ':%s:' % entry[5:] entry = open(entry[5:], 'rb').read() if entry.startswith('#manifest\n'): logger.debug("Validating manifest %s:\n", entry) validate(hc2002.manifest, yaml.safe_load(entry), scope)