support volume and network in the direct api
This commit is contained in:
@@ -34,12 +34,14 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
|||||||
|
|
||||||
gettext.install('nova', unicode=1)
|
gettext.install('nova', unicode=1)
|
||||||
|
|
||||||
|
from nova import compute
|
||||||
from nova import flags
|
from nova import flags
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
|
from nova import network
|
||||||
from nova import utils
|
from nova import utils
|
||||||
|
from nova import volume
|
||||||
from nova import wsgi
|
from nova import wsgi
|
||||||
from nova.api import direct
|
from nova.api import direct
|
||||||
from nova.compute import api as compute_api
|
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
@@ -50,12 +52,15 @@ flags.DEFINE_flag(flags.HelpshortFlag())
|
|||||||
flags.DEFINE_flag(flags.HelpXMLFlag())
|
flags.DEFINE_flag(flags.HelpXMLFlag())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
utils.default_flagfile()
|
utils.default_flagfile()
|
||||||
FLAGS(sys.argv)
|
FLAGS(sys.argv)
|
||||||
logging.setup()
|
logging.setup()
|
||||||
|
|
||||||
direct.register_service('compute', compute_api.API())
|
direct.register_service('compute', compute.API())
|
||||||
|
direct.register_service('volume', volume.API())
|
||||||
|
direct.register_service('network', network.API())
|
||||||
direct.register_service('reflect', direct.Reflection())
|
direct.register_service('reflect', direct.Reflection())
|
||||||
router = direct.Router()
|
router = direct.Router()
|
||||||
with_json = direct.JsonParamsMiddleware(router)
|
with_json = direct.JsonParamsMiddleware(router)
|
||||||
|
@@ -25,7 +25,9 @@ import webob
|
|||||||
from nova import compute
|
from nova import compute
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
from nova import network
|
||||||
from nova import test
|
from nova import test
|
||||||
|
from nova import volume
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.api import direct
|
from nova.api import direct
|
||||||
from nova.tests import test_cloud
|
from nova.tests import test_cloud
|
||||||
@@ -93,12 +95,20 @@ class DirectTestCase(test.TestCase):
|
|||||||
class DirectCloudTestCase(test_cloud.CloudTestCase):
|
class DirectCloudTestCase(test_cloud.CloudTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DirectCloudTestCase, self).setUp()
|
super(DirectCloudTestCase, self).setUp()
|
||||||
compute_handle = compute.API(network_api=self.cloud.network_api,
|
compute_handle = compute.API(image_service=self.cloud.image_service)
|
||||||
volume_api=self.cloud.volume_api)
|
volume_handle = volume.API()
|
||||||
|
network_handle = network.API()
|
||||||
direct.register_service('compute', compute_handle)
|
direct.register_service('compute', compute_handle)
|
||||||
|
direct.register_service('volume', volume_handle)
|
||||||
|
direct.register_service('network', network_handle)
|
||||||
|
|
||||||
self.router = direct.JsonParamsMiddleware(direct.Router())
|
self.router = direct.JsonParamsMiddleware(direct.Router())
|
||||||
proxy = direct.Proxy(self.router)
|
proxy = direct.Proxy(self.router)
|
||||||
self.cloud.compute_api = proxy.compute
|
self.cloud.compute_api = proxy.compute
|
||||||
|
self.cloud.volume_api = proxy.volume
|
||||||
|
self.cloud.network_api = proxy.network
|
||||||
|
compute_handle.volume_api = proxy.volume
|
||||||
|
compute_handle.network_api = proxy.network
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(DirectCloudTestCase, self).tearDown()
|
super(DirectCloudTestCase, self).tearDown()
|
||||||
|
Reference in New Issue
Block a user