Rename nimble to mogan (5)
This will clean up all things Change-Id: I57682cbeb62e03f3bf65359729136362c35d69fc
This commit is contained in:
parent
7575d1b96e
commit
e508d77796
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Version 1 of the Nimble API
|
Version 1 of the Mogan API
|
||||||
|
|
||||||
Specification can be found at doc/source/webapi/v1.rst
|
Specification can be found at doc/source/webapi/v1.rst
|
||||||
"""
|
"""
|
||||||
|
@ -33,7 +33,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, app, conf, public_api_routes=None):
|
def __init__(self, app, conf, public_api_routes=None):
|
||||||
api_routes = [] if public_api_routes is None else public_api_routes
|
api_routes = [] if public_api_routes is None else public_api_routes
|
||||||
self._nimble_app = app
|
self._mogan_app = app
|
||||||
route_pattern_tpl = '%s(\.json)?$'
|
route_pattern_tpl = '%s(\.json)?$'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -57,6 +57,6 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
|
|||||||
self.public_api_routes))
|
self.public_api_routes))
|
||||||
|
|
||||||
if env['is_public_api']:
|
if env['is_public_api']:
|
||||||
return self._nimble_app(env, start_response)
|
return self._mogan_app(env, start_response)
|
||||||
|
|
||||||
return super(AuthTokenMiddleware, self).__call__(env, start_response)
|
return super(AuthTokenMiddleware, self).__call__(env, start_response)
|
||||||
|
@ -31,7 +31,7 @@ from mogan.conf import CONF
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class NimbleException(Exception):
|
class MoganException(Exception):
|
||||||
"""Base Mogan Exception
|
"""Base Mogan Exception
|
||||||
|
|
||||||
To correctly use this class, inherit from it and define
|
To correctly use this class, inherit from it and define
|
||||||
@ -74,7 +74,7 @@ class NimbleException(Exception):
|
|||||||
# happened
|
# happened
|
||||||
message = self._msg_fmt
|
message = self._msg_fmt
|
||||||
|
|
||||||
super(NimbleException, self).__init__(message)
|
super(MoganException, self).__init__(message)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Encode to utf-8 then wsme api can consume it as well."""
|
"""Encode to utf-8 then wsme api can consume it as well."""
|
||||||
@ -88,7 +88,7 @@ class NimbleException(Exception):
|
|||||||
return unicode(self.args[0])
|
return unicode(self.args[0])
|
||||||
|
|
||||||
|
|
||||||
class NotAuthorized(NimbleException):
|
class NotAuthorized(MoganException):
|
||||||
_msg_fmt = _("Not authorized.")
|
_msg_fmt = _("Not authorized.")
|
||||||
code = http_client.FORBIDDEN
|
code = http_client.FORBIDDEN
|
||||||
|
|
||||||
@ -101,12 +101,12 @@ class HTTPForbidden(NotAuthorized):
|
|||||||
_msg_fmt = _("Access was denied to the following resource: %(resource)s")
|
_msg_fmt = _("Access was denied to the following resource: %(resource)s")
|
||||||
|
|
||||||
|
|
||||||
class NotFound(NimbleException):
|
class NotFound(MoganException):
|
||||||
_msg_fmt = _("Resource could not be found.")
|
_msg_fmt = _("Resource could not be found.")
|
||||||
code = http_client.NOT_FOUND
|
code = http_client.NOT_FOUND
|
||||||
|
|
||||||
|
|
||||||
class Invalid(NimbleException):
|
class Invalid(MoganException):
|
||||||
_msg_fmt = _("Unacceptable parameters.")
|
_msg_fmt = _("Unacceptable parameters.")
|
||||||
code = http_client.BAD_REQUEST
|
code = http_client.BAD_REQUEST
|
||||||
|
|
||||||
@ -117,22 +117,22 @@ class InvalidParameterValue(Invalid):
|
|||||||
_msg_fmt = _("%(err)s")
|
_msg_fmt = _("%(err)s")
|
||||||
|
|
||||||
|
|
||||||
class Conflict(NimbleException):
|
class Conflict(MoganException):
|
||||||
_msg_fmt = _('Conflict.')
|
_msg_fmt = _('Conflict.')
|
||||||
code = http_client.CONFLICT
|
code = http_client.CONFLICT
|
||||||
|
|
||||||
|
|
||||||
class TemporaryFailure(NimbleException):
|
class TemporaryFailure(MoganException):
|
||||||
_msg_fmt = _("Resource temporarily unavailable, please retry.")
|
_msg_fmt = _("Resource temporarily unavailable, please retry.")
|
||||||
code = http_client.SERVICE_UNAVAILABLE
|
code = http_client.SERVICE_UNAVAILABLE
|
||||||
|
|
||||||
|
|
||||||
class NotAcceptable(NimbleException):
|
class NotAcceptable(MoganException):
|
||||||
_msg_fmt = _("Request not acceptable.")
|
_msg_fmt = _("Request not acceptable.")
|
||||||
code = http_client.NOT_ACCEPTABLE
|
code = http_client.NOT_ACCEPTABLE
|
||||||
|
|
||||||
|
|
||||||
class ConfigInvalid(NimbleException):
|
class ConfigInvalid(MoganException):
|
||||||
_msg_fmt = _("Invalid configuration file. %(error_msg)s")
|
_msg_fmt = _("Invalid configuration file. %(error_msg)s")
|
||||||
|
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ class InvalidUUID(Invalid):
|
|||||||
msg_fmt = _("Expected a uuid but received %(uuid)s.")
|
msg_fmt = _("Expected a uuid but received %(uuid)s.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceTypeAlreadyExists(NimbleException):
|
class InstanceTypeAlreadyExists(MoganException):
|
||||||
_msg_fmt = _("InstanceType with uuid %(uuid)s already exists.")
|
_msg_fmt = _("InstanceType with uuid %(uuid)s already exists.")
|
||||||
|
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ class InstanceTypeNotFound(NotFound):
|
|||||||
msg_fmt = _("InstanceType %(type_id)s could not be found.")
|
msg_fmt = _("InstanceType %(type_id)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceAlreadyExists(NimbleException):
|
class InstanceAlreadyExists(MoganException):
|
||||||
_msg_fmt = _("Instance with name %(name)s already exists.")
|
_msg_fmt = _("Instance with name %(name)s already exists.")
|
||||||
|
|
||||||
|
|
||||||
@ -184,15 +184,15 @@ class DuplicateName(Conflict):
|
|||||||
_msg_fmt = _("A instance with name %(name)s already exists.")
|
_msg_fmt = _("A instance with name %(name)s already exists.")
|
||||||
|
|
||||||
|
|
||||||
class KeystoneUnauthorized(NimbleException):
|
class KeystoneUnauthorized(MoganException):
|
||||||
_msg_fmt = _("Not authorized in Keystone.")
|
_msg_fmt = _("Not authorized in Keystone.")
|
||||||
|
|
||||||
|
|
||||||
class KeystoneFailure(NimbleException):
|
class KeystoneFailure(MoganException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CatalogNotFound(NimbleException):
|
class CatalogNotFound(MoganException):
|
||||||
_msg_fmt = _("Service type %(service_type)s with endpoint type "
|
_msg_fmt = _("Service type %(service_type)s with endpoint type "
|
||||||
"%(endpoint_type)s not found in keystone service catalog.")
|
"%(endpoint_type)s not found in keystone service catalog.")
|
||||||
|
|
||||||
@ -205,11 +205,11 @@ class SchedulerNodeWeigherNotFound(NotFound):
|
|||||||
message = _("Scheduler Node Weigher %(weigher_name)s could not be found.")
|
message = _("Scheduler Node Weigher %(weigher_name)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class NoValidNode(NimbleException):
|
class NoValidNode(MoganException):
|
||||||
message = _("No valid node was found. %(reason)s")
|
message = _("No valid node was found. %(reason)s")
|
||||||
|
|
||||||
|
|
||||||
class TypeExtraSpecUpdateCreateFailed(NimbleException):
|
class TypeExtraSpecUpdateCreateFailed(MoganException):
|
||||||
msg_fmt = _("Instance Type %(id)s extra spec cannot be updated or"
|
msg_fmt = _("Instance Type %(id)s extra spec cannot be updated or"
|
||||||
"created after %(retries)d retries.")
|
"created after %(retries)d retries.")
|
||||||
|
|
||||||
@ -219,11 +219,11 @@ class InstanceTypeExtraSpecsNotFound(NotFound):
|
|||||||
"key %(extra_specs_key)s.")
|
"key %(extra_specs_key)s.")
|
||||||
|
|
||||||
|
|
||||||
class InterfacePlugException(NimbleException):
|
class InterfacePlugException(MoganException):
|
||||||
msg_fmt = _("Interface plugin failed")
|
msg_fmt = _("Interface plugin failed")
|
||||||
|
|
||||||
|
|
||||||
class NetworkError(NimbleException):
|
class NetworkError(MoganException):
|
||||||
_msg_fmt = _("Network operation failure.")
|
_msg_fmt = _("Network operation failure.")
|
||||||
|
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ class ValidationError(Invalid):
|
|||||||
msg_fmt = "%(detail)s"
|
msg_fmt = "%(detail)s"
|
||||||
|
|
||||||
|
|
||||||
class ImageNotAuthorized(NimbleException):
|
class ImageNotAuthorized(MoganException):
|
||||||
msg_fmt = _("Not authorized for image %(image_id)s.")
|
msg_fmt = _("Not authorized for image %(image_id)s.")
|
||||||
|
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ class ImageNotFound(NotFound):
|
|||||||
msg_fmt = _("Image %(image_id)s could not be found.")
|
msg_fmt = _("Image %(image_id)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class GlanceConnectionFailed(NimbleException):
|
class GlanceConnectionFailed(MoganException):
|
||||||
msg_fmt = _("Connection to glance host %(server)s failed: "
|
msg_fmt = _("Connection to glance host %(server)s failed: "
|
||||||
"%(reason)s")
|
"%(reason)s")
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ def _make_task_name(cls, addons=None):
|
|||||||
return base_name + extra
|
return base_name + extra
|
||||||
|
|
||||||
|
|
||||||
class NimbleTask(task.Task):
|
class MoganTask(task.Task):
|
||||||
"""The root task class for all mogan tasks.
|
"""The root task class for all mogan tasks.
|
||||||
|
|
||||||
It automatically names the given task using the module and class that
|
It automatically names the given task using the module and class that
|
||||||
@ -38,7 +38,7 @@ class NimbleTask(task.Task):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, addons=None, **kwargs):
|
def __init__(self, addons=None, **kwargs):
|
||||||
super(NimbleTask, self).__init__(self.make_name(addons), **kwargs)
|
super(MoganTask, self).__init__(self.make_name(addons), **kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def make_name(cls, addons=None):
|
def make_name(cls, addons=None):
|
||||||
|
@ -82,7 +82,7 @@ class IronicClientWrapper(object):
|
|||||||
except ironic_exc.Unauthorized:
|
except ironic_exc.Unauthorized:
|
||||||
msg = _("Unable to authenticate Ironic client.")
|
msg = _("Unable to authenticate Ironic client.")
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.NimbleException(msg)
|
raise exception.MoganException(msg)
|
||||||
|
|
||||||
return cli
|
return cli
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ from six.moves.urllib import parse # for legacy options loading only
|
|||||||
from mogan.common import exception
|
from mogan.common import exception
|
||||||
from mogan.common.i18n import _
|
from mogan.common.i18n import _
|
||||||
from mogan.common.i18n import _LE
|
from mogan.common.i18n import _LE
|
||||||
from mogan.conf import auth as nimble_auth
|
from mogan.conf import auth as mogan_auth
|
||||||
from mogan.conf import CONF
|
from mogan.conf import CONF
|
||||||
|
|
||||||
|
|
||||||
@ -72,12 +72,12 @@ def ks_exceptions(f):
|
|||||||
|
|
||||||
@ks_exceptions
|
@ks_exceptions
|
||||||
def get_session(group):
|
def get_session(group):
|
||||||
auth = nimble_auth.load_auth(CONF, group) or _get_legacy_auth()
|
auth = mogan_auth.load_auth(CONF, group) or _get_legacy_auth()
|
||||||
if not auth:
|
if not auth:
|
||||||
msg = _("Failed to load auth from either [%(new)s] or [%(old)s] "
|
msg = _("Failed to load auth from either [%(new)s] or [%(old)s] "
|
||||||
"config sections.")
|
"config sections.")
|
||||||
raise exception.ConfigInvalid(message=msg, new=group,
|
raise exception.ConfigInvalid(message=msg, new=group,
|
||||||
old=nimble_auth.LEGACY_SECTION)
|
old=mogan_auth.LEGACY_SECTION)
|
||||||
session = kaloading.load_session_from_conf_options(
|
session = kaloading.load_session_from_conf_options(
|
||||||
CONF, group, auth=auth)
|
CONF, group, auth=auth)
|
||||||
return session
|
return session
|
||||||
@ -89,7 +89,7 @@ def _get_legacy_auth():
|
|||||||
|
|
||||||
Used only to provide backward compatibility with old configs.
|
Used only to provide backward compatibility with old configs.
|
||||||
"""
|
"""
|
||||||
conf = getattr(CONF, nimble_auth.LEGACY_SECTION)
|
conf = getattr(CONF, mogan_auth.LEGACY_SECTION)
|
||||||
legacy_loader = kaloading.get_plugin_loader('password')
|
legacy_loader = kaloading.get_plugin_loader('password')
|
||||||
auth_params = {
|
auth_params = {
|
||||||
'auth_url': conf.auth_uri,
|
'auth_url': conf.auth_uri,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_context import context as nimble_context
|
from oslo_context import context as mogan_context
|
||||||
import oslo_messaging as messaging
|
import oslo_messaging as messaging
|
||||||
|
|
||||||
from mogan.common import exception
|
from mogan.common import exception
|
||||||
@ -90,7 +90,7 @@ class RequestContextSerializer(messaging.Serializer):
|
|||||||
return context.to_dict()
|
return context.to_dict()
|
||||||
|
|
||||||
def deserialize_context(self, context):
|
def deserialize_context(self, context):
|
||||||
return nimble_context.RequestContext.from_dict(context)
|
return mogan_context.RequestContext.from_dict(context)
|
||||||
|
|
||||||
|
|
||||||
def get_transport_url(url_str=None):
|
def get_transport_url(url_str=None):
|
||||||
|
@ -51,7 +51,7 @@ class RPCService(service.Service):
|
|||||||
|
|
||||||
target = messaging.Target(topic=self.topic, server=self.host)
|
target = messaging.Target(topic=self.topic, server=self.host)
|
||||||
endpoints = [self.manager]
|
endpoints = [self.manager]
|
||||||
serializer = objects_base.NimbleObjectSerializer()
|
serializer = objects_base.MoganObjectSerializer()
|
||||||
self.rpcserver = rpc.get_server(target, endpoints, serializer)
|
self.rpcserver = rpc.get_server(target, endpoints, serializer)
|
||||||
self.rpcserver.start()
|
self.rpcserver.start()
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
Please see https://alembic.readthedocs.org/en/latest/index.html for general documentation
|
Please see https://alembic.readthedocs.org/en/latest/index.html for general documentation
|
||||||
|
|
||||||
To create alembic migrations use:
|
To create alembic migrations use:
|
||||||
$ nimble-dbsync revision --message --autogenerate
|
$ mogan-dbsync revision --message --autogenerate
|
||||||
|
|
||||||
Stamp db with most recent migration version, without actually running migrations
|
Stamp db with most recent migration version, without actually running migrations
|
||||||
$ nimble-dbsync stamp --revision head
|
$ mogan-dbsync stamp --revision head
|
||||||
|
|
||||||
Upgrade can be performed by:
|
Upgrade can be performed by:
|
||||||
$ nimble-dbsync - for backward compatibility
|
$ mogan-dbsync - for backward compatibility
|
||||||
$ nimble-dbsync upgrade
|
$ mogan-dbsync upgrade
|
||||||
# nimble-dbsync upgrade --revision head
|
# mogan-dbsync upgrade --revision head
|
||||||
|
@ -43,7 +43,7 @@ def table_args():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class NimbleBase(models.TimestampMixin,
|
class MoganBase(models.TimestampMixin,
|
||||||
models.ModelBase):
|
models.ModelBase):
|
||||||
|
|
||||||
metadata = None
|
metadata = None
|
||||||
@ -55,7 +55,7 @@ class NimbleBase(models.TimestampMixin,
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
Base = declarative_base(cls=NimbleBase)
|
Base = declarative_base(cls=MoganBase)
|
||||||
|
|
||||||
|
|
||||||
class Instance(Base):
|
class Instance(Base):
|
||||||
|
@ -38,7 +38,7 @@ ACTION = 'instance:create'
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class ScheduleCreateInstanceTask(flow_utils.NimbleTask):
|
class ScheduleCreateInstanceTask(flow_utils.MoganTask):
|
||||||
"""Activates a scheduler driver and handles any subsequent failure."""
|
"""Activates a scheduler driver and handles any subsequent failure."""
|
||||||
|
|
||||||
def __init__(self, manager):
|
def __init__(self, manager):
|
||||||
@ -60,7 +60,7 @@ class ScheduleCreateInstanceTask(flow_utils.NimbleTask):
|
|||||||
instance.save()
|
instance.save()
|
||||||
|
|
||||||
|
|
||||||
class OnFailureRescheduleTask(flow_utils.NimbleTask):
|
class OnFailureRescheduleTask(flow_utils.MoganTask):
|
||||||
"""Triggers a rescheduling request to be sent when reverting occurs.
|
"""Triggers a rescheduling request to be sent when reverting occurs.
|
||||||
|
|
||||||
If rescheduling doesn't occur this task errors out the instance.
|
If rescheduling doesn't occur this task errors out the instance.
|
||||||
@ -125,14 +125,14 @@ class OnFailureRescheduleTask(flow_utils.NimbleTask):
|
|||||||
try:
|
try:
|
||||||
self._reschedule(context, cause, instance=instance, **kwargs)
|
self._reschedule(context, cause, instance=instance, **kwargs)
|
||||||
return True
|
return True
|
||||||
except exception.NimbleException:
|
except exception.MoganException:
|
||||||
LOG.exception(_LE("Instance %s: rescheduling failed"),
|
LOG.exception(_LE("Instance %s: rescheduling failed"),
|
||||||
instance.uuid)
|
instance.uuid)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class SetInstanceInfoTask(flow_utils.NimbleTask):
|
class SetInstanceInfoTask(flow_utils.MoganTask):
|
||||||
"""Set instance info to ironic node and validate it."""
|
"""Set instance info to ironic node and validate it."""
|
||||||
|
|
||||||
def __init__(self, ironicclient):
|
def __init__(self, ironicclient):
|
||||||
@ -174,7 +174,7 @@ class SetInstanceInfoTask(flow_utils.NimbleTask):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class BuildNetworkTask(flow_utils.NimbleTask):
|
class BuildNetworkTask(flow_utils.MoganTask):
|
||||||
"""Build network for the instance."""
|
"""Build network for the instance."""
|
||||||
|
|
||||||
def __init__(self, network_api, ironicclient):
|
def __init__(self, network_api, ironicclient):
|
||||||
@ -273,7 +273,7 @@ class BuildNetworkTask(flow_utils.NimbleTask):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class CreateInstanceTask(flow_utils.NimbleTask):
|
class CreateInstanceTask(flow_utils.MoganTask):
|
||||||
"""Set instance info to ironic node and validate it."""
|
"""Set instance info to ironic node and validate it."""
|
||||||
|
|
||||||
def __init__(self, ironicclient):
|
def __init__(self, ironicclient):
|
||||||
|
@ -136,7 +136,7 @@ class EngineManager(base_manager.BaseEngineManager):
|
|||||||
% {'state': node.provision_state,
|
% {'state': node.provision_state,
|
||||||
'node': node.uuid})
|
'node': node.uuid})
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.NimbleException(msg)
|
raise exception.MoganException(msg)
|
||||||
else:
|
else:
|
||||||
data['tries'] += 1
|
data['tries'] += 1
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ class EngineManager(base_manager.BaseEngineManager):
|
|||||||
except Exception:
|
except Exception:
|
||||||
msg = _("Create manager instance flow failed.")
|
msg = _("Create manager instance flow failed.")
|
||||||
LOG.exception(msg)
|
LOG.exception(msg)
|
||||||
raise exception.NimbleException(msg)
|
raise exception.MoganException(msg)
|
||||||
|
|
||||||
def _run_flow():
|
def _run_flow():
|
||||||
# This code executes create instance flow. If something goes wrong,
|
# This code executes create instance flow. If something goes wrong,
|
||||||
|
@ -44,7 +44,7 @@ class EngineAPI(object):
|
|||||||
|
|
||||||
target = messaging.Target(topic=self.topic,
|
target = messaging.Target(topic=self.topic,
|
||||||
version='1.0')
|
version='1.0')
|
||||||
serializer = objects_base.NimbleObjectSerializer()
|
serializer = objects_base.MoganObjectSerializer()
|
||||||
self.client = rpc.get_client(target,
|
self.client = rpc.get_client(target,
|
||||||
version_cap=self.RPC_API_VERSION,
|
version_cap=self.RPC_API_VERSION,
|
||||||
serializer=serializer)
|
serializer=serializer)
|
||||||
|
@ -17,8 +17,8 @@ from mogan.objects import base
|
|||||||
from mogan.objects import fields
|
from mogan.objects import fields
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class NotificationObject(base.NimbleObject):
|
class NotificationObject(base.MoganObject):
|
||||||
"""Base class for every notification related versioned object."""
|
"""Base class for every notification related versioned object."""
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
@ -32,7 +32,7 @@ class NotificationObject(base.NimbleObject):
|
|||||||
self.obj_reset_changes(recursive=False)
|
self.obj_reset_changes(recursive=False)
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_notification
|
@base.MoganObjectRegistry.register_notification
|
||||||
class EventType(NotificationObject):
|
class EventType(NotificationObject):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
@ -51,7 +51,7 @@ class EventType(NotificationObject):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class NotificationPayloadBase(NotificationObject):
|
class NotificationPayloadBase(NotificationObject):
|
||||||
"""Base class for the payload of versioned notifications."""
|
"""Base class for the payload of versioned notifications."""
|
||||||
# SCHEMA defines how to populate the payload fields. It is a dictionary
|
# SCHEMA defines how to populate the payload fields. It is a dictionary
|
||||||
@ -97,7 +97,7 @@ class NotificationPayloadBase(NotificationObject):
|
|||||||
self.obj_reset_changes(recursive=False)
|
self.obj_reset_changes(recursive=False)
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_notification
|
@base.MoganObjectRegistry.register_notification
|
||||||
class NotificationPublisher(NotificationObject):
|
class NotificationPublisher(NotificationObject):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
@ -112,7 +112,7 @@ class NotificationPublisher(NotificationObject):
|
|||||||
return cls(host=service.host, binary=service.binary)
|
return cls(host=service.host, binary=service.binary)
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class NotificationBase(NotificationObject):
|
class NotificationBase(NotificationObject):
|
||||||
"""Base class for versioned notifications.
|
"""Base class for versioned notifications.
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ def notification_sample(sample):
|
|||||||
to the notification object for documentation generation purposes.
|
to the notification object for documentation generation purposes.
|
||||||
|
|
||||||
:param sample: the path of the sample json file relative to the
|
:param sample: the path of the sample json file relative to the
|
||||||
doc/notification_samples/ directory in the nimble repository
|
doc/notification_samples/ directory in the mogan repository
|
||||||
root.
|
root.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ from mogan import objects
|
|||||||
from mogan.objects import fields as object_fields
|
from mogan.objects import fields as object_fields
|
||||||
|
|
||||||
|
|
||||||
class NimbleObjectRegistry(object_base.VersionedObjectRegistry):
|
class MoganObjectRegistry(object_base.VersionedObjectRegistry):
|
||||||
notification_classes = []
|
notification_classes = []
|
||||||
|
|
||||||
def registration_hook(self, cls, index):
|
def registration_hook(self, cls, index):
|
||||||
@ -59,7 +59,7 @@ class NimbleObjectRegistry(object_base.VersionedObjectRegistry):
|
|||||||
cls.register(notification_cls)
|
cls.register(notification_cls)
|
||||||
|
|
||||||
|
|
||||||
class NimbleObject(object_base.VersionedObject):
|
class MoganObject(object_base.VersionedObject):
|
||||||
"""Base class and object factory.
|
"""Base class and object factory.
|
||||||
|
|
||||||
This forms the base of all objects that can be remoted or instantiated
|
This forms the base of all objects that can be remoted or instantiated
|
||||||
@ -69,7 +69,7 @@ class NimbleObject(object_base.VersionedObject):
|
|||||||
as appropriate.
|
as appropriate.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
OBJ_SERIAL_NAMESPACE = 'nimble_object'
|
OBJ_SERIAL_NAMESPACE = 'mogan_object'
|
||||||
OBJ_PROJECT_NAMESPACE = 'mogan'
|
OBJ_PROJECT_NAMESPACE = 'mogan'
|
||||||
|
|
||||||
# TODO(lintan) Refactor these fields and create PersistentObject and
|
# TODO(lintan) Refactor these fields and create PersistentObject and
|
||||||
@ -85,7 +85,7 @@ class NimbleObject(object_base.VersionedObject):
|
|||||||
if hasattr(self, k))
|
if hasattr(self, k))
|
||||||
|
|
||||||
def obj_refresh(self, loaded_object):
|
def obj_refresh(self, loaded_object):
|
||||||
"""Applies updates for objects that inherit from base.NimbleObject.
|
"""Applies updates for objects that inherit from base. MoganObject.
|
||||||
|
|
||||||
Checks for updated attributes in an object. Updates are applied from
|
Checks for updated attributes in an object. Updates are applied from
|
||||||
the loaded object column by column in comparison with the current
|
the loaded object column by column in comparison with the current
|
||||||
@ -112,6 +112,6 @@ class NimbleObject(object_base.VersionedObject):
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
class NimbleObjectSerializer(object_base.VersionedObjectSerializer):
|
class MoganObjectSerializer(object_base.VersionedObjectSerializer):
|
||||||
# Base class to use for object hydration
|
# Base class to use for object hydration
|
||||||
OBJ_BASE_CLASS = NimbleObject
|
OBJ_BASE_CLASS = MoganObject
|
||||||
|
@ -111,12 +111,12 @@ class MACAddressField(object_fields.AutoTypedField):
|
|||||||
AUTO_TYPE = MACAddress()
|
AUTO_TYPE = MACAddress()
|
||||||
|
|
||||||
|
|
||||||
class BaseNimbleEnum(object_fields.Enum):
|
class BaseMoganEnum(object_fields.Enum):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(BaseNimbleEnum, self).__init__(valid_values=self.__class__.ALL)
|
super(BaseMoganEnum, self).__init__(valid_values=self.__class__.ALL)
|
||||||
|
|
||||||
|
|
||||||
class NotificationPriority(BaseNimbleEnum):
|
class NotificationPriority(BaseMoganEnum):
|
||||||
AUDIT = 'audit'
|
AUDIT = 'audit'
|
||||||
CRITICAL = 'critical'
|
CRITICAL = 'critical'
|
||||||
DEBUG = 'debug'
|
DEBUG = 'debug'
|
||||||
@ -128,7 +128,7 @@ class NotificationPriority(BaseNimbleEnum):
|
|||||||
ALL = (AUDIT, CRITICAL, DEBUG, INFO, ERROR, SAMPLE, WARN)
|
ALL = (AUDIT, CRITICAL, DEBUG, INFO, ERROR, SAMPLE, WARN)
|
||||||
|
|
||||||
|
|
||||||
class NotificationPhase(BaseNimbleEnum):
|
class NotificationPhase(BaseMoganEnum):
|
||||||
START = 'start'
|
START = 'start'
|
||||||
END = 'end'
|
END = 'end'
|
||||||
ERROR = 'error'
|
ERROR = 'error'
|
||||||
@ -136,7 +136,7 @@ class NotificationPhase(BaseNimbleEnum):
|
|||||||
ALL = (START, END, ERROR)
|
ALL = (START, END, ERROR)
|
||||||
|
|
||||||
|
|
||||||
class NotificationAction(BaseNimbleEnum):
|
class NotificationAction(BaseMoganEnum):
|
||||||
UPDATE = 'update'
|
UPDATE = 'update'
|
||||||
EXCEPTION = 'exception'
|
EXCEPTION = 'exception'
|
||||||
DELETE = 'delete'
|
DELETE = 'delete'
|
||||||
|
@ -21,8 +21,8 @@ from mogan.objects import base
|
|||||||
from mogan.objects import fields as object_fields
|
from mogan.objects import fields as object_fields
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register
|
@base.MoganObjectRegistry.register
|
||||||
class Instance(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
class Instance(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ from mogan.objects import base
|
|||||||
from mogan.objects import fields as object_fields
|
from mogan.objects import fields as object_fields
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register
|
@base.MoganObjectRegistry.register
|
||||||
class InstanceType(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
class InstanceType(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import six
|
|||||||
import testscenarios
|
import testscenarios
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from mogan.common import config as nimble_config
|
from mogan.common import config as mogan_config
|
||||||
from mogan.tests import policy_fixture
|
from mogan.tests import policy_fixture
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class TestCase(base.BaseTestCase):
|
|||||||
sqlite_synchronous=False,
|
sqlite_synchronous=False,
|
||||||
group='database')
|
group='database')
|
||||||
CONF.set_override('glance_api_servers', 'fake-glance', 'glance')
|
CONF.set_override('glance_api_servers', 'fake-glance', 'glance')
|
||||||
nimble_config.parse_args([], default_config_files=[])
|
mogan_config.parse_args([], default_config_files=[])
|
||||||
|
|
||||||
def config(self, **kw):
|
def config(self, **kw):
|
||||||
"""Override config options for a test."""
|
"""Override config options for a test."""
|
||||||
|
@ -18,7 +18,7 @@ import fixtures
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_policy import opts as policy_opts
|
from oslo_policy import opts as policy_opts
|
||||||
|
|
||||||
from mogan.common import policy as nimble_policy
|
from mogan.common import policy as mogan_policy
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
@ -39,5 +39,5 @@ class PolicyFixture(fixtures.Fixture):
|
|||||||
policy_file.write(policy_data)
|
policy_file.write(policy_data)
|
||||||
policy_opts.set_defaults(CONF)
|
policy_opts.set_defaults(CONF)
|
||||||
CONF.set_override('policy_file', self.policy_file_name, 'oslo_policy')
|
CONF.set_override('policy_file', self.policy_file_name, 'oslo_policy')
|
||||||
nimble_policy._ENFORCER = None
|
mogan_policy._ENFORCER = None
|
||||||
self.addCleanup(nimble_policy.get_enforcer().clear)
|
self.addCleanup(mogan_policy.get_enforcer().clear)
|
||||||
|
@ -32,7 +32,7 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def skip_checks(cls):
|
def skip_checks(cls):
|
||||||
super(BaseBaremetalComputeTest, cls).skip_checks()
|
super(BaseBaremetalComputeTest, cls).skip_checks()
|
||||||
if not CONF.service_available.nimble_plugin:
|
if not CONF.service_available.mogan_plugin:
|
||||||
raise cls.skipException("Mogan support is required")
|
raise cls.skipException("Mogan support is required")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -28,7 +28,7 @@ class BaremetalComputeAPITest(base.BaseBaremetalComputeTest):
|
|||||||
def resource_setup(cls):
|
def resource_setup(cls):
|
||||||
super(BaremetalComputeAPITest, cls).resource_setup()
|
super(BaremetalComputeAPITest, cls).resource_setup()
|
||||||
for i in six.moves.xrange(3):
|
for i in six.moves.xrange(3):
|
||||||
body = {"name": data_utils.rand_name('nimble_instance_type'),
|
body = {"name": data_utils.rand_name('mogan_instance_type'),
|
||||||
"description": "mogan instance type description",
|
"description": "mogan instance type description",
|
||||||
'is_public': bool(data_utils.rand_int_id(0, 1))}
|
'is_public': bool(data_utils.rand_int_id(0, 1))}
|
||||||
resp = cls.baremetal_compute_client.create_instance_type(**body)
|
resp = cls.baremetal_compute_client.create_instance_type(**body)
|
||||||
@ -50,11 +50,11 @@ class BaremetalComputeAPITest(base.BaseBaremetalComputeTest):
|
|||||||
@test.idempotent_id('f6ad64af-abc9-456c-9109-bc27cd9af635')
|
@test.idempotent_id('f6ad64af-abc9-456c-9109-bc27cd9af635')
|
||||||
def test_type_create_show_delete(self):
|
def test_type_create_show_delete(self):
|
||||||
# Create an instance type
|
# Create an instance type
|
||||||
body = {"name": 'nimble_type_create',
|
body = {"name": 'mogan_type_create',
|
||||||
"description": "mogan instance type description",
|
"description": "mogan instance type description",
|
||||||
'is_public': True}
|
'is_public': True}
|
||||||
resp = self.baremetal_compute_client.create_instance_type(**body)
|
resp = self.baremetal_compute_client.create_instance_type(**body)
|
||||||
self.assertEqual('nimble_type_create', resp['name'])
|
self.assertEqual('mogan_type_create', resp['name'])
|
||||||
self.assertEqual('mogan instance type description',
|
self.assertEqual('mogan instance type description',
|
||||||
resp['description'])
|
resp['description'])
|
||||||
self.assertEqual(True, resp['is_public'])
|
self.assertEqual(True, resp['is_public'])
|
||||||
@ -62,7 +62,7 @@ class BaremetalComputeAPITest(base.BaseBaremetalComputeTest):
|
|||||||
self.assertIn('extra_specs', resp)
|
self.assertIn('extra_specs', resp)
|
||||||
self.assertIn('links', resp)
|
self.assertIn('links', resp)
|
||||||
resp = self.baremetal_compute_client.show_instance_type(resp['uuid'])
|
resp = self.baremetal_compute_client.show_instance_type(resp['uuid'])
|
||||||
self.assertEqual('nimble_type_create', resp['name'])
|
self.assertEqual('mogan_type_create', resp['name'])
|
||||||
self.assertEqual('mogan instance type description',
|
self.assertEqual('mogan instance type description',
|
||||||
resp['description'])
|
resp['description'])
|
||||||
self.assertEqual(True, resp['is_public'])
|
self.assertEqual(True, resp['is_public'])
|
||||||
|
@ -19,7 +19,7 @@ service_available_group = cfg.OptGroup(name="service_available",
|
|||||||
title="Available OpenStack Services")
|
title="Available OpenStack Services")
|
||||||
|
|
||||||
ServiceAvailableGroup = [
|
ServiceAvailableGroup = [
|
||||||
cfg.BoolOpt("nimble_plugin",
|
cfg.BoolOpt("mogan_plugin",
|
||||||
default=True,
|
default=True,
|
||||||
help="Whether or not Mogan is expected to be available"),
|
help="Whether or not Mogan is expected to be available"),
|
||||||
]
|
]
|
||||||
|
@ -17,11 +17,11 @@ from mogan.common import exception
|
|||||||
from mogan.tests import base
|
from mogan.tests import base
|
||||||
|
|
||||||
|
|
||||||
class TestNimbleException(base.TestCase):
|
class TestMoganException(base.TestCase):
|
||||||
def test____init__(self):
|
def test____init__(self):
|
||||||
expected = b'\xc3\xa9\xe0\xaf\xb2\xe0\xbe\x84'
|
expected = b'\xc3\xa9\xe0\xaf\xb2\xe0\xbe\x84'
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
expected = expected.decode('utf-8')
|
expected = expected.decode('utf-8')
|
||||||
message = six.unichr(233) + six.unichr(0x0bf2) + six.unichr(3972)
|
message = six.unichr(233) + six.unichr(0x0bf2) + six.unichr(3972)
|
||||||
exc = exception.NimbleException(message)
|
exc = exception.MoganException(message)
|
||||||
self.assertEqual(expected, exc.__str__())
|
self.assertEqual(expected, exc.__str__())
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_context import context as nimble_context
|
from oslo_context import context as mogan_context
|
||||||
import oslo_messaging as messaging
|
import oslo_messaging as messaging
|
||||||
|
|
||||||
from mogan.common import rpc
|
from mogan.common import rpc
|
||||||
@ -72,7 +72,7 @@ class TestRequestContextSerializer(base.TestCase):
|
|||||||
|
|
||||||
self.mock_serializer = mock.MagicMock()
|
self.mock_serializer = mock.MagicMock()
|
||||||
self.serializer = rpc.RequestContextSerializer(self.mock_serializer)
|
self.serializer = rpc.RequestContextSerializer(self.mock_serializer)
|
||||||
self.context = nimble_context.RequestContext()
|
self.context = mogan_context.RequestContext()
|
||||||
self.entity = {'foo': 'bar'}
|
self.entity = {'foo': 'bar'}
|
||||||
|
|
||||||
def test_serialize_entity(self):
|
def test_serialize_entity(self):
|
||||||
|
@ -39,7 +39,7 @@ class TestRPCService(base.TestCase):
|
|||||||
constants.MANAGER_TOPIC)
|
constants.MANAGER_TOPIC)
|
||||||
|
|
||||||
@mock.patch.object(oslo_messaging, 'Target', autospec=True)
|
@mock.patch.object(oslo_messaging, 'Target', autospec=True)
|
||||||
@mock.patch.object(objects_base, 'NimbleObjectSerializer', autospec=True)
|
@mock.patch.object(objects_base, 'MoganObjectSerializer', autospec=True)
|
||||||
@mock.patch.object(rpc, 'get_server', autospec=True)
|
@mock.patch.object(rpc, 'get_server', autospec=True)
|
||||||
@mock.patch.object(manager.EngineManager, 'init_host', autospec=True)
|
@mock.patch.object(manager.EngineManager, 'init_host', autospec=True)
|
||||||
def test_start(self, mock_init_method, mock_rpc, mock_ios, mock_target):
|
def test_start(self, mock_init_method, mock_rpc, mock_ios, mock_target):
|
||||||
@ -55,7 +55,7 @@ class TestRPCService(base.TestCase):
|
|||||||
class TestWSGIService(base.TestCase):
|
class TestWSGIService(base.TestCase):
|
||||||
@mock.patch.object(service.wsgi, 'Server')
|
@mock.patch.object(service.wsgi, 'Server')
|
||||||
def test_workers_set_default(self, wsgi_server):
|
def test_workers_set_default(self, wsgi_server):
|
||||||
service_name = "nimble_api"
|
service_name = "mogan_api"
|
||||||
test_service = service.WSGIService(service_name)
|
test_service = service.WSGIService(service_name)
|
||||||
self.assertEqual(processutils.get_worker_count(),
|
self.assertEqual(processutils.get_worker_count(),
|
||||||
test_service.workers)
|
test_service.workers)
|
||||||
@ -68,13 +68,13 @@ class TestWSGIService(base.TestCase):
|
|||||||
@mock.patch.object(service.wsgi, 'Server')
|
@mock.patch.object(service.wsgi, 'Server')
|
||||||
def test_workers_set_correct_setting(self, wsgi_server):
|
def test_workers_set_correct_setting(self, wsgi_server):
|
||||||
self.config(api_workers=8, group='api')
|
self.config(api_workers=8, group='api')
|
||||||
test_service = service.WSGIService("nimble_api")
|
test_service = service.WSGIService("mogan_api")
|
||||||
self.assertEqual(8, test_service.workers)
|
self.assertEqual(8, test_service.workers)
|
||||||
|
|
||||||
@mock.patch.object(service.wsgi, 'Server')
|
@mock.patch.object(service.wsgi, 'Server')
|
||||||
def test_workers_set_zero_setting(self, wsgi_server):
|
def test_workers_set_zero_setting(self, wsgi_server):
|
||||||
self.config(api_workers=0, group='api')
|
self.config(api_workers=0, group='api')
|
||||||
test_service = service.WSGIService("nimble_api")
|
test_service = service.WSGIService("mogan_api")
|
||||||
self.assertEqual(processutils.get_worker_count(), test_service.workers)
|
self.assertEqual(processutils.get_worker_count(), test_service.workers)
|
||||||
|
|
||||||
@mock.patch.object(service.wsgi, 'Server')
|
@mock.patch.object(service.wsgi, 'Server')
|
||||||
@ -82,14 +82,14 @@ class TestWSGIService(base.TestCase):
|
|||||||
self.config(api_workers=-2, group='api')
|
self.config(api_workers=-2, group='api')
|
||||||
self.assertRaises(exception.ConfigInvalid,
|
self.assertRaises(exception.ConfigInvalid,
|
||||||
service.WSGIService,
|
service.WSGIService,
|
||||||
'nimble_api')
|
'mogan_api')
|
||||||
self.assertFalse(wsgi_server.called)
|
self.assertFalse(wsgi_server.called)
|
||||||
|
|
||||||
@mock.patch.object(service.wsgi, 'Server')
|
@mock.patch.object(service.wsgi, 'Server')
|
||||||
def test_wsgi_service_with_ssl_enabled(self, wsgi_server):
|
def test_wsgi_service_with_ssl_enabled(self, wsgi_server):
|
||||||
self.config(enable_ssl_api=True, group='api')
|
self.config(enable_ssl_api=True, group='api')
|
||||||
service_name = 'nimble_api'
|
service_name = 'mogan_api'
|
||||||
srv = service.WSGIService('nimble_api', CONF.api.enable_ssl_api)
|
srv = service.WSGIService('mogan_api', CONF.api.enable_ssl_api)
|
||||||
wsgi_server.assert_called_once_with(CONF, service_name,
|
wsgi_server.assert_called_once_with(CONF, service_name,
|
||||||
srv.app,
|
srv.app,
|
||||||
host='0.0.0.0',
|
host='0.0.0.0',
|
||||||
|
@ -16,7 +16,7 @@ from keystoneauth1 import identity as kaidentity
|
|||||||
from keystoneauth1 import loading as kaloading
|
from keystoneauth1 import loading as kaloading
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from mogan.conf import auth as nimble_auth
|
from mogan.conf import auth as mogan_auth
|
||||||
from mogan.tests import base
|
from mogan.tests import base
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ class AuthConfTestCase(base.TestCase):
|
|||||||
group='keystone')
|
group='keystone')
|
||||||
self.test_group = 'test_group'
|
self.test_group = 'test_group'
|
||||||
self.cfg_fixture.conf.register_group(cfg.OptGroup(self.test_group))
|
self.cfg_fixture.conf.register_group(cfg.OptGroup(self.test_group))
|
||||||
nimble_auth.register_auth_opts(self.cfg_fixture.conf, self.test_group)
|
mogan_auth.register_auth_opts(self.cfg_fixture.conf, self.test_group)
|
||||||
self.config(auth_type='password',
|
self.config(auth_type='password',
|
||||||
group=self.test_group)
|
group=self.test_group)
|
||||||
# NOTE(pas-ha) this is due to auth_plugin options
|
# NOTE(pas-ha) this is due to auth_plugin options
|
||||||
@ -44,7 +44,7 @@ class AuthConfTestCase(base.TestCase):
|
|||||||
group=self.test_group)
|
group=self.test_group)
|
||||||
|
|
||||||
def test_add_auth_opts(self):
|
def test_add_auth_opts(self):
|
||||||
opts = nimble_auth.add_auth_opts([])
|
opts = mogan_auth.add_auth_opts([])
|
||||||
# check that there is no duplicates
|
# check that there is no duplicates
|
||||||
names = {o.dest for o in opts}
|
names = {o.dest for o in opts}
|
||||||
self.assertEqual(len(names), len(opts))
|
self.assertEqual(len(names), len(opts))
|
||||||
@ -56,7 +56,7 @@ class AuthConfTestCase(base.TestCase):
|
|||||||
self.assertTrue(expected.issubset(names))
|
self.assertTrue(expected.issubset(names))
|
||||||
|
|
||||||
def test_load_auth(self):
|
def test_load_auth(self):
|
||||||
auth = nimble_auth.load_auth(self.cfg_fixture.conf, self.test_group)
|
auth = mogan_auth.load_auth(self.cfg_fixture.conf, self.test_group)
|
||||||
# NOTE(pas-ha) 'password' auth_plugin is used
|
# NOTE(pas-ha) 'password' auth_plugin is used
|
||||||
self.assertIsInstance(auth, kaidentity.generic.password.Password)
|
self.assertIsInstance(auth, kaidentity.generic.password.Password)
|
||||||
self.assertEqual('http://127.0.0.1:9898', auth.auth_url)
|
self.assertEqual('http://127.0.0.1:9898', auth.auth_url)
|
||||||
@ -66,5 +66,5 @@ class AuthConfTestCase(base.TestCase):
|
|||||||
# so when we set the required auth_url to None,
|
# so when we set the required auth_url to None,
|
||||||
# MissingOption is raised
|
# MissingOption is raised
|
||||||
self.config(auth_url=None, group=self.test_group)
|
self.config(auth_url=None, group=self.test_group)
|
||||||
self.assertIsNone(nimble_auth.load_auth(
|
self.assertIsNone(mogan_auth.load_auth(
|
||||||
self.cfg_fixture.conf, self.test_group))
|
self.cfg_fixture.conf, self.test_group))
|
||||||
|
@ -32,8 +32,8 @@ class FakeFilterScheduler(filter_scheduler.FilterScheduler):
|
|||||||
self.node_manager = node_manager.NodeManager()
|
self.node_manager = node_manager.NodeManager()
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register
|
@base.MoganObjectRegistry.register
|
||||||
class FakeNode(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
class FakeNode(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||||
fields = {
|
fields = {
|
||||||
'id': object_fields.IntegerField(),
|
'id': object_fields.IntegerField(),
|
||||||
'uuid': object_fields.UUIDField(nullable=True),
|
'uuid': object_fields.UUIDField(nullable=True),
|
||||||
|
@ -101,7 +101,7 @@ class ManageInstanceTestCase(mgr_utils.ServiceSetUpMixin,
|
|||||||
refresh_cache_mock.side_effect = None
|
refresh_cache_mock.side_effect = None
|
||||||
self._start_service()
|
self._start_service()
|
||||||
|
|
||||||
self.assertRaises(exception.NimbleException,
|
self.assertRaises(exception.MoganException,
|
||||||
self.service._destroy_instance,
|
self.service._destroy_instance,
|
||||||
self.context, instance)
|
self.context, instance)
|
||||||
self._stop_service()
|
self._stop_service()
|
||||||
|
@ -21,8 +21,8 @@ from mogan.tests import base as test_base
|
|||||||
|
|
||||||
|
|
||||||
class TestNotificationBase(test_base.TestCase):
|
class TestNotificationBase(test_base.TestCase):
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestObject(base.NimbleObject):
|
class TestObject(base.MoganObject):
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
fields = {
|
fields = {
|
||||||
'field_1': fields.StringField(),
|
'field_1': fields.StringField(),
|
||||||
@ -30,7 +30,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
'not_important_field': fields.IntegerField(),
|
'not_important_field': fields.IntegerField(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestNotificationPayload(notification.NotificationPayloadBase):
|
class TestNotificationPayload(notification.NotificationPayloadBase):
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
super(TestNotificationBase.TestNotificationPayload,
|
super(TestNotificationBase.TestNotificationPayload,
|
||||||
self).populate_schema(source_field=source_field)
|
self).populate_schema(source_field=source_field)
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestNotificationPayloadEmptySchema(
|
class TestNotificationPayloadEmptySchema(
|
||||||
notification.NotificationPayloadBase):
|
notification.NotificationPayloadBase):
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
@ -60,14 +60,14 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
|
|
||||||
@notification.notification_sample('test-update-1.json')
|
@notification.notification_sample('test-update-1.json')
|
||||||
@notification.notification_sample('test-update-2.json')
|
@notification.notification_sample('test-update-2.json')
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestNotification(notification.NotificationBase):
|
class TestNotification(notification.NotificationBase):
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
fields = {
|
fields = {
|
||||||
'payload': fields.ObjectField('TestNotificationPayload')
|
'payload': fields.ObjectField('TestNotificationPayload')
|
||||||
}
|
}
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestNotificationEmptySchema(notification.NotificationBase):
|
class TestNotificationEmptySchema(notification.NotificationBase):
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
fields = {
|
fields = {
|
||||||
@ -75,13 +75,13 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected_payload = {
|
expected_payload = {
|
||||||
'nimble_object.name': 'TestNotificationPayload',
|
'mogan_object.name': 'TestNotificationPayload',
|
||||||
'nimble_object.data': {
|
'mogan_object.data': {
|
||||||
'extra_field': 'test string',
|
'extra_field': 'test string',
|
||||||
'field_1': 'test1',
|
'field_1': 'test1',
|
||||||
'field_2': 42},
|
'field_2': 42},
|
||||||
'nimble_object.version': '1.0',
|
'mogan_object.version': '1.0',
|
||||||
'nimble_object.namespace': 'mogan'}
|
'mogan_object.namespace': 'mogan'}
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestNotificationBase, self).setUp()
|
super(TestNotificationBase, self).setUp()
|
||||||
@ -99,7 +99,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
action=fields.NotificationAction.UPDATE,
|
action=fields.NotificationAction.UPDATE,
|
||||||
phase=fields.NotificationPhase.START),
|
phase=fields.NotificationPhase.START),
|
||||||
publisher=notification.NotificationPublisher(
|
publisher=notification.NotificationPublisher(
|
||||||
host='fake-host', binary='nimble-fake'),
|
host='fake-host', binary='mogan-fake'),
|
||||||
priority=fields.NotificationPriority.INFO,
|
priority=fields.NotificationPriority.INFO,
|
||||||
payload=self.payload)
|
payload=self.payload)
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
expected_event_type,
|
expected_event_type,
|
||||||
expected_payload):
|
expected_payload):
|
||||||
mock_notifier.prepare.assert_called_once_with(
|
mock_notifier.prepare.assert_called_once_with(
|
||||||
publisher_id='nimble-fake:fake-host')
|
publisher_id='mogan-fake:fake-host')
|
||||||
mock_notify = mock_notifier.prepare.return_value.info
|
mock_notify = mock_notifier.prepare.return_value.info
|
||||||
self.assertTrue(mock_notify.called)
|
self.assertTrue(mock_notify.called)
|
||||||
self.assertEqual(mock_notify.call_args[0][0], mock_context)
|
self.assertEqual(mock_notify.call_args[0][0], mock_context)
|
||||||
@ -135,7 +135,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
object='test_object',
|
object='test_object',
|
||||||
action=fields.NotificationAction.UPDATE),
|
action=fields.NotificationAction.UPDATE),
|
||||||
publisher=notification.NotificationPublisher(
|
publisher=notification.NotificationPublisher(
|
||||||
host='fake-host', binary='nimble-fake'),
|
host='fake-host', binary='mogan-fake'),
|
||||||
priority=fields.NotificationPriority.INFO,
|
priority=fields.NotificationPriority.INFO,
|
||||||
payload=self.payload)
|
payload=self.payload)
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
object='test_object',
|
object='test_object',
|
||||||
action=fields.NotificationAction.UPDATE),
|
action=fields.NotificationAction.UPDATE),
|
||||||
publisher=notification.NotificationPublisher(
|
publisher=notification.NotificationPublisher(
|
||||||
host='fake-host', binary='nimble-fake'),
|
host='fake-host', binary='mogan-fake'),
|
||||||
priority=fields.NotificationPriority.INFO,
|
priority=fields.NotificationPriority.INFO,
|
||||||
payload=self.payload)
|
payload=self.payload)
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
object='test_object',
|
object='test_object',
|
||||||
action=fields.NotificationAction.UPDATE),
|
action=fields.NotificationAction.UPDATE),
|
||||||
publisher=notification.NotificationPublisher(
|
publisher=notification.NotificationPublisher(
|
||||||
host='fake-host', binary='nimble-fake'),
|
host='fake-host', binary='mogan-fake'),
|
||||||
priority=fields.NotificationPriority.INFO,
|
priority=fields.NotificationPriority.INFO,
|
||||||
payload=non_populated_payload)
|
payload=non_populated_payload)
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
object='test_object',
|
object='test_object',
|
||||||
action=fields.NotificationAction.UPDATE),
|
action=fields.NotificationAction.UPDATE),
|
||||||
publisher=notification.NotificationPublisher(
|
publisher=notification.NotificationPublisher(
|
||||||
host='fake-host', binary='nimble-fake'),
|
host='fake-host', binary='mogan-fake'),
|
||||||
priority=fields.NotificationPriority.INFO,
|
priority=fields.NotificationPriority.INFO,
|
||||||
payload=non_populated_payload)
|
payload=non_populated_payload)
|
||||||
|
|
||||||
@ -209,10 +209,10 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
mock_context,
|
mock_context,
|
||||||
expected_event_type='test_object.update',
|
expected_event_type='test_object.update',
|
||||||
expected_payload={
|
expected_payload={
|
||||||
'nimble_object.name': 'TestNotificationPayloadEmptySchema',
|
'mogan_object.name': 'TestNotificationPayloadEmptySchema',
|
||||||
'nimble_object.data': {'extra_field': u'test string'},
|
'mogan_object.data': {'extra_field': u'test string'},
|
||||||
'nimble_object.version': '1.0',
|
'mogan_object.version': '1.0',
|
||||||
'nimble_object.namespace': 'mogan'})
|
'mogan_object.namespace': 'mogan'})
|
||||||
|
|
||||||
def test_sample_decorator(self):
|
def test_sample_decorator(self):
|
||||||
self.assertEqual(2, len(self.TestNotification.samples))
|
self.assertEqual(2, len(self.TestNotification.samples))
|
||||||
|
@ -30,8 +30,8 @@ from mogan.tests import base as test_base
|
|||||||
gettext.install('mogan')
|
gettext.install('mogan')
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register
|
@base.MoganObjectRegistry.register
|
||||||
class MyObj(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
class MyObj(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||||
VERSION = '1.1'
|
VERSION = '1.1'
|
||||||
|
|
||||||
fields = {'foo': fields.IntegerField(),
|
fields = {'foo': fields.IntegerField(),
|
||||||
@ -88,40 +88,40 @@ class MyObj2(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestSubclassedObject(MyObj):
|
class TestSubclassedObject(MyObj):
|
||||||
fields = {'new_field': fields.StringField()}
|
fields = {'new_field': fields.StringField()}
|
||||||
|
|
||||||
|
|
||||||
class _TestObject(object):
|
class _TestObject(object):
|
||||||
def test_hydration_type_error(self):
|
def test_hydration_type_error(self):
|
||||||
primitive = {'nimble_object.name': 'MyObj',
|
primitive = {'mogan_object.name': 'MyObj',
|
||||||
'nimble_object.namespace': 'mogan',
|
'mogan_object.namespace': 'mogan',
|
||||||
'nimble_object.version': '1.5',
|
'mogan_object.version': '1.5',
|
||||||
'nimble_object.data': {'foo': 'a'}}
|
'mogan_object.data': {'foo': 'a'}}
|
||||||
self.assertRaises(ValueError, MyObj.obj_from_primitive, primitive)
|
self.assertRaises(ValueError, MyObj.obj_from_primitive, primitive)
|
||||||
|
|
||||||
def test_hydration(self):
|
def test_hydration(self):
|
||||||
primitive = {'nimble_object.name': 'MyObj',
|
primitive = {'mogan_object.name': 'MyObj',
|
||||||
'nimble_object.namespace': 'mogan',
|
'mogan_object.namespace': 'mogan',
|
||||||
'nimble_object.version': '1.5',
|
'mogan_object.version': '1.5',
|
||||||
'nimble_object.data': {'foo': 1}}
|
'mogan_object.data': {'foo': 1}}
|
||||||
obj = MyObj.obj_from_primitive(primitive)
|
obj = MyObj.obj_from_primitive(primitive)
|
||||||
self.assertEqual(1, obj.foo)
|
self.assertEqual(1, obj.foo)
|
||||||
|
|
||||||
def test_hydration_bad_ns(self):
|
def test_hydration_bad_ns(self):
|
||||||
primitive = {'nimble_object.name': 'MyObj',
|
primitive = {'mogan_object.name': 'MyObj',
|
||||||
'nimble_object.namespace': 'foo',
|
'mogan_object.namespace': 'foo',
|
||||||
'nimble_object.version': '1.5',
|
'mogan_object.version': '1.5',
|
||||||
'nimble_object.data': {'foo': 1}}
|
'mogan_object.data': {'foo': 1}}
|
||||||
self.assertRaises(object_exception.UnsupportedObjectError,
|
self.assertRaises(object_exception.UnsupportedObjectError,
|
||||||
MyObj.obj_from_primitive, primitive)
|
MyObj.obj_from_primitive, primitive)
|
||||||
|
|
||||||
def test_dehydration(self):
|
def test_dehydration(self):
|
||||||
expected = {'nimble_object.name': 'MyObj',
|
expected = {'mogan_object.name': 'MyObj',
|
||||||
'nimble_object.namespace': 'mogan',
|
'mogan_object.namespace': 'mogan',
|
||||||
'nimble_object.version': '1.5',
|
'mogan_object.version': '1.5',
|
||||||
'nimble_object.data': {'foo': 1}}
|
'mogan_object.data': {'foo': 1}}
|
||||||
obj = MyObj(self.context)
|
obj = MyObj(self.context)
|
||||||
obj.foo = 1
|
obj.foo = 1
|
||||||
obj.obj_reset_changes()
|
obj.obj_reset_changes()
|
||||||
@ -153,8 +153,8 @@ class _TestObject(object):
|
|||||||
self.assertEqual('loaded!', obj.bar)
|
self.assertEqual('loaded!', obj.bar)
|
||||||
|
|
||||||
def test_load_in_base(self):
|
def test_load_in_base(self):
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class Foo(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
class Foo(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||||
fields = {'foobar': fields.IntegerField()}
|
fields = {'foobar': fields.IntegerField()}
|
||||||
obj = Foo(self.context)
|
obj = Foo(self.context)
|
||||||
|
|
||||||
@ -167,11 +167,11 @@ class _TestObject(object):
|
|||||||
obj.foo = 1
|
obj.foo = 1
|
||||||
obj.obj_reset_changes()
|
obj.obj_reset_changes()
|
||||||
self.assertEqual('loaded!', obj.bar)
|
self.assertEqual('loaded!', obj.bar)
|
||||||
expected = {'nimble_object.name': 'MyObj',
|
expected = {'mogan_object.name': 'MyObj',
|
||||||
'nimble_object.namespace': 'mogan',
|
'mogan_object.namespace': 'mogan',
|
||||||
'nimble_object.version': '1.5',
|
'mogan_object.version': '1.5',
|
||||||
'nimble_object.changes': ['bar'],
|
'mogan_object.changes': ['bar'],
|
||||||
'nimble_object.data': {'foo': 1,
|
'mogan_object.data': {'foo': 1,
|
||||||
'bar': 'loaded!'}}
|
'bar': 'loaded!'}}
|
||||||
self.assertEqual(expected, obj.obj_to_primitive())
|
self.assertEqual(expected, obj.obj_to_primitive())
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ class _TestObject(object):
|
|||||||
obj.foo = 123
|
obj.foo = 123
|
||||||
self.assertEqual(set(['foo']), obj.obj_what_changed())
|
self.assertEqual(set(['foo']), obj.obj_what_changed())
|
||||||
primitive = obj.obj_to_primitive()
|
primitive = obj.obj_to_primitive()
|
||||||
self.assertIn('nimble_object.changes', primitive)
|
self.assertIn('mogan_object.changes', primitive)
|
||||||
obj2 = MyObj.obj_from_primitive(primitive)
|
obj2 = MyObj.obj_from_primitive(primitive)
|
||||||
self.assertEqual(set(['foo']), obj2.obj_what_changed())
|
self.assertEqual(set(['foo']), obj2.obj_what_changed())
|
||||||
obj2.obj_reset_changes()
|
obj2.obj_reset_changes()
|
||||||
@ -188,7 +188,7 @@ class _TestObject(object):
|
|||||||
|
|
||||||
def test_unknown_objtype(self):
|
def test_unknown_objtype(self):
|
||||||
self.assertRaises(object_exception.UnsupportedObjectError,
|
self.assertRaises(object_exception.UnsupportedObjectError,
|
||||||
base.NimbleObject.obj_class_from_name, 'foo', '1.0')
|
base.MoganObject.obj_class_from_name, 'foo', '1.0')
|
||||||
|
|
||||||
def test_with_alternate_context(self):
|
def test_with_alternate_context(self):
|
||||||
ctxt1 = context.RequestContext('foo', 'foo')
|
ctxt1 = context.RequestContext('foo', 'foo')
|
||||||
@ -255,21 +255,21 @@ class _TestObject(object):
|
|||||||
obj = MyObj(self.context)
|
obj = MyObj(self.context)
|
||||||
obj.created_at = dt
|
obj.created_at = dt
|
||||||
obj.updated_at = dt
|
obj.updated_at = dt
|
||||||
expected = {'nimble_object.name': 'MyObj',
|
expected = {'mogan_object.name': 'MyObj',
|
||||||
'nimble_object.namespace': 'mogan',
|
'mogan_object.namespace': 'mogan',
|
||||||
'nimble_object.version': '1.5',
|
'mogan_object.version': '1.5',
|
||||||
'nimble_object.changes':
|
'mogan_object.changes':
|
||||||
['created_at', 'updated_at'],
|
['created_at', 'updated_at'],
|
||||||
'nimble_object.data':
|
'mogan_object.data':
|
||||||
{'created_at': datatime.stringify(dt),
|
{'created_at': datatime.stringify(dt),
|
||||||
'updated_at': datatime.stringify(dt),
|
'updated_at': datatime.stringify(dt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actual = obj.obj_to_primitive()
|
actual = obj.obj_to_primitive()
|
||||||
# nimble_object.changes is built from a set and order is undefined
|
# mogan_object.changes is built from a set and order is undefined
|
||||||
self.assertEqual(sorted(expected['nimble_object.changes']),
|
self.assertEqual(sorted(expected['mogan_object.changes']),
|
||||||
sorted(actual['nimble_object.changes']))
|
sorted(actual['mogan_object.changes']))
|
||||||
del expected['nimble_object.changes'], actual['nimble_object.changes']
|
del expected['mogan_object.changes'], actual['mogan_object.changes']
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
def test_contains(self):
|
def test_contains(self):
|
||||||
@ -303,7 +303,7 @@ class _TestObject(object):
|
|||||||
self.assertRaises(AttributeError, obj.get, 'nothing', 3)
|
self.assertRaises(AttributeError, obj.get, 'nothing', 3)
|
||||||
|
|
||||||
def test_object_inheritance(self):
|
def test_object_inheritance(self):
|
||||||
base_fields = list(base.NimbleObject.fields)
|
base_fields = list(base.MoganObject.fields)
|
||||||
myobj_fields = ['foo', 'bar', 'missing'] + base_fields
|
myobj_fields = ['foo', 'bar', 'missing'] + base_fields
|
||||||
myobj3_fields = ['new_field']
|
myobj3_fields = ['new_field']
|
||||||
self.assertTrue(issubclass(TestSubclassedObject, MyObj))
|
self.assertTrue(issubclass(TestSubclassedObject, MyObj))
|
||||||
@ -325,8 +325,8 @@ class _TestObject(object):
|
|||||||
self.assertEqual({}, obj.obj_get_changes())
|
self.assertEqual({}, obj.obj_get_changes())
|
||||||
|
|
||||||
def test_obj_fields(self):
|
def test_obj_fields(self):
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestObj(base.NimbleObject,
|
class TestObj(base.MoganObject,
|
||||||
object_base.VersionedObjectDictCompat):
|
object_base.VersionedObjectDictCompat):
|
||||||
fields = {'foo': fields.IntegerField()}
|
fields = {'foo': fields.IntegerField()}
|
||||||
obj_extra_fields = ['bar']
|
obj_extra_fields = ['bar']
|
||||||
@ -340,8 +340,8 @@ class _TestObject(object):
|
|||||||
set(obj.obj_fields))
|
set(obj.obj_fields))
|
||||||
|
|
||||||
def test_refresh_object(self):
|
def test_refresh_object(self):
|
||||||
@base.NimbleObjectRegistry.register_if(False)
|
@base.MoganObjectRegistry.register_if(False)
|
||||||
class TestObj(base.NimbleObject,
|
class TestObj(base.MoganObject,
|
||||||
object_base.VersionedObjectDictCompat):
|
object_base.VersionedObjectDictCompat):
|
||||||
fields = {'foo': fields.IntegerField(),
|
fields = {'foo': fields.IntegerField(),
|
||||||
'bar': fields.StringField()}
|
'bar': fields.StringField()}
|
||||||
@ -363,7 +363,7 @@ class _TestObject(object):
|
|||||||
self.assertEqual(set(['foo', 'bar']), obj.obj_what_changed())
|
self.assertEqual(set(['foo', 'bar']), obj.obj_what_changed())
|
||||||
|
|
||||||
def test_assign_value_without_DictCompat(self):
|
def test_assign_value_without_DictCompat(self):
|
||||||
class TestObj(base.NimbleObject):
|
class TestObj(base.MoganObject):
|
||||||
fields = {'foo': fields.IntegerField(),
|
fields = {'foo': fields.IntegerField(),
|
||||||
'bar': fields.StringField()}
|
'bar': fields.StringField()}
|
||||||
obj = TestObj(self.context)
|
obj = TestObj(self.context)
|
||||||
@ -392,7 +392,7 @@ expected_object_fingerprints = {
|
|||||||
class TestObjectVersions(test_base.TestCase):
|
class TestObjectVersions(test_base.TestCase):
|
||||||
|
|
||||||
def test_object_version_check(self):
|
def test_object_version_check(self):
|
||||||
classes = base.NimbleObjectRegistry.obj_classes()
|
classes = base.MoganObjectRegistry.obj_classes()
|
||||||
checker = object_fixture.ObjectVersionChecker(obj_classes=classes)
|
checker = object_fixture.ObjectVersionChecker(obj_classes=classes)
|
||||||
# Compute the difference between actual fingerprints and
|
# Compute the difference between actual fingerprints and
|
||||||
# expect fingerprints. expect = actual = {} if there is no change.
|
# expect fingerprints. expect = actual = {} if there is no change.
|
||||||
@ -407,23 +407,23 @@ class TestObjectVersions(test_base.TestCase):
|
|||||||
class TestObjectSerializer(test_base.TestCase):
|
class TestObjectSerializer(test_base.TestCase):
|
||||||
|
|
||||||
def test_object_serialization(self):
|
def test_object_serialization(self):
|
||||||
ser = base.NimbleObjectSerializer()
|
ser = base.MoganObjectSerializer()
|
||||||
obj = MyObj(self.context)
|
obj = MyObj(self.context)
|
||||||
primitive = ser.serialize_entity(self.context, obj)
|
primitive = ser.serialize_entity(self.context, obj)
|
||||||
self.assertIn('nimble_object.name', primitive)
|
self.assertIn('mogan_object.name', primitive)
|
||||||
obj2 = ser.deserialize_entity(self.context, primitive)
|
obj2 = ser.deserialize_entity(self.context, primitive)
|
||||||
self.assertIsInstance(obj2, MyObj)
|
self.assertIsInstance(obj2, MyObj)
|
||||||
self.assertEqual(self.context, obj2._context)
|
self.assertEqual(self.context, obj2._context)
|
||||||
|
|
||||||
def test_object_serialization_iterables(self):
|
def test_object_serialization_iterables(self):
|
||||||
ser = base.NimbleObjectSerializer()
|
ser = base.MoganObjectSerializer()
|
||||||
obj = MyObj(self.context)
|
obj = MyObj(self.context)
|
||||||
for iterable in (list, tuple, set):
|
for iterable in (list, tuple, set):
|
||||||
thing = iterable([obj])
|
thing = iterable([obj])
|
||||||
primitive = ser.serialize_entity(self.context, thing)
|
primitive = ser.serialize_entity(self.context, thing)
|
||||||
self.assertEqual(1, len(primitive))
|
self.assertEqual(1, len(primitive))
|
||||||
for item in primitive:
|
for item in primitive:
|
||||||
self.assertNotIsInstance(item, base.NimbleObject)
|
self.assertNotIsInstance(item, base.MoganObject)
|
||||||
thing2 = ser.deserialize_entity(self.context, primitive)
|
thing2 = ser.deserialize_entity(self.context, primitive)
|
||||||
self.assertEqual(1, len(thing2))
|
self.assertEqual(1, len(thing2))
|
||||||
for item in thing2:
|
for item in thing2:
|
||||||
@ -433,7 +433,7 @@ class TestObjectSerializer(test_base.TestCase):
|
|||||||
class TestRegistry(test_base.TestCase):
|
class TestRegistry(test_base.TestCase):
|
||||||
@mock.patch('mogan.objects.base.objects')
|
@mock.patch('mogan.objects.base.objects')
|
||||||
def test_hook_chooses_newer_properly(self, mock_objects):
|
def test_hook_chooses_newer_properly(self, mock_objects):
|
||||||
reg = base.NimbleObjectRegistry()
|
reg = base.MoganObjectRegistry()
|
||||||
reg.registration_hook(MyObj, 0)
|
reg.registration_hook(MyObj, 0)
|
||||||
|
|
||||||
class MyNewerObj(object):
|
class MyNewerObj(object):
|
||||||
|
Loading…
Reference in New Issue
Block a user