failure conditions are being sent back properly now
This commit is contained in:
3
.mailmap
3
.mailmap
@@ -29,6 +29,7 @@
|
|||||||
<matt.dietz@rackspace.com> <matthewdietz@Matthew-Dietzs-MacBook-Pro.local>
|
<matt.dietz@rackspace.com> <matthewdietz@Matthew-Dietzs-MacBook-Pro.local>
|
||||||
<matt.dietz@rackspace.com> <mdietz@openstack>
|
<matt.dietz@rackspace.com> <mdietz@openstack>
|
||||||
<mordred@inaugust.com> <mordred@hudson>
|
<mordred@inaugust.com> <mordred@hudson>
|
||||||
|
<naveedm9@gmail.com> <naveed.massjouni@rackspace.com>
|
||||||
<nirmal.ranganathan@rackspace.com> <nirmal.ranganathan@rackspace.coom>
|
<nirmal.ranganathan@rackspace.com> <nirmal.ranganathan@rackspace.coom>
|
||||||
<paul@openstack.org> <paul.voccio@rackspace.com>
|
<paul@openstack.org> <paul.voccio@rackspace.com>
|
||||||
<paul@openstack.org> <pvoccio@castor.local>
|
<paul@openstack.org> <pvoccio@castor.local>
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
<rlane@wikimedia.org> <laner@controller>
|
<rlane@wikimedia.org> <laner@controller>
|
||||||
<sleepsonthefloor@gmail.com> <root@tonbuntu>
|
<sleepsonthefloor@gmail.com> <root@tonbuntu>
|
||||||
<soren.hansen@rackspace.com> <soren@linux2go.dk>
|
<soren.hansen@rackspace.com> <soren@linux2go.dk>
|
||||||
|
<throughnothing@gmail.com> <will.wolf@rackspace.com>
|
||||||
<todd@ansolabs.com> <todd@lapex>
|
<todd@ansolabs.com> <todd@lapex>
|
||||||
<todd@ansolabs.com> <todd@rubidine.com>
|
<todd@ansolabs.com> <todd@rubidine.com>
|
||||||
<tushar.vitthal.patil@gmail.com> <tpatil@vertex.co.in>
|
<tushar.vitthal.patil@gmail.com> <tpatil@vertex.co.in>
|
||||||
@@ -44,5 +46,4 @@
|
|||||||
<ueno.nachi@lab.ntt.co.jp> <openstack@lab.ntt.co.jp>
|
<ueno.nachi@lab.ntt.co.jp> <openstack@lab.ntt.co.jp>
|
||||||
<vishvananda@gmail.com> <root@mirror.nasanebula.net>
|
<vishvananda@gmail.com> <root@mirror.nasanebula.net>
|
||||||
<vishvananda@gmail.com> <root@ubuntu>
|
<vishvananda@gmail.com> <root@ubuntu>
|
||||||
<naveedm9@gmail.com> <naveed.massjouni@rackspace.com>
|
|
||||||
<vishvananda@gmail.com> <vishvananda@yahoo.com>
|
<vishvananda@gmail.com> <vishvananda@yahoo.com>
|
||||||
|
|||||||
2
Authors
2
Authors
@@ -80,7 +80,7 @@ Trey Morris <trey.morris@rackspace.com>
|
|||||||
Tushar Patil <tushar.vitthal.patil@gmail.com>
|
Tushar Patil <tushar.vitthal.patil@gmail.com>
|
||||||
Vasiliy Shlykov <vash@vasiliyshlykov.org>
|
Vasiliy Shlykov <vash@vasiliyshlykov.org>
|
||||||
Vishvananda Ishaya <vishvananda@gmail.com>
|
Vishvananda Ishaya <vishvananda@gmail.com>
|
||||||
William Wolf <will.wolf@rackspace.com>
|
William Wolf <throughnothing@gmail.com>
|
||||||
Yoshiaki Tamura <yoshi@midokura.jp>
|
Yoshiaki Tamura <yoshi@midokura.jp>
|
||||||
Youcef Laribi <Youcef.Laribi@eu.citrix.com>
|
Youcef Laribi <Youcef.Laribi@eu.citrix.com>
|
||||||
Yuriy Taraday <yorik.sar@gmail.com>
|
Yuriy Taraday <yorik.sar@gmail.com>
|
||||||
|
|||||||
@@ -397,11 +397,10 @@ class ProjectCommands(object):
|
|||||||
arguments: project_id [key] [value]"""
|
arguments: project_id [key] [value]"""
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
if key:
|
if key:
|
||||||
quo = {'project_id': project_id, key: value}
|
|
||||||
try:
|
try:
|
||||||
db.quota_update(ctxt, project_id, quo)
|
db.quota_update(ctxt, project_id, key, value)
|
||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
db.quota_create(ctxt, quo)
|
db.quota_create(ctxt, project_id, key, value)
|
||||||
project_quota = quota.get_quota(ctxt, project_id)
|
project_quota = quota.get_quota(ctxt, project_id)
|
||||||
for key, value in project_quota.iteritems():
|
for key, value in project_quota.iteritems():
|
||||||
print '%s: %s' % (key, value)
|
print '%s: %s' % (key, value)
|
||||||
|
|||||||
@@ -305,3 +305,8 @@ class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler):
|
|||||||
instance_type = request_spec['instance_type']
|
instance_type = request_spec['instance_type']
|
||||||
query = driver.instance_type_to_filter(instance_type)
|
query = driver.instance_type_to_filter(instance_type)
|
||||||
return driver.filter_hosts(self.zone_manager, query)
|
return driver.filter_hosts(self.zone_manager, query)
|
||||||
|
|
||||||
|
def weigh_hosts(self, num, request_spec, hosts):
|
||||||
|
"""Derived classes must override this method and return
|
||||||
|
a lists of hosts in [{weight, hostname}] format."""
|
||||||
|
return []
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ class ZoneAwareScheduler(driver.Scheduler):
|
|||||||
|
|
||||||
# Create build plan and provision ...
|
# Create build plan and provision ...
|
||||||
build_plan = self.select(context, request_spec)
|
build_plan = self.select(context, request_spec)
|
||||||
|
if not build_plan:
|
||||||
|
raise driver.NoValidHost(_('No hosts were available'))
|
||||||
|
|
||||||
for item in build_plan:
|
for item in build_plan:
|
||||||
self.provision_instance(context, topic, item)
|
self.provision_instance(context, topic, item)
|
||||||
|
|
||||||
@@ -67,15 +70,14 @@ class ZoneAwareScheduler(driver.Scheduler):
|
|||||||
anything about the children."""
|
anything about the children."""
|
||||||
return self._schedule(context, "compute", request_spec, *args, **kwargs)
|
return self._schedule(context, "compute", request_spec, *args, **kwargs)
|
||||||
|
|
||||||
|
# TODO(sandy): We're only focused on compute instances right now,
|
||||||
|
# so we don't implement the default "schedule()" method required
|
||||||
|
# of Schedulers.
|
||||||
def schedule(self, context, topic, request_spec, *args, **kwargs):
|
def schedule(self, context, topic, request_spec, *args, **kwargs):
|
||||||
"""The schedule() contract requires we return the one
|
"""The schedule() contract requires we return the one
|
||||||
best-suited host for this request.
|
best-suited host for this request.
|
||||||
"""
|
"""
|
||||||
res = self._schedule(context, topic, request_spec, *args, **kwargs)
|
|
||||||
# TODO(sirp): should this be a host object rather than a weight-dict?
|
|
||||||
if not res:
|
|
||||||
raise driver.NoValidHost(_('No hosts were available'))
|
raise driver.NoValidHost(_('No hosts were available'))
|
||||||
return res[0]
|
|
||||||
|
|
||||||
def _schedule(self, context, topic, request_spec, *args, **kwargs):
|
def _schedule(self, context, topic, request_spec, *args, **kwargs):
|
||||||
"""Returns a list of hosts that meet the required specs,
|
"""Returns a list of hosts that meet the required specs,
|
||||||
|
|||||||
@@ -279,6 +279,26 @@ class CloudTestCase(test.TestCase):
|
|||||||
user_group=['all'])
|
user_group=['all'])
|
||||||
self.assertEqual(True, result['is_public'])
|
self.assertEqual(True, result['is_public'])
|
||||||
|
|
||||||
|
def test_deregister_image(self):
|
||||||
|
deregister_image = self.cloud.deregister_image
|
||||||
|
|
||||||
|
def fake_delete(self, context, id):
|
||||||
|
return None
|
||||||
|
|
||||||
|
self.stubs.Set(local.LocalImageService, 'delete', fake_delete)
|
||||||
|
# valid image
|
||||||
|
result = deregister_image(self.context, 'ami-00000001')
|
||||||
|
self.assertEqual(result['imageId'], 'ami-00000001')
|
||||||
|
# invalid image
|
||||||
|
self.stubs.UnsetAll()
|
||||||
|
|
||||||
|
def fake_detail_empty(self, context):
|
||||||
|
return []
|
||||||
|
|
||||||
|
self.stubs.Set(local.LocalImageService, 'detail', fake_detail_empty)
|
||||||
|
self.assertRaises(exception.ImageNotFound, deregister_image,
|
||||||
|
self.context, 'ami-bad001')
|
||||||
|
|
||||||
def test_console_output(self):
|
def test_console_output(self):
|
||||||
instance_type = FLAGS.default_instance_type
|
instance_type = FLAGS.default_instance_type
|
||||||
max_count = 1
|
max_count = 1
|
||||||
@@ -338,41 +358,6 @@ class CloudTestCase(test.TestCase):
|
|||||||
self._create_key('test')
|
self._create_key('test')
|
||||||
self.cloud.delete_key_pair(self.context, 'test')
|
self.cloud.delete_key_pair(self.context, 'test')
|
||||||
|
|
||||||
def test_run_instances(self):
|
|
||||||
if FLAGS.connection_type == 'fake':
|
|
||||||
LOG.debug(_("Can't test instances without a real virtual env."))
|
|
||||||
return
|
|
||||||
image_id = FLAGS.default_image
|
|
||||||
instance_type = FLAGS.default_instance_type
|
|
||||||
max_count = 1
|
|
||||||
kwargs = {'image_id': image_id,
|
|
||||||
'instance_type': instance_type,
|
|
||||||
'max_count': max_count}
|
|
||||||
rv = self.cloud.run_instances(self.context, **kwargs)
|
|
||||||
# TODO: check for proper response
|
|
||||||
instance_id = rv['reservationSet'][0].keys()[0]
|
|
||||||
instance = rv['reservationSet'][0][instance_id][0]
|
|
||||||
LOG.debug(_("Need to watch instance %s until it's running..."),
|
|
||||||
instance['instance_id'])
|
|
||||||
while True:
|
|
||||||
greenthread.sleep(1)
|
|
||||||
info = self.cloud._get_instance(instance['instance_id'])
|
|
||||||
LOG.debug(info['state'])
|
|
||||||
if info['state'] == power_state.RUNNING:
|
|
||||||
break
|
|
||||||
self.assert_(rv)
|
|
||||||
|
|
||||||
if FLAGS.connection_type != 'fake':
|
|
||||||
time.sleep(45) # Should use boto for polling here
|
|
||||||
for reservations in rv['reservationSet']:
|
|
||||||
# for res_id in reservations.keys():
|
|
||||||
# LOG.debug(reservations[res_id])
|
|
||||||
# for instance in reservations[res_id]:
|
|
||||||
for instance in reservations[reservations.keys()[0]]:
|
|
||||||
instance_id = instance['instance_id']
|
|
||||||
LOG.debug(_("Terminating instance %s"), instance_id)
|
|
||||||
rv = self.compute.terminate_instance(instance_id)
|
|
||||||
|
|
||||||
def test_terminate_instances(self):
|
def test_terminate_instances(self):
|
||||||
inst1 = db.instance_create(self.context, {'reservation_id': 'a',
|
inst1 = db.instance_create(self.context, {'reservation_id': 'a',
|
||||||
'image_id': 1,
|
'image_id': 1,
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
try:
|
try:
|
||||||
conn.spawn(instance, network_info)
|
conn.spawn(instance, network_info)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
count = (0 <= e.message.find('Unexpected method call'))
|
count = (0 <= str(e.message).find('Unexpected method call'))
|
||||||
|
|
||||||
self.assertTrue(count)
|
self.assertTrue(count)
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
"""Test suite for XenAPI."""
|
"""Test suite for XenAPI."""
|
||||||
|
|
||||||
|
import eventlet
|
||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -198,6 +199,28 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
self.context = context.RequestContext('fake', 'fake', False)
|
self.context = context.RequestContext('fake', 'fake', False)
|
||||||
self.conn = xenapi_conn.get_connection(False)
|
self.conn = xenapi_conn.get_connection(False)
|
||||||
|
|
||||||
|
def test_parallel_builds(self):
|
||||||
|
stubs.stubout_loopingcall_delay(self.stubs)
|
||||||
|
|
||||||
|
def _do_build(id, proj, user, *args):
|
||||||
|
values = {
|
||||||
|
'id': id,
|
||||||
|
'project_id': proj,
|
||||||
|
'user_id': user,
|
||||||
|
'image_id': 1,
|
||||||
|
'kernel_id': 2,
|
||||||
|
'ramdisk_id': 3,
|
||||||
|
'instance_type_id': '3', # m1.large
|
||||||
|
'mac_address': 'aa:bb:cc:dd:ee:ff',
|
||||||
|
'os_type': 'linux'}
|
||||||
|
instance = db.instance_create(self.context, values)
|
||||||
|
self.conn.spawn(instance)
|
||||||
|
|
||||||
|
gt1 = eventlet.spawn(_do_build, 1, self.project.id, self.user.id)
|
||||||
|
gt2 = eventlet.spawn(_do_build, 2, self.project.id, self.user.id)
|
||||||
|
gt1.wait()
|
||||||
|
gt2.wait()
|
||||||
|
|
||||||
def test_list_instances_0(self):
|
def test_list_instances_0(self):
|
||||||
instances = self.conn.list_instances()
|
instances = self.conn.list_instances()
|
||||||
self.assertEquals(instances, [])
|
self.assertEquals(instances, [])
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
"""Stubouts, mocks and fixtures for the test suite"""
|
"""Stubouts, mocks and fixtures for the test suite"""
|
||||||
|
|
||||||
|
import eventlet
|
||||||
from nova.virt import xenapi_conn
|
from nova.virt import xenapi_conn
|
||||||
from nova.virt.xenapi import fake
|
from nova.virt.xenapi import fake
|
||||||
from nova.virt.xenapi import volume_utils
|
from nova.virt.xenapi import volume_utils
|
||||||
@@ -28,29 +29,6 @@ def stubout_instance_snapshot(stubs):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def fake_fetch_image(cls, session, instance_id, image, user, project,
|
def fake_fetch_image(cls, session, instance_id, image, user, project,
|
||||||
type):
|
type):
|
||||||
# Stubout wait_for_task
|
|
||||||
def fake_wait_for_task(self, task, id):
|
|
||||||
class FakeEvent:
|
|
||||||
|
|
||||||
def send(self, value):
|
|
||||||
self.rv = value
|
|
||||||
|
|
||||||
def wait(self):
|
|
||||||
return self.rv
|
|
||||||
|
|
||||||
done = FakeEvent()
|
|
||||||
self._poll_task(id, task, done)
|
|
||||||
rv = done.wait()
|
|
||||||
return rv
|
|
||||||
|
|
||||||
def fake_loop(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
stubs.Set(xenapi_conn.XenAPISession, 'wait_for_task',
|
|
||||||
fake_wait_for_task)
|
|
||||||
|
|
||||||
stubs.Set(xenapi_conn.XenAPISession, '_stop_loop', fake_loop)
|
|
||||||
|
|
||||||
from nova.virt.xenapi.fake import create_vdi
|
from nova.virt.xenapi.fake import create_vdi
|
||||||
name_label = "instance-%s" % instance_id
|
name_label = "instance-%s" % instance_id
|
||||||
#TODO: create fake SR record
|
#TODO: create fake SR record
|
||||||
@@ -63,11 +41,6 @@ def stubout_instance_snapshot(stubs):
|
|||||||
|
|
||||||
stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image)
|
stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image)
|
||||||
|
|
||||||
def fake_parse_xmlrpc_value(val):
|
|
||||||
return val
|
|
||||||
|
|
||||||
stubs.Set(xenapi_conn, '_parse_xmlrpc_value', fake_parse_xmlrpc_value)
|
|
||||||
|
|
||||||
def fake_wait_for_vhd_coalesce(session, instance_id, sr_ref, vdi_ref,
|
def fake_wait_for_vhd_coalesce(session, instance_id, sr_ref, vdi_ref,
|
||||||
original_parent_uuid):
|
original_parent_uuid):
|
||||||
from nova.virt.xenapi.fake import create_vdi
|
from nova.virt.xenapi.fake import create_vdi
|
||||||
@@ -144,6 +117,16 @@ def stubout_loopingcall_start(stubs):
|
|||||||
stubs.Set(utils.LoopingCall, 'start', fake_start)
|
stubs.Set(utils.LoopingCall, 'start', fake_start)
|
||||||
|
|
||||||
|
|
||||||
|
def stubout_loopingcall_delay(stubs):
|
||||||
|
def fake_start(self, interval, now=True):
|
||||||
|
self._running = True
|
||||||
|
eventlet.sleep(1)
|
||||||
|
self.f(*self.args, **self.kw)
|
||||||
|
# This would fail before parallel xenapi calls were fixed
|
||||||
|
assert self._running == False
|
||||||
|
stubs.Set(utils.LoopingCall, 'start', fake_start)
|
||||||
|
|
||||||
|
|
||||||
class FakeSessionForVMTests(fake.SessionBase):
|
class FakeSessionForVMTests(fake.SessionBase):
|
||||||
""" Stubs out a XenAPISession for VM tests """
|
""" Stubs out a XenAPISession for VM tests """
|
||||||
def __init__(self, uri):
|
def __init__(self, uri):
|
||||||
|
|||||||
Reference in New Issue
Block a user