def prepare_launch_config(scaling_group_uuid, launch_config): """ Prepare a launch_config for the specified scaling_group. This is responsible for returning a copy of the launch config that has metadata and unique server names added. :param IScalingGroup scaling_group: The scaling group this server is getting launched for. :param dict launch_config: The complete launch_config args we want to build servers from. :return dict: The prepared launch config. """ launch_config = freeze(launch_config) lb_descriptions = json_to_LBConfigs(launch_config.get('loadBalancers', [])) launch_config = prepare_server_launch_config(scaling_group_uuid, launch_config, lb_descriptions) suffix = generate_server_name() launch_config = set_server_name(launch_config, suffix) return thaw(launch_config)
def prepare_launch_config(scaling_group_uuid, launch_config): """ Prepare a launch_config for the specified scaling_group. This is responsible for returning a copy of the launch config that has metadata and unique server names added. :param IScalingGroup scaling_group: The scaling group this server is getting launched for. :param dict launch_config: The complete launch_config args we want to build servers from. :return dict: The prepared launch config. """ launch_config = freeze(launch_config) lb_descriptions = json_to_LBConfigs(launch_config.get('loadBalancers', [])) launch_config = prepare_server_launch_config( scaling_group_uuid, launch_config, lb_descriptions) suffix = generate_server_name() launch_config = set_server_name(launch_config, suffix) return thaw(launch_config)
def prepare_launch_config(scaling_group_uuid, launch_config): """ Prepare a launch_config for the specified scaling_group. This is responsible for returning a copy of the launch config that has metadata and unique server names added. :param IScalingGroup scaling_group: The scaling group this server is getting launched for. :param dict launch_config: The complete launch_config args we want to build servers from. :return dict: The prepared launch config. """ launch_config = deepcopy(launch_config) server_config = launch_config['server'] if 'metadata' not in server_config: server_config['metadata'] = {} server_config['metadata'].update(generate_server_metadata( scaling_group_uuid, launch_config)) if server_config.get('name'): server_name = server_config.get('name') server_config['name'] = '{0}-{1}'.format(server_name, generate_server_name()) else: server_config['name'] = generate_server_name() for lb_config in launch_config.get('loadBalancers', []): if 'metadata' not in lb_config: lb_config['metadata'] = {} lb_config['metadata']['rax:auto_scaling_group_id'] = scaling_group_uuid lb_config['metadata']['rax:auto_scaling_server_name'] = server_config['name'] return launch_config
def prepare_launch_config(scaling_group_uuid, launch_config): """ Prepare a launch_config for the specified scaling_group. This is responsible for returning a copy of the launch config that has metadata and unique server names added. :param IScalingGroup scaling_group: The scaling group this server is getting launched for. :param dict launch_config: The complete launch_config args we want to build servers from. :return dict: The prepared launch config. """ launch_config = deepcopy(launch_config) server_config = launch_config['server'] if 'metadata' not in server_config: server_config['metadata'] = {} server_config['metadata']['rax:auto_scaling_group_id'] = scaling_group_uuid name_parts = [generate_server_name()] server_name_suffix = server_config.get('name') if server_name_suffix: name_parts.append(server_name_suffix) server_config['name'] = '-'.join(name_parts) for lb_config in launch_config.get('loadBalancers', []): if 'metadata' not in lb_config: lb_config['metadata'] = {} lb_config['metadata']['rax:auto_scaling_group_id'] = scaling_group_uuid lb_config['metadata']['rax:auto_scaling_server_name'] = server_config[ 'name'] return launch_config
def prepare_launch_config(scaling_group_uuid, launch_config): """ Prepare a launch_config for the specified scaling_group. This is responsible for returning a copy of the launch config that has metadata and unique server names added. :param IScalingGroup scaling_group: The scaling group this server is getting launched for. :param dict launch_config: The complete launch_config args we want to build servers from. :return dict: The prepared launch config. """ launch_config = deepcopy(launch_config) server_config = launch_config['server'] if 'metadata' not in server_config: server_config['metadata'] = {} server_config['metadata']['rax:auto_scaling_group_id'] = scaling_group_uuid name_parts = [generate_server_name()] server_name_suffix = server_config.get('name') if server_name_suffix: name_parts.append(server_name_suffix) server_config['name'] = '-'.join(name_parts) for lb_config in launch_config.get('loadBalancers', []): if 'metadata' not in lb_config: lb_config['metadata'] = {} lb_config['metadata']['rax:auto_scaling_group_id'] = scaling_group_uuid lb_config['metadata']['rax:auto_scaling_server_name'] = server_config['name'] return launch_config