Merge "Use list_servers for polling rather than get_server_by_id"
This commit is contained in:
commit
2d70f8bd55
@ -3930,8 +3930,9 @@ class OpenStackCloud(object):
|
|||||||
server_id = server['id']
|
server_id = server['id']
|
||||||
for _ in _utils._iterate_timeout(
|
for _ in _utils._iterate_timeout(
|
||||||
timeout,
|
timeout,
|
||||||
"Timeout waiting for the floating IP to be attached."):
|
"Timeout waiting for the floating IP to be attached.",
|
||||||
server = self.get_server_by_id(server_id)
|
wait=self._SERVER_AGE):
|
||||||
|
server = self.get_server(server_id)
|
||||||
ext_ip = meta.get_server_ip(server, ext_tag='floating')
|
ext_ip = meta.get_server_ip(server, ext_tag='floating')
|
||||||
if ext_ip == floating_ip['floating_ip_address']:
|
if ext_ip == floating_ip['floating_ip_address']:
|
||||||
return server
|
return server
|
||||||
@ -4682,11 +4683,14 @@ class OpenStackCloud(object):
|
|||||||
for count in _utils._iterate_timeout(
|
for count in _utils._iterate_timeout(
|
||||||
timeout,
|
timeout,
|
||||||
"Timeout waiting for server {0} to "
|
"Timeout waiting for server {0} to "
|
||||||
"rebuild.".format(server_id)):
|
"rebuild.".format(server_id),
|
||||||
|
wait=self._SERVER_AGE):
|
||||||
try:
|
try:
|
||||||
server = self.get_server_by_id(server_id)
|
server = self.get_server(server_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
if not server:
|
||||||
|
continue
|
||||||
|
|
||||||
if server['status'] == 'ACTIVE':
|
if server['status'] == 'ACTIVE':
|
||||||
server.adminPass = admin_pass
|
server.adminPass = admin_pass
|
||||||
|
@ -532,16 +532,16 @@ class TestFloatingIP(base.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@patch.object(OpenStackCloud, 'delete_floating_ip')
|
@patch.object(OpenStackCloud, 'delete_floating_ip')
|
||||||
@patch.object(OpenStackCloud, 'get_server_by_id')
|
@patch.object(OpenStackCloud, 'get_server')
|
||||||
@patch.object(OpenStackCloud, 'create_floating_ip')
|
@patch.object(OpenStackCloud, 'create_floating_ip')
|
||||||
@patch.object(OpenStackCloud, 'has_service')
|
@patch.object(OpenStackCloud, 'has_service')
|
||||||
def test_add_ip_refresh_timeout(
|
def test_add_ip_refresh_timeout(
|
||||||
self, mock_has_service, mock_create_floating_ip,
|
self, mock_has_service, mock_create_floating_ip,
|
||||||
mock_get_server_by_id, mock_delete_floating_ip):
|
mock_get_server, mock_delete_floating_ip):
|
||||||
mock_has_service.return_value = True
|
mock_has_service.return_value = True
|
||||||
|
|
||||||
mock_create_floating_ip.return_value = self.floating_ip
|
mock_create_floating_ip.return_value = self.floating_ip
|
||||||
mock_get_server_by_id.return_value = self.fake_server
|
mock_get_server.return_value = self.fake_server
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.OpenStackCloudTimeout,
|
exc.OpenStackCloudTimeout,
|
||||||
|
@ -56,13 +56,13 @@ class TestRebuildServer(base.TestCase):
|
|||||||
with patch("shade.OpenStackCloud"):
|
with patch("shade.OpenStackCloud"):
|
||||||
config = {
|
config = {
|
||||||
"servers.rebuild.return_value": rebuild_server,
|
"servers.rebuild.return_value": rebuild_server,
|
||||||
"servers.get.return_value": error_server,
|
"servers.list.return_value": [error_server],
|
||||||
"floating_ips.list.return_value": [fake_floating_ip]
|
"floating_ips.list.return_value": [fake_floating_ip]
|
||||||
}
|
}
|
||||||
OpenStackCloud.nova_client = Mock(**config)
|
OpenStackCloud.nova_client = Mock(**config)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
OpenStackCloudException,
|
OpenStackCloudException,
|
||||||
self.cloud.rebuild_server, "a", "b", wait=True)
|
self.cloud.rebuild_server, "1234", "b", wait=True)
|
||||||
|
|
||||||
def test_rebuild_server_timeout(self):
|
def test_rebuild_server_timeout(self):
|
||||||
"""
|
"""
|
||||||
@ -73,7 +73,7 @@ class TestRebuildServer(base.TestCase):
|
|||||||
with patch("shade.OpenStackCloud"):
|
with patch("shade.OpenStackCloud"):
|
||||||
config = {
|
config = {
|
||||||
"servers.rebuild.return_value": rebuild_server,
|
"servers.rebuild.return_value": rebuild_server,
|
||||||
"servers.get.return_value": rebuild_server,
|
"servers.list.return_value": [rebuild_server],
|
||||||
}
|
}
|
||||||
OpenStackCloud.nova_client = Mock(**config)
|
OpenStackCloud.nova_client = Mock(**config)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
@ -125,7 +125,7 @@ class TestRebuildServer(base.TestCase):
|
|||||||
'5678')
|
'5678')
|
||||||
config = {
|
config = {
|
||||||
"servers.rebuild.return_value": rebuild_server,
|
"servers.rebuild.return_value": rebuild_server,
|
||||||
"servers.get.return_value": active_server,
|
"servers.list.return_value": [active_server],
|
||||||
"floating_ips.list.return_value": [fake_floating_ip]
|
"floating_ips.list.return_value": [fake_floating_ip]
|
||||||
}
|
}
|
||||||
OpenStackCloud.nova_client = Mock(**config)
|
OpenStackCloud.nova_client = Mock(**config)
|
||||||
@ -135,7 +135,7 @@ class TestRebuildServer(base.TestCase):
|
|||||||
meta.obj_to_dict(ret_active_server),
|
meta.obj_to_dict(ret_active_server),
|
||||||
cloud_name='cloud-name', region_name='RegionOne'),
|
cloud_name='cloud-name', region_name='RegionOne'),
|
||||||
self.cloud.rebuild_server(
|
self.cloud.rebuild_server(
|
||||||
"a", "b", wait=True, admin_pass='ooBootheiX0edoh'))
|
"1234", "b", wait=True, admin_pass='ooBootheiX0edoh'))
|
||||||
|
|
||||||
def test_rebuild_server_wait(self):
|
def test_rebuild_server_wait(self):
|
||||||
"""
|
"""
|
||||||
@ -150,7 +150,7 @@ class TestRebuildServer(base.TestCase):
|
|||||||
'5678')
|
'5678')
|
||||||
config = {
|
config = {
|
||||||
"servers.rebuild.return_value": rebuild_server,
|
"servers.rebuild.return_value": rebuild_server,
|
||||||
"servers.get.return_value": active_server,
|
"servers.list.return_value": [active_server],
|
||||||
"floating_ips.list.return_value": [fake_floating_ip]
|
"floating_ips.list.return_value": [fake_floating_ip]
|
||||||
}
|
}
|
||||||
OpenStackCloud.nova_client = Mock(**config)
|
OpenStackCloud.nova_client = Mock(**config)
|
||||||
@ -159,4 +159,4 @@ class TestRebuildServer(base.TestCase):
|
|||||||
_utils.normalize_server(
|
_utils.normalize_server(
|
||||||
meta.obj_to_dict(active_server),
|
meta.obj_to_dict(active_server),
|
||||||
cloud_name='cloud-name', region_name='RegionOne'),
|
cloud_name='cloud-name', region_name='RegionOne'),
|
||||||
self.cloud.rebuild_server("a", "b", wait=True))
|
self.cloud.rebuild_server("1234", "b", wait=True))
|
||||||
|
@ -21,37 +21,37 @@ class TestException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestTask(task_manager.Task):
|
class TaskTest(task_manager.Task):
|
||||||
def main(self, client):
|
def main(self, client):
|
||||||
raise TestException("This is a test exception")
|
raise TestException("This is a test exception")
|
||||||
|
|
||||||
|
|
||||||
class TestTaskGenerator(task_manager.Task):
|
class TaskTestGenerator(task_manager.Task):
|
||||||
def main(self, client):
|
def main(self, client):
|
||||||
yield 1
|
yield 1
|
||||||
|
|
||||||
|
|
||||||
class TestTaskInt(task_manager.Task):
|
class TaskTestInt(task_manager.Task):
|
||||||
def main(self, client):
|
def main(self, client):
|
||||||
return int(1)
|
return int(1)
|
||||||
|
|
||||||
|
|
||||||
class TestTaskFloat(task_manager.Task):
|
class TaskTestFloat(task_manager.Task):
|
||||||
def main(self, client):
|
def main(self, client):
|
||||||
return float(2.0)
|
return float(2.0)
|
||||||
|
|
||||||
|
|
||||||
class TestTaskStr(task_manager.Task):
|
class TaskTestStr(task_manager.Task):
|
||||||
def main(self, client):
|
def main(self, client):
|
||||||
return "test"
|
return "test"
|
||||||
|
|
||||||
|
|
||||||
class TestTaskBool(task_manager.Task):
|
class TaskTestBool(task_manager.Task):
|
||||||
def main(self, client):
|
def main(self, client):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class TestTaskSet(task_manager.Task):
|
class TaskTestSet(task_manager.Task):
|
||||||
def main(self, client):
|
def main(self, client):
|
||||||
return set([1, 2])
|
return set([1, 2])
|
||||||
|
|
||||||
@ -69,24 +69,24 @@ class TestTaskManager(base.TestCase):
|
|||||||
Specifically, we test if we get the same behaviour with all the
|
Specifically, we test if we get the same behaviour with all the
|
||||||
configured interpreters (e.g. py27, p34, pypy, ...)
|
configured interpreters (e.g. py27, p34, pypy, ...)
|
||||||
"""
|
"""
|
||||||
self.assertRaises(TestException, self.manager.submit_task, TestTask())
|
self.assertRaises(TestException, self.manager.submit_task, TaskTest())
|
||||||
|
|
||||||
def test_dont_munchify_int(self):
|
def test_dont_munchify_int(self):
|
||||||
ret = self.manager.submit_task(TestTaskInt())
|
ret = self.manager.submit_task(TaskTestInt())
|
||||||
self.assertIsInstance(ret, int)
|
self.assertIsInstance(ret, int)
|
||||||
|
|
||||||
def test_dont_munchify_float(self):
|
def test_dont_munchify_float(self):
|
||||||
ret = self.manager.submit_task(TestTaskFloat())
|
ret = self.manager.submit_task(TaskTestFloat())
|
||||||
self.assertIsInstance(ret, float)
|
self.assertIsInstance(ret, float)
|
||||||
|
|
||||||
def test_dont_munchify_str(self):
|
def test_dont_munchify_str(self):
|
||||||
ret = self.manager.submit_task(TestTaskStr())
|
ret = self.manager.submit_task(TaskTestStr())
|
||||||
self.assertIsInstance(ret, str)
|
self.assertIsInstance(ret, str)
|
||||||
|
|
||||||
def test_dont_munchify_bool(self):
|
def test_dont_munchify_bool(self):
|
||||||
ret = self.manager.submit_task(TestTaskBool())
|
ret = self.manager.submit_task(TaskTestBool())
|
||||||
self.assertIsInstance(ret, bool)
|
self.assertIsInstance(ret, bool)
|
||||||
|
|
||||||
def test_dont_munchify_set(self):
|
def test_dont_munchify_set(self):
|
||||||
ret = self.manager.submit_task(TestTaskSet())
|
ret = self.manager.submit_task(TaskTestSet())
|
||||||
self.assertIsInstance(ret, set)
|
self.assertIsInstance(ret, set)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user