merge trunk
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
ZoneManager oversees all communications with child Zones.
|
ZoneManager oversees all communications with child Zones.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import novatools
|
import novaclient
|
||||||
import thread
|
import thread
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
@@ -85,9 +85,9 @@ class ZoneState(object):
|
|||||||
"attempts. Marking inactive.") % locals())
|
"attempts. Marking inactive.") % locals())
|
||||||
|
|
||||||
|
|
||||||
def _call_novatools(zone):
|
def _call_novaclient(zone):
|
||||||
"""Call novatools. Broken out for testing purposes."""
|
"""Call novaclient. Broken out for testing purposes."""
|
||||||
client = novatools.OpenStack(zone.username, zone.password, zone.api_url)
|
client = novaclient.OpenStack(zone.username, zone.password, zone.api_url)
|
||||||
return client.zones.info()._info
|
return client.zones.info()._info
|
||||||
|
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ def _poll_zone(zone):
|
|||||||
"""Eventlet worker to poll a zone."""
|
"""Eventlet worker to poll a zone."""
|
||||||
logging.debug(_("Polling zone: %s") % zone.api_url)
|
logging.debug(_("Polling zone: %s") % zone.api_url)
|
||||||
try:
|
try:
|
||||||
zone.update_metadata(_call_novatools(zone))
|
zone.update_metadata(_call_novaclient(zone))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
zone.log_error(traceback.format_exc())
|
zone.log_error(traceback.format_exc())
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Tests For ZoneManager
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import mox
|
import mox
|
||||||
import novatools
|
import novaclient
|
||||||
|
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import db
|
from nova import db
|
||||||
@@ -40,8 +40,8 @@ class FakeZone:
|
|||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
|
|
||||||
def exploding_novatools(zone):
|
def exploding_novaclient(zone):
|
||||||
"""Used when we want to simulate a novatools call failing."""
|
"""Used when we want to simulate a novaclient call failing."""
|
||||||
raise Exception("kaboom")
|
raise Exception("kaboom")
|
||||||
|
|
||||||
|
|
||||||
@@ -139,8 +139,8 @@ class ZoneManagerTestCase(test.TestCase):
|
|||||||
self.assertEquals(zm.zone_states[2].username, 'user2')
|
self.assertEquals(zm.zone_states[2].username, 'user2')
|
||||||
|
|
||||||
def test_poll_zone(self):
|
def test_poll_zone(self):
|
||||||
self.mox.StubOutWithMock(zone_manager, '_call_novatools')
|
self.mox.StubOutWithMock(zone_manager, '_call_novaclient')
|
||||||
zone_manager._call_novatools(mox.IgnoreArg()).AndReturn(
|
zone_manager._call_novaclient(mox.IgnoreArg()).AndReturn(
|
||||||
dict(name='zohan', capabilities='hairdresser'))
|
dict(name='zohan', capabilities='hairdresser'))
|
||||||
|
|
||||||
zone_state = zone_manager.ZoneState()
|
zone_state = zone_manager.ZoneState()
|
||||||
@@ -156,7 +156,7 @@ class ZoneManagerTestCase(test.TestCase):
|
|||||||
self.assertEquals(zone_state.name, 'zohan')
|
self.assertEquals(zone_state.name, 'zohan')
|
||||||
|
|
||||||
def test_poll_zone_fails(self):
|
def test_poll_zone_fails(self):
|
||||||
self.stubs.Set(zone_manager, "_call_novatools", exploding_novatools)
|
self.stubs.Set(zone_manager, "_call_novaclient", exploding_novaclient)
|
||||||
|
|
||||||
zone_state = zone_manager.ZoneState()
|
zone_state = zone_manager.ZoneState()
|
||||||
zone_state.update_credentials(FakeZone(id=2,
|
zone_state.update_credentials(FakeZone(id=2,
|
||||||
|
|||||||
Reference in New Issue
Block a user