Ejemplo n.º 1
0
def report(instances):
    if not instances:
        raise Exception("Internal error: instances not found!")

    oneinstance = instances[list(instances.keys())[0]]
    infraid = oneinstance['infra_id']
    nodename = oneinstance['resolved_node_definition']['name']
    count = len(instances)

    target_count = int(
        util.coalesce(main_uds.get_scaling_target_count(infraid, nodename),
                      count))
    target_count += len(
        list(main_uds.get_scaling_createnode(infraid, nodename).keys()))
    target_count -= len(
        list(main_uds.get_scaling_destroynode(infraid, nodename).keys()))

    target_min, target_max = get_scaling_limits(
        oneinstance['node_description'])
    target_count = keep_limits_for_scaling(target_count,
                                           oneinstance['node_description'])

    return dict(actual=count,
                target=target_count,
                min=target_min,
                max=target_max)
Ejemplo n.º 2
0
def process_create_node_requests(node, targetcount):
    nodename = node['name']
    infraid = node['infra_id']
    createnodes = main_uds.get_scaling_createnode(infraid, nodename)
    if len(createnodes.keys()) > 0:
        targetmax = node['scaling']['max']
        targetcount += len(createnodes.keys())
        targetcount = min(targetcount,targetmax)
        for keyid in createnodes.keys():
            main_uds.del_scaling_createnode(infraid,nodename,keyid)
        main_uds.set_scaling_target_count(infraid,nodename,targetcount)
    return targetcount
Ejemplo n.º 3
0
def process_create_node_requests(node, targetcount):
    nodename = node['name']
    infraid = node['infra_id']
    createnodes = main_uds.get_scaling_createnode(infraid, nodename)
    if len(list(createnodes.keys())) > 0:
        targetmin, targetmax = get_scaling_limits(node)
        targetcount += len(list(createnodes.keys()))
        if targetcount > targetmax:
            log.warning(
                'Scaling: request(s) ignored, maximum count (%i) reached for node \'%s\'',
                targetmax, nodename)
            targetcount = targetmax
        for keyid in list(createnodes.keys()):
            main_uds.del_scaling_createnode(infraid, nodename, keyid)
        main_uds.set_scaling_target_count(infraid, nodename, targetcount)
    return targetcount
Ejemplo n.º 4
0
def report(instances):
    if not instances:
        raise Exception("Internal error: instances not found!")
    
    oneinstance = instances[instances.keys()[0]]
    infraid = oneinstance['infra_id']
    nodename = oneinstance['resolved_node_definition']['name']
    count = len(instances)
    
    target_count = int(util.coalesce(main_uds.get_scaling_target_count(infraid,nodename),
                    count))
    target_count += len(main_uds.get_scaling_createnode(infraid,nodename).keys())
    target_count -= len(main_uds.get_scaling_destroynode(infraid,nodename).keys())

    target_min = oneinstance['node_description'].get('scaling',dict()).get('min',1)
    target_max = oneinstance['node_description'].get('scaling',dict()).get('max',1)

    target_count = max(target_count,target_min)
    target_count = min(target_count,target_max)

    return dict(actual=count, target=target_count, min=target_min,
            max=target_max)