Пример #1
0
def update_machine_consumption(redis_db, mr, new_alloc, old_alloc):
    for instance in mr.instances:
        vm_ip, container_id = instance
        prior_consumption = resource_datastore.read_machine_consumption(
            redis_db, vm_ip)
        new_consumption = float(
            prior_consumption[mr.resource]) + new_alloc - old_alloc

        utilization_dict = {}
        utilization_dict[mr.resource] = new_consumption
        resource_datastore.write_machine_consumption(redis_db, vm_ip,
                                                     utilization_dict)
Пример #2
0
def init_cluster_capacities_r(redis_db, machine_type, quilt_overhead):
    print 'Initializing the per machine capacities'
    resource_alloc = get_instance_specs(machine_type)
    quilt_usage = {}

    # Leave some resources available for Quilt containers to run (OVS, etc.)
    # This is dictated by quilt overheads
    for resource in resource_alloc:
        max_cap = resource_alloc[resource]
        quilt_usage[resource] = ((quilt_overhead) / 100.0) * max_cap

    all_vms = get_actual_vms()

    for vm_ip in all_vms:
        resource_datastore.write_machine_consumption(redis_db, vm_ip,
                                                     quilt_usage)
        resource_datastore.write_machine_capacity(redis_db, vm_ip,
                                                  resource_alloc)