Remove openstack.compute usage
Change-Id: I898952ae6f141759aeacc8dec5756ffe4e14ca51 Signed-off-by: Julien Danjou <julien.danjou@enovance.com>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
download-cache = /tmp/.buildout_cache/
|
||||
parts =
|
||||
django
|
||||
openstack-compute
|
||||
openstackx
|
||||
quantum
|
||||
python-novaclient
|
||||
@@ -84,7 +83,6 @@ eggs =
|
||||
${horizon:eggs}
|
||||
${glance-dependencies:eggs}
|
||||
extra-paths =
|
||||
${buildout:directory}/parts/openstack-compute
|
||||
${buildout:directory}/parts/openstackx
|
||||
${buildout:directory}/parts/python-novaclient
|
||||
${buildout:directory}/parts/python-keystoneclient
|
||||
@@ -92,12 +90,6 @@ extra-paths =
|
||||
|
||||
## Dependencies fetch from git
|
||||
# git dependencies end up as a subdirectory of ${buildout:directory}/parts/
|
||||
[openstack-compute]
|
||||
recipe = zerokspot.recipe.git
|
||||
repository = git://github.com/jacobian/openstack.compute.git
|
||||
as_egg = True
|
||||
|
||||
|
||||
[openstackx]
|
||||
recipe = zerokspot.recipe.git
|
||||
repository = git://github.com/cloudbuilders/openstackx.git
|
||||
|
||||
@@ -22,7 +22,6 @@ import functools
|
||||
import logging
|
||||
|
||||
from django.utils.decorators import available_attrs
|
||||
import openstack.compute
|
||||
import openstackx.admin
|
||||
import openstackx.api.exceptions as openstackx_exceptions
|
||||
import openstackx.extras
|
||||
@@ -33,9 +32,6 @@ from horizon.api.base import *
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
REBOOT_HARD = openstack.compute.servers.REBOOT_HARD
|
||||
|
||||
|
||||
def check_openstackx(f):
|
||||
"""Decorator that adds extra info to api exceptions
|
||||
|
||||
@@ -61,22 +57,6 @@ def check_openstackx(f):
|
||||
raise
|
||||
return inner
|
||||
|
||||
|
||||
def compute_api(request):
|
||||
management_url = url_for(request, 'compute')
|
||||
compute = openstack.compute.Compute(
|
||||
auth_token=request.user.token,
|
||||
management_url=management_url)
|
||||
# this below hack is necessary to make the jacobian compute client work
|
||||
# TODO(mgius): It looks like this is unused now?
|
||||
compute.client.auth_token = request.user.token
|
||||
compute.client.management_url = management_url
|
||||
LOG.debug('compute_api connection created using token "%s"'
|
||||
' and url "%s"' %
|
||||
(request.user.token, management_url))
|
||||
return compute
|
||||
|
||||
|
||||
def admin_api(request):
|
||||
management_url = url_for(request, 'compute', True)
|
||||
LOG.debug('admin_api connection created using token "%s"'
|
||||
|
||||
@@ -24,13 +24,12 @@ import logging
|
||||
|
||||
from django.contrib import messages
|
||||
from novaclient.v1_1 import client as nova_client
|
||||
from novaclient.v1_1.servers import REBOOT_HARD
|
||||
|
||||
from horizon.api.base import *
|
||||
from horizon.api.deprecated import admin_api
|
||||
from horizon.api.deprecated import compute_api
|
||||
from horizon.api.deprecated import check_openstackx
|
||||
from horizon.api.deprecated import extras_api
|
||||
from horizon.api.deprecated import REBOOT_HARD
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@@ -95,7 +94,7 @@ class Server(APIResourceWrapper):
|
||||
return "(not found)"
|
||||
|
||||
def reboot(self, hardness=REBOOT_HARD):
|
||||
compute_api(self.request).servers.reboot(self.id, hardness)
|
||||
novaclient(self.request).servers.reboot(self.id, hardness)
|
||||
|
||||
|
||||
class ServerAttributes(APIDictWrapper):
|
||||
@@ -227,7 +226,7 @@ def server_create(request, name, image, flavor,
|
||||
|
||||
|
||||
def server_delete(request, instance):
|
||||
compute_api(request).servers.delete(instance)
|
||||
novaclient(request).servers.delete(instance)
|
||||
|
||||
|
||||
def server_get(request, instance_id):
|
||||
|
||||
@@ -26,7 +26,6 @@ from django import shortcuts
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
import openstackx
|
||||
import openstack
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import users
|
||||
@@ -52,8 +51,7 @@ class HorizonMiddleware(object):
|
||||
messages.error(request, _(unicode(exception)))
|
||||
return shortcuts.redirect('/auth/logout')
|
||||
|
||||
if type(exception) in [openstack.compute.exceptions.Forbidden,
|
||||
openstackx.api.exceptions.Forbidden]:
|
||||
if type(exception) == openstackx.api.exceptions.Forbidden:
|
||||
# flush other error messages, which are collateral damage
|
||||
# when our token expires
|
||||
for message in messages.get_messages(request):
|
||||
|
||||
@@ -23,10 +23,10 @@ from __future__ import absolute_import
|
||||
from django import http
|
||||
from django.conf import settings
|
||||
from mox import IsA
|
||||
from openstack import compute as OSCompute
|
||||
from openstackx import admin as OSAdmin
|
||||
from openstackx import auth as OSAuth
|
||||
from openstackx import extras as OSExtras
|
||||
from novaclient.v1_1 import servers
|
||||
|
||||
|
||||
from horizon.tests.api_tests.utils import *
|
||||
@@ -174,35 +174,6 @@ class NovaAdminApiTests(APITestCase):
|
||||
|
||||
|
||||
class ComputeApiTests(APITestCase):
|
||||
def stub_compute_api(self, count=1):
|
||||
self.mox.StubOutWithMock(api.nova, 'compute_api')
|
||||
compute_api = self.mox.CreateMock(OSCompute.Compute)
|
||||
for i in range(count):
|
||||
api.nova.compute_api(IsA(http.HttpRequest)) \
|
||||
.AndReturn(compute_api)
|
||||
return compute_api
|
||||
|
||||
def test_get_compute_api(self):
|
||||
class ComputeClient(object):
|
||||
__slots__ = ['auth_token', 'management_url']
|
||||
|
||||
self.mox.StubOutClassWithMocks(OSCompute, 'Compute')
|
||||
compute_api = OSCompute.Compute(auth_token=TEST_TOKEN,
|
||||
management_url=TEST_URL)
|
||||
|
||||
compute_api.client = ComputeClient()
|
||||
|
||||
self.mox.StubOutWithMock(api.deprecated, 'url_for')
|
||||
api.deprecated.url_for(IsA(http.HttpRequest),
|
||||
'compute').AndReturn(TEST_URL)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
compute_api = api.nova.compute_api(self.request)
|
||||
|
||||
self.assertIsNotNone(compute_api)
|
||||
self.assertEqual(compute_api.client.auth_token, TEST_TOKEN)
|
||||
self.assertEqual(compute_api.client.management_url, TEST_URL)
|
||||
|
||||
def test_flavor_get(self):
|
||||
FLAVOR_ID = 6
|
||||
@@ -221,10 +192,9 @@ class ComputeApiTests(APITestCase):
|
||||
def test_server_delete(self):
|
||||
INSTANCE = 'anInstance'
|
||||
|
||||
compute_api = self.stub_compute_api()
|
||||
|
||||
compute_api.servers = self.mox.CreateMockAnything()
|
||||
compute_api.servers.delete(INSTANCE).AndReturn(TEST_RETURN)
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
novaclient.servers.delete(INSTANCE).AndReturn(TEST_RETURN)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@@ -234,17 +204,13 @@ class ComputeApiTests(APITestCase):
|
||||
|
||||
def test_server_reboot(self):
|
||||
INSTANCE_ID = '2'
|
||||
HARDNESS = 'diamond'
|
||||
HARDNESS = servers.REBOOT_HARD
|
||||
|
||||
server = self.mox.CreateMock(servers.Server)
|
||||
server.reboot(HARDNESS)
|
||||
|
||||
self.mox.StubOutWithMock(api.nova, 'server_get')
|
||||
|
||||
server = self.mox.CreateMock(OSCompute.Server)
|
||||
server.reboot(OSCompute.servers.REBOOT_HARD).AndReturn(TEST_RETURN)
|
||||
api.nova.server_get(IsA(http.HttpRequest),
|
||||
INSTANCE_ID).AndReturn(server)
|
||||
|
||||
server = self.mox.CreateMock(OSCompute.Server)
|
||||
server.reboot(HARDNESS).AndReturn(TEST_RETURN)
|
||||
api.nova.server_get(IsA(http.HttpRequest),
|
||||
INSTANCE_ID).AndReturn(server)
|
||||
|
||||
@@ -253,10 +219,6 @@ class ComputeApiTests(APITestCase):
|
||||
ret_val = api.server_reboot(self.request, INSTANCE_ID)
|
||||
self.assertIsNone(ret_val)
|
||||
|
||||
ret_val = api.server_reboot(self.request, INSTANCE_ID,
|
||||
hardness=HARDNESS)
|
||||
self.assertIsNone(ret_val)
|
||||
|
||||
def test_server_create(self):
|
||||
NAME = 'server'
|
||||
IMAGE = 'anImage'
|
||||
@@ -265,7 +227,6 @@ class ComputeApiTests(APITestCase):
|
||||
KEY = 'user'
|
||||
SECGROUP = self.mox.CreateMock(api.SecurityGroup)
|
||||
|
||||
server = self.mox.CreateMock(OSCompute.Server)
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
novaclient.servers.create(NAME, IMAGE, FLAVOR, userdata=USER_DATA,
|
||||
|
||||
@@ -25,7 +25,6 @@ xattr
|
||||
|
||||
-e git+https://github.com/openstack/quantum.git@stable/diablo#egg=quantum
|
||||
-e git+https://github.com/cloudbuilders/openstackx.git#egg=openstackx
|
||||
-e git+https://github.com/jacobian/openstack.compute.git#egg=openstack
|
||||
-e git+https://github.com/rackspace/python-novaclient.git#egg=python-novaclient
|
||||
-e git+https://github.com/4P/python-keystoneclient.git#egg=python-keystoneclient
|
||||
-e git+https://github.com/openstack/glance.git#egg=glance
|
||||
|
||||
Reference in New Issue
Block a user