def _update_bucket_counts()

in src/hpc/autoscale/ccbindings/mock.py [0:0]


def _update_bucket_counts(bucket: NodearrayBucketStatus, num_nodes: int) -> None:
    vcpu_count = bucket.virtual_machine.vcpu_count

    for attr in dir(bucket):
        if not attr[0].isalpha() or "count" not in attr:
            continue

        mag = vcpu_count if "core" in attr else num_nodes
        current_value = getattr(bucket, attr)
        if "consumed" in attr or "active" in attr:
            setattr(bucket, attr, current_value + mag)
        elif "available" in attr:
            setattr(bucket, attr, current_value - mag)
        elif "max" in attr or "quota" in attr:
            pass
        else:
            assert False, attr
    pass