def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = LaunchConfigurationInput() input.set_from_dict(req.params) lc = LaunchConfigurationType('LaunchConfiguration') lc.set_from_intype(input, make_arn(input.LaunchConfigurationName, self.xamznRequestId, 'launchConfigurationName')) self._system.create_launch_config(user_obj, lc) res = self.get_response() doc = self.get_default_response_body_dom(doc_name="CreateLaunchConfigurationResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def __call__(self, req): user_obj = self.get_user_obj(req) log_request(req, user_obj) input = LaunchConfigurationInput() input.set_from_dict(req.params) lc = LaunchConfigurationType('LaunchConfiguration') lc.set_from_intype( input, make_arn(input.LaunchConfigurationName, self.xamznRequestId, 'launchConfigurationName')) self._system.create_launch_config(user_obj, lc) res = self.get_response() doc = self.get_default_response_body_dom( doc_name="CreateLaunchConfigurationResponse") res.unicode_body = doc.documentElement.toprettyxml() log_reply(doc, user_obj) return res
def get_launch_configs(self, user_obj, names=None, max=-1, startToken=None): next_token = None dts = self._dtrs_client.list_dts(user_obj.access_id) dts.sort() # now that we have the final list, look up each description lc_list_type = AWSListType('LaunchConfigurations') for lc_name in dts: if lc_list_type.get_length() >= max and max > -1: break dt_descr = self._get_dt_details(lc_name, user_obj.access_id) for site in sorted(dt_descr['mappings'].keys()): mapped_def = dt_descr['mappings'][site] out_name = '%s@%s' % (lc_name, site) if lc_list_type.get_length() >= max and max > -1: break if out_name == startToken: startToken = None if startToken is None and (names is None or out_name in names): ot_lc = LaunchConfigurationType('LaunchConfiguration') ot_lc.BlockDeviceMappings = AWSListType( 'BlockDeviceMappings') if 'CreatedTime' not in mapped_def.keys(): # This is an LC that was created with the new Phantom API, ignore it continue tm = _get_time(mapped_def['CreatedTime']) ot_lc.CreatedTime = DateTimeType('CreatedTime', tm) ot_lc.ImageId = mapped_def['iaas_image'] ot_lc.InstanceMonitoring = InstanceMonitoringType( 'InstanceMonitoring') ot_lc.InstanceMonitoring.Enabled = False ot_lc.InstanceType = mapped_def['iaas_allocation'] ot_lc.KernelId = None ot_lc.KeyName = phantom_get_default_key_name() ot_lc.LaunchConfigurationARN = mapped_def[ 'LaunchConfigurationARN'] ot_lc.LaunchConfigurationName = out_name ot_lc.RamdiskId = None ot_lc.SecurityGroups = AWSListType('SecurityGroups') contextualization = dt_descr.get('contextualization') if contextualization is not None and contextualization.get( 'method') == 'userdata': # UserData should be base64-encoded to be properly decoded by boto ot_lc.UserData = base64.b64encode( contextualization.get('userdata')) else: ot_lc.UserData = None lc_list_type.add_item(ot_lc) # XXX need to set next_token return (lc_list_type, next_token)
def get_launch_configs(self, user_obj, names=None, max=-1, startToken=None): next_token = None dts = self._dtrs_client.list_dts(user_obj.access_id) dts.sort() # now that we have the final list, look up each description lc_list_type = AWSListType('LaunchConfigurations') for lc_name in dts: if lc_list_type.get_length() >= max and max > -1: break dt_descr = self._get_dt_details(lc_name, user_obj.access_id) for site in sorted(dt_descr['mappings'].keys()): mapped_def = dt_descr['mappings'][site] out_name = '%s@%s' % (lc_name, site) if lc_list_type.get_length() >= max and max > -1: break if out_name == startToken: startToken = None if startToken is None and (names is None or out_name in names): ot_lc = LaunchConfigurationType('LaunchConfiguration') ot_lc.BlockDeviceMappings = AWSListType('BlockDeviceMappings') if 'CreatedTime' not in mapped_def.keys(): # This is an LC that was created with the new Phantom API, ignore it continue tm = _get_time(mapped_def['CreatedTime']) ot_lc.CreatedTime = DateTimeType('CreatedTime', tm) ot_lc.ImageId = mapped_def['iaas_image'] ot_lc.InstanceMonitoring = InstanceMonitoringType('InstanceMonitoring') ot_lc.InstanceMonitoring.Enabled = False ot_lc.InstanceType = mapped_def['iaas_allocation'] ot_lc.KernelId = None ot_lc.KeyName = phantom_get_default_key_name() ot_lc.LaunchConfigurationARN = mapped_def['LaunchConfigurationARN'] ot_lc.LaunchConfigurationName = out_name ot_lc.RamdiskId = None ot_lc.SecurityGroups = AWSListType('SecurityGroups') contextualization = dt_descr.get('contextualization') if contextualization is not None and contextualization.get('method') == 'userdata': # UserData should be base64-encoded to be properly decoded by boto ot_lc.UserData = base64.b64encode(contextualization.get('userdata')) else: ot_lc.UserData = None lc_list_type.add_item(ot_lc) # XXX need to set next_token return (lc_list_type, next_token)
def db_launch_config_to_outtype(lcdb): lc = LaunchConfigurationType('LaunchConfiguration') lc.ImageId = lcdb.ImageId lc.InstanceType = lcdb.InstanceType lc.KernelId = lcdb.KernelId lc.KeyName = lcdb.KeyName lc.LaunchConfigurationARN = lcdb.LaunchConfigurationARN lc.LaunchConfigurationName = lcdb.LaunchConfigurationName lc.RamdiskId = lcdb.RamdiskId lc.UserData = lcdb.UserData for sg in lcdb.security_groups: lc.SecurityGroups.type_list.append(sg.name) lc.InstanceMonitoring.Enabled = lcdb.InstanceMonitoring #lc.BlockDeviceMappings lc.CreatedTime = DateTimeType('CreatedTime', lcdb.CreatedTime) return lc