return None
+def get_hypervisors(nova_client):
+ try:
+ nodes = []
+ hypervisors = nova_client.hypervisors.list()
+ for hypervisor in hypervisors:
+ nodes.append(hypervisor.hypervisor_hostname)
+ return nodes
+ except Exception, e:
+ print "Error [get_hypervisors(nova_client)]:", e
+ return None
+
+
def create_flavor(nova_client, flavor_name, ram, disk, vcpus):
try:
flavor = nova_client.flavors.create(flavor_name, ram, vcpus, disk)
network_id,
instance_name="functest-vm",
confdrive=True,
- userdata=None):
+ userdata=None,
+ av_zone=''):
nova_client = get_nova_client()
try:
flavor = nova_client.flavors.find(name=flavor_name)
name=instance_name,
flavor=flavor,
image=image_id,
- nics=[{"net-id": network_id}]
+ nics=[{"net-id": network_id}],
+ availability_zone=av_zone
)
else:
instance = nova_client.servers.create(
image=image_id,
nics=[{"net-id": network_id}],
config_drive=confdrive,
- userdata=userdata
+ userdata=userdata,
+ availability_zone=av_zone
)
return instance
network_id,
instance_name="",
config_drive=False,
- userdata=""):
+ userdata="",
+ av_zone=''):
SLEEP = 3
VM_BOOT_TIMEOUT = 180
nova_client = get_nova_client()
network_id,
instance_name,
config_drive,
- userdata)
+ userdata,
+ av_zone)
count = VM_BOOT_TIMEOUT / SLEEP
for n in range(count, -1, -1):