2014-10-07 12:07:58 |
Vincent Ladeuil |
description |
Selecting the testbed nova instance flavor broke when we moved from canonistack to hpcloud because those clouds use different names.
In the general case, tests don't consume a lot of resources so we can default to m1.small for canonistack and standard.small for hpcloud (fix in progress for bug #1287955).
Points to consider:
- we want a sane default that works for supported clouds,
- we need that default to be in some config file so we can quickly fix re-occurrence of bug #1287955),
- we need a way to override that default for specific packages/tickets while providing some way to avoid abuses (how do we prevent someone from picking an xxl image so their tests complete faster than everyone elses) |
Selecting the testbed nova instance flavor broke when we moved from canonistack to hpcloud because those clouds use different names.
In the general case, tests don't consume a lot of resources so we can default to m1.small for canonistack and standard.small for hpcloud (fix in progress for bug #1287955).
Points to consider:
- we want a sane default that works for supported clouds (see below),
- we need a way to override that default for specific packages/tickets while providing some way to avoid abuses (how do we prevent someone from picking an xxl image so their tests complete faster than everyone elses)
ev proposed:
from novaclient.v1_1 import client
import os
import sys
def find_flavour(client, min_vcpu, min_mem):
'''Find the most minimal flavour that meets the vCPU and memory
constraints.'''
flavors = nova_client.flavors.list()
filtered = [x for x in flavors if x.vcpus >= min_vcpu and x.ram >= min_mem]
if len(filtered) < 1:
msg = 'Could not find any flavors that matched the constraints'
msg = '%s (%d vCPU, %d mem)' % (msg, min_vcpu, min_mem)
raise KeyError, msg
by_cpu = sorted(filtered, cmp=lambda x, y: cmp(x.vcpus, y.vcpus))
by_mem = sorted(by_cpu, cmp=lambda x, y: cmp(x.ram, y.ram))
return by_mem[0]
if __name__ == '__main__':
args = [
os.environ['OS_USERNAME'],
os.environ['OS_PASSWORD'],
os.environ['OS_TENANT_NAME'],
os.environ['OS_AUTH_URL'],
]
nova_client = client.Client(*args)
print find_flavour(client, int(sys.argv[1]), int(sys.argv[2]))
Which would give us a cloud agnostic default (well, based on min_vcpu and min_mem but that's better than using cloud specific names). |
|