Migrate climate namespace to blazar
Although the Climate project was renamed to Blazar in 2014, the code has still been using the climate namespace. This patch moves all code to the blazar directory and allows users and operators to use the 'blazar' command namespace. The 'climate' namespace remains O release to allow users of Blazar time to move their own code to the blazar namespace, but will be removed in P release development cycle. Change-Id: Icbe6fab1051aae4ac819982a1fa4f323cb0bf2d0 Partial-Bug: #1662734
This commit is contained in:
@@ -3,7 +3,7 @@ include README.rst
|
|||||||
include ChangeLog
|
include ChangeLog
|
||||||
include LICENSE
|
include LICENSE
|
||||||
|
|
||||||
recursive-include climate/locale *
|
recursive-include blazar/locale *
|
||||||
|
|
||||||
exclude .gitignore
|
exclude .gitignore
|
||||||
exclude .gitreview
|
exclude .gitreview
|
||||||
|
@@ -10,7 +10,7 @@ Prerequisites
|
|||||||
-------------
|
-------------
|
||||||
* Keystone v3 API endpoint
|
* Keystone v3 API endpoint
|
||||||
* Dedicated account for write operations on behalf of the admin
|
* Dedicated account for write operations on behalf of the admin
|
||||||
climate_username
|
blazar_username
|
||||||
* Service account
|
* Service account
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
__path__ = [
|
|
||||||
os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
|
|
||||||
'climate')]
|
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from climate import context
|
from blazar import context
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
|
|
||||||
|
|
||||||
def ctx_from_headers(headers):
|
def ctx_from_headers(headers):
|
||||||
@@ -27,7 +27,7 @@ def ctx_from_headers(headers):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
raise exceptions.WrongFormat()
|
raise exceptions.WrongFormat()
|
||||||
|
|
||||||
return context.ClimateContext(
|
return context.BlazarContext(
|
||||||
user_id=headers['X-User-Id'],
|
user_id=headers['X-User-Id'],
|
||||||
project_id=headers['X-Project-Id'],
|
project_id=headers['X-Project-Id'],
|
||||||
auth_token=headers['X-Auth-Token'],
|
auth_token=headers['X-Auth-Token'],
|
@@ -16,7 +16,7 @@
|
|||||||
import json
|
import json
|
||||||
import pecan
|
import pecan
|
||||||
|
|
||||||
from climate.api.v2 import controllers
|
from blazar.api.v2 import controllers
|
||||||
|
|
||||||
|
|
||||||
class RootController(object):
|
class RootController(object):
|
@@ -21,23 +21,23 @@ from oslo_log import log as logging
|
|||||||
from oslo_middleware import debug
|
from oslo_middleware import debug
|
||||||
from werkzeug import exceptions as werkzeug_exceptions
|
from werkzeug import exceptions as werkzeug_exceptions
|
||||||
|
|
||||||
from climate.api.v1.oshosts import v1_0 as host_api_v1_0
|
from blazar.api.v1.oshosts import v1_0 as host_api_v1_0
|
||||||
from climate.api.v1 import utils as api_utils
|
from blazar.api.v1 import utils as api_utils
|
||||||
from climate.api.v1 import v1_0 as api_v1_0
|
from blazar.api.v1 import v1_0 as api_v1_0
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
CONF.import_opt('os_auth_host', 'climate.config')
|
CONF.import_opt('os_auth_host', 'blazar.config')
|
||||||
CONF.import_opt('os_auth_port', 'climate.config')
|
CONF.import_opt('os_auth_port', 'blazar.config')
|
||||||
CONF.import_opt('os_auth_protocol', 'climate.config')
|
CONF.import_opt('os_auth_protocol', 'blazar.config')
|
||||||
CONF.import_opt('os_admin_username', 'climate.config')
|
CONF.import_opt('os_admin_username', 'blazar.config')
|
||||||
CONF.import_opt('os_admin_password', 'climate.config')
|
CONF.import_opt('os_admin_password', 'blazar.config')
|
||||||
CONF.import_opt('os_admin_project_name', 'climate.config')
|
CONF.import_opt('os_admin_project_name', 'blazar.config')
|
||||||
CONF.import_opt('os_auth_version', 'climate.config')
|
CONF.import_opt('os_auth_version', 'blazar.config')
|
||||||
CONF.import_opt('log_exchange', 'climate.config')
|
CONF.import_opt('log_exchange', 'blazar.config')
|
||||||
|
|
||||||
|
|
||||||
eventlet.monkey_patch(
|
eventlet.monkey_patch(
|
||||||
@@ -71,9 +71,9 @@ def version_list():
|
|||||||
def make_app():
|
def make_app():
|
||||||
"""App builder (wsgi).
|
"""App builder (wsgi).
|
||||||
|
|
||||||
Entry point for Climate REST API server.
|
Entry point for Blazar REST API server.
|
||||||
"""
|
"""
|
||||||
app = flask.Flask('climate.api')
|
app = flask.Flask('blazar.api')
|
||||||
|
|
||||||
app.route('/', methods=['GET'])(version_list)
|
app.route('/', methods=['GET'])(version_list)
|
||||||
app.route('/versions', methods=['GET'])(version_list)
|
app.route('/versions', methods=['GET'])(version_list)
|
@@ -13,9 +13,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.manager.oshosts import rpcapi as manager_rpcapi
|
from blazar.manager.oshosts import rpcapi as manager_rpcapi
|
||||||
from climate import policy
|
from blazar import policy
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
|
|
||||||
class API(object):
|
class API(object):
|
||||||
@@ -42,7 +42,7 @@ class API(object):
|
|||||||
def get_computehost(self, host_id):
|
def get_computehost(self, host_id):
|
||||||
"""Get computehost by its ID.
|
"""Get computehost by its ID.
|
||||||
|
|
||||||
:param host_id: ID of the computehost in Climate DB.
|
:param host_id: ID of the computehost in Blazar DB.
|
||||||
:type host_id: str
|
:type host_id: str
|
||||||
"""
|
"""
|
||||||
return self.manager_rpcapi.get_computehost(host_id)
|
return self.manager_rpcapi.get_computehost(host_id)
|
||||||
@@ -51,7 +51,7 @@ class API(object):
|
|||||||
def update_computehost(self, host_id, data):
|
def update_computehost(self, host_id, data):
|
||||||
"""Update computehost. Only name changing may be proceeded.
|
"""Update computehost. Only name changing may be proceeded.
|
||||||
|
|
||||||
:param host_id: ID of the computehost in Climate DB.
|
:param host_id: ID of the computehost in Blazar DB.
|
||||||
:type host_id: str
|
:type host_id: str
|
||||||
:param data: New computehost characteristics.
|
:param data: New computehost characteristics.
|
||||||
:type data: dict
|
:type data: dict
|
||||||
@@ -62,7 +62,7 @@ class API(object):
|
|||||||
def delete_computehost(self, host_id):
|
def delete_computehost(self, host_id):
|
||||||
"""Delete specified computehost.
|
"""Delete specified computehost.
|
||||||
|
|
||||||
:param host_id: ID of the computehost in Climate DB.
|
:param host_id: ID of the computehost in Blazar DB.
|
||||||
:type host_id: str
|
:type host_id: str
|
||||||
"""
|
"""
|
||||||
self.manager_rpcapi.delete_computehost(host_id)
|
self.manager_rpcapi.delete_computehost(host_id)
|
@@ -13,10 +13,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.api.v1.oshosts import service
|
from blazar.api.v1.oshosts import service
|
||||||
from climate.api.v1 import utils as api_utils
|
from blazar.api.v1 import utils as api_utils
|
||||||
from climate.api.v1 import validation
|
from blazar.api.v1 import validation
|
||||||
from climate import utils
|
from blazar import utils
|
||||||
|
|
||||||
|
|
||||||
rest = api_utils.Rest('host_v1_0', __name__)
|
rest = api_utils.Rest('host_v1_0', __name__)
|
@@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from climate import context
|
from blazar import context
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate.manager import rpcapi as manager_rpcapi
|
from blazar.manager import rpcapi as manager_rpcapi
|
||||||
from climate import policy
|
from blazar import policy
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ class API(object):
|
|||||||
def get_lease(self, lease_id):
|
def get_lease(self, lease_id):
|
||||||
"""Get lease by its ID.
|
"""Get lease by its ID.
|
||||||
|
|
||||||
:param lease_id: ID of the lease in Climate DB.
|
:param lease_id: ID of the lease in Blazar DB.
|
||||||
:type lease_id: str
|
:type lease_id: str
|
||||||
"""
|
"""
|
||||||
return self.manager_rpcapi.get_lease(lease_id)
|
return self.manager_rpcapi.get_lease(lease_id)
|
||||||
@@ -64,7 +64,7 @@ class API(object):
|
|||||||
def update_lease(self, lease_id, data):
|
def update_lease(self, lease_id, data):
|
||||||
"""Update lease. Only name changing and prolonging may be proceeded.
|
"""Update lease. Only name changing and prolonging may be proceeded.
|
||||||
|
|
||||||
:param lease_id: ID of the lease in Climate DB.
|
:param lease_id: ID of the lease in Blazar DB.
|
||||||
:type lease_id: str
|
:type lease_id: str
|
||||||
:param data: New lease characteristics.
|
:param data: New lease characteristics.
|
||||||
:type data: dict
|
:type data: dict
|
||||||
@@ -74,9 +74,9 @@ class API(object):
|
|||||||
start_date = data.pop('start_date', None)
|
start_date = data.pop('start_date', None)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
raise exceptions.ClimateException('Only name changing and '
|
raise exceptions.BlazarException('Only name changing and '
|
||||||
'dates changing may be '
|
'dates changing may be '
|
||||||
'proceeded.')
|
'proceeded.')
|
||||||
data = {}
|
data = {}
|
||||||
if new_name:
|
if new_name:
|
||||||
data['name'] = new_name
|
data['name'] = new_name
|
||||||
@@ -90,7 +90,7 @@ class API(object):
|
|||||||
def delete_lease(self, lease_id):
|
def delete_lease(self, lease_id):
|
||||||
"""Delete specified lease.
|
"""Delete specified lease.
|
||||||
|
|
||||||
:param lease_id: ID of the lease in Climate DB.
|
:param lease_id: ID of the lease in Blazar DB.
|
||||||
:type lease_id: str
|
:type lease_id: str
|
||||||
"""
|
"""
|
||||||
self.manager_rpcapi.delete_lease(lease_id)
|
self.manager_rpcapi.delete_lease(lease_id)
|
@@ -21,11 +21,11 @@ import oslo_messaging as messaging
|
|||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from werkzeug import datastructures
|
from werkzeug import datastructures
|
||||||
|
|
||||||
from climate.api import context
|
from blazar.api import context
|
||||||
from climate.db import exceptions as db_exceptions
|
from blazar.db import exceptions as db_exceptions
|
||||||
from climate import exceptions as ex
|
from blazar import exceptions as ex
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
from climate.manager import exceptions as manager_exceptions
|
from blazar.manager import exceptions as manager_exceptions
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ class Rest(flask.Blueprint):
|
|||||||
with context.ctx_from_headers(flask.request.headers):
|
with context.ctx_from_headers(flask.request.headers):
|
||||||
try:
|
try:
|
||||||
return func(**kwargs)
|
return func(**kwargs)
|
||||||
except ex.ClimateException as e:
|
except ex.BlazarException as e:
|
||||||
return bad_request(e)
|
return bad_request(e)
|
||||||
except messaging.RemoteError as e:
|
except messaging.RemoteError as e:
|
||||||
# Get the exception from manager and common exceptions
|
# Get the exception from manager and common exceptions
|
||||||
@@ -96,7 +96,7 @@ class Rest(flask.Blueprint):
|
|||||||
cls.code)
|
cls.code)
|
||||||
else:
|
else:
|
||||||
# We obfuscate all Exceptions
|
# We obfuscate all Exceptions
|
||||||
# but Climate ones for
|
# but Blazar ones for
|
||||||
# security reasons
|
# security reasons
|
||||||
err = 'Internal Server Error'
|
err = 'Internal Server Error'
|
||||||
return internal_error(500, err, e)
|
return internal_error(500, err, e)
|
||||||
@@ -241,7 +241,7 @@ def internal_error(status_code, descr, exc=None):
|
|||||||
|
|
||||||
|
|
||||||
def bad_request(error):
|
def bad_request(error):
|
||||||
"""Called if Climate exception occurred."""
|
"""Called if Blazar exception occurred."""
|
||||||
if not error.code:
|
if not error.code:
|
||||||
error.code = 400
|
error.code = 400
|
||||||
|
|
@@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from climate.api.v1 import service
|
from blazar.api.v1 import service
|
||||||
from climate.api.v1 import utils as api_utils
|
from blazar.api.v1 import utils as api_utils
|
||||||
from climate.api.v1 import validation
|
from blazar.api.v1 import validation
|
||||||
from climate import utils
|
from blazar import utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@@ -17,8 +17,8 @@ import functools
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from climate.api.v1 import utils as api_utils
|
from blazar.api.v1 import utils as api_utils
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
|
|
||||||
|
|
||||||
def check_exists(get_function, object_id=None, **get_args):
|
def check_exists(get_function, object_id=None, **get_args):
|
@@ -18,8 +18,8 @@ from oslo_config import cfg
|
|||||||
from oslo_middleware import debug
|
from oslo_middleware import debug
|
||||||
import pecan
|
import pecan
|
||||||
|
|
||||||
from climate.api.v2 import hooks
|
from blazar.api.v2 import hooks
|
||||||
from climate.api.v2 import middleware
|
from blazar.api.v2 import middleware
|
||||||
|
|
||||||
|
|
||||||
auth_opts = [
|
auth_opts = [
|
||||||
@@ -31,7 +31,7 @@ auth_opts = [
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.register_opts(auth_opts)
|
CONF.register_opts(auth_opts)
|
||||||
|
|
||||||
CONF.import_opt('log_exchange', 'climate.config')
|
CONF.import_opt('log_exchange', 'blazar.config')
|
||||||
|
|
||||||
OPT_GROUP_NAME = 'keystone_authtoken'
|
OPT_GROUP_NAME = 'keystone_authtoken'
|
||||||
|
|
||||||
@@ -71,8 +71,8 @@ def setup_app(pecan_config=None, extra_hooks=None):
|
|||||||
def make_app():
|
def make_app():
|
||||||
config = {
|
config = {
|
||||||
'app': {
|
'app': {
|
||||||
'modules': ['climate.api.v2'],
|
'modules': ['blazar.api.v2'],
|
||||||
'root': 'climate.api.root.RootController',
|
'root': 'blazar.api.root.RootController',
|
||||||
'enable_acl': True,
|
'enable_acl': True,
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -22,8 +22,8 @@ import pecan
|
|||||||
from pecan import rest
|
from pecan import rest
|
||||||
from stevedore import enabled
|
from stevedore import enabled
|
||||||
|
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class V2Controller(rest.RestController):
|
|||||||
|
|
||||||
self.extension_manager = enabled.EnabledExtensionManager(
|
self.extension_manager = enabled.EnabledExtensionManager(
|
||||||
check_func=lambda ext: ext.name in CONF.api.api_v2_controllers,
|
check_func=lambda ext: ext.name in CONF.api.api_v2_controllers,
|
||||||
namespace='climate.api.v2.controllers.extensions',
|
namespace='blazar.api.v2.controllers.extensions',
|
||||||
invoke_on_load=True
|
invoke_on_load=True
|
||||||
)
|
)
|
||||||
self._log_missing_plugins(CONF.api.api_v2_controllers)
|
self._log_missing_plugins(CONF.api.api_v2_controllers)
|
||||||
@@ -62,7 +62,7 @@ class V2Controller(rest.RestController):
|
|||||||
try:
|
try:
|
||||||
setattr(self, ext.obj.name, ext.obj)
|
setattr(self, ext.obj.name, ext.obj)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise exceptions.ClimateException(
|
raise exceptions.BlazarException(
|
||||||
_("API name must be specified for "
|
_("API name must be specified for "
|
||||||
"extension {0}").format(ext.name))
|
"extension {0}").format(ext.name))
|
||||||
self._routes.update(ext.obj.extra_routes)
|
self._routes.update(ext.obj.extra_routes)
|
@@ -16,7 +16,7 @@
|
|||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
from climate.api.v2.controllers import types
|
from blazar.api.v2.controllers import types
|
||||||
|
|
||||||
|
|
||||||
class _Base(wtypes.DynamicBase):
|
class _Base(wtypes.DynamicBase):
|
@@ -18,13 +18,13 @@ import pecan
|
|||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
import wsmeext.pecan as wsme_pecan
|
import wsmeext.pecan as wsme_pecan
|
||||||
|
|
||||||
from climate.api.v2.controllers import base
|
from blazar.api.v2.controllers import base
|
||||||
from climate.api.v2.controllers import extensions
|
from blazar.api.v2.controllers import extensions
|
||||||
from climate.api.v2.controllers import types
|
from blazar.api.v2.controllers import types
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
from climate import policy
|
from blazar import policy
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ class HostsController(extensions.BaseController):
|
|||||||
if host is not None:
|
if host is not None:
|
||||||
return Host.convert(host)
|
return Host.convert(host)
|
||||||
else:
|
else:
|
||||||
raise exceptions.ClimateException(_("Host can't be created"))
|
raise exceptions.BlazarException(_("Host can't be created"))
|
||||||
|
|
||||||
@policy.authorize('oshosts', 'update')
|
@policy.authorize('oshosts', 'update')
|
||||||
@wsme_pecan.wsexpose(Host, types.IntegerType(), body=Host,
|
@wsme_pecan.wsexpose(Host, types.IntegerType(), body=Host,
|
@@ -17,14 +17,14 @@ import pecan
|
|||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
import wsmeext.pecan as wsme_pecan
|
import wsmeext.pecan as wsme_pecan
|
||||||
|
|
||||||
from climate.api.v2.controllers import base
|
from blazar.api.v2.controllers import base
|
||||||
from climate.api.v2.controllers import extensions
|
from blazar.api.v2.controllers import extensions
|
||||||
from climate.api.v2.controllers import types
|
from blazar.api.v2.controllers import types
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
from climate.manager import service
|
from blazar.manager import service
|
||||||
from climate import policy
|
from blazar import policy
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
|
|
||||||
class Lease(base._Base):
|
class Lease(base._Base):
|
||||||
@@ -126,7 +126,7 @@ class LeasesController(extensions.BaseController):
|
|||||||
if lease is not None:
|
if lease is not None:
|
||||||
return Lease.convert(lease)
|
return Lease.convert(lease)
|
||||||
else:
|
else:
|
||||||
raise exceptions.ClimateException(_("Lease can't be created"))
|
raise exceptions.BlazarException(_("Lease can't be created"))
|
||||||
|
|
||||||
@policy.authorize('leases', 'update')
|
@policy.authorize('leases', 'update')
|
||||||
@wsme_pecan.wsexpose(Lease, types.UuidType(), body=Lease, status_code=202)
|
@wsme_pecan.wsexpose(Lease, types.UuidType(), body=Lease, status_code=202)
|
||||||
@@ -144,10 +144,10 @@ class LeasesController(extensions.BaseController):
|
|||||||
None)
|
None)
|
||||||
|
|
||||||
if sublease_dct != {}:
|
if sublease_dct != {}:
|
||||||
raise exceptions.ClimateException('Only name changing, '
|
raise exceptions.BlazarException('Only name changing, '
|
||||||
'dates and before end '
|
'dates and before end '
|
||||||
'notifications may be '
|
'notifications may be '
|
||||||
'proceeded.')
|
'proceeded.')
|
||||||
if new_name:
|
if new_name:
|
||||||
sublease_dct['name'] = new_name
|
sublease_dct['name'] = new_name
|
||||||
if end_date:
|
if end_date:
|
@@ -21,7 +21,7 @@ import six
|
|||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
from wsme import utils as wutils
|
from wsme import utils as wutils
|
||||||
|
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
|
|
||||||
|
|
||||||
class UuidType(wtypes.UserType):
|
class UuidType(wtypes.UserType):
|
@@ -17,10 +17,10 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from pecan import hooks
|
from pecan import hooks
|
||||||
|
|
||||||
from climate.api import context
|
from blazar.api import context
|
||||||
from climate.db import api as dbapi
|
from blazar.db import api as dbapi
|
||||||
from climate.manager.oshosts import rpcapi as hosts_rpcapi
|
from blazar.manager.oshosts import rpcapi as hosts_rpcapi
|
||||||
from climate.manager import rpcapi
|
from blazar.manager import rpcapi
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@@ -18,10 +18,10 @@ import json
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from climate.db import exceptions as db_exceptions
|
from blazar.db import exceptions as db_exceptions
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
from climate.manager import exceptions as manager_exceptions
|
from blazar.manager import exceptions as manager_exceptions
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class ParsableErrorMiddleware(object):
|
|||||||
try:
|
try:
|
||||||
status_code = int(status.split(' ')[0])
|
status_code = int(status.split(' ')[0])
|
||||||
except (ValueError, TypeError): # pragma: nocover
|
except (ValueError, TypeError): # pragma: nocover
|
||||||
raise exceptions.ClimateException(_(
|
raise exceptions.BlazarException(_(
|
||||||
'Status {0} was unexpected').format(status))
|
'Status {0} was unexpected').format(status))
|
||||||
else:
|
else:
|
||||||
if status_code >= 400:
|
if status_code >= 400:
|
||||||
@@ -69,7 +69,7 @@ class ParsableErrorMiddleware(object):
|
|||||||
# still work if no errors are raised
|
# still work if no errors are raised
|
||||||
try:
|
try:
|
||||||
app_iter = self.app(environ, replacement_start_response)
|
app_iter = self.app(environ, replacement_start_response)
|
||||||
except exceptions.ClimateException as e:
|
except exceptions.BlazarException as e:
|
||||||
faultstring = "{0} {1}".format(e.__class__.__name__, str(e))
|
faultstring = "{0} {1}".format(e.__class__.__name__, str(e))
|
||||||
replacement_start_response(
|
replacement_start_response(
|
||||||
webob.response.Response(status=str(e.code)).status,
|
webob.response.Response(status=str(e.code)).status,
|
@@ -22,11 +22,11 @@ from eventlet import wsgi
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
gettext.install('climate', unicode=1)
|
gettext.install('blazar', unicode=1)
|
||||||
|
|
||||||
from climate.api.v1 import app as v1_app
|
from blazar.api.v1 import app as v1_app
|
||||||
from climate.api.v2 import app as v2_app
|
from blazar.api.v2 import app as v2_app
|
||||||
from climate.utils import service as service_utils
|
from blazar.utils import service as service_utils
|
||||||
|
|
||||||
|
|
||||||
opts = [
|
opts = [
|
||||||
@@ -46,7 +46,7 @@ CONF = cfg.CONF
|
|||||||
CONF.register_cli_opts(opts)
|
CONF.register_cli_opts(opts)
|
||||||
CONF.register_opts(api_opts)
|
CONF.register_opts(api_opts)
|
||||||
|
|
||||||
CONF.import_opt('host', 'climate.config')
|
CONF.import_opt('host', 'blazar.config')
|
||||||
|
|
||||||
|
|
||||||
class VersionSelectorApplication(object):
|
class VersionSelectorApplication(object):
|
||||||
@@ -90,8 +90,8 @@ class VersionSelectorApplication(object):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Entry point to start Climate API wsgi server."""
|
"""Entry point to start Blazar API wsgi server."""
|
||||||
cfg.CONF(sys.argv[1:], project='climate', prog='climate-api')
|
cfg.CONF(sys.argv[1:], project='blazar', prog='blazar-api')
|
||||||
service_utils.prepare_service(sys.argv)
|
service_utils.prepare_service(sys.argv)
|
||||||
if not CONF.enable_v1_api:
|
if not CONF.enable_v1_api:
|
||||||
app = v2_app.make_app()
|
app = v2_app.make_app()
|
@@ -21,16 +21,16 @@ eventlet.monkey_patch()
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_service import service
|
from oslo_service import service
|
||||||
|
|
||||||
gettext.install('climate', unicode=1)
|
gettext.install('blazar', unicode=1)
|
||||||
|
|
||||||
from climate.db import api as db_api
|
from blazar.db import api as db_api
|
||||||
from climate.manager import service as manager_service
|
from blazar.manager import service as manager_service
|
||||||
from climate.notification import notifier
|
from blazar.notification import notifier
|
||||||
from climate.utils import service as service_utils
|
from blazar.utils import service as service_utils
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
cfg.CONF(project='climate', prog='climate-manager')
|
cfg.CONF(project='blazar', prog='blazar-manager')
|
||||||
service_utils.prepare_service(sys.argv)
|
service_utils.prepare_service(sys.argv)
|
||||||
db_api.setup_db()
|
db_api.setup_db()
|
||||||
notifier.init()
|
notifier.init()
|
@@ -47,7 +47,7 @@ os_opts = [
|
|||||||
'The user must have admin role in <os_admin_project_name> '
|
'The user must have admin role in <os_admin_project_name> '
|
||||||
'project'),
|
'project'),
|
||||||
cfg.StrOpt('os_admin_password',
|
cfg.StrOpt('os_admin_password',
|
||||||
default='climate',
|
default='blazar',
|
||||||
help='Password of the admin user'),
|
help='Password of the admin user'),
|
||||||
cfg.StrOpt('os_admin_project_name',
|
cfg.StrOpt('os_admin_project_name',
|
||||||
default='admin',
|
default='admin',
|
@@ -77,7 +77,7 @@ class BaseContext(object):
|
|||||||
return self.__values
|
return self.__values
|
||||||
|
|
||||||
|
|
||||||
class ClimateContext(BaseContext):
|
class BlazarContext(BaseContext):
|
||||||
|
|
||||||
_elements = set([
|
_elements = set([
|
||||||
"user_id",
|
"user_id",
|
||||||
@@ -100,8 +100,8 @@ class ClimateContext(BaseContext):
|
|||||||
|
|
||||||
|
|
||||||
def current():
|
def current():
|
||||||
return ClimateContext.current()
|
return BlazarContext.current()
|
||||||
|
|
||||||
|
|
||||||
def elevated():
|
def elevated():
|
||||||
return ClimateContext.elevated()
|
return BlazarContext.elevated()
|
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
"""Defines interface for DB access.
|
"""Defines interface for DB access.
|
||||||
|
|
||||||
Functions in this module are imported into the climate.db namespace. Call these
|
Functions in this module are imported into the blazar.db namespace. Call these
|
||||||
functions from climate.db namespace, not the climate.db.api namespace.
|
functions from blazar.db namespace, not the blazar.db.api namespace.
|
||||||
|
|
||||||
All functions in this module return objects that implement a dictionary-like
|
All functions in this module return objects that implement a dictionary-like
|
||||||
interface.
|
interface.
|
||||||
@@ -27,7 +27,7 @@ interface.
|
|||||||
`sqlalchemy` is the only supported backend right now.
|
`sqlalchemy` is the only supported backend right now.
|
||||||
|
|
||||||
:sql_connection: string specifying the sqlalchemy connection to use, like:
|
:sql_connection: string specifying the sqlalchemy connection to use, like:
|
||||||
`sqlite:///var/lib/climate/climate.sqlite`.
|
`sqlite:///var/lib/blazar/blazar.sqlite`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ from oslo_log import log as logging
|
|||||||
|
|
||||||
|
|
||||||
_BACKEND_MAPPING = {
|
_BACKEND_MAPPING = {
|
||||||
'sqlalchemy': 'climate.db.sqlalchemy.api',
|
'sqlalchemy': 'blazar.db.sqlalchemy.api',
|
||||||
}
|
}
|
||||||
|
|
||||||
db_options.set_defaults(cfg.CONF)
|
db_options.set_defaults(cfg.CONF)
|
@@ -20,7 +20,7 @@ from oslo_utils import importutils
|
|||||||
|
|
||||||
|
|
||||||
db_driver_opts = [
|
db_driver_opts = [
|
||||||
cfg.StrOpt('db_driver', default='climate.db',
|
cfg.StrOpt('db_driver', default='blazar.db',
|
||||||
help='Driver to use for database access')
|
help='Driver to use for database access')
|
||||||
]
|
]
|
||||||
|
|
@@ -15,28 +15,28 @@
|
|||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ClimateDBException(exceptions.ClimateException):
|
class BlazarDBException(exceptions.BlazarException):
|
||||||
msg_fmt = _('An unknown database exception occurred')
|
msg_fmt = _('An unknown database exception occurred')
|
||||||
|
|
||||||
|
|
||||||
class ClimateDBDuplicateEntry(ClimateDBException):
|
class BlazarDBDuplicateEntry(BlazarDBException):
|
||||||
msg_fmt = _('Duplicate entry for %(columns)s in %(model)s model was found')
|
msg_fmt = _('Duplicate entry for %(columns)s in %(model)s model was found')
|
||||||
|
|
||||||
|
|
||||||
class ClimateDBNotFound(ClimateDBException):
|
class BlazarDBNotFound(BlazarDBException):
|
||||||
msg_fmt = _('%(id)s %(model)s was not found')
|
msg_fmt = _('%(id)s %(model)s was not found')
|
||||||
|
|
||||||
|
|
||||||
class ClimateDBInvalidFilter(ClimateDBException):
|
class BlazarDBInvalidFilter(BlazarDBException):
|
||||||
msg_fmt = _('%(query_filter)s is invalid')
|
msg_fmt = _('%(query_filter)s is invalid')
|
||||||
|
|
||||||
|
|
||||||
class ClimateDBInvalidFilterOperator(ClimateDBException):
|
class BlazarDBInvalidFilterOperator(BlazarDBException):
|
||||||
msg_fmt = _('%(filter_operator)s is invalid')
|
msg_fmt = _('%(filter_operator)s is invalid')
|
@@ -14,44 +14,44 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
Climate project uses Alembic to handle database migrations. A migration occurs
|
Blazar project uses Alembic to handle database migrations. A migration occurs
|
||||||
by executing a script that details the changes needed to upgrade/downgrade
|
by executing a script that details the changes needed to upgrade/downgrade
|
||||||
the database. The migration scripts are ordered so that multiple scripts
|
the database. The migration scripts are ordered so that multiple scripts
|
||||||
can run sequentially to update the database.
|
can run sequentially to update the database.
|
||||||
|
|
||||||
You can then upgrade to the latest database version via:
|
You can then upgrade to the latest database version via:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf upgrade head
|
$ blazar-db-manage --config-file /path/to/blazar.conf upgrade head
|
||||||
|
|
||||||
To check the current database version:
|
To check the current database version:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf current
|
$ blazar-db-manage --config-file /path/to/blazar.conf current
|
||||||
|
|
||||||
To create a script to run the migration offline:
|
To create a script to run the migration offline:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf upgrade head --sql
|
$ blazar-db-manage --config-file /path/to/blazar.conf upgrade head --sql
|
||||||
|
|
||||||
To run the offline migration between specific migration versions:
|
To run the offline migration between specific migration versions:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf upgrade \
|
$ blazar-db-manage --config-file /path/to/blazar.conf upgrade \
|
||||||
<start version>:<end version> --sql
|
<start version>:<end version> --sql
|
||||||
|
|
||||||
Upgrade the database incrementally:
|
Upgrade the database incrementally:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf \
|
$ blazar-db-manage --config-file /path/to/blazar.conf \
|
||||||
upgrade --delta <# of revs>
|
upgrade --delta <# of revs>
|
||||||
|
|
||||||
Downgrade the database by a certain number of revisions:
|
Downgrade the database by a certain number of revisions:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf downgrade \
|
$ blazar-db-manage --config-file /path/to/blazar.conf downgrade \
|
||||||
--delta <# of revs>
|
--delta <# of revs>
|
||||||
|
|
||||||
|
|
||||||
DEVELOPERS:
|
DEVELOPERS:
|
||||||
A database migration script is required when you submit a change to Climate
|
A database migration script is required when you submit a change to Blazar
|
||||||
that alters the database model definition. The migration script is a special
|
that alters the database model definition. The migration script is a special
|
||||||
python file that includes code to update/downgrade the database to match the
|
python file that includes code to update/downgrade the database to match the
|
||||||
changes in the model definition. Alembic will execute these scripts in order to
|
changes in the model definition. Alembic will execute these scripts in order to
|
||||||
provide a linear migration path between revision. The climate-db-manage command
|
provide a linear migration path between revision. The blazar-db-manage command
|
||||||
can be used to generate migration template for you to complete. The operations
|
can be used to generate migration template for you to complete. The operations
|
||||||
in the template are those supported by the Alembic migration library.
|
in the template are those supported by the Alembic migration library.
|
||||||
After you modified the Climate models accordingly, you can create the revision.
|
After you modified the Blazar models accordingly, you can create the revision.
|
||||||
|
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf revision \
|
$ blazar-db-manage --config-file /path/to/blazar.conf revision \
|
||||||
-m "description of revision" \
|
-m "description of revision" \
|
||||||
--autogenerate
|
--autogenerate
|
||||||
|
|
||||||
@@ -63,13 +63,13 @@ In rare circumstances, you may want to start with an empty migration template
|
|||||||
and manually author the changes necessary for an upgrade/downgrade. You can
|
and manually author the changes necessary for an upgrade/downgrade. You can
|
||||||
create a blank file via:
|
create a blank file via:
|
||||||
|
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf revision \
|
$ blazar-db-manage --config-file /path/to/blazar.conf revision \
|
||||||
-m "description of revision"
|
-m "description of revision"
|
||||||
|
|
||||||
The migration timeline should remain linear so that there is a clear path when
|
The migration timeline should remain linear so that there is a clear path when
|
||||||
upgrading/downgrading. To verify that the timeline does branch, you can run
|
upgrading/downgrading. To verify that the timeline does branch, you can run
|
||||||
this command:
|
this command:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf check_migration
|
$ blazar-db-manage --config-file /path/to/blazar.conf check_migration
|
||||||
|
|
||||||
If the migration path does branch, you can find the branch point via:
|
If the migration path does branch, you can find the branch point via:
|
||||||
$ climate-db-manage --config-file /path/to/climate.conf history
|
$ blazar-db-manage --config-file /path/to/blazar.conf history
|
@@ -11,7 +11,7 @@ script_location = %(here)s/alembic_migrations
|
|||||||
# the 'revision' command, regardless of autogenerate
|
# the 'revision' command, regardless of autogenerate
|
||||||
# revision_environment = false
|
# revision_environment = false
|
||||||
|
|
||||||
# default to an empty string because the Climate migration cli will
|
# default to an empty string because the Blazar migration cli will
|
||||||
# extract the correct value and set it programatically before alembic is fully
|
# extract the correct value and set it programatically before alembic is fully
|
||||||
# invoked.
|
# invoked.
|
||||||
sqlalchemy.url =
|
sqlalchemy.url =
|
@@ -17,8 +17,8 @@ from alembic import context
|
|||||||
from sqlalchemy import create_engine, pool
|
from sqlalchemy import create_engine, pool
|
||||||
from logging import config as log_config
|
from logging import config as log_config
|
||||||
|
|
||||||
from climate.db.sqlalchemy import model_base
|
from blazar.db.sqlalchemy import model_base
|
||||||
from climate.db.sqlalchemy import models # noqa
|
from blazar.db.sqlalchemy import models # noqa
|
||||||
|
|
||||||
# this is the Alembic Config object, which provides
|
# this is the Alembic Config object, which provides
|
||||||
# access to the values within the .ini file in use.
|
# access to the values within the .ini file in use.
|
||||||
@@ -32,7 +32,7 @@ log_config.fileConfig(config.config_file_name)
|
|||||||
# for 'autogenerate' support
|
# for 'autogenerate' support
|
||||||
# from myapp import mymodel
|
# from myapp import mymodel
|
||||||
# target_metadata = mymodel.Base.metadata
|
# target_metadata = mymodel.Base.metadata
|
||||||
target_metadata = model_base.ClimateBase.metadata
|
target_metadata = model_base.BlazarBase.metadata
|
||||||
|
|
||||||
# other values from the config, defined by the needs of env.py,
|
# other values from the config, defined by the needs of env.py,
|
||||||
# can be acquired:
|
# can be acquired:
|
||||||
@@ -79,6 +79,6 @@ def run_migrations_online(config):
|
|||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
if context.is_offline_mode():
|
if context.is_offline_mode():
|
||||||
run_migrations_offline(config.climate_config)
|
run_migrations_offline(config.blazar_config)
|
||||||
else:
|
else:
|
||||||
run_migrations_online(config.climate_config)
|
run_migrations_online(config.blazar_config)
|
3
blazar/db/migration/alembic_migrations/versions/README
Normal file
3
blazar/db/migration/alembic_migrations/versions/README
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
This directory contains the migration scripts for the Blazar project. Please
|
||||||
|
see the README in blazar/db/migration on how to use and generate new
|
||||||
|
migrations.
|
@@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
"""CLI tool to manage the Climate DB. Inspired by Neutron's same tool."""
|
"""CLI tool to manage the Blazar DB. Inspired by Neutron's same tool."""
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
import os
|
import os
|
||||||
@@ -25,8 +25,8 @@ from alembic import util as alembic_util
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import options as db_options
|
from oslo_db import options as db_options
|
||||||
|
|
||||||
gettext.install('climate', unicode=1)
|
gettext.install('blazar', unicode=1)
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@@ -112,7 +112,7 @@ def main():
|
|||||||
config = alembic_config.Config(
|
config = alembic_config.Config(
|
||||||
os.path.join(os.path.dirname(__file__), 'alembic.ini')
|
os.path.join(os.path.dirname(__file__), 'alembic.ini')
|
||||||
)
|
)
|
||||||
config.climate_config = CONF
|
config.blazar_config = CONF
|
||||||
|
|
||||||
CONF()
|
CONF()
|
||||||
db_options.set_defaults(CONF)
|
db_options.set_defaults(CONF)
|
@@ -25,10 +25,10 @@ import sqlalchemy as sa
|
|||||||
from sqlalchemy.sql.expression import asc
|
from sqlalchemy.sql.expression import asc
|
||||||
from sqlalchemy.sql.expression import desc
|
from sqlalchemy.sql.expression import desc
|
||||||
|
|
||||||
from climate.db import exceptions as db_exc
|
from blazar.db import exceptions as db_exc
|
||||||
from climate.db.sqlalchemy import facade_wrapper
|
from blazar.db.sqlalchemy import facade_wrapper
|
||||||
from climate.db.sqlalchemy import models
|
from blazar.db.sqlalchemy import models
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -161,7 +161,7 @@ def reservation_create(values):
|
|||||||
reservation.save(session=session)
|
reservation.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=reservation.__class__.__name__, columns=e.columns)
|
model=reservation.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
return reservation_get(reservation.id)
|
return reservation_get(reservation.id)
|
||||||
@@ -185,8 +185,8 @@ def reservation_destroy(reservation_id):
|
|||||||
|
|
||||||
if not reservation:
|
if not reservation:
|
||||||
# raise not found error
|
# raise not found error
|
||||||
raise db_exc.ClimateDBNotFound(id=reservation_id,
|
raise db_exc.BlazarDBNotFound(id=reservation_id,
|
||||||
model='Reservation')
|
model='Reservation')
|
||||||
|
|
||||||
session.delete(reservation)
|
session.delete(reservation)
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ def lease_create(values):
|
|||||||
lease.save(session=session)
|
lease.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=lease.__class__.__name__, columns=e.columns)
|
model=lease.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -245,7 +245,7 @@ def lease_create(values):
|
|||||||
reservation.save(session=session)
|
reservation.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=reservation.__class__.__name__, columns=e.columns)
|
model=reservation.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -256,7 +256,7 @@ def lease_create(values):
|
|||||||
event.save(session=session)
|
event.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=event.__class__.__name__, columns=e.columns)
|
model=event.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
return lease_get(lease.id)
|
return lease_get(lease.id)
|
||||||
@@ -280,7 +280,7 @@ def lease_destroy(lease_id):
|
|||||||
|
|
||||||
if not lease:
|
if not lease:
|
||||||
# raise not found error
|
# raise not found error
|
||||||
raise db_exc.ClimateDBNotFound(id=lease_id, model='Lease')
|
raise db_exc.BlazarDBNotFound(id=lease_id, model='Lease')
|
||||||
|
|
||||||
session.delete(lease)
|
session.delete(lease)
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ def event_create(values):
|
|||||||
event.save(session=session)
|
event.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=event.__class__.__name__, columns=e.columns)
|
model=event.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
return event_get(event.id)
|
return event_get(event.id)
|
||||||
@@ -379,7 +379,7 @@ def event_destroy(event_id):
|
|||||||
|
|
||||||
if not event:
|
if not event:
|
||||||
# raise not found error
|
# raise not found error
|
||||||
raise db_exc.ClimateDBNotFound(id=event_id, model='Event')
|
raise db_exc.BlazarDBNotFound(id=event_id, model='Event')
|
||||||
|
|
||||||
session.delete(event)
|
session.delete(event)
|
||||||
|
|
||||||
@@ -421,7 +421,7 @@ def host_reservation_create(values):
|
|||||||
host_reservation.save(session=session)
|
host_reservation.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=host_reservation.__class__.__name__, columns=e.columns)
|
model=host_reservation.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
return host_reservation_get(host_reservation.id)
|
return host_reservation_get(host_reservation.id)
|
||||||
@@ -447,7 +447,7 @@ def host_reservation_destroy(host_reservation_id):
|
|||||||
|
|
||||||
if not host_reservation:
|
if not host_reservation:
|
||||||
# raise not found error
|
# raise not found error
|
||||||
raise db_exc.ClimateDBNotFound(
|
raise db_exc.BlazarDBNotFound(
|
||||||
id=host_reservation_id, model='ComputeHostReservation')
|
id=host_reservation_id, model='ComputeHostReservation')
|
||||||
|
|
||||||
session.delete(host_reservation)
|
session.delete(host_reservation)
|
||||||
@@ -490,7 +490,7 @@ def host_allocation_create(values):
|
|||||||
host_allocation.save(session=session)
|
host_allocation.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=host_allocation.__class__.__name__, columns=e.columns)
|
model=host_allocation.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
return host_allocation_get(host_allocation.id)
|
return host_allocation_get(host_allocation.id)
|
||||||
@@ -516,7 +516,7 @@ def host_allocation_destroy(host_allocation_id):
|
|||||||
|
|
||||||
if not host_allocation:
|
if not host_allocation:
|
||||||
# raise not found error
|
# raise not found error
|
||||||
raise db_exc.ClimateDBNotFound(
|
raise db_exc.BlazarDBNotFound(
|
||||||
id=host_allocation_id, model='ComputeHostAllocation')
|
id=host_allocation_id, model='ComputeHostAllocation')
|
||||||
|
|
||||||
session.delete(host_allocation)
|
session.delete(host_allocation)
|
||||||
@@ -577,7 +577,7 @@ def host_get_all_by_queries(queries):
|
|||||||
try:
|
try:
|
||||||
key, op, value = query.split(' ', 3)
|
key, op, value = query.split(' ', 3)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise db_exc.ClimateDBInvalidFilter(query_filter=query)
|
raise db_exc.BlazarDBInvalidFilter(query_filter=query)
|
||||||
|
|
||||||
column = getattr(models.ComputeHost, key, None)
|
column = getattr(models.ComputeHost, key, None)
|
||||||
if column:
|
if column:
|
||||||
@@ -590,7 +590,7 @@ def host_get_all_by_queries(queries):
|
|||||||
attr = filter(lambda e: hasattr(column, e % op),
|
attr = filter(lambda e: hasattr(column, e % op),
|
||||||
['%s', '%s_', '__%s__'])[0] % op
|
['%s', '%s_', '__%s__'])[0] % op
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise db_exc.ClimateDBInvalidFilterOperator(
|
raise db_exc.BlazarDBInvalidFilterOperator(
|
||||||
filter_operator=op)
|
filter_operator=op)
|
||||||
|
|
||||||
if value == 'null':
|
if value == 'null':
|
||||||
@@ -606,7 +606,7 @@ def host_get_all_by_queries(queries):
|
|||||||
).filter(models.ComputeHostExtraCapability.capability_name == key
|
).filter(models.ComputeHostExtraCapability.capability_name == key
|
||||||
).all()
|
).all()
|
||||||
if not extra_filter:
|
if not extra_filter:
|
||||||
raise db_exc.ClimateDBNotFound(
|
raise db_exc.BlazarDBNotFound(
|
||||||
id=key, model='ComputeHostExtraCapability')
|
id=key, model='ComputeHostExtraCapability')
|
||||||
|
|
||||||
for host in extra_filter:
|
for host in extra_filter:
|
||||||
@@ -630,7 +630,7 @@ def host_create(values):
|
|||||||
host.save(session=session)
|
host.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=host.__class__.__name__, columns=e.columns)
|
model=host.__class__.__name__, columns=e.columns)
|
||||||
|
|
||||||
return host_get(host.id)
|
return host_get(host.id)
|
||||||
@@ -654,7 +654,7 @@ def host_destroy(host_id):
|
|||||||
|
|
||||||
if not host:
|
if not host:
|
||||||
# raise not found error
|
# raise not found error
|
||||||
raise db_exc.ClimateDBNotFound(id=host_id, model='Host')
|
raise db_exc.BlazarDBNotFound(id=host_id, model='Host')
|
||||||
|
|
||||||
session.delete(host)
|
session.delete(host)
|
||||||
|
|
||||||
@@ -691,7 +691,7 @@ def host_extra_capability_create(values):
|
|||||||
host_extra_capability.save(session=session)
|
host_extra_capability.save(session=session)
|
||||||
except common_db_exc.DBDuplicateEntry as e:
|
except common_db_exc.DBDuplicateEntry as e:
|
||||||
# raise exception about duplicated columns (e.columns)
|
# raise exception about duplicated columns (e.columns)
|
||||||
raise db_exc.ClimateDBDuplicateEntry(
|
raise db_exc.BlazarDBDuplicateEntry(
|
||||||
model=host_extra_capability.__class__.__name__,
|
model=host_extra_capability.__class__.__name__,
|
||||||
columns=e.columns)
|
columns=e.columns)
|
||||||
|
|
||||||
@@ -720,7 +720,7 @@ def host_extra_capability_destroy(host_extra_capability_id):
|
|||||||
|
|
||||||
if not host_extra_capability:
|
if not host_extra_capability:
|
||||||
# raise not found error
|
# raise not found error
|
||||||
raise db_exc.ClimateDBNotFound(
|
raise db_exc.BlazarDBNotFound(
|
||||||
id=host_extra_capability_id,
|
id=host_extra_capability_id,
|
||||||
model='ComputeHostExtraCapability')
|
model='ComputeHostExtraCapability')
|
||||||
|
|
@@ -18,8 +18,8 @@ from sqlalchemy.ext import declarative
|
|||||||
from sqlalchemy.orm import attributes
|
from sqlalchemy.orm import attributes
|
||||||
|
|
||||||
|
|
||||||
class _ClimateBase(models.ModelBase, models.TimestampMixin):
|
class _BlazarBase(models.ModelBase, models.TimestampMixin):
|
||||||
"""Base class for all Climate SQLAlchemy DB Models."""
|
"""Base class for all Blazar SQLAlchemy DB Models."""
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
"""sqlalchemy based automatic to_dict method."""
|
"""sqlalchemy based automatic to_dict method."""
|
||||||
@@ -44,4 +44,4 @@ def datetime_to_str(dct, attr_name):
|
|||||||
if dct.get(attr_name) is not None:
|
if dct.get(attr_name) is not None:
|
||||||
dct[attr_name] = dct[attr_name].isoformat(' ')
|
dct[attr_name] = dct[attr_name].isoformat(' ')
|
||||||
|
|
||||||
ClimateBase = declarative.declarative_base(cls=_ClimateBase)
|
BlazarBase = declarative.declarative_base(cls=_BlazarBase)
|
@@ -21,7 +21,7 @@ import sqlalchemy as sa
|
|||||||
from sqlalchemy.dialects.mysql import MEDIUMTEXT
|
from sqlalchemy.dialects.mysql import MEDIUMTEXT
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from climate.db.sqlalchemy import model_base as mb
|
from blazar.db.sqlalchemy import model_base as mb
|
||||||
# FIXME: https://bugs.launchpad.net/climate/+bug/1300132
|
# FIXME: https://bugs.launchpad.net/climate/+bug/1300132
|
||||||
# LOG = logging.getLogger(__name__)
|
# LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ def _id_column():
|
|||||||
|
|
||||||
# Main objects: Lease, Reservation, Event
|
# Main objects: Lease, Reservation, Event
|
||||||
|
|
||||||
class Lease(mb.ClimateBase):
|
class Lease(mb.BlazarBase):
|
||||||
"""Contains all info about lease."""
|
"""Contains all info about lease."""
|
||||||
|
|
||||||
__tablename__ = 'leases'
|
__tablename__ = 'leases'
|
||||||
@@ -75,7 +75,7 @@ class Lease(mb.ClimateBase):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
class Reservation(mb.ClimateBase):
|
class Reservation(mb.BlazarBase):
|
||||||
"""Specifies group of nodes within a cluster."""
|
"""Specifies group of nodes within a cluster."""
|
||||||
|
|
||||||
__tablename__ = 'reservations'
|
__tablename__ = 'reservations'
|
||||||
@@ -120,7 +120,7 @@ class Reservation(mb.ClimateBase):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
class Event(mb.ClimateBase):
|
class Event(mb.BlazarBase):
|
||||||
"""An events occurring with the lease."""
|
"""An events occurring with the lease."""
|
||||||
|
|
||||||
__tablename__ = 'events'
|
__tablename__ = 'events'
|
||||||
@@ -135,7 +135,7 @@ class Event(mb.ClimateBase):
|
|||||||
return super(Event, self).to_dict()
|
return super(Event, self).to_dict()
|
||||||
|
|
||||||
|
|
||||||
class ComputeHostReservation(mb.ClimateBase):
|
class ComputeHostReservation(mb.BlazarBase):
|
||||||
"""Description
|
"""Description
|
||||||
|
|
||||||
Specifies resources asked by reservation from
|
Specifies resources asked by reservation from
|
||||||
@@ -155,7 +155,7 @@ class ComputeHostReservation(mb.ClimateBase):
|
|||||||
return super(ComputeHostReservation, self).to_dict()
|
return super(ComputeHostReservation, self).to_dict()
|
||||||
|
|
||||||
|
|
||||||
class ComputeHostAllocation(mb.ClimateBase):
|
class ComputeHostAllocation(mb.BlazarBase):
|
||||||
"""Mapping between ComputeHost, ComputeHostReservation and Reservation."""
|
"""Mapping between ComputeHost, ComputeHostReservation and Reservation."""
|
||||||
|
|
||||||
__tablename__ = 'computehost_allocations'
|
__tablename__ = 'computehost_allocations'
|
||||||
@@ -170,7 +170,7 @@ class ComputeHostAllocation(mb.ClimateBase):
|
|||||||
return super(ComputeHostAllocation, self).to_dict()
|
return super(ComputeHostAllocation, self).to_dict()
|
||||||
|
|
||||||
|
|
||||||
class ComputeHost(mb.ClimateBase):
|
class ComputeHost(mb.BlazarBase):
|
||||||
"""Description
|
"""Description
|
||||||
|
|
||||||
Specifies resources asked by reservation from
|
Specifies resources asked by reservation from
|
||||||
@@ -199,7 +199,7 @@ class ComputeHost(mb.ClimateBase):
|
|||||||
return super(ComputeHost, self).to_dict()
|
return super(ComputeHost, self).to_dict()
|
||||||
|
|
||||||
|
|
||||||
class ComputeHostExtraCapability(mb.ClimateBase):
|
class ComputeHostExtraCapability(mb.BlazarBase):
|
||||||
"""Description
|
"""Description
|
||||||
|
|
||||||
Allows to define extra capabilities per administrator request for each
|
Allows to define extra capabilities per administrator request for each
|
@@ -19,8 +19,8 @@ import sys
|
|||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from climate.db.sqlalchemy import facade_wrapper
|
from blazar.db.sqlalchemy import facade_wrapper
|
||||||
from climate.db.sqlalchemy import models
|
from blazar.db.sqlalchemy import models
|
||||||
|
|
||||||
get_session = facade_wrapper.get_session
|
get_session = facade_wrapper.get_session
|
||||||
|
|
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
"""Defines interface for DB access.
|
"""Defines interface for DB access.
|
||||||
|
|
||||||
Functions in this module are imported into the climate.db namespace. Call these
|
Functions in this module are imported into the blazar.db namespace. Call these
|
||||||
functions from climate.db namespace, not the climate.db.api namespace.
|
functions from blazar.db namespace, not the blazar.db.api namespace.
|
||||||
|
|
||||||
All functions in this module return objects that implement a dictionary-like
|
All functions in this module return objects that implement a dictionary-like
|
||||||
interface.
|
interface.
|
||||||
@@ -38,7 +38,7 @@ from oslo_log import log as logging
|
|||||||
|
|
||||||
|
|
||||||
_BACKEND_MAPPING = {
|
_BACKEND_MAPPING = {
|
||||||
'sqlalchemy': 'climate.db.sqlalchemy.utils',
|
'sqlalchemy': 'blazar.db.sqlalchemy.utils',
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPL = db_api.DBAPI(cfg.CONF.database.backend,
|
IMPL = db_api.DBAPI(cfg.CONF.database.backend,
|
@@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ClimateException(Exception):
|
class BlazarException(Exception):
|
||||||
"""Base Climate Exception.
|
"""Base Blazar Exception.
|
||||||
|
|
||||||
To correctly use this class, inherit from it and define
|
To correctly use this class, inherit from it and define
|
||||||
a 'msg_fmt' and 'code' properties.
|
a 'msg_fmt' and 'code' properties.
|
||||||
@@ -49,16 +49,16 @@ class ClimateException(Exception):
|
|||||||
|
|
||||||
message = self.msg_fmt
|
message = self.msg_fmt
|
||||||
|
|
||||||
super(ClimateException, self).__init__(message)
|
super(BlazarException, self).__init__(message)
|
||||||
|
|
||||||
|
|
||||||
class NotFound(ClimateException):
|
class NotFound(BlazarException):
|
||||||
"""Object not found exception."""
|
"""Object not found exception."""
|
||||||
msg_fmt = _("Object with %(object)s not found")
|
msg_fmt = _("Object with %(object)s not found")
|
||||||
code = 404
|
code = 404
|
||||||
|
|
||||||
|
|
||||||
class NotAuthorized(ClimateException):
|
class NotAuthorized(BlazarException):
|
||||||
msg_fmt = _("Not authorized")
|
msg_fmt = _("Not authorized")
|
||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class PolicyNotAuthorized(NotAuthorized):
|
|||||||
msg_fmt = _("Policy doesn't allow %(action)s to be performed")
|
msg_fmt = _("Policy doesn't allow %(action)s to be performed")
|
||||||
|
|
||||||
|
|
||||||
class ConfigNotFound(ClimateException):
|
class ConfigNotFound(BlazarException):
|
||||||
msg_fmt = _("Could not find config at %(path)s")
|
msg_fmt = _("Could not find config at %(path)s")
|
||||||
|
|
||||||
|
|
||||||
@@ -75,22 +75,22 @@ class ServiceCatalogNotFound(NotFound):
|
|||||||
msg_fmt = _("Could not find service catalog")
|
msg_fmt = _("Could not find service catalog")
|
||||||
|
|
||||||
|
|
||||||
class WrongFormat(ClimateException):
|
class WrongFormat(BlazarException):
|
||||||
msg_fmt = _("Unenxpectable object format")
|
msg_fmt = _("Unenxpectable object format")
|
||||||
|
|
||||||
|
|
||||||
class ServiceClient(ClimateException):
|
class ServiceClient(BlazarException):
|
||||||
msg_fmt = _("Service %(service)s have some problems")
|
msg_fmt = _("Service %(service)s have some problems")
|
||||||
|
|
||||||
|
|
||||||
class TaskFailed(ClimateException):
|
class TaskFailed(BlazarException):
|
||||||
msg_fmt = _('Current task failed')
|
msg_fmt = _('Current task failed')
|
||||||
|
|
||||||
|
|
||||||
class Timeout(ClimateException):
|
class Timeout(BlazarException):
|
||||||
msg_fmt = _('Current task failed with timeout')
|
msg_fmt = _('Current task failed with timeout')
|
||||||
|
|
||||||
|
|
||||||
class InvalidInput(ClimateException):
|
class InvalidInput(BlazarException):
|
||||||
code = 400
|
code = 400
|
||||||
msg_fmt = _("Expected a %(cls)s type but received %(value)s.")
|
msg_fmt = _("Expected a %(cls)s type but received %(value)s.")
|
@@ -18,7 +18,7 @@ See http://docs.openstack.org/developer/oslo.i18n/usage.html
|
|||||||
|
|
||||||
import oslo_i18n
|
import oslo_i18n
|
||||||
|
|
||||||
DOMAIN = 'climate'
|
DOMAIN = 'blazar'
|
||||||
|
|
||||||
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
|
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
|
||||||
|
|
@@ -18,13 +18,13 @@ import oslo_messaging as messaging
|
|||||||
|
|
||||||
opts = [
|
opts = [
|
||||||
cfg.StrOpt('rpc_topic',
|
cfg.StrOpt('rpc_topic',
|
||||||
default='climate.manager',
|
default='blazar.manager',
|
||||||
help='The topic Climate uses for climate-manager messages.'),
|
help='The topic Blazar uses for blazar-manager messages.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.register_opts(opts, 'manager')
|
CONF.register_opts(opts, 'manager')
|
||||||
CONF.import_opt('host', 'climate.config')
|
CONF.import_opt('host', 'blazar.config')
|
||||||
RPC_API_VERSION = '1.0'
|
RPC_API_VERSION = '1.0'
|
||||||
|
|
||||||
|
|
@@ -13,8 +13,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
|
|
||||||
|
|
||||||
class NoFreePool(exceptions.NotFound):
|
class NoFreePool(exceptions.NotFound):
|
||||||
@@ -25,23 +25,23 @@ class HostNotInFreePool(exceptions.NotFound):
|
|||||||
msg_fmt = _("Host %(host)s not in freepool '%(freepool_name)s'")
|
msg_fmt = _("Host %(host)s not in freepool '%(freepool_name)s'")
|
||||||
|
|
||||||
|
|
||||||
class CantRemoveHost(exceptions.ClimateException):
|
class CantRemoveHost(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Can't remove host(s) %(host)s from Aggregate %(pool)s")
|
msg_fmt = _("Can't remove host(s) %(host)s from Aggregate %(pool)s")
|
||||||
|
|
||||||
|
|
||||||
class CantAddHost(exceptions.ClimateException):
|
class CantAddHost(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Can't add host(s) %(host)s to Aggregate %(pool)s")
|
msg_fmt = _("Can't add host(s) %(host)s to Aggregate %(pool)s")
|
||||||
|
|
||||||
|
|
||||||
class AggregateHaveHost(exceptions.ClimateException):
|
class AggregateHaveHost(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Can't delete Aggregate '%(name)s', "
|
msg_fmt = _("Can't delete Aggregate '%(name)s', "
|
||||||
"host(s) attached to it : %(hosts)s")
|
"host(s) attached to it : %(hosts)s")
|
||||||
|
|
||||||
|
|
||||||
class AggregateAlreadyHasHost(exceptions.ClimateException):
|
class AggregateAlreadyHasHost(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Aggregate %(pool)s already has host(s) %(host)s ")
|
msg_fmt = _("Aggregate %(pool)s already has host(s) %(host)s ")
|
||||||
|
|
||||||
@@ -58,45 +58,45 @@ class InvalidHost(exceptions.NotAuthorized):
|
|||||||
msg_fmt = _("Invalid values for host %(host)s")
|
msg_fmt = _("Invalid values for host %(host)s")
|
||||||
|
|
||||||
|
|
||||||
class MultipleHostsFound(exceptions.ClimateException):
|
class MultipleHostsFound(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Multiple Hosts found for pattern '%(host)s'")
|
msg_fmt = _("Multiple Hosts found for pattern '%(host)s'")
|
||||||
|
|
||||||
|
|
||||||
class HostHavingServers(exceptions.ClimateException):
|
class HostHavingServers(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Servers [%(servers)s] found for host %(host)s")
|
msg_fmt = _("Servers [%(servers)s] found for host %(host)s")
|
||||||
|
|
||||||
|
|
||||||
class PluginConfigurationError(exceptions.ClimateException):
|
class PluginConfigurationError(exceptions.BlazarException):
|
||||||
msg_fmt = _("Plugin Configuration error : %(error)s")
|
msg_fmt = _("Plugin Configuration error : %(error)s")
|
||||||
|
|
||||||
|
|
||||||
class EventError(exceptions.ClimateException):
|
class EventError(exceptions.BlazarException):
|
||||||
msg_fmt = '%(error)s'
|
msg_fmt = '%(error)s'
|
||||||
|
|
||||||
|
|
||||||
class InvalidDate(exceptions.ClimateException):
|
class InvalidDate(exceptions.BlazarException):
|
||||||
msg_fmt = _(
|
msg_fmt = _(
|
||||||
'%(date)s is an invalid date. Required format: %(date_format)s')
|
'%(date)s is an invalid date. Required format: %(date_format)s')
|
||||||
|
|
||||||
|
|
||||||
class UnsupportedResourceType(exceptions.ClimateException):
|
class UnsupportedResourceType(exceptions.BlazarException):
|
||||||
msg_fmt = _("The %(resource_type)s resource type is not supported")
|
msg_fmt = _("The %(resource_type)s resource type is not supported")
|
||||||
|
|
||||||
|
|
||||||
class LeaseNameAlreadyExists(exceptions.ClimateException):
|
class LeaseNameAlreadyExists(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("The lease with name: %(name)s already exists")
|
msg_fmt = _("The lease with name: %(name)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class MissingTrustId(exceptions.ClimateException):
|
class MissingTrustId(exceptions.BlazarException):
|
||||||
msg_fmt = _("A trust id is required")
|
msg_fmt = _("A trust id is required")
|
||||||
|
|
||||||
|
|
||||||
# oshost plugin related exceptions
|
# oshost plugin related exceptions
|
||||||
|
|
||||||
class CantAddExtraCapability(exceptions.ClimateException):
|
class CantAddExtraCapability(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Can't add extracapabilities %(keys)s to Host %(host)s")
|
msg_fmt = _("Can't add extracapabilities %(keys)s to Host %(host)s")
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ class ServiceNotFound(exceptions.NotFound):
|
|||||||
msg_fmt = _("Service %(service)s not found")
|
msg_fmt = _("Service %(service)s not found")
|
||||||
|
|
||||||
|
|
||||||
class WrongClientVersion(exceptions.ClimateException):
|
class WrongClientVersion(exceptions.BlazarException):
|
||||||
code = 400
|
code = 400
|
||||||
msg_fmt = _("Unfortunately you use wrong client version")
|
msg_fmt = _("Unfortunately you use wrong client version")
|
||||||
|
|
||||||
@@ -121,20 +121,20 @@ class NoManagementUrl(exceptions.NotFound):
|
|||||||
msg_fmt = _("You haven't management url for service")
|
msg_fmt = _("You haven't management url for service")
|
||||||
|
|
||||||
|
|
||||||
class HypervisorNotFound(exceptions.ClimateException):
|
class HypervisorNotFound(exceptions.BlazarException):
|
||||||
msg_fmt = _("Aggregate '%(pool)s' not found!")
|
msg_fmt = _("Aggregate '%(pool)s' not found!")
|
||||||
|
|
||||||
|
|
||||||
class NotEnoughHostsAvailable(exceptions.ClimateException):
|
class NotEnoughHostsAvailable(exceptions.BlazarException):
|
||||||
msg_fmt = _("Not enough hosts available")
|
msg_fmt = _("Not enough hosts available")
|
||||||
|
|
||||||
|
|
||||||
class MalformedRequirements(exceptions.ClimateException):
|
class MalformedRequirements(exceptions.BlazarException):
|
||||||
code = 400
|
code = 400
|
||||||
msg_fmt = _("Malformed requirements %(rqrms)s")
|
msg_fmt = _("Malformed requirements %(rqrms)s")
|
||||||
|
|
||||||
|
|
||||||
class InvalidState(exceptions.ClimateException):
|
class InvalidState(exceptions.BlazarException):
|
||||||
code = 409
|
code = 409
|
||||||
msg_fmt = _("Invalid State %(state)s for %(id)s")
|
msg_fmt = _("Invalid State %(state)s for %(id)s")
|
||||||
|
|
||||||
@@ -143,5 +143,5 @@ class InvalidStateUpdate(InvalidState):
|
|||||||
msg_fmt = _("Unable to update ID %(id)s state with %(action)s:%(status)s")
|
msg_fmt = _("Unable to update ID %(id)s state with %(action)s:%(status)s")
|
||||||
|
|
||||||
|
|
||||||
class ProjectIdNotFound(exceptions.ClimateException):
|
class ProjectIdNotFound(exceptions.BlazarException):
|
||||||
msg_fmt = _("No project_id found in current context")
|
msg_fmt = _("No project_id found in current context")
|
@@ -15,17 +15,17 @@
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from climate import manager
|
from blazar import manager
|
||||||
from climate.utils import service
|
from blazar.utils import service
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.import_opt('rpc_topic', 'climate.manager.service', 'manager')
|
CONF.import_opt('rpc_topic', 'blazar.manager.service', 'manager')
|
||||||
|
|
||||||
|
|
||||||
class ManagerRPCAPI(service.RPCClient):
|
class ManagerRPCAPI(service.RPCClient):
|
||||||
"""Client side for the Manager RPC API.
|
"""Client side for the Manager RPC API.
|
||||||
|
|
||||||
Used from other services to communicate with climate-manager service.
|
Used from other services to communicate with blazar-manager service.
|
||||||
"""
|
"""
|
||||||
BASE_RPC_API_VERSION = '1.0'
|
BASE_RPC_API_VERSION = '1.0'
|
||||||
|
|
@@ -13,14 +13,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate import manager
|
from blazar import manager
|
||||||
from climate.utils import service
|
from blazar.utils import service
|
||||||
|
|
||||||
|
|
||||||
class ManagerRPCAPI(service.RPCClient):
|
class ManagerRPCAPI(service.RPCClient):
|
||||||
"""Client side for the Manager RPC API.
|
"""Client side for the Manager RPC API.
|
||||||
|
|
||||||
Used from other services to communicate with climate-manager service.
|
Used from other services to communicate with blazar-manager service.
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initiate RPC API client with needed topic and RPC version."""
|
"""Initiate RPC API client with needed topic and RPC version."""
|
@@ -21,15 +21,15 @@ from oslo_log import log as logging
|
|||||||
import six
|
import six
|
||||||
from stevedore import enabled
|
from stevedore import enabled
|
||||||
|
|
||||||
from climate.db import api as db_api
|
from blazar.db import api as db_api
|
||||||
from climate.db import exceptions as db_ex
|
from blazar.db import exceptions as db_ex
|
||||||
from climate import exceptions as common_ex
|
from blazar import exceptions as common_ex
|
||||||
from climate.i18n import _
|
from blazar.i18n import _
|
||||||
from climate import manager
|
from blazar import manager
|
||||||
from climate.manager import exceptions
|
from blazar.manager import exceptions
|
||||||
from climate.notification import api as notification_api
|
from blazar.notification import api as notification_api
|
||||||
from climate.utils import service as service_utils
|
from blazar.utils import service as service_utils
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
manager_opts = [
|
manager_opts = [
|
||||||
cfg.ListOpt('plugins',
|
cfg.ListOpt('plugins',
|
||||||
@@ -52,9 +52,9 @@ LEASE_DATE_FORMAT = "%Y-%m-%d %H:%M"
|
|||||||
|
|
||||||
|
|
||||||
class ManagerService(service_utils.RPCServer):
|
class ManagerService(service_utils.RPCServer):
|
||||||
"""Service class for the climate-manager service.
|
"""Service class for the blazar-manager service.
|
||||||
|
|
||||||
Responsible for working with Climate DB, scheduling logic, running events,
|
Responsible for working with Blazar DB, scheduling logic, running events,
|
||||||
working with plugins, etc.
|
working with plugins, etc.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
|
|
||||||
extension_manager = enabled.EnabledExtensionManager(
|
extension_manager = enabled.EnabledExtensionManager(
|
||||||
check_func=lambda ext: ext.name in config_plugins,
|
check_func=lambda ext: ext.name in config_plugins,
|
||||||
namespace='climate.resource.plugins',
|
namespace='blazar.resource.plugins',
|
||||||
invoke_on_load=False
|
invoke_on_load=False
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
def _event(self):
|
def _event(self):
|
||||||
"""Tries to commit event.
|
"""Tries to commit event.
|
||||||
|
|
||||||
If there is an event in Climate DB to be done, do it and change its
|
If there is an event in Blazar DB to be done, do it and change its
|
||||||
status to 'DONE'.
|
status to 'DONE'.
|
||||||
"""
|
"""
|
||||||
LOG.debug('Trying to get event from DB.')
|
LOG.debug('Trying to get event from DB.')
|
||||||
@@ -224,7 +224,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
before_end_date)
|
before_end_date)
|
||||||
self._check_date_within_lease_limits(before_end_date,
|
self._check_date_within_lease_limits(before_end_date,
|
||||||
lease_values)
|
lease_values)
|
||||||
except common_ex.ClimateException as e:
|
except common_ex.BlazarException as e:
|
||||||
LOG.error("Invalid before_end_date param. %s" % e.message)
|
LOG.error("Invalid before_end_date param. %s" % e.message)
|
||||||
raise e
|
raise e
|
||||||
elif CONF.manager.notify_hours_before_lease_end > 0:
|
elif CONF.manager.notify_hours_before_lease_end > 0:
|
||||||
@@ -244,11 +244,11 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
lease_values.update({'trust_id': trust_id})
|
lease_values.update({'trust_id': trust_id})
|
||||||
lease = db_api.lease_create(lease_values)
|
lease = db_api.lease_create(lease_values)
|
||||||
lease_id = lease['id']
|
lease_id = lease['id']
|
||||||
except db_ex.ClimateDBDuplicateEntry:
|
except db_ex.BlazarDBDuplicateEntry:
|
||||||
LOG.exception('Cannot create a lease - duplicated lease name')
|
LOG.exception('Cannot create a lease - duplicated lease name')
|
||||||
raise exceptions.LeaseNameAlreadyExists(
|
raise exceptions.LeaseNameAlreadyExists(
|
||||||
name=lease_values['name'])
|
name=lease_values['name'])
|
||||||
except db_ex.ClimateDBException:
|
except db_ex.BlazarDBException:
|
||||||
LOG.exception('Cannot create a lease')
|
LOG.exception('Cannot create a lease')
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@@ -265,7 +265,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
raise exceptions.UnsupportedResourceType(
|
raise exceptions.UnsupportedResourceType(
|
||||||
resource_type)
|
resource_type)
|
||||||
except (exceptions.UnsupportedResourceType,
|
except (exceptions.UnsupportedResourceType,
|
||||||
common_ex.ClimateException):
|
common_ex.BlazarException):
|
||||||
LOG.exception("Failed to create reservation for a lease. "
|
LOG.exception("Failed to create reservation for a lease. "
|
||||||
"Rollback the lease and associated "
|
"Rollback the lease and associated "
|
||||||
"reservations")
|
"reservations")
|
||||||
@@ -334,7 +334,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
before_end_date = self._date_from_string(before_end_date)
|
before_end_date = self._date_from_string(before_end_date)
|
||||||
self._check_date_within_lease_limits(before_end_date,
|
self._check_date_within_lease_limits(before_end_date,
|
||||||
values)
|
values)
|
||||||
except common_ex.ClimateException as e:
|
except common_ex.BlazarException as e:
|
||||||
LOG.error("Invalid before_end_date param. %s" % e.message)
|
LOG.error("Invalid before_end_date param. %s" % e.message)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
if not event:
|
if not event:
|
||||||
raise common_ex.ClimateException(
|
raise common_ex.BlazarException(
|
||||||
'Start lease event not found')
|
'Start lease event not found')
|
||||||
db_api.event_update(event['id'], {'time': values['start_date']})
|
db_api.event_update(event['id'], {'time': values['start_date']})
|
||||||
|
|
||||||
@@ -370,7 +370,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
if not event:
|
if not event:
|
||||||
raise common_ex.ClimateException(
|
raise common_ex.BlazarException(
|
||||||
'End lease event not found')
|
'End lease event not found')
|
||||||
db_api.event_update(event['id'], {'time': values['end_date']})
|
db_api.event_update(event['id'], {'time': values['end_date']})
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
plugin = self.plugins[reservation['resource_type']]
|
plugin = self.plugins[reservation['resource_type']]
|
||||||
try:
|
try:
|
||||||
plugin.on_end(reservation['resource_id'])
|
plugin.on_end(reservation['resource_id'])
|
||||||
except (db_ex.ClimateDBException, RuntimeError):
|
except (db_ex.BlazarDBException, RuntimeError):
|
||||||
LOG.exception("Failed to delete a reservation "
|
LOG.exception("Failed to delete a reservation "
|
||||||
"for a lease.")
|
"for a lease.")
|
||||||
raise
|
raise
|
||||||
@@ -430,7 +430,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
self.resource_actions[resource_type][action_time](
|
self.resource_actions[resource_type][action_time](
|
||||||
reservation['resource_id']
|
reservation['resource_id']
|
||||||
)
|
)
|
||||||
except common_ex.ClimateException:
|
except common_ex.BlazarException:
|
||||||
LOG.exception("Failed to execute action %(action)s "
|
LOG.exception("Failed to execute action %(action)s "
|
||||||
"for lease %(lease)s"
|
"for lease %(lease)s"
|
||||||
% {
|
% {
|
@@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from climate.notification import notifier
|
from blazar.notification import notifier
|
||||||
|
|
||||||
IMPL = notifier.Notifier()
|
IMPL = notifier.Notifier()
|
||||||
|
|
@@ -20,7 +20,7 @@ import oslo_messaging as messaging
|
|||||||
|
|
||||||
notification_opts = [
|
notification_opts = [
|
||||||
cfg.StrOpt('publisher_id',
|
cfg.StrOpt('publisher_id',
|
||||||
default="climate.lease",
|
default="blazar.lease",
|
||||||
help='Publisher ID for notifications')
|
help='Publisher ID for notifications')
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ def get_notifier(publisher_id):
|
|||||||
|
|
||||||
|
|
||||||
class Notifier(object):
|
class Notifier(object):
|
||||||
"""Notification class for climate
|
"""Notification class for blazar
|
||||||
|
|
||||||
Responsible for sending lease events notifications using oslo.nofity
|
Responsible for sending lease events notifications using oslo.nofity
|
||||||
"""
|
"""
|
56
blazar/opts.py
Normal file
56
blazar/opts.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
# implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
import blazar.api.v2.app
|
||||||
|
import blazar.api.v2.controllers
|
||||||
|
import blazar.cmd.api
|
||||||
|
import blazar.config
|
||||||
|
import blazar.db.base
|
||||||
|
import blazar.db.migration.cli
|
||||||
|
import blazar.manager
|
||||||
|
import blazar.manager.service
|
||||||
|
import blazar.notification.notifier
|
||||||
|
import blazar.plugins.instances.vm_plugin
|
||||||
|
import blazar.plugins.oshosts.host_plugin
|
||||||
|
import blazar.plugins.oshosts.reservation_pool
|
||||||
|
import blazar.utils.openstack.keystone
|
||||||
|
import blazar.utils.openstack.nova
|
||||||
|
|
||||||
|
|
||||||
|
def list_opts():
|
||||||
|
return [
|
||||||
|
('DEFAULT',
|
||||||
|
itertools.chain(
|
||||||
|
blazar.api.v2.app.auth_opts,
|
||||||
|
blazar.cmd.api.api_opts,
|
||||||
|
blazar.cmd.api.opts,
|
||||||
|
blazar.config.cli_opts,
|
||||||
|
blazar.config.os_opts,
|
||||||
|
blazar.db.base.db_driver_opts,
|
||||||
|
blazar.db.migration.cli.command_opts,
|
||||||
|
blazar.utils.openstack.keystone.opts,
|
||||||
|
blazar.utils.openstack.keystone.keystone_opts,
|
||||||
|
blazar.utils.openstack.nova.nova_opts)),
|
||||||
|
('api', blazar.api.v2.controllers.api_opts),
|
||||||
|
('manager', itertools.chain(blazar.manager.opts,
|
||||||
|
blazar.manager.service.manager_opts)),
|
||||||
|
('notifications', blazar.notification.notifier.notification_opts),
|
||||||
|
(blazar.plugins.instances.RESOURCE_TYPE,
|
||||||
|
blazar.plugins.instances.vm_plugin.plugin_opts),
|
||||||
|
(blazar.plugins.oshosts.RESOURCE_TYPE, itertools.chain(
|
||||||
|
blazar.plugins.oshosts.host_plugin.plugin_opts,
|
||||||
|
blazar.plugins.oshosts.reservation_pool.OPTS)),
|
||||||
|
|
||||||
|
]
|
@@ -19,7 +19,7 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from climate.db import api as db_api
|
from blazar.db import api as db_api
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
@@ -13,7 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.plugins import base
|
from blazar.plugins import base
|
||||||
|
|
||||||
|
|
||||||
class DummyVMPlugin(base.BasePlugin):
|
class DummyVMPlugin(base.BasePlugin):
|
@@ -18,10 +18,10 @@ from novaclient import exceptions as nova_exceptions
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from climate import exceptions as climate_exceptions
|
from blazar import exceptions as blazar_exceptions
|
||||||
from climate.plugins import base
|
from blazar.plugins import base
|
||||||
from climate.plugins import instances as plugin
|
from blazar.plugins import instances as plugin
|
||||||
from climate.utils.openstack import nova
|
from blazar.utils.openstack import nova
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class VMPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||||||
# creating snapshot or suspending already deleted instance
|
# creating snapshot or suspending already deleted instance
|
||||||
|
|
||||||
if 'create_image' in actions:
|
if 'create_image' in actions:
|
||||||
with eventlet.timeout.Timeout(600, climate_exceptions.Timeout):
|
with eventlet.timeout.Timeout(600, blazar_exceptions.Timeout):
|
||||||
try:
|
try:
|
||||||
self.nova.servers.create_image(resource_id)
|
self.nova.servers.create_image(resource_id)
|
||||||
eventlet.sleep(5)
|
eventlet.sleep(5)
|
||||||
@@ -71,7 +71,7 @@ class VMPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||||||
except nova_exceptions.NotFound:
|
except nova_exceptions.NotFound:
|
||||||
LOG.error('Instance %s has been already deleted. '
|
LOG.error('Instance %s has been already deleted. '
|
||||||
'Cannot create image.' % resource_id)
|
'Cannot create image.' % resource_id)
|
||||||
except climate_exceptions.Timeout:
|
except blazar_exceptions.Timeout:
|
||||||
LOG.error('Image create failed with timeout. Take a look '
|
LOG.error('Image create failed with timeout. Take a look '
|
||||||
'at nova.')
|
'at nova.')
|
||||||
except nova_exceptions.Conflict as e:
|
except nova_exceptions.Conflict as e:
|
||||||
@@ -105,10 +105,10 @@ class VMPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||||||
else:
|
else:
|
||||||
LOG.error('Nova reported unexpected task status %s for '
|
LOG.error('Nova reported unexpected task status %s for '
|
||||||
'instance %s' % (task_state, resource_id))
|
'instance %s' % (task_state, resource_id))
|
||||||
raise climate_exceptions.TaskFailed()
|
raise blazar_exceptions.TaskFailed()
|
||||||
|
|
||||||
def _split_actions(self, actions):
|
def _split_actions(self, actions):
|
||||||
try:
|
try:
|
||||||
return actions.replace(' ', '').split(',')
|
return actions.replace(' ', '').split(',')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise climate_exceptions.WrongFormat()
|
raise blazar_exceptions.WrongFormat()
|
@@ -21,16 +21,16 @@ import uuid
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from climate.db import api as db_api
|
from blazar.db import api as db_api
|
||||||
from climate.db import exceptions as db_ex
|
from blazar.db import exceptions as db_ex
|
||||||
from climate.db import utils as db_utils
|
from blazar.db import utils as db_utils
|
||||||
from climate.manager import exceptions as manager_ex
|
from blazar.manager import exceptions as manager_ex
|
||||||
from climate.plugins import base
|
from blazar.plugins import base
|
||||||
from climate.plugins import oshosts as plugin
|
from blazar.plugins import oshosts as plugin
|
||||||
from climate.plugins.oshosts import nova_inventory
|
from blazar.plugins.oshosts import nova_inventory
|
||||||
from climate.plugins.oshosts import reservation_pool as rp
|
from blazar.plugins.oshosts import reservation_pool as rp
|
||||||
from climate.utils.openstack import nova
|
from blazar.utils.openstack import nova
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
plugin_opts = [
|
plugin_opts = [
|
||||||
cfg.StrOpt('on_end',
|
cfg.StrOpt('on_end',
|
||||||
@@ -255,7 +255,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||||||
if trust_id:
|
if trust_id:
|
||||||
host_details.update({'trust_id': trust_id})
|
host_details.update({'trust_id': trust_id})
|
||||||
host = db_api.host_create(host_details)
|
host = db_api.host_create(host_details)
|
||||||
except db_ex.ClimateDBException:
|
except db_ex.BlazarDBException:
|
||||||
# We need to rollback
|
# We need to rollback
|
||||||
# TODO(sbauza): Investigate use of Taskflow for atomic
|
# TODO(sbauza): Investigate use of Taskflow for atomic
|
||||||
# transactions
|
# transactions
|
||||||
@@ -269,7 +269,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
db_api.host_extra_capability_create(values)
|
db_api.host_extra_capability_create(values)
|
||||||
except db_ex.ClimateDBException:
|
except db_ex.BlazarDBException:
|
||||||
cantaddextracapability.append(key)
|
cantaddextracapability.append(key)
|
||||||
if cantaddextracapability:
|
if cantaddextracapability:
|
||||||
raise manager_ex.CantAddExtraCapability(
|
raise manager_ex.CantAddExtraCapability(
|
||||||
@@ -329,7 +329,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||||||
# NOTE(sbauza): Extracapabilities will be destroyed thanks to
|
# NOTE(sbauza): Extracapabilities will be destroyed thanks to
|
||||||
# the DB FK.
|
# the DB FK.
|
||||||
db_api.host_destroy(host_id)
|
db_api.host_destroy(host_id)
|
||||||
except db_ex.ClimateDBException:
|
except db_ex.BlazarDBException:
|
||||||
# Nothing so bad, but we need to advert the admin
|
# Nothing so bad, but we need to advert the admin
|
||||||
# he has to rerun
|
# he has to rerun
|
||||||
raise manager_ex.CantRemoveHost(host=host_id,
|
raise manager_ex.CantRemoveHost(host=host_id,
|
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
from novaclient import exceptions as nova_exceptions
|
from novaclient import exceptions as nova_exceptions
|
||||||
|
|
||||||
from climate.manager import exceptions as manager_exceptions
|
from blazar.manager import exceptions as manager_exceptions
|
||||||
from climate.utils.openstack import nova
|
from blazar.utils.openstack import nova
|
||||||
|
|
||||||
|
|
||||||
class NovaInventory(nova.NovaClientWrapper):
|
class NovaInventory(nova.NovaClientWrapper):
|
@@ -20,10 +20,10 @@ from novaclient import exceptions as nova_exceptions
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from climate import context
|
from blazar import context
|
||||||
from climate.manager import exceptions as manager_exceptions
|
from blazar.manager import exceptions as manager_exceptions
|
||||||
from climate.plugins import oshosts as plugin
|
from blazar.plugins import oshosts as plugin
|
||||||
from climate.utils.openstack import nova
|
from blazar.utils.openstack import nova
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -34,14 +34,16 @@ OPTS = [
|
|||||||
help='Name of the special aggregate where all hosts '
|
help='Name of the special aggregate where all hosts '
|
||||||
'are candidate for physical host reservation'),
|
'are candidate for physical host reservation'),
|
||||||
cfg.StrOpt('project_id_key',
|
cfg.StrOpt('project_id_key',
|
||||||
default='climate:project',
|
default='blazar:project',
|
||||||
help='Aggregate metadata value for key matching project_id'),
|
help='Aggregate metadata value for key matching project_id'),
|
||||||
cfg.StrOpt('climate_owner',
|
cfg.StrOpt('blazar_owner',
|
||||||
default='climate:owner',
|
default='blazar:owner',
|
||||||
|
deprecated_name='climate_owner',
|
||||||
help='Aggregate metadata key for knowing owner project_id'),
|
help='Aggregate metadata key for knowing owner project_id'),
|
||||||
cfg.StrOpt('climate_az_prefix',
|
cfg.StrOpt('blazar_az_prefix',
|
||||||
default='climate:',
|
default='blazar:',
|
||||||
help='Prefix for Availability Zones created by Climate'),
|
deprecated_name='climate_az_prefix',
|
||||||
|
help='Prefix for Availability Zones created by Blazar'),
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@@ -98,7 +100,7 @@ class ReservationPool(nova.NovaClientWrapper):
|
|||||||
name = name or self._generate_aggregate_name()
|
name = name or self._generate_aggregate_name()
|
||||||
|
|
||||||
if az:
|
if az:
|
||||||
az_name = "%s%s" % (self.config.climate_az_prefix,
|
az_name = "%s%s" % (self.config.blazar_az_prefix,
|
||||||
name)
|
name)
|
||||||
LOG.debug('Creating pool aggregate: %s '
|
LOG.debug('Creating pool aggregate: %s '
|
||||||
'with Availability Zone %s' % (name, az_name))
|
'with Availability Zone %s' % (name, az_name))
|
||||||
@@ -117,7 +119,7 @@ class ReservationPool(nova.NovaClientWrapper):
|
|||||||
LOG.error(e.message)
|
LOG.error(e.message)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
meta = {self.config.climate_owner: project_id}
|
meta = {self.config.blazar_owner: project_id}
|
||||||
self.nova.aggregates.set_metadata(agg, meta)
|
self.nova.aggregates.set_metadata(agg, meta)
|
||||||
|
|
||||||
return agg
|
return agg
|
@@ -13,7 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Policy Engine For Climate."""
|
"""Policy Engine For Blazar."""
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
@@ -22,8 +22,8 @@ from oslo_log import log as logging
|
|||||||
from oslo_policy import opts
|
from oslo_policy import opts
|
||||||
from oslo_policy import policy
|
from oslo_policy import policy
|
||||||
|
|
||||||
from climate import context
|
from blazar import context
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
opts.set_defaults(CONF)
|
opts.set_defaults(CONF)
|
||||||
@@ -60,7 +60,7 @@ def set_rules(data, default_rule=None):
|
|||||||
def enforce(context, action, target, do_raise=True):
|
def enforce(context, action, target, do_raise=True):
|
||||||
"""Verifies that the action is valid on the target in this context.
|
"""Verifies that the action is valid on the target in this context.
|
||||||
|
|
||||||
:param context: climate context
|
:param context: blazar context
|
||||||
:param action: string representing the action to be checked
|
:param action: string representing the action to be checked
|
||||||
this should be colon separated for clarity.
|
this should be colon separated for clarity.
|
||||||
i.e. ``compute:create_instance``,
|
i.e. ``compute:create_instance``,
|
||||||
@@ -72,7 +72,7 @@ def enforce(context, action, target, do_raise=True):
|
|||||||
:param do_raise: if True (the default), raises PolicyNotAuthorized;
|
:param do_raise: if True (the default), raises PolicyNotAuthorized;
|
||||||
if False, returns False
|
if False, returns False
|
||||||
|
|
||||||
:raises climate.exceptions.PolicyNotAuthorized: if verification fails
|
:raises blazar.exceptions.PolicyNotAuthorized: if verification fails
|
||||||
and do_raise is True.
|
and do_raise is True.
|
||||||
|
|
||||||
:return: returns a non-False value (not necessarily "True") if
|
:return: returns a non-False value (not necessarily "True") if
|
||||||
@@ -93,7 +93,7 @@ def enforce(context, action, target, do_raise=True):
|
|||||||
**extra)
|
**extra)
|
||||||
|
|
||||||
|
|
||||||
def authorize(extension, action=None, api='climate', ctx=None,
|
def authorize(extension, action=None, api='blazar', ctx=None,
|
||||||
target=None):
|
target=None):
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
|
|
@@ -13,16 +13,16 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Actions and states for Climate objects."""
|
"""Actions and states for Blazar objects."""
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from climate.db import api as db_api
|
from blazar.db import api as db_api
|
||||||
from climate.db import exceptions as db_exc
|
from blazar.db import exceptions as db_exc
|
||||||
from climate.manager import exceptions as mgr_exc
|
from blazar.manager import exceptions as mgr_exc
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ class LeaseState(ObjectState):
|
|||||||
def save(self):
|
def save(self):
|
||||||
try:
|
try:
|
||||||
db_api.lease_update(self.id, self.current())
|
db_api.lease_update(self.id, self.current())
|
||||||
except db_exc.ClimateDBException:
|
except db_exc.BlazarDBException:
|
||||||
# Lease can be not yet in DB, we must first write it
|
# Lease can be not yet in DB, we must first write it
|
||||||
raise mgr_exc.InvalidState(id=self.id, state=self.current())
|
raise mgr_exc.InvalidState(id=self.id, state=self.current())
|
||||||
return self.current()
|
return self.current()
|
@@ -24,15 +24,15 @@ from oslo_log import log as logging
|
|||||||
from oslotest import base
|
from oslotest import base
|
||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
|
|
||||||
from climate import context
|
from blazar import context
|
||||||
from climate.db.sqlalchemy import api as db_api
|
from blazar.db.sqlalchemy import api as db_api
|
||||||
from climate.db.sqlalchemy import facade_wrapper
|
from blazar.db.sqlalchemy import facade_wrapper
|
||||||
from climate import policy
|
from blazar import policy
|
||||||
from climate.tests import fake_policy
|
from blazar.tests import fake_policy
|
||||||
|
|
||||||
cfg.CONF.set_override('use_stderr', False)
|
cfg.CONF.set_override('use_stderr', False)
|
||||||
|
|
||||||
logging.setup(cfg.CONF, 'climate')
|
logging.setup(cfg.CONF, 'blazar')
|
||||||
_DB_CACHE = None
|
_DB_CACHE = None
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ class TestCase(testscenarios.WithScenarios, base.BaseTestCase):
|
|||||||
"""Run before each test method to initialize test environment."""
|
"""Run before each test method to initialize test environment."""
|
||||||
super(TestCase, self).setUp()
|
super(TestCase, self).setUp()
|
||||||
self.context_mock = None
|
self.context_mock = None
|
||||||
cfg.CONF(args=[], project='climate')
|
cfg.CONF(args=[], project='blazar')
|
||||||
self.policy = self.useFixture(PolicyFixture())
|
self.policy = self.useFixture(PolicyFixture())
|
||||||
|
|
||||||
def patch(self, obj, attr):
|
def patch(self, obj, attr):
|
||||||
@@ -90,7 +90,7 @@ class TestCase(testscenarios.WithScenarios, base.BaseTestCase):
|
|||||||
|
|
||||||
def set_context(self, ctx):
|
def set_context(self, ctx):
|
||||||
if self.context_mock is None:
|
if self.context_mock is None:
|
||||||
self.context_mock = self.patch(context.ClimateContext, 'current')
|
self.context_mock = self.patch(context.BlazarContext, 'current')
|
||||||
self.context_mock.return_value = ctx
|
self.context_mock.return_value = ctx
|
||||||
|
|
||||||
|
|
@@ -22,11 +22,11 @@ import pecan.testing
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
from climate.api import context as api_context
|
from blazar.api import context as api_context
|
||||||
from climate import context
|
from blazar import context
|
||||||
from climate.manager.oshosts import rpcapi as hosts_rpcapi
|
from blazar.manager.oshosts import rpcapi as hosts_rpcapi
|
||||||
from climate.manager import rpcapi
|
from blazar.manager import rpcapi
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
PATH_PREFIX = '/v2'
|
PATH_PREFIX = '/v2'
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ class APITest(tests.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
def fake_ctx_from_headers(headers):
|
def fake_ctx_from_headers(headers):
|
||||||
if not headers:
|
if not headers:
|
||||||
return context.ClimateContext(
|
return context.BlazarContext(
|
||||||
user_id='fake', project_id='fake', roles=['member'])
|
user_id='fake', project_id='fake', roles=['member'])
|
||||||
roles = headers.get('X-Roles', six.text_type('member')).split(',')
|
roles = headers.get('X-Roles', six.text_type('member')).split(',')
|
||||||
return context.ClimateContext(
|
return context.BlazarContext(
|
||||||
user_id=headers.get('X-User-Id', 'fake'),
|
user_id=headers.get('X-User-Id', 'fake'),
|
||||||
project_id=headers.get('X-Project-Id', 'fake'),
|
project_id=headers.get('X-Project-Id', 'fake'),
|
||||||
auth_token=headers.get('X-Auth-Token', None),
|
auth_token=headers.get('X-Auth-Token', None),
|
||||||
@@ -100,8 +100,8 @@ class APITest(tests.TestCase):
|
|||||||
|
|
||||||
self.config = {
|
self.config = {
|
||||||
'app': {
|
'app': {
|
||||||
'modules': ['climate.api.v2'],
|
'modules': ['blazar.api.v2'],
|
||||||
'root': 'climate.api.root.RootController',
|
'root': 'blazar.api.root.RootController',
|
||||||
'enable_acl': enable_acl,
|
'enable_acl': enable_acl,
|
||||||
},
|
},
|
||||||
}
|
}
|
@@ -16,8 +16,8 @@
|
|||||||
Tests for ACL. Checks whether certain kinds of requests
|
Tests for ACL. Checks whether certain kinds of requests
|
||||||
are blocked or allowed to be processed.
|
are blocked or allowed to be processed.
|
||||||
"""
|
"""
|
||||||
from climate import policy
|
from blazar import policy
|
||||||
from climate.tests import api
|
from blazar.tests import api
|
||||||
|
|
||||||
|
|
||||||
class TestACL(api.APITest):
|
class TestACL(api.APITest):
|
@@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from climate.api import context as api_context
|
from blazar.api import context as api_context
|
||||||
from climate import context
|
from blazar import context
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class ContextTestCase(tests.TestCase):
|
class ContextTestCase(tests.TestCase):
|
||||||
@@ -33,7 +33,7 @@ class ContextTestCase(tests.TestCase):
|
|||||||
u'X-Roles': u'user_name0, user_name1'}
|
u'X-Roles': u'user_name0, user_name1'}
|
||||||
|
|
||||||
def test_ctx_from_headers(self):
|
def test_ctx_from_headers(self):
|
||||||
self.context = self.patch(context, 'ClimateContext')
|
self.context = self.patch(context, 'BlazarContext')
|
||||||
catalog = json.dumps({'nova': 'catalog'})
|
catalog = json.dumps({'nova': 'catalog'})
|
||||||
self.fake_headers[u'X-Service-Catalog'] = catalog
|
self.fake_headers[u'X-Service-Catalog'] = catalog
|
||||||
api_context.ctx_from_headers(self.fake_headers)
|
api_context.ctx_from_headers(self.fake_headers)
|
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from climate.tests import api
|
from blazar.tests import api
|
||||||
|
|
||||||
|
|
||||||
class TestRoot(api.APITest):
|
class TestRoot(api.APITest):
|
@@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from climate.api.v1 import app as v1_app
|
from blazar.api.v1 import app as v1_app
|
||||||
from climate.api.v2 import app as v2_app
|
from blazar.api.v2 import app as v2_app
|
||||||
from climate.cmd import api
|
from blazar.cmd import api
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class FakeWSGIApp(object):
|
class FakeWSGIApp(object):
|
@@ -13,8 +13,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.api.v1.oshosts import service as service_api
|
from blazar.api.v1.oshosts import service as service_api
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class RPCApiTestCase(tests.TestCase):
|
class RPCApiTestCase(tests.TestCase):
|
@@ -13,10 +13,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.api.v1.oshosts import service as service_api
|
from blazar.api.v1.oshosts import service as service_api
|
||||||
from climate.api.v1.oshosts import v1_0 as api
|
from blazar.api.v1.oshosts import v1_0 as api
|
||||||
from climate.api.v1 import utils as utils_api
|
from blazar.api.v1 import utils as utils_api
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class RESTApiTestCase(tests.TestCase):
|
class RESTApiTestCase(tests.TestCase):
|
@@ -18,10 +18,10 @@ from keystonemiddleware import auth_token
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from werkzeug import exceptions as werkzeug_exceptions
|
from werkzeug import exceptions as werkzeug_exceptions
|
||||||
|
|
||||||
from climate.api.v1 import app
|
from blazar.api.v1 import app
|
||||||
from climate.api.v1.oshosts import v1_0 as host_api_v1_0
|
from blazar.api.v1.oshosts import v1_0 as host_api_v1_0
|
||||||
from climate.api.v1 import utils as api_utils
|
from blazar.api.v1 import utils as api_utils
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class AppTestCase(tests.TestCase):
|
class AppTestCase(tests.TestCase):
|
||||||
@@ -76,7 +76,7 @@ class AppTestCase(tests.TestCase):
|
|||||||
auth_port='35357',
|
auth_port='35357',
|
||||||
auth_protocol='http',
|
auth_protocol='http',
|
||||||
auth_version='v2.0',
|
auth_version='v2.0',
|
||||||
admin_password='climate',
|
admin_password='blazar',
|
||||||
auth_host='127.0.0.1')
|
auth_host='127.0.0.1')
|
||||||
|
|
||||||
|
|
@@ -13,8 +13,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.api.v1 import service as service_api
|
from blazar.api.v1 import service as service_api
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class RPCApiTestCase(tests.TestCase):
|
class RPCApiTestCase(tests.TestCase):
|
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import flask
|
import flask
|
||||||
|
|
||||||
from climate.api.v1 import utils
|
from blazar.api.v1 import utils
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class Error:
|
class Error:
|
@@ -13,10 +13,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.api.v1 import service as service_api
|
from blazar.api.v1 import service as service_api
|
||||||
from climate.api.v1 import utils as utils_api
|
from blazar.api.v1 import utils as utils_api
|
||||||
from climate.api.v1 import v1_0 as api
|
from blazar.api.v1 import v1_0 as api
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class RESTApiTestCase(tests.TestCase):
|
class RESTApiTestCase(tests.TestCase):
|
@@ -13,11 +13,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from climate.api.v1 import service as service_api
|
from blazar.api.v1 import service as service_api
|
||||||
from climate.api.v1 import utils as api_utils
|
from blazar.api.v1 import utils as api_utils
|
||||||
from climate.api.v1 import validation as validation_api
|
from blazar.api.v1 import validation as validation_api
|
||||||
from climate import exceptions
|
from blazar import exceptions
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
|
|
||||||
class ValidationTestCase(tests.TestCase):
|
class ValidationTestCase(tests.TestCase):
|
@@ -20,8 +20,8 @@ import uuid
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
from climate.tests import api
|
from blazar.tests import api
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
|
|
||||||
def fake_computehost(**kw):
|
def fake_computehost(**kw):
|
@@ -20,8 +20,8 @@ import uuid
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
from climate.tests import api
|
from blazar.tests import api
|
||||||
from climate.utils import trusts
|
from blazar.utils import trusts
|
||||||
|
|
||||||
|
|
||||||
def fake_lease(**kw):
|
def fake_lease(**kw):
|
@@ -37,13 +37,13 @@ from oslo_log import log as logging
|
|||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
|
|
||||||
import climate.db.migration
|
import blazar.db.migration
|
||||||
from climate import tests
|
from blazar import tests
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
synchronized = lockutils.synchronized_with_prefix('climate-')
|
synchronized = lockutils.synchronized_with_prefix('blazar-')
|
||||||
|
|
||||||
|
|
||||||
def _get_connect_string(backend, user, passwd, database):
|
def _get_connect_string(backend, user, passwd, database):
|
||||||
@@ -78,14 +78,14 @@ def _is_backend_avail(backend, user, passwd, database):
|
|||||||
|
|
||||||
|
|
||||||
def _have_mysql(user, passwd, database):
|
def _have_mysql(user, passwd, database):
|
||||||
present = os.environ.get('CLIMATE_MYSQL_PRESENT')
|
present = os.environ.get('BLAZAR_MYSQL_PRESENT')
|
||||||
if present is None:
|
if present is None:
|
||||||
return _is_backend_avail('mysql', user, passwd, database)
|
return _is_backend_avail('mysql', user, passwd, database)
|
||||||
return present.lower() in ('', 'true')
|
return present.lower() in ('', 'true')
|
||||||
|
|
||||||
|
|
||||||
def _have_postgresql(user, passwd, database):
|
def _have_postgresql(user, passwd, database):
|
||||||
present = os.environ.get('CLIMATE_TEST_POSTGRESQL_PRESENT')
|
present = os.environ.get('BLAZAR_TEST_POSTGRESQL_PRESENT')
|
||||||
if present is None:
|
if present is None:
|
||||||
return _is_backend_avail('postgres', user, passwd, database)
|
return _is_backend_avail('postgres', user, passwd, database)
|
||||||
return present.lower() in ('', 'true')
|
return present.lower() in ('', 'true')
|
||||||
@@ -187,18 +187,18 @@ class BaseMigrationTestCase(tests.TestCase):
|
|||||||
self.DEFAULT_CONFIG_FILE = os.path.join(
|
self.DEFAULT_CONFIG_FILE = os.path.join(
|
||||||
os.path.dirname(__file__),
|
os.path.dirname(__file__),
|
||||||
'test_migrations.conf')
|
'test_migrations.conf')
|
||||||
# Test machines can set the CLIMATE_TEST_MIGRATIONS_CONF variable
|
# Test machines can set the BLAZAR_TEST_MIGRATIONS_CONF variable
|
||||||
# to override the location of the config file for migration testing
|
# to override the location of the config file for migration testing
|
||||||
self.CONFIG_FILE_PATH = os.environ.get(
|
self.CONFIG_FILE_PATH = os.environ.get(
|
||||||
'CLIMATE_TEST_MIGRATIONS_CONF',
|
'BLAZAR_TEST_MIGRATIONS_CONF',
|
||||||
self.DEFAULT_CONFIG_FILE)
|
self.DEFAULT_CONFIG_FILE)
|
||||||
|
|
||||||
self.ALEMBIC_CONFIG = alembic_config.Config(
|
self.ALEMBIC_CONFIG = alembic_config.Config(
|
||||||
os.path.join(os.path.dirname(climate.db.migration.__file__),
|
os.path.join(os.path.dirname(blazar.db.migration.__file__),
|
||||||
'alembic.ini')
|
'alembic.ini')
|
||||||
)
|
)
|
||||||
|
|
||||||
self.ALEMBIC_CONFIG.climate_config = CONF
|
self.ALEMBIC_CONFIG.blazar_config = CONF
|
||||||
|
|
||||||
self.snake_walk = False
|
self.snake_walk = False
|
||||||
self.downgrade = False
|
self.downgrade = False
|
@@ -40,7 +40,7 @@ postgres=# create database openstack_citest with owner openstack_citest;
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from climate.tests.db import migration
|
from blazar.tests.db import migration
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user