def extract_autoscaling_capacity(configuration, elastigroup_config):
    """
    This function will set the Spotinst capacity from the Senza AutoScaling settings.
    It will add a default capacity of 1 if none is present.
    The target capacity will be adjusted to be within the minimum and maximum boundaries
    If there's already a capacity section it will be left untouched
    """
    if 'capacity' in elastigroup_config:
        return
    auto_scaling = configuration.get('AutoScaling', None)
    target = 1
    minimum = 1
    maximum = 1
    if auto_scaling:
        minimum = int(auto_scaling.get('Minimum', minimum))
        maximum = int(auto_scaling.get('Maximum', maximum))
        target = min(max(minimum, int(auto_scaling.get('DesiredCapacity', 1
            ))), maximum)
    elastigroup_config['capacity'] = {'target': target, 'minimum': minimum,
        'maximum': maximum}
