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:
parent
1e120b67f0
commit
68d769bf71
@ -3,7 +3,7 @@ include README.rst
|
||||
include ChangeLog
|
||||
include LICENSE
|
||||
|
||||
recursive-include climate/locale *
|
||||
recursive-include blazar/locale *
|
||||
|
||||
exclude .gitignore
|
||||
exclude .gitreview
|
||||
|
@ -10,7 +10,7 @@ Prerequisites
|
||||
-------------
|
||||
* Keystone v3 API endpoint
|
||||
* Dedicated account for write operations on behalf of the admin
|
||||
climate_username
|
||||
blazar_username
|
||||
* Service account
|
||||
|
||||
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
|
||||
|
||||
from climate import context
|
||||
from climate import exceptions
|
||||
from blazar import context
|
||||
from blazar import exceptions
|
||||
|
||||
|
||||
def ctx_from_headers(headers):
|
||||
@ -27,7 +27,7 @@ def ctx_from_headers(headers):
|
||||
except TypeError:
|
||||
raise exceptions.WrongFormat()
|
||||
|
||||
return context.ClimateContext(
|
||||
return context.BlazarContext(
|
||||
user_id=headers['X-User-Id'],
|
||||
project_id=headers['X-Project-Id'],
|
||||
auth_token=headers['X-Auth-Token'],
|
@ -16,7 +16,7 @@
|
||||
import json
|
||||
import pecan
|
||||
|
||||
from climate.api.v2 import controllers
|
||||
from blazar.api.v2 import controllers
|
||||
|
||||
|
||||
class RootController(object):
|
@ -21,23 +21,23 @@ from oslo_log import log as logging
|
||||
from oslo_middleware import debug
|
||||
from werkzeug import exceptions as werkzeug_exceptions
|
||||
|
||||
from climate.api.v1.oshosts import v1_0 as host_api_v1_0
|
||||
from climate.api.v1 import utils as api_utils
|
||||
from climate.api.v1 import v1_0 as api_v1_0
|
||||
from blazar.api.v1.oshosts import v1_0 as host_api_v1_0
|
||||
from blazar.api.v1 import utils as api_utils
|
||||
from blazar.api.v1 import v1_0 as api_v1_0
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
CONF.import_opt('os_auth_host', 'climate.config')
|
||||
CONF.import_opt('os_auth_port', 'climate.config')
|
||||
CONF.import_opt('os_auth_protocol', 'climate.config')
|
||||
CONF.import_opt('os_admin_username', 'climate.config')
|
||||
CONF.import_opt('os_admin_password', 'climate.config')
|
||||
CONF.import_opt('os_admin_project_name', 'climate.config')
|
||||
CONF.import_opt('os_auth_version', 'climate.config')
|
||||
CONF.import_opt('log_exchange', 'climate.config')
|
||||
CONF.import_opt('os_auth_host', 'blazar.config')
|
||||
CONF.import_opt('os_auth_port', 'blazar.config')
|
||||
CONF.import_opt('os_auth_protocol', 'blazar.config')
|
||||
CONF.import_opt('os_admin_username', 'blazar.config')
|
||||
CONF.import_opt('os_admin_password', 'blazar.config')
|
||||
CONF.import_opt('os_admin_project_name', 'blazar.config')
|
||||
CONF.import_opt('os_auth_version', 'blazar.config')
|
||||
CONF.import_opt('log_exchange', 'blazar.config')
|
||||
|
||||
|
||||
eventlet.monkey_patch(
|
||||
@ -71,9 +71,9 @@ def version_list():
|
||||
def make_app():
|
||||
"""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('/versions', methods=['GET'])(version_list)
|
@ -13,9 +13,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.manager.oshosts import rpcapi as manager_rpcapi
|
||||
from climate import policy
|
||||
from climate.utils import trusts
|
||||
from blazar.manager.oshosts import rpcapi as manager_rpcapi
|
||||
from blazar import policy
|
||||
from blazar.utils import trusts
|
||||
|
||||
|
||||
class API(object):
|
||||
@ -42,7 +42,7 @@ class API(object):
|
||||
def get_computehost(self, host_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
|
||||
"""
|
||||
return self.manager_rpcapi.get_computehost(host_id)
|
||||
@ -51,7 +51,7 @@ class API(object):
|
||||
def update_computehost(self, host_id, data):
|
||||
"""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
|
||||
:param data: New computehost characteristics.
|
||||
:type data: dict
|
||||
@ -62,7 +62,7 @@ class API(object):
|
||||
def delete_computehost(self, host_id):
|
||||
"""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
|
||||
"""
|
||||
self.manager_rpcapi.delete_computehost(host_id)
|
@ -13,10 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.api.v1.oshosts import service
|
||||
from climate.api.v1 import utils as api_utils
|
||||
from climate.api.v1 import validation
|
||||
from climate import utils
|
||||
from blazar.api.v1.oshosts import service
|
||||
from blazar.api.v1 import utils as api_utils
|
||||
from blazar.api.v1 import validation
|
||||
from blazar import utils
|
||||
|
||||
|
||||
rest = api_utils.Rest('host_v1_0', __name__)
|
@ -15,11 +15,11 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from climate import context
|
||||
from climate import exceptions
|
||||
from climate.manager import rpcapi as manager_rpcapi
|
||||
from climate import policy
|
||||
from climate.utils import trusts
|
||||
from blazar import context
|
||||
from blazar import exceptions
|
||||
from blazar.manager import rpcapi as manager_rpcapi
|
||||
from blazar import policy
|
||||
from blazar.utils import trusts
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -55,7 +55,7 @@ class API(object):
|
||||
def get_lease(self, lease_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
|
||||
"""
|
||||
return self.manager_rpcapi.get_lease(lease_id)
|
||||
@ -64,7 +64,7 @@ class API(object):
|
||||
def update_lease(self, lease_id, data):
|
||||
"""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
|
||||
:param data: New lease characteristics.
|
||||
:type data: dict
|
||||
@ -74,9 +74,9 @@ class API(object):
|
||||
start_date = data.pop('start_date', None)
|
||||
|
||||
if data:
|
||||
raise exceptions.ClimateException('Only name changing and '
|
||||
'dates changing may be '
|
||||
'proceeded.')
|
||||
raise exceptions.BlazarException('Only name changing and '
|
||||
'dates changing may be '
|
||||
'proceeded.')
|
||||
data = {}
|
||||
if new_name:
|
||||
data['name'] = new_name
|
||||
@ -90,7 +90,7 @@ class API(object):
|
||||
def delete_lease(self, lease_id):
|
||||
"""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
|
||||
"""
|
||||
self.manager_rpcapi.delete_lease(lease_id)
|
@ -21,11 +21,11 @@ import oslo_messaging as messaging
|
||||
from oslo_serialization import jsonutils
|
||||
from werkzeug import datastructures
|
||||
|
||||
from climate.api import context
|
||||
from climate.db import exceptions as db_exceptions
|
||||
from climate import exceptions as ex
|
||||
from climate.i18n import _
|
||||
from climate.manager import exceptions as manager_exceptions
|
||||
from blazar.api import context
|
||||
from blazar.db import exceptions as db_exceptions
|
||||
from blazar import exceptions as ex
|
||||
from blazar.i18n import _
|
||||
from blazar.manager import exceptions as manager_exceptions
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -74,7 +74,7 @@ class Rest(flask.Blueprint):
|
||||
with context.ctx_from_headers(flask.request.headers):
|
||||
try:
|
||||
return func(**kwargs)
|
||||
except ex.ClimateException as e:
|
||||
except ex.BlazarException as e:
|
||||
return bad_request(e)
|
||||
except messaging.RemoteError as e:
|
||||
# Get the exception from manager and common exceptions
|
||||
@ -96,7 +96,7 @@ class Rest(flask.Blueprint):
|
||||
cls.code)
|
||||
else:
|
||||
# We obfuscate all Exceptions
|
||||
# but Climate ones for
|
||||
# but Blazar ones for
|
||||
# security reasons
|
||||
err = 'Internal Server Error'
|
||||
return internal_error(500, err, e)
|
||||
@ -241,7 +241,7 @@ def internal_error(status_code, descr, exc=None):
|
||||
|
||||
|
||||
def bad_request(error):
|
||||
"""Called if Climate exception occurred."""
|
||||
"""Called if Blazar exception occurred."""
|
||||
if not error.code:
|
||||
error.code = 400
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from climate.api.v1 import service
|
||||
from climate.api.v1 import utils as api_utils
|
||||
from climate.api.v1 import validation
|
||||
from climate import utils
|
||||
from blazar.api.v1 import service
|
||||
from blazar.api.v1 import utils as api_utils
|
||||
from blazar.api.v1 import validation
|
||||
from blazar import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -17,8 +17,8 @@ import functools
|
||||
|
||||
import six
|
||||
|
||||
from climate.api.v1 import utils as api_utils
|
||||
from climate import exceptions
|
||||
from blazar.api.v1 import utils as api_utils
|
||||
from blazar import exceptions
|
||||
|
||||
|
||||
def check_exists(get_function, object_id=None, **get_args):
|
@ -18,8 +18,8 @@ from oslo_config import cfg
|
||||
from oslo_middleware import debug
|
||||
import pecan
|
||||
|
||||
from climate.api.v2 import hooks
|
||||
from climate.api.v2 import middleware
|
||||
from blazar.api.v2 import hooks
|
||||
from blazar.api.v2 import middleware
|
||||
|
||||
|
||||
auth_opts = [
|
||||
@ -31,7 +31,7 @@ auth_opts = [
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(auth_opts)
|
||||
|
||||
CONF.import_opt('log_exchange', 'climate.config')
|
||||
CONF.import_opt('log_exchange', 'blazar.config')
|
||||
|
||||
OPT_GROUP_NAME = 'keystone_authtoken'
|
||||
|
||||
@ -71,8 +71,8 @@ def setup_app(pecan_config=None, extra_hooks=None):
|
||||
def make_app():
|
||||
config = {
|
||||
'app': {
|
||||
'modules': ['climate.api.v2'],
|
||||
'root': 'climate.api.root.RootController',
|
||||
'modules': ['blazar.api.v2'],
|
||||
'root': 'blazar.api.root.RootController',
|
||||
'enable_acl': True,
|
||||
}
|
||||
}
|
@ -22,8 +22,8 @@ import pecan
|
||||
from pecan import rest
|
||||
from stevedore import enabled
|
||||
|
||||
from climate import exceptions
|
||||
from climate.i18n import _
|
||||
from blazar import exceptions
|
||||
from blazar.i18n import _
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -53,7 +53,7 @@ class V2Controller(rest.RestController):
|
||||
|
||||
self.extension_manager = enabled.EnabledExtensionManager(
|
||||
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
|
||||
)
|
||||
self._log_missing_plugins(CONF.api.api_v2_controllers)
|
||||
@ -62,7 +62,7 @@ class V2Controller(rest.RestController):
|
||||
try:
|
||||
setattr(self, ext.obj.name, ext.obj)
|
||||
except TypeError:
|
||||
raise exceptions.ClimateException(
|
||||
raise exceptions.BlazarException(
|
||||
_("API name must be specified for "
|
||||
"extension {0}").format(ext.name))
|
||||
self._routes.update(ext.obj.extra_routes)
|
@ -16,7 +16,7 @@
|
||||
import wsme
|
||||
from wsme import types as wtypes
|
||||
|
||||
from climate.api.v2.controllers import types
|
||||
from blazar.api.v2.controllers import types
|
||||
|
||||
|
||||
class _Base(wtypes.DynamicBase):
|
@ -18,13 +18,13 @@ import pecan
|
||||
from wsme import types as wtypes
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from climate.api.v2.controllers import base
|
||||
from climate.api.v2.controllers import extensions
|
||||
from climate.api.v2.controllers import types
|
||||
from climate import exceptions
|
||||
from climate.i18n import _
|
||||
from climate import policy
|
||||
from climate.utils import trusts
|
||||
from blazar.api.v2.controllers import base
|
||||
from blazar.api.v2.controllers import extensions
|
||||
from blazar.api.v2.controllers import types
|
||||
from blazar import exceptions
|
||||
from blazar.i18n import _
|
||||
from blazar import policy
|
||||
from blazar.utils import trusts
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -142,7 +142,7 @@ class HostsController(extensions.BaseController):
|
||||
if host is not None:
|
||||
return Host.convert(host)
|
||||
else:
|
||||
raise exceptions.ClimateException(_("Host can't be created"))
|
||||
raise exceptions.BlazarException(_("Host can't be created"))
|
||||
|
||||
@policy.authorize('oshosts', 'update')
|
||||
@wsme_pecan.wsexpose(Host, types.IntegerType(), body=Host,
|
@ -17,14 +17,14 @@ import pecan
|
||||
from wsme import types as wtypes
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from climate.api.v2.controllers import base
|
||||
from climate.api.v2.controllers import extensions
|
||||
from climate.api.v2.controllers import types
|
||||
from climate import exceptions
|
||||
from climate.i18n import _
|
||||
from climate.manager import service
|
||||
from climate import policy
|
||||
from climate.utils import trusts
|
||||
from blazar.api.v2.controllers import base
|
||||
from blazar.api.v2.controllers import extensions
|
||||
from blazar.api.v2.controllers import types
|
||||
from blazar import exceptions
|
||||
from blazar.i18n import _
|
||||
from blazar.manager import service
|
||||
from blazar import policy
|
||||
from blazar.utils import trusts
|
||||
|
||||
|
||||
class Lease(base._Base):
|
||||
@ -126,7 +126,7 @@ class LeasesController(extensions.BaseController):
|
||||
if lease is not None:
|
||||
return Lease.convert(lease)
|
||||
else:
|
||||
raise exceptions.ClimateException(_("Lease can't be created"))
|
||||
raise exceptions.BlazarException(_("Lease can't be created"))
|
||||
|
||||
@policy.authorize('leases', 'update')
|
||||
@wsme_pecan.wsexpose(Lease, types.UuidType(), body=Lease, status_code=202)
|
||||
@ -144,10 +144,10 @@ class LeasesController(extensions.BaseController):
|
||||
None)
|
||||
|
||||
if sublease_dct != {}:
|
||||
raise exceptions.ClimateException('Only name changing, '
|
||||
'dates and before end '
|
||||
'notifications may be '
|
||||
'proceeded.')
|
||||
raise exceptions.BlazarException('Only name changing, '
|
||||
'dates and before end '
|
||||
'notifications may be '
|
||||
'proceeded.')
|
||||
if new_name:
|
||||
sublease_dct['name'] = new_name
|
||||
if end_date:
|
@ -21,7 +21,7 @@ import six
|
||||
from wsme import types as wtypes
|
||||
from wsme import utils as wutils
|
||||
|
||||
from climate import exceptions
|
||||
from blazar import exceptions
|
||||
|
||||
|
||||
class UuidType(wtypes.UserType):
|
@ -17,10 +17,10 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from pecan import hooks
|
||||
|
||||
from climate.api import context
|
||||
from climate.db import api as dbapi
|
||||
from climate.manager.oshosts import rpcapi as hosts_rpcapi
|
||||
from climate.manager import rpcapi
|
||||
from blazar.api import context
|
||||
from blazar.db import api as dbapi
|
||||
from blazar.manager.oshosts import rpcapi as hosts_rpcapi
|
||||
from blazar.manager import rpcapi
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -18,10 +18,10 @@ import json
|
||||
from oslo_log import log as logging
|
||||
import webob
|
||||
|
||||
from climate.db import exceptions as db_exceptions
|
||||
from climate import exceptions
|
||||
from climate.i18n import _
|
||||
from climate.manager import exceptions as manager_exceptions
|
||||
from blazar.db import exceptions as db_exceptions
|
||||
from blazar import exceptions
|
||||
from blazar.i18n import _
|
||||
from blazar.manager import exceptions as manager_exceptions
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -48,7 +48,7 @@ class ParsableErrorMiddleware(object):
|
||||
try:
|
||||
status_code = int(status.split(' ')[0])
|
||||
except (ValueError, TypeError): # pragma: nocover
|
||||
raise exceptions.ClimateException(_(
|
||||
raise exceptions.BlazarException(_(
|
||||
'Status {0} was unexpected').format(status))
|
||||
else:
|
||||
if status_code >= 400:
|
||||
@ -69,7 +69,7 @@ class ParsableErrorMiddleware(object):
|
||||
# still work if no errors are raised
|
||||
try:
|
||||
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))
|
||||
replacement_start_response(
|
||||
webob.response.Response(status=str(e.code)).status,
|
@ -22,11 +22,11 @@ from eventlet import wsgi
|
||||
from oslo_config import cfg
|
||||
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 climate.api.v2 import app as v2_app
|
||||
from climate.utils import service as service_utils
|
||||
from blazar.api.v1 import app as v1_app
|
||||
from blazar.api.v2 import app as v2_app
|
||||
from blazar.utils import service as service_utils
|
||||
|
||||
|
||||
opts = [
|
||||
@ -46,7 +46,7 @@ CONF = cfg.CONF
|
||||
CONF.register_cli_opts(opts)
|
||||
CONF.register_opts(api_opts)
|
||||
|
||||
CONF.import_opt('host', 'climate.config')
|
||||
CONF.import_opt('host', 'blazar.config')
|
||||
|
||||
|
||||
class VersionSelectorApplication(object):
|
||||
@ -90,8 +90,8 @@ class VersionSelectorApplication(object):
|
||||
|
||||
|
||||
def main():
|
||||
"""Entry point to start Climate API wsgi server."""
|
||||
cfg.CONF(sys.argv[1:], project='climate', prog='climate-api')
|
||||
"""Entry point to start Blazar API wsgi server."""
|
||||
cfg.CONF(sys.argv[1:], project='blazar', prog='blazar-api')
|
||||
service_utils.prepare_service(sys.argv)
|
||||
if not CONF.enable_v1_api:
|
||||
app = v2_app.make_app()
|
@ -21,16 +21,16 @@ eventlet.monkey_patch()
|
||||
from oslo_config import cfg
|
||||
from oslo_service import service
|
||||
|
||||
gettext.install('climate', unicode=1)
|
||||
gettext.install('blazar', unicode=1)
|
||||
|
||||
from climate.db import api as db_api
|
||||
from climate.manager import service as manager_service
|
||||
from climate.notification import notifier
|
||||
from climate.utils import service as service_utils
|
||||
from blazar.db import api as db_api
|
||||
from blazar.manager import service as manager_service
|
||||
from blazar.notification import notifier
|
||||
from blazar.utils import service as service_utils
|
||||
|
||||
|
||||
def main():
|
||||
cfg.CONF(project='climate', prog='climate-manager')
|
||||
cfg.CONF(project='blazar', prog='blazar-manager')
|
||||
service_utils.prepare_service(sys.argv)
|
||||
db_api.setup_db()
|
||||
notifier.init()
|
@ -47,7 +47,7 @@ os_opts = [
|
||||
'The user must have admin role in <os_admin_project_name> '
|
||||
'project'),
|
||||
cfg.StrOpt('os_admin_password',
|
||||
default='climate',
|
||||
default='blazar',
|
||||
help='Password of the admin user'),
|
||||
cfg.StrOpt('os_admin_project_name',
|
||||
default='admin',
|
@ -77,7 +77,7 @@ class BaseContext(object):
|
||||
return self.__values
|
||||
|
||||
|
||||
class ClimateContext(BaseContext):
|
||||
class BlazarContext(BaseContext):
|
||||
|
||||
_elements = set([
|
||||
"user_id",
|
||||
@ -100,8 +100,8 @@ class ClimateContext(BaseContext):
|
||||
|
||||
|
||||
def current():
|
||||
return ClimateContext.current()
|
||||
return BlazarContext.current()
|
||||
|
||||
|
||||
def elevated():
|
||||
return ClimateContext.elevated()
|
||||
return BlazarContext.elevated()
|
@ -15,8 +15,8 @@
|
||||
|
||||
"""Defines interface for DB access.
|
||||
|
||||
Functions in this module are imported into the climate.db namespace. Call these
|
||||
functions from climate.db namespace, not the climate.db.api namespace.
|
||||
Functions in this module are imported into the blazar.db namespace. Call these
|
||||
functions from blazar.db namespace, not the blazar.db.api namespace.
|
||||
|
||||
All functions in this module return objects that implement a dictionary-like
|
||||
interface.
|
||||
@ -27,7 +27,7 @@ interface.
|
||||
`sqlalchemy` is the only supported backend right now.
|
||||
|
||||
: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 = {
|
||||
'sqlalchemy': 'climate.db.sqlalchemy.api',
|
||||
'sqlalchemy': 'blazar.db.sqlalchemy.api',
|
||||
}
|
||||
|
||||
db_options.set_defaults(cfg.CONF)
|
@ -20,7 +20,7 @@ from oslo_utils import importutils
|
||||
|
||||
|
||||
db_driver_opts = [
|
||||
cfg.StrOpt('db_driver', default='climate.db',
|
||||
cfg.StrOpt('db_driver', default='blazar.db',
|
||||
help='Driver to use for database access')
|
||||
]
|
||||
|
@ -15,28 +15,28 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from climate import exceptions
|
||||
from climate.i18n import _
|
||||
from blazar import exceptions
|
||||
from blazar.i18n import _
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ClimateDBException(exceptions.ClimateException):
|
||||
class BlazarDBException(exceptions.BlazarException):
|
||||
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')
|
||||
|
||||
|
||||
class ClimateDBNotFound(ClimateDBException):
|
||||
class BlazarDBNotFound(BlazarDBException):
|
||||
msg_fmt = _('%(id)s %(model)s was not found')
|
||||
|
||||
|
||||
class ClimateDBInvalidFilter(ClimateDBException):
|
||||
class BlazarDBInvalidFilter(BlazarDBException):
|
||||
msg_fmt = _('%(query_filter)s is invalid')
|
||||
|
||||
|
||||
class ClimateDBInvalidFilterOperator(ClimateDBException):
|
||||
class BlazarDBInvalidFilterOperator(BlazarDBException):
|
||||
msg_fmt = _('%(filter_operator)s is invalid')
|
@ -14,44 +14,44 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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
|
||||
the database. The migration scripts are ordered so that multiple scripts
|
||||
can run sequentially to update the database.
|
||||
|
||||
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:
|
||||
$ 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:
|
||||
$ 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:
|
||||
$ 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
|
||||
|
||||
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>
|
||||
|
||||
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>
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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" \
|
||||
--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
|
||||
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"
|
||||
|
||||
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
|
||||
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:
|
||||
$ 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
|
||||
# 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
|
||||
# invoked.
|
||||
sqlalchemy.url =
|
@ -17,8 +17,8 @@ from alembic import context
|
||||
from sqlalchemy import create_engine, pool
|
||||
from logging import config as log_config
|
||||
|
||||
from climate.db.sqlalchemy import model_base
|
||||
from climate.db.sqlalchemy import models # noqa
|
||||
from blazar.db.sqlalchemy import model_base
|
||||
from blazar.db.sqlalchemy import models # noqa
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
@ -32,7 +32,7 @@ log_config.fileConfig(config.config_file_name)
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# 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,
|
||||
# can be acquired:
|
||||
@ -79,6 +79,6 @@ def run_migrations_online(config):
|
||||
connection.close()
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline(config.climate_config)
|
||||
run_migrations_offline(config.blazar_config)
|
||||
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.
|
||||
|
||||
|
||||
"""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 os
|
||||
@ -25,8 +25,8 @@ from alembic import util as alembic_util
|
||||
from oslo_config import cfg
|
||||
from oslo_db import options as db_options
|
||||
|
||||
gettext.install('climate', unicode=1)
|
||||
from climate.i18n import _
|
||||
gettext.install('blazar', unicode=1)
|
||||
from blazar.i18n import _
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -112,7 +112,7 @@ def main():
|
||||
config = alembic_config.Config(
|
||||
os.path.join(os.path.dirname(__file__), 'alembic.ini')
|
||||
)
|
||||
config.climate_config = CONF
|
||||
config.blazar_config = CONF
|
||||
|
||||
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 desc
|
||||
|
||||
from climate.db import exceptions as db_exc
|
||||
from climate.db.sqlalchemy import facade_wrapper
|
||||
from climate.db.sqlalchemy import models
|
||||
from climate.i18n import _
|
||||
from blazar.db import exceptions as db_exc
|
||||
from blazar.db.sqlalchemy import facade_wrapper
|
||||
from blazar.db.sqlalchemy import models
|
||||
from blazar.i18n import _
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -161,7 +161,7 @@ def reservation_create(values):
|
||||
reservation.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=reservation.__class__.__name__, columns=e.columns)
|
||||
|
||||
return reservation_get(reservation.id)
|
||||
@ -185,8 +185,8 @@ def reservation_destroy(reservation_id):
|
||||
|
||||
if not reservation:
|
||||
# raise not found error
|
||||
raise db_exc.ClimateDBNotFound(id=reservation_id,
|
||||
model='Reservation')
|
||||
raise db_exc.BlazarDBNotFound(id=reservation_id,
|
||||
model='Reservation')
|
||||
|
||||
session.delete(reservation)
|
||||
|
||||
@ -234,7 +234,7 @@ def lease_create(values):
|
||||
lease.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=lease.__class__.__name__, columns=e.columns)
|
||||
|
||||
try:
|
||||
@ -245,7 +245,7 @@ def lease_create(values):
|
||||
reservation.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=reservation.__class__.__name__, columns=e.columns)
|
||||
|
||||
try:
|
||||
@ -256,7 +256,7 @@ def lease_create(values):
|
||||
event.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=event.__class__.__name__, columns=e.columns)
|
||||
|
||||
return lease_get(lease.id)
|
||||
@ -280,7 +280,7 @@ def lease_destroy(lease_id):
|
||||
|
||||
if not lease:
|
||||
# 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)
|
||||
|
||||
@ -355,7 +355,7 @@ def event_create(values):
|
||||
event.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=event.__class__.__name__, columns=e.columns)
|
||||
|
||||
return event_get(event.id)
|
||||
@ -379,7 +379,7 @@ def event_destroy(event_id):
|
||||
|
||||
if not event:
|
||||
# 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)
|
||||
|
||||
@ -421,7 +421,7 @@ def host_reservation_create(values):
|
||||
host_reservation.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=host_reservation.__class__.__name__, columns=e.columns)
|
||||
|
||||
return host_reservation_get(host_reservation.id)
|
||||
@ -447,7 +447,7 @@ def host_reservation_destroy(host_reservation_id):
|
||||
|
||||
if not host_reservation:
|
||||
# raise not found error
|
||||
raise db_exc.ClimateDBNotFound(
|
||||
raise db_exc.BlazarDBNotFound(
|
||||
id=host_reservation_id, model='ComputeHostReservation')
|
||||
|
||||
session.delete(host_reservation)
|
||||
@ -490,7 +490,7 @@ def host_allocation_create(values):
|
||||
host_allocation.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=host_allocation.__class__.__name__, columns=e.columns)
|
||||
|
||||
return host_allocation_get(host_allocation.id)
|
||||
@ -516,7 +516,7 @@ def host_allocation_destroy(host_allocation_id):
|
||||
|
||||
if not host_allocation:
|
||||
# raise not found error
|
||||
raise db_exc.ClimateDBNotFound(
|
||||
raise db_exc.BlazarDBNotFound(
|
||||
id=host_allocation_id, model='ComputeHostAllocation')
|
||||
|
||||
session.delete(host_allocation)
|
||||
@ -577,7 +577,7 @@ def host_get_all_by_queries(queries):
|
||||
try:
|
||||
key, op, value = query.split(' ', 3)
|
||||
except ValueError:
|
||||
raise db_exc.ClimateDBInvalidFilter(query_filter=query)
|
||||
raise db_exc.BlazarDBInvalidFilter(query_filter=query)
|
||||
|
||||
column = getattr(models.ComputeHost, key, None)
|
||||
if column:
|
||||
@ -590,7 +590,7 @@ def host_get_all_by_queries(queries):
|
||||
attr = filter(lambda e: hasattr(column, e % op),
|
||||
['%s', '%s_', '__%s__'])[0] % op
|
||||
except IndexError:
|
||||
raise db_exc.ClimateDBInvalidFilterOperator(
|
||||
raise db_exc.BlazarDBInvalidFilterOperator(
|
||||
filter_operator=op)
|
||||
|
||||
if value == 'null':
|
||||
@ -606,7 +606,7 @@ def host_get_all_by_queries(queries):
|
||||
).filter(models.ComputeHostExtraCapability.capability_name == key
|
||||
).all()
|
||||
if not extra_filter:
|
||||
raise db_exc.ClimateDBNotFound(
|
||||
raise db_exc.BlazarDBNotFound(
|
||||
id=key, model='ComputeHostExtraCapability')
|
||||
|
||||
for host in extra_filter:
|
||||
@ -630,7 +630,7 @@ def host_create(values):
|
||||
host.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=host.__class__.__name__, columns=e.columns)
|
||||
|
||||
return host_get(host.id)
|
||||
@ -654,7 +654,7 @@ def host_destroy(host_id):
|
||||
|
||||
if not host:
|
||||
# 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)
|
||||
|
||||
@ -691,7 +691,7 @@ def host_extra_capability_create(values):
|
||||
host_extra_capability.save(session=session)
|
||||
except common_db_exc.DBDuplicateEntry as e:
|
||||
# raise exception about duplicated columns (e.columns)
|
||||
raise db_exc.ClimateDBDuplicateEntry(
|
||||
raise db_exc.BlazarDBDuplicateEntry(
|
||||
model=host_extra_capability.__class__.__name__,
|
||||
columns=e.columns)
|
||||
|
||||
@ -720,7 +720,7 @@ def host_extra_capability_destroy(host_extra_capability_id):
|
||||
|
||||
if not host_extra_capability:
|
||||
# raise not found error
|
||||
raise db_exc.ClimateDBNotFound(
|
||||
raise db_exc.BlazarDBNotFound(
|
||||
id=host_extra_capability_id,
|
||||
model='ComputeHostExtraCapability')
|
||||
|
@ -18,8 +18,8 @@ from sqlalchemy.ext import declarative
|
||||
from sqlalchemy.orm import attributes
|
||||
|
||||
|
||||
class _ClimateBase(models.ModelBase, models.TimestampMixin):
|
||||
"""Base class for all Climate SQLAlchemy DB Models."""
|
||||
class _BlazarBase(models.ModelBase, models.TimestampMixin):
|
||||
"""Base class for all Blazar SQLAlchemy DB Models."""
|
||||
|
||||
def to_dict(self):
|
||||
"""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:
|
||||
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.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
|
||||
# LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -44,7 +44,7 @@ def _id_column():
|
||||
|
||||
# Main objects: Lease, Reservation, Event
|
||||
|
||||
class Lease(mb.ClimateBase):
|
||||
class Lease(mb.BlazarBase):
|
||||
"""Contains all info about lease."""
|
||||
|
||||
__tablename__ = 'leases'
|
||||
@ -75,7 +75,7 @@ class Lease(mb.ClimateBase):
|
||||
return d
|
||||
|
||||
|
||||
class Reservation(mb.ClimateBase):
|
||||
class Reservation(mb.BlazarBase):
|
||||
"""Specifies group of nodes within a cluster."""
|
||||
|
||||
__tablename__ = 'reservations'
|
||||
@ -120,7 +120,7 @@ class Reservation(mb.ClimateBase):
|
||||
return d
|
||||
|
||||
|
||||
class Event(mb.ClimateBase):
|
||||
class Event(mb.BlazarBase):
|
||||
"""An events occurring with the lease."""
|
||||
|
||||
__tablename__ = 'events'
|
||||
@ -135,7 +135,7 @@ class Event(mb.ClimateBase):
|
||||
return super(Event, self).to_dict()
|
||||
|
||||
|
||||
class ComputeHostReservation(mb.ClimateBase):
|
||||
class ComputeHostReservation(mb.BlazarBase):
|
||||
"""Description
|
||||
|
||||
Specifies resources asked by reservation from
|
||||
@ -155,7 +155,7 @@ class ComputeHostReservation(mb.ClimateBase):
|
||||
return super(ComputeHostReservation, self).to_dict()
|
||||
|
||||
|
||||
class ComputeHostAllocation(mb.ClimateBase):
|
||||
class ComputeHostAllocation(mb.BlazarBase):
|
||||
"""Mapping between ComputeHost, ComputeHostReservation and Reservation."""
|
||||
|
||||
__tablename__ = 'computehost_allocations'
|
||||
@ -170,7 +170,7 @@ class ComputeHostAllocation(mb.ClimateBase):
|
||||
return super(ComputeHostAllocation, self).to_dict()
|
||||
|
||||
|
||||
class ComputeHost(mb.ClimateBase):
|
||||
class ComputeHost(mb.BlazarBase):
|
||||
"""Description
|
||||
|
||||
Specifies resources asked by reservation from
|
||||
@ -199,7 +199,7 @@ class ComputeHost(mb.ClimateBase):
|
||||
return super(ComputeHost, self).to_dict()
|
||||
|
||||
|
||||
class ComputeHostExtraCapability(mb.ClimateBase):
|
||||
class ComputeHostExtraCapability(mb.BlazarBase):
|
||||
"""Description
|
||||
|
||||
Allows to define extra capabilities per administrator request for each
|
@ -19,8 +19,8 @@ import sys
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from climate.db.sqlalchemy import facade_wrapper
|
||||
from climate.db.sqlalchemy import models
|
||||
from blazar.db.sqlalchemy import facade_wrapper
|
||||
from blazar.db.sqlalchemy import models
|
||||
|
||||
get_session = facade_wrapper.get_session
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
"""Defines interface for DB access.
|
||||
|
||||
Functions in this module are imported into the climate.db namespace. Call these
|
||||
functions from climate.db namespace, not the climate.db.api namespace.
|
||||
Functions in this module are imported into the blazar.db namespace. Call these
|
||||
functions from blazar.db namespace, not the blazar.db.api namespace.
|
||||
|
||||
All functions in this module return objects that implement a dictionary-like
|
||||
interface.
|
||||
@ -38,7 +38,7 @@ from oslo_log import log as logging
|
||||
|
||||
|
||||
_BACKEND_MAPPING = {
|
||||
'sqlalchemy': 'climate.db.sqlalchemy.utils',
|
||||
'sqlalchemy': 'blazar.db.sqlalchemy.utils',
|
||||
}
|
||||
|
||||
IMPL = db_api.DBAPI(cfg.CONF.database.backend,
|
@ -16,14 +16,14 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from climate.i18n import _
|
||||
from blazar.i18n import _
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ClimateException(Exception):
|
||||
"""Base Climate Exception.
|
||||
class BlazarException(Exception):
|
||||
"""Base Blazar Exception.
|
||||
|
||||
To correctly use this class, inherit from it and define
|
||||
a 'msg_fmt' and 'code' properties.
|
||||
@ -49,16 +49,16 @@ class ClimateException(Exception):
|
||||
|
||||
message = self.msg_fmt
|
||||
|
||||
super(ClimateException, self).__init__(message)
|
||||
super(BlazarException, self).__init__(message)
|
||||
|
||||
|
||||
class NotFound(ClimateException):
|
||||
class NotFound(BlazarException):
|
||||
"""Object not found exception."""
|
||||
msg_fmt = _("Object with %(object)s not found")
|
||||
code = 404
|
||||
|
||||
|
||||
class NotAuthorized(ClimateException):
|
||||
class NotAuthorized(BlazarException):
|
||||
msg_fmt = _("Not authorized")
|
||||
code = 403
|
||||
|
||||
@ -67,7 +67,7 @@ class PolicyNotAuthorized(NotAuthorized):
|
||||
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")
|
||||
|
||||
|
||||
@ -75,22 +75,22 @@ class ServiceCatalogNotFound(NotFound):
|
||||
msg_fmt = _("Could not find service catalog")
|
||||
|
||||
|
||||
class WrongFormat(ClimateException):
|
||||
class WrongFormat(BlazarException):
|
||||
msg_fmt = _("Unenxpectable object format")
|
||||
|
||||
|
||||
class ServiceClient(ClimateException):
|
||||
class ServiceClient(BlazarException):
|
||||
msg_fmt = _("Service %(service)s have some problems")
|
||||
|
||||
|
||||
class TaskFailed(ClimateException):
|
||||
class TaskFailed(BlazarException):
|
||||
msg_fmt = _('Current task failed')
|
||||
|
||||
|
||||
class Timeout(ClimateException):
|
||||
class Timeout(BlazarException):
|
||||
msg_fmt = _('Current task failed with timeout')
|
||||
|
||||
|
||||
class InvalidInput(ClimateException):
|
||||
class InvalidInput(BlazarException):
|
||||
code = 400
|
||||
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
|
||||
|
||||
DOMAIN = 'climate'
|
||||
DOMAIN = 'blazar'
|
||||
|
||||
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
|
||||
|
@ -18,13 +18,13 @@ import oslo_messaging as messaging
|
||||
|
||||
opts = [
|
||||
cfg.StrOpt('rpc_topic',
|
||||
default='climate.manager',
|
||||
help='The topic Climate uses for climate-manager messages.'),
|
||||
default='blazar.manager',
|
||||
help='The topic Blazar uses for blazar-manager messages.'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(opts, 'manager')
|
||||
CONF.import_opt('host', 'climate.config')
|
||||
CONF.import_opt('host', 'blazar.config')
|
||||
RPC_API_VERSION = '1.0'
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate import exceptions
|
||||
from climate.i18n import _
|
||||
from blazar import exceptions
|
||||
from blazar.i18n import _
|
||||
|
||||
|
||||
class NoFreePool(exceptions.NotFound):
|
||||
@ -25,23 +25,23 @@ class HostNotInFreePool(exceptions.NotFound):
|
||||
msg_fmt = _("Host %(host)s not in freepool '%(freepool_name)s'")
|
||||
|
||||
|
||||
class CantRemoveHost(exceptions.ClimateException):
|
||||
class CantRemoveHost(exceptions.BlazarException):
|
||||
code = 409
|
||||
msg_fmt = _("Can't remove host(s) %(host)s from Aggregate %(pool)s")
|
||||
|
||||
|
||||
class CantAddHost(exceptions.ClimateException):
|
||||
class CantAddHost(exceptions.BlazarException):
|
||||
code = 409
|
||||
msg_fmt = _("Can't add host(s) %(host)s to Aggregate %(pool)s")
|
||||
|
||||
|
||||
class AggregateHaveHost(exceptions.ClimateException):
|
||||
class AggregateHaveHost(exceptions.BlazarException):
|
||||
code = 409
|
||||
msg_fmt = _("Can't delete Aggregate '%(name)s', "
|
||||
"host(s) attached to it : %(hosts)s")
|
||||
|
||||
|
||||
class AggregateAlreadyHasHost(exceptions.ClimateException):
|
||||
class AggregateAlreadyHasHost(exceptions.BlazarException):
|
||||
code = 409
|
||||
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")
|
||||
|
||||
|
||||
class MultipleHostsFound(exceptions.ClimateException):
|
||||
class MultipleHostsFound(exceptions.BlazarException):
|
||||
code = 409
|
||||
msg_fmt = _("Multiple Hosts found for pattern '%(host)s'")
|
||||
|
||||
|
||||
class HostHavingServers(exceptions.ClimateException):
|
||||
class HostHavingServers(exceptions.BlazarException):
|
||||
code = 409
|
||||
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")
|
||||
|
||||
|
||||
class EventError(exceptions.ClimateException):
|
||||
class EventError(exceptions.BlazarException):
|
||||
msg_fmt = '%(error)s'
|
||||
|
||||
|
||||
class InvalidDate(exceptions.ClimateException):
|
||||
class InvalidDate(exceptions.BlazarException):
|
||||
msg_fmt = _(
|
||||
'%(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")
|
||||
|
||||
|
||||
class LeaseNameAlreadyExists(exceptions.ClimateException):
|
||||
class LeaseNameAlreadyExists(exceptions.BlazarException):
|
||||
code = 409
|
||||
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")
|
||||
|
||||
|
||||
# oshost plugin related exceptions
|
||||
|
||||
class CantAddExtraCapability(exceptions.ClimateException):
|
||||
class CantAddExtraCapability(exceptions.BlazarException):
|
||||
code = 409
|
||||
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")
|
||||
|
||||
|
||||
class WrongClientVersion(exceptions.ClimateException):
|
||||
class WrongClientVersion(exceptions.BlazarException):
|
||||
code = 400
|
||||
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")
|
||||
|
||||
|
||||
class HypervisorNotFound(exceptions.ClimateException):
|
||||
class HypervisorNotFound(exceptions.BlazarException):
|
||||
msg_fmt = _("Aggregate '%(pool)s' not found!")
|
||||
|
||||
|
||||
class NotEnoughHostsAvailable(exceptions.ClimateException):
|
||||
class NotEnoughHostsAvailable(exceptions.BlazarException):
|
||||
msg_fmt = _("Not enough hosts available")
|
||||
|
||||
|
||||
class MalformedRequirements(exceptions.ClimateException):
|
||||
class MalformedRequirements(exceptions.BlazarException):
|
||||
code = 400
|
||||
msg_fmt = _("Malformed requirements %(rqrms)s")
|
||||
|
||||
|
||||
class InvalidState(exceptions.ClimateException):
|
||||
class InvalidState(exceptions.BlazarException):
|
||||
code = 409
|
||||
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")
|
||||
|
||||
|
||||
class ProjectIdNotFound(exceptions.ClimateException):
|
||||
class ProjectIdNotFound(exceptions.BlazarException):
|
||||
msg_fmt = _("No project_id found in current context")
|
@ -15,17 +15,17 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from climate import manager
|
||||
from climate.utils import service
|
||||
from blazar import manager
|
||||
from blazar.utils import service
|
||||
|
||||
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):
|
||||
"""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'
|
||||
|
@ -13,14 +13,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate import manager
|
||||
from climate.utils import service
|
||||
from blazar import manager
|
||||
from blazar.utils import service
|
||||
|
||||
|
||||
class ManagerRPCAPI(service.RPCClient):
|
||||
"""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):
|
||||
"""Initiate RPC API client with needed topic and RPC version."""
|
@ -21,15 +21,15 @@ from oslo_log import log as logging
|
||||
import six
|
||||
from stevedore import enabled
|
||||
|
||||
from climate.db import api as db_api
|
||||
from climate.db import exceptions as db_ex
|
||||
from climate import exceptions as common_ex
|
||||
from climate.i18n import _
|
||||
from climate import manager
|
||||
from climate.manager import exceptions
|
||||
from climate.notification import api as notification_api
|
||||
from climate.utils import service as service_utils
|
||||
from climate.utils import trusts
|
||||
from blazar.db import api as db_api
|
||||
from blazar.db import exceptions as db_ex
|
||||
from blazar import exceptions as common_ex
|
||||
from blazar.i18n import _
|
||||
from blazar import manager
|
||||
from blazar.manager import exceptions
|
||||
from blazar.notification import api as notification_api
|
||||
from blazar.utils import service as service_utils
|
||||
from blazar.utils import trusts
|
||||
|
||||
manager_opts = [
|
||||
cfg.ListOpt('plugins',
|
||||
@ -52,9 +52,9 @@ LEASE_DATE_FORMAT = "%Y-%m-%d %H:%M"
|
||||
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
@ -75,7 +75,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
|
||||
extension_manager = enabled.EnabledExtensionManager(
|
||||
check_func=lambda ext: ext.name in config_plugins,
|
||||
namespace='climate.resource.plugins',
|
||||
namespace='blazar.resource.plugins',
|
||||
invoke_on_load=False
|
||||
)
|
||||
|
||||
@ -120,7 +120,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
def _event(self):
|
||||
"""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'.
|
||||
"""
|
||||
LOG.debug('Trying to get event from DB.')
|
||||
@ -224,7 +224,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
before_end_date)
|
||||
self._check_date_within_lease_limits(before_end_date,
|
||||
lease_values)
|
||||
except common_ex.ClimateException as e:
|
||||
except common_ex.BlazarException as e:
|
||||
LOG.error("Invalid before_end_date param. %s" % e.message)
|
||||
raise e
|
||||
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 = db_api.lease_create(lease_values)
|
||||
lease_id = lease['id']
|
||||
except db_ex.ClimateDBDuplicateEntry:
|
||||
except db_ex.BlazarDBDuplicateEntry:
|
||||
LOG.exception('Cannot create a lease - duplicated lease name')
|
||||
raise exceptions.LeaseNameAlreadyExists(
|
||||
name=lease_values['name'])
|
||||
except db_ex.ClimateDBException:
|
||||
except db_ex.BlazarDBException:
|
||||
LOG.exception('Cannot create a lease')
|
||||
raise
|
||||
else:
|
||||
@ -265,7 +265,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
raise exceptions.UnsupportedResourceType(
|
||||
resource_type)
|
||||
except (exceptions.UnsupportedResourceType,
|
||||
common_ex.ClimateException):
|
||||
common_ex.BlazarException):
|
||||
LOG.exception("Failed to create reservation for a lease. "
|
||||
"Rollback the lease and associated "
|
||||
"reservations")
|
||||
@ -334,7 +334,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
before_end_date = self._date_from_string(before_end_date)
|
||||
self._check_date_within_lease_limits(before_end_date,
|
||||
values)
|
||||
except common_ex.ClimateException as e:
|
||||
except common_ex.BlazarException as e:
|
||||
LOG.error("Invalid before_end_date param. %s" % e.message)
|
||||
raise e
|
||||
|
||||
@ -357,7 +357,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
}
|
||||
)
|
||||
if not event:
|
||||
raise common_ex.ClimateException(
|
||||
raise common_ex.BlazarException(
|
||||
'Start lease event not found')
|
||||
db_api.event_update(event['id'], {'time': values['start_date']})
|
||||
|
||||
@ -370,7 +370,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
}
|
||||
)
|
||||
if not event:
|
||||
raise common_ex.ClimateException(
|
||||
raise common_ex.BlazarException(
|
||||
'End lease event not found')
|
||||
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']]
|
||||
try:
|
||||
plugin.on_end(reservation['resource_id'])
|
||||
except (db_ex.ClimateDBException, RuntimeError):
|
||||
except (db_ex.BlazarDBException, RuntimeError):
|
||||
LOG.exception("Failed to delete a reservation "
|
||||
"for a lease.")
|
||||
raise
|
||||
@ -430,7 +430,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
self.resource_actions[resource_type][action_time](
|
||||
reservation['resource_id']
|
||||
)
|
||||
except common_ex.ClimateException:
|
||||
except common_ex.BlazarException:
|
||||
LOG.exception("Failed to execute action %(action)s "
|
||||
"for lease %(lease)s"
|
||||
% {
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from climate.notification import notifier
|
||||
from blazar.notification import notifier
|
||||
|
||||
IMPL = notifier.Notifier()
|
||||
|
@ -20,7 +20,7 @@ import oslo_messaging as messaging
|
||||
|
||||
notification_opts = [
|
||||
cfg.StrOpt('publisher_id',
|
||||
default="climate.lease",
|
||||
default="blazar.lease",
|
||||
help='Publisher ID for notifications')
|
||||
]
|
||||
|
||||
@ -53,7 +53,7 @@ def get_notifier(publisher_id):
|
||||
|
||||
|
||||
class Notifier(object):
|
||||
"""Notification class for climate
|
||||
"""Notification class for blazar
|
||||
|
||||
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
|
||||
import six
|
||||
|
||||
from climate.db import api as db_api
|
||||
from blazar.db import api as db_api
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.plugins import base
|
||||
from blazar.plugins import base
|
||||
|
||||
|
||||
class DummyVMPlugin(base.BasePlugin):
|
@ -18,10 +18,10 @@ from novaclient import exceptions as nova_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from climate import exceptions as climate_exceptions
|
||||
from climate.plugins import base
|
||||
from climate.plugins import instances as plugin
|
||||
from climate.utils.openstack import nova
|
||||
from blazar import exceptions as blazar_exceptions
|
||||
from blazar.plugins import base
|
||||
from blazar.plugins import instances as plugin
|
||||
from blazar.utils.openstack import nova
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -62,7 +62,7 @@ class VMPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
||||
# creating snapshot or suspending already deleted instance
|
||||
|
||||
if 'create_image' in actions:
|
||||
with eventlet.timeout.Timeout(600, climate_exceptions.Timeout):
|
||||
with eventlet.timeout.Timeout(600, blazar_exceptions.Timeout):
|
||||
try:
|
||||
self.nova.servers.create_image(resource_id)
|
||||
eventlet.sleep(5)
|
||||
@ -71,7 +71,7 @@ class VMPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
||||
except nova_exceptions.NotFound:
|
||||
LOG.error('Instance %s has been already deleted. '
|
||||
'Cannot create image.' % resource_id)
|
||||
except climate_exceptions.Timeout:
|
||||
except blazar_exceptions.Timeout:
|
||||
LOG.error('Image create failed with timeout. Take a look '
|
||||
'at nova.')
|
||||
except nova_exceptions.Conflict as e:
|
||||
@ -105,10 +105,10 @@ class VMPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
||||
else:
|
||||
LOG.error('Nova reported unexpected task status %s for '
|
||||
'instance %s' % (task_state, resource_id))
|
||||
raise climate_exceptions.TaskFailed()
|
||||
raise blazar_exceptions.TaskFailed()
|
||||
|
||||
def _split_actions(self, actions):
|
||||
try:
|
||||
return actions.replace(' ', '').split(',')
|
||||
except AttributeError:
|
||||
raise climate_exceptions.WrongFormat()
|
||||
raise blazar_exceptions.WrongFormat()
|
@ -21,16 +21,16 @@ import uuid
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from climate.db import api as db_api
|
||||
from climate.db import exceptions as db_ex
|
||||
from climate.db import utils as db_utils
|
||||
from climate.manager import exceptions as manager_ex
|
||||
from climate.plugins import base
|
||||
from climate.plugins import oshosts as plugin
|
||||
from climate.plugins.oshosts import nova_inventory
|
||||
from climate.plugins.oshosts import reservation_pool as rp
|
||||
from climate.utils.openstack import nova
|
||||
from climate.utils import trusts
|
||||
from blazar.db import api as db_api
|
||||
from blazar.db import exceptions as db_ex
|
||||
from blazar.db import utils as db_utils
|
||||
from blazar.manager import exceptions as manager_ex
|
||||
from blazar.plugins import base
|
||||
from blazar.plugins import oshosts as plugin
|
||||
from blazar.plugins.oshosts import nova_inventory
|
||||
from blazar.plugins.oshosts import reservation_pool as rp
|
||||
from blazar.utils.openstack import nova
|
||||
from blazar.utils import trusts
|
||||
|
||||
plugin_opts = [
|
||||
cfg.StrOpt('on_end',
|
||||
@ -255,7 +255,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
||||
if trust_id:
|
||||
host_details.update({'trust_id': trust_id})
|
||||
host = db_api.host_create(host_details)
|
||||
except db_ex.ClimateDBException:
|
||||
except db_ex.BlazarDBException:
|
||||
# We need to rollback
|
||||
# TODO(sbauza): Investigate use of Taskflow for atomic
|
||||
# transactions
|
||||
@ -269,7 +269,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
||||
}
|
||||
try:
|
||||
db_api.host_extra_capability_create(values)
|
||||
except db_ex.ClimateDBException:
|
||||
except db_ex.BlazarDBException:
|
||||
cantaddextracapability.append(key)
|
||||
if cantaddextracapability:
|
||||
raise manager_ex.CantAddExtraCapability(
|
||||
@ -329,7 +329,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
|
||||
# NOTE(sbauza): Extracapabilities will be destroyed thanks to
|
||||
# the DB FK.
|
||||
db_api.host_destroy(host_id)
|
||||
except db_ex.ClimateDBException:
|
||||
except db_ex.BlazarDBException:
|
||||
# Nothing so bad, but we need to advert the admin
|
||||
# he has to rerun
|
||||
raise manager_ex.CantRemoveHost(host=host_id,
|
@ -15,8 +15,8 @@
|
||||
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
|
||||
from climate.manager import exceptions as manager_exceptions
|
||||
from climate.utils.openstack import nova
|
||||
from blazar.manager import exceptions as manager_exceptions
|
||||
from blazar.utils.openstack import nova
|
||||
|
||||
|
||||
class NovaInventory(nova.NovaClientWrapper):
|
@ -20,10 +20,10 @@ from novaclient import exceptions as nova_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from climate import context
|
||||
from climate.manager import exceptions as manager_exceptions
|
||||
from climate.plugins import oshosts as plugin
|
||||
from climate.utils.openstack import nova
|
||||
from blazar import context
|
||||
from blazar.manager import exceptions as manager_exceptions
|
||||
from blazar.plugins import oshosts as plugin
|
||||
from blazar.utils.openstack import nova
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -34,14 +34,16 @@ OPTS = [
|
||||
help='Name of the special aggregate where all hosts '
|
||||
'are candidate for physical host reservation'),
|
||||
cfg.StrOpt('project_id_key',
|
||||
default='climate:project',
|
||||
default='blazar:project',
|
||||
help='Aggregate metadata value for key matching project_id'),
|
||||
cfg.StrOpt('climate_owner',
|
||||
default='climate:owner',
|
||||
cfg.StrOpt('blazar_owner',
|
||||
default='blazar:owner',
|
||||
deprecated_name='climate_owner',
|
||||
help='Aggregate metadata key for knowing owner project_id'),
|
||||
cfg.StrOpt('climate_az_prefix',
|
||||
default='climate:',
|
||||
help='Prefix for Availability Zones created by Climate'),
|
||||
cfg.StrOpt('blazar_az_prefix',
|
||||
default='blazar:',
|
||||
deprecated_name='climate_az_prefix',
|
||||
help='Prefix for Availability Zones created by Blazar'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -98,7 +100,7 @@ class ReservationPool(nova.NovaClientWrapper):
|
||||
name = name or self._generate_aggregate_name()
|
||||
|
||||
if az:
|
||||
az_name = "%s%s" % (self.config.climate_az_prefix,
|
||||
az_name = "%s%s" % (self.config.blazar_az_prefix,
|
||||
name)
|
||||
LOG.debug('Creating pool aggregate: %s '
|
||||
'with Availability Zone %s' % (name, az_name))
|
||||
@ -117,7 +119,7 @@ class ReservationPool(nova.NovaClientWrapper):
|
||||
LOG.error(e.message)
|
||||
raise e
|
||||
|
||||
meta = {self.config.climate_owner: project_id}
|
||||
meta = {self.config.blazar_owner: project_id}
|
||||
self.nova.aggregates.set_metadata(agg, meta)
|
||||
|
||||
return agg
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Policy Engine For Climate."""
|
||||
"""Policy Engine For Blazar."""
|
||||
|
||||
import functools
|
||||
|
||||
@ -22,8 +22,8 @@ from oslo_log import log as logging
|
||||
from oslo_policy import opts
|
||||
from oslo_policy import policy
|
||||
|
||||
from climate import context
|
||||
from climate import exceptions
|
||||
from blazar import context
|
||||
from blazar import exceptions
|
||||
|
||||
CONF = cfg.CONF
|
||||
opts.set_defaults(CONF)
|
||||
@ -60,7 +60,7 @@ def set_rules(data, default_rule=None):
|
||||
def enforce(context, action, target, do_raise=True):
|
||||
"""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
|
||||
this should be colon separated for clarity.
|
||||
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;
|
||||
if False, returns False
|
||||
|
||||
:raises climate.exceptions.PolicyNotAuthorized: if verification fails
|
||||
:raises blazar.exceptions.PolicyNotAuthorized: if verification fails
|
||||
and do_raise is True.
|
||||
|
||||
:return: returns a non-False value (not necessarily "True") if
|
||||
@ -93,7 +93,7 @@ def enforce(context, action, target, do_raise=True):
|
||||
**extra)
|
||||
|
||||
|
||||
def authorize(extension, action=None, api='climate', ctx=None,
|
||||
def authorize(extension, action=None, api='blazar', ctx=None,
|
||||
target=None):
|
||||
def decorator(func):
|
||||
|
@ -13,16 +13,16 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Actions and states for Climate objects."""
|
||||
"""Actions and states for Blazar objects."""
|
||||
|
||||
import abc
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from climate.db import api as db_api
|
||||
from climate.db import exceptions as db_exc
|
||||
from climate.manager import exceptions as mgr_exc
|
||||
from blazar.db import api as db_api
|
||||
from blazar.db import exceptions as db_exc
|
||||
from blazar.manager import exceptions as mgr_exc
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -90,7 +90,7 @@ class LeaseState(ObjectState):
|
||||
def save(self):
|
||||
try:
|
||||
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
|
||||
raise mgr_exc.InvalidState(id=self.id, state=self.current())
|
||||
return self.current()
|
@ -24,15 +24,15 @@ from oslo_log import log as logging
|
||||
from oslotest import base
|
||||
from oslotest import mockpatch
|
||||
|
||||
from climate import context
|
||||
from climate.db.sqlalchemy import api as db_api
|
||||
from climate.db.sqlalchemy import facade_wrapper
|
||||
from climate import policy
|
||||
from climate.tests import fake_policy
|
||||
from blazar import context
|
||||
from blazar.db.sqlalchemy import api as db_api
|
||||
from blazar.db.sqlalchemy import facade_wrapper
|
||||
from blazar import policy
|
||||
from blazar.tests import fake_policy
|
||||
|
||||
cfg.CONF.set_override('use_stderr', False)
|
||||
|
||||
logging.setup(cfg.CONF, 'climate')
|
||||
logging.setup(cfg.CONF, 'blazar')
|
||||
_DB_CACHE = None
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class TestCase(testscenarios.WithScenarios, base.BaseTestCase):
|
||||
"""Run before each test method to initialize test environment."""
|
||||
super(TestCase, self).setUp()
|
||||
self.context_mock = None
|
||||
cfg.CONF(args=[], project='climate')
|
||||
cfg.CONF(args=[], project='blazar')
|
||||
self.policy = self.useFixture(PolicyFixture())
|
||||
|
||||
def patch(self, obj, attr):
|
||||
@ -90,7 +90,7 @@ class TestCase(testscenarios.WithScenarios, base.BaseTestCase):
|
||||
|
||||
def set_context(self, ctx):
|
||||
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
|
||||
|
||||
|
@ -22,11 +22,11 @@ import pecan.testing
|
||||
import six
|
||||
|
||||
|
||||
from climate.api import context as api_context
|
||||
from climate import context
|
||||
from climate.manager.oshosts import rpcapi as hosts_rpcapi
|
||||
from climate.manager import rpcapi
|
||||
from climate import tests
|
||||
from blazar.api import context as api_context
|
||||
from blazar import context
|
||||
from blazar.manager.oshosts import rpcapi as hosts_rpcapi
|
||||
from blazar.manager import rpcapi
|
||||
from blazar import tests
|
||||
|
||||
PATH_PREFIX = '/v2'
|
||||
|
||||
@ -42,10 +42,10 @@ class APITest(tests.TestCase):
|
||||
def setUp(self):
|
||||
def fake_ctx_from_headers(headers):
|
||||
if not headers:
|
||||
return context.ClimateContext(
|
||||
return context.BlazarContext(
|
||||
user_id='fake', project_id='fake', roles=['member'])
|
||||
roles = headers.get('X-Roles', six.text_type('member')).split(',')
|
||||
return context.ClimateContext(
|
||||
return context.BlazarContext(
|
||||
user_id=headers.get('X-User-Id', 'fake'),
|
||||
project_id=headers.get('X-Project-Id', 'fake'),
|
||||
auth_token=headers.get('X-Auth-Token', None),
|
||||
@ -100,8 +100,8 @@ class APITest(tests.TestCase):
|
||||
|
||||
self.config = {
|
||||
'app': {
|
||||
'modules': ['climate.api.v2'],
|
||||
'root': 'climate.api.root.RootController',
|
||||
'modules': ['blazar.api.v2'],
|
||||
'root': 'blazar.api.root.RootController',
|
||||
'enable_acl': enable_acl,
|
||||
},
|
||||
}
|
@ -16,8 +16,8 @@
|
||||
Tests for ACL. Checks whether certain kinds of requests
|
||||
are blocked or allowed to be processed.
|
||||
"""
|
||||
from climate import policy
|
||||
from climate.tests import api
|
||||
from blazar import policy
|
||||
from blazar.tests import api
|
||||
|
||||
|
||||
class TestACL(api.APITest):
|
@ -15,10 +15,10 @@
|
||||
|
||||
import json
|
||||
|
||||
from climate.api import context as api_context
|
||||
from climate import context
|
||||
from climate import exceptions
|
||||
from climate import tests
|
||||
from blazar.api import context as api_context
|
||||
from blazar import context
|
||||
from blazar import exceptions
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class ContextTestCase(tests.TestCase):
|
||||
@ -33,7 +33,7 @@ class ContextTestCase(tests.TestCase):
|
||||
u'X-Roles': u'user_name0, user_name1'}
|
||||
|
||||
def test_ctx_from_headers(self):
|
||||
self.context = self.patch(context, 'ClimateContext')
|
||||
self.context = self.patch(context, 'BlazarContext')
|
||||
catalog = json.dumps({'nova': 'catalog'})
|
||||
self.fake_headers[u'X-Service-Catalog'] = catalog
|
||||
api_context.ctx_from_headers(self.fake_headers)
|
@ -15,7 +15,7 @@
|
||||
|
||||
import json
|
||||
|
||||
from climate.tests import api
|
||||
from blazar.tests import api
|
||||
|
||||
|
||||
class TestRoot(api.APITest):
|
@ -15,10 +15,10 @@
|
||||
|
||||
import json
|
||||
|
||||
from climate.api.v1 import app as v1_app
|
||||
from climate.api.v2 import app as v2_app
|
||||
from climate.cmd import api
|
||||
from climate import tests
|
||||
from blazar.api.v1 import app as v1_app
|
||||
from blazar.api.v2 import app as v2_app
|
||||
from blazar.cmd import api
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class FakeWSGIApp(object):
|
@ -13,8 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.api.v1.oshosts import service as service_api
|
||||
from climate import tests
|
||||
from blazar.api.v1.oshosts import service as service_api
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class RPCApiTestCase(tests.TestCase):
|
@ -13,10 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.api.v1.oshosts import service as service_api
|
||||
from climate.api.v1.oshosts import v1_0 as api
|
||||
from climate.api.v1 import utils as utils_api
|
||||
from climate import tests
|
||||
from blazar.api.v1.oshosts import service as service_api
|
||||
from blazar.api.v1.oshosts import v1_0 as api
|
||||
from blazar.api.v1 import utils as utils_api
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class RESTApiTestCase(tests.TestCase):
|
@ -18,10 +18,10 @@ from keystonemiddleware import auth_token
|
||||
from oslo_config import cfg
|
||||
from werkzeug import exceptions as werkzeug_exceptions
|
||||
|
||||
from climate.api.v1 import app
|
||||
from climate.api.v1.oshosts import v1_0 as host_api_v1_0
|
||||
from climate.api.v1 import utils as api_utils
|
||||
from climate import tests
|
||||
from blazar.api.v1 import app
|
||||
from blazar.api.v1.oshosts import v1_0 as host_api_v1_0
|
||||
from blazar.api.v1 import utils as api_utils
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class AppTestCase(tests.TestCase):
|
||||
@ -76,7 +76,7 @@ class AppTestCase(tests.TestCase):
|
||||
auth_port='35357',
|
||||
auth_protocol='http',
|
||||
auth_version='v2.0',
|
||||
admin_password='climate',
|
||||
admin_password='blazar',
|
||||
auth_host='127.0.0.1')
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.api.v1 import service as service_api
|
||||
from climate import tests
|
||||
from blazar.api.v1 import service as service_api
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class RPCApiTestCase(tests.TestCase):
|
@ -15,8 +15,8 @@
|
||||
|
||||
import flask
|
||||
|
||||
from climate.api.v1 import utils
|
||||
from climate import tests
|
||||
from blazar.api.v1 import utils
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class Error:
|
@ -13,10 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.api.v1 import service as service_api
|
||||
from climate.api.v1 import utils as utils_api
|
||||
from climate.api.v1 import v1_0 as api
|
||||
from climate import tests
|
||||
from blazar.api.v1 import service as service_api
|
||||
from blazar.api.v1 import utils as utils_api
|
||||
from blazar.api.v1 import v1_0 as api
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class RESTApiTestCase(tests.TestCase):
|
@ -13,11 +13,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from climate.api.v1 import service as service_api
|
||||
from climate.api.v1 import utils as api_utils
|
||||
from climate.api.v1 import validation as validation_api
|
||||
from climate import exceptions
|
||||
from climate import tests
|
||||
from blazar.api.v1 import service as service_api
|
||||
from blazar.api.v1 import utils as api_utils
|
||||
from blazar.api.v1 import validation as validation_api
|
||||
from blazar import exceptions
|
||||
from blazar import tests
|
||||
|
||||
|
||||
class ValidationTestCase(tests.TestCase):
|
@ -20,8 +20,8 @@ import uuid
|
||||
import six
|
||||
|
||||
|
||||
from climate.tests import api
|
||||
from climate.utils import trusts
|
||||
from blazar.tests import api
|
||||
from blazar.utils import trusts
|
||||
|
||||
|
||||
def fake_computehost(**kw):
|
@ -20,8 +20,8 @@ import uuid
|
||||
import six
|
||||
|
||||
|
||||
from climate.tests import api
|
||||
from climate.utils import trusts
|
||||
from blazar.tests import api
|
||||
from blazar.utils import trusts
|
||||
|
||||
|
||||
def fake_lease(**kw):
|
@ -37,13 +37,13 @@ from oslo_log import log as logging
|
||||
import sqlalchemy
|
||||
import sqlalchemy.exc
|
||||
|
||||
import climate.db.migration
|
||||
from climate import tests
|
||||
import blazar.db.migration
|
||||
from blazar import tests
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
synchronized = lockutils.synchronized_with_prefix('climate-')
|
||||
synchronized = lockutils.synchronized_with_prefix('blazar-')
|
||||
|
||||
|
||||
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):
|
||||
present = os.environ.get('CLIMATE_MYSQL_PRESENT')
|
||||
present = os.environ.get('BLAZAR_MYSQL_PRESENT')
|
||||
if present is None:
|
||||
return _is_backend_avail('mysql', user, passwd, database)
|
||||
return present.lower() in ('', 'true')
|
||||
|
||||
|
||||
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:
|
||||
return _is_backend_avail('postgres', user, passwd, database)
|
||||
return present.lower() in ('', 'true')
|
||||
@ -187,18 +187,18 @@ class BaseMigrationTestCase(tests.TestCase):
|
||||
self.DEFAULT_CONFIG_FILE = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'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
|
||||
self.CONFIG_FILE_PATH = os.environ.get(
|
||||
'CLIMATE_TEST_MIGRATIONS_CONF',
|
||||
'BLAZAR_TEST_MIGRATIONS_CONF',
|
||||
self.DEFAULT_CONFIG_FILE)
|
||||
|
||||
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')
|
||||
)
|
||||
|
||||
self.ALEMBIC_CONFIG.climate_config = CONF
|
||||
self.ALEMBIC_CONFIG.blazar_config = CONF
|
||||
|
||||
self.snake_walk = False
|
||||
self.downgrade = False
|
@ -40,7 +40,7 @@ postgres=# create database openstack_citest with owner openstack_citest;
|
||||
from oslo_config import cfg
|
||||
import sqlalchemy
|
||||
|
||||
from climate.tests.db import migration
|
||||
from blazar.tests.db import migration
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user