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.
|
||||
|
||||
"""
|
||||
Version 1 of the Nimble API
|
||||
Version 1 of the Mogan API
|
||||
|
||||
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):
|
||||
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)?$'
|
||||
|
||||
try:
|
||||
@ -57,6 +57,6 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
|
||||
self.public_api_routes))
|
||||
|
||||
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)
|
||||
|
@ -31,7 +31,7 @@ from mogan.conf import CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NimbleException(Exception):
|
||||
class MoganException(Exception):
|
||||
"""Base Mogan Exception
|
||||
|
||||
To correctly use this class, inherit from it and define
|
||||
@ -74,7 +74,7 @@ class NimbleException(Exception):
|
||||
# happened
|
||||
message = self._msg_fmt
|
||||
|
||||
super(NimbleException, self).__init__(message)
|
||||
super(MoganException, self).__init__(message)
|
||||
|
||||
def __str__(self):
|
||||
"""Encode to utf-8 then wsme api can consume it as well."""
|
||||
@ -88,7 +88,7 @@ class NimbleException(Exception):
|
||||
return unicode(self.args[0])
|
||||
|
||||
|
||||
class NotAuthorized(NimbleException):
|
||||
class NotAuthorized(MoganException):
|
||||
_msg_fmt = _("Not authorized.")
|
||||
code = http_client.FORBIDDEN
|
||||
|
||||
@ -101,12 +101,12 @@ class HTTPForbidden(NotAuthorized):
|
||||
_msg_fmt = _("Access was denied to the following resource: %(resource)s")
|
||||
|
||||
|
||||
class NotFound(NimbleException):
|
||||
class NotFound(MoganException):
|
||||
_msg_fmt = _("Resource could not be found.")
|
||||
code = http_client.NOT_FOUND
|
||||
|
||||
|
||||
class Invalid(NimbleException):
|
||||
class Invalid(MoganException):
|
||||
_msg_fmt = _("Unacceptable parameters.")
|
||||
code = http_client.BAD_REQUEST
|
||||
|
||||
@ -117,22 +117,22 @@ class InvalidParameterValue(Invalid):
|
||||
_msg_fmt = _("%(err)s")
|
||||
|
||||
|
||||
class Conflict(NimbleException):
|
||||
class Conflict(MoganException):
|
||||
_msg_fmt = _('Conflict.')
|
||||
code = http_client.CONFLICT
|
||||
|
||||
|
||||
class TemporaryFailure(NimbleException):
|
||||
class TemporaryFailure(MoganException):
|
||||
_msg_fmt = _("Resource temporarily unavailable, please retry.")
|
||||
code = http_client.SERVICE_UNAVAILABLE
|
||||
|
||||
|
||||
class NotAcceptable(NimbleException):
|
||||
class NotAcceptable(MoganException):
|
||||
_msg_fmt = _("Request not acceptable.")
|
||||
code = http_client.NOT_ACCEPTABLE
|
||||
|
||||
|
||||
class ConfigInvalid(NimbleException):
|
||||
class ConfigInvalid(MoganException):
|
||||
_msg_fmt = _("Invalid configuration file. %(error_msg)s")
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ class InvalidUUID(Invalid):
|
||||
msg_fmt = _("Expected a uuid but received %(uuid)s.")
|
||||
|
||||
|
||||
class InstanceTypeAlreadyExists(NimbleException):
|
||||
class InstanceTypeAlreadyExists(MoganException):
|
||||
_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.")
|
||||
|
||||
|
||||
class InstanceAlreadyExists(NimbleException):
|
||||
class InstanceAlreadyExists(MoganException):
|
||||
_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.")
|
||||
|
||||
|
||||
class KeystoneUnauthorized(NimbleException):
|
||||
class KeystoneUnauthorized(MoganException):
|
||||
_msg_fmt = _("Not authorized in Keystone.")
|
||||
|
||||
|
||||
class KeystoneFailure(NimbleException):
|
||||
class KeystoneFailure(MoganException):
|
||||
pass
|
||||
|
||||
|
||||
class CatalogNotFound(NimbleException):
|
||||
class CatalogNotFound(MoganException):
|
||||
_msg_fmt = _("Service type %(service_type)s with endpoint type "
|
||||
"%(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.")
|
||||
|
||||
|
||||
class NoValidNode(NimbleException):
|
||||
class NoValidNode(MoganException):
|
||||
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"
|
||||
"created after %(retries)d retries.")
|
||||
|
||||
@ -219,11 +219,11 @@ class InstanceTypeExtraSpecsNotFound(NotFound):
|
||||
"key %(extra_specs_key)s.")
|
||||
|
||||
|
||||
class InterfacePlugException(NimbleException):
|
||||
class InterfacePlugException(MoganException):
|
||||
msg_fmt = _("Interface plugin failed")
|
||||
|
||||
|
||||
class NetworkError(NimbleException):
|
||||
class NetworkError(MoganException):
|
||||
_msg_fmt = _("Network operation failure.")
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ class ValidationError(Invalid):
|
||||
msg_fmt = "%(detail)s"
|
||||
|
||||
|
||||
class ImageNotAuthorized(NimbleException):
|
||||
class ImageNotAuthorized(MoganException):
|
||||
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.")
|
||||
|
||||
|
||||
class GlanceConnectionFailed(NimbleException):
|
||||
class GlanceConnectionFailed(MoganException):
|
||||
msg_fmt = _("Connection to glance host %(server)s failed: "
|
||||
"%(reason)s")
|
||||
|
||||
|
@ -30,7 +30,7 @@ def _make_task_name(cls, addons=None):
|
||||
return base_name + extra
|
||||
|
||||
|
||||
class NimbleTask(task.Task):
|
||||
class MoganTask(task.Task):
|
||||
"""The root task class for all mogan tasks.
|
||||
|
||||
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):
|
||||
super(NimbleTask, self).__init__(self.make_name(addons), **kwargs)
|
||||
super(MoganTask, self).__init__(self.make_name(addons), **kwargs)
|
||||
|
||||
@classmethod
|
||||
def make_name(cls, addons=None):
|
||||
|
@ -82,7 +82,7 @@ class IronicClientWrapper(object):
|
||||
except ironic_exc.Unauthorized:
|
||||
msg = _("Unable to authenticate Ironic client.")
|
||||
LOG.error(msg)
|
||||
raise exception.NimbleException(msg)
|
||||
raise exception.MoganException(msg)
|
||||
|
||||
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.i18n import _
|
||||
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
|
||||
|
||||
|
||||
@ -72,12 +72,12 @@ def ks_exceptions(f):
|
||||
|
||||
@ks_exceptions
|
||||
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:
|
||||
msg = _("Failed to load auth from either [%(new)s] or [%(old)s] "
|
||||
"config sections.")
|
||||
raise exception.ConfigInvalid(message=msg, new=group,
|
||||
old=nimble_auth.LEGACY_SECTION)
|
||||
old=mogan_auth.LEGACY_SECTION)
|
||||
session = kaloading.load_session_from_conf_options(
|
||||
CONF, group, auth=auth)
|
||||
return session
|
||||
@ -89,7 +89,7 @@ def _get_legacy_auth():
|
||||
|
||||
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')
|
||||
auth_params = {
|
||||
'auth_url': conf.auth_uri,
|
||||
|
@ -14,7 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
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
|
||||
|
||||
from mogan.common import exception
|
||||
@ -90,7 +90,7 @@ class RequestContextSerializer(messaging.Serializer):
|
||||
return context.to_dict()
|
||||
|
||||
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):
|
||||
|
@ -51,7 +51,7 @@ class RPCService(service.Service):
|
||||
|
||||
target = messaging.Target(topic=self.topic, server=self.host)
|
||||
endpoints = [self.manager]
|
||||
serializer = objects_base.NimbleObjectSerializer()
|
||||
serializer = objects_base.MoganObjectSerializer()
|
||||
self.rpcserver = rpc.get_server(target, endpoints, serializer)
|
||||
self.rpcserver.start()
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
Please see https://alembic.readthedocs.org/en/latest/index.html for general documentation
|
||||
|
||||
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
|
||||
$ nimble-dbsync stamp --revision head
|
||||
$ mogan-dbsync stamp --revision head
|
||||
|
||||
Upgrade can be performed by:
|
||||
$ nimble-dbsync - for backward compatibility
|
||||
$ nimble-dbsync upgrade
|
||||
# nimble-dbsync upgrade --revision head
|
||||
$ mogan-dbsync - for backward compatibility
|
||||
$ mogan-dbsync upgrade
|
||||
# mogan-dbsync upgrade --revision head
|
||||
|
@ -43,8 +43,8 @@ def table_args():
|
||||
return None
|
||||
|
||||
|
||||
class NimbleBase(models.TimestampMixin,
|
||||
models.ModelBase):
|
||||
class MoganBase(models.TimestampMixin,
|
||||
models.ModelBase):
|
||||
|
||||
metadata = None
|
||||
|
||||
@ -55,7 +55,7 @@ class NimbleBase(models.TimestampMixin,
|
||||
return d
|
||||
|
||||
|
||||
Base = declarative_base(cls=NimbleBase)
|
||||
Base = declarative_base(cls=MoganBase)
|
||||
|
||||
|
||||
class Instance(Base):
|
||||
|
@ -38,7 +38,7 @@ ACTION = 'instance:create'
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class ScheduleCreateInstanceTask(flow_utils.NimbleTask):
|
||||
class ScheduleCreateInstanceTask(flow_utils.MoganTask):
|
||||
"""Activates a scheduler driver and handles any subsequent failure."""
|
||||
|
||||
def __init__(self, manager):
|
||||
@ -60,7 +60,7 @@ class ScheduleCreateInstanceTask(flow_utils.NimbleTask):
|
||||
instance.save()
|
||||
|
||||
|
||||
class OnFailureRescheduleTask(flow_utils.NimbleTask):
|
||||
class OnFailureRescheduleTask(flow_utils.MoganTask):
|
||||
"""Triggers a rescheduling request to be sent when reverting occurs.
|
||||
|
||||
If rescheduling doesn't occur this task errors out the instance.
|
||||
@ -125,14 +125,14 @@ class OnFailureRescheduleTask(flow_utils.NimbleTask):
|
||||
try:
|
||||
self._reschedule(context, cause, instance=instance, **kwargs)
|
||||
return True
|
||||
except exception.NimbleException:
|
||||
except exception.MoganException:
|
||||
LOG.exception(_LE("Instance %s: rescheduling failed"),
|
||||
instance.uuid)
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class SetInstanceInfoTask(flow_utils.NimbleTask):
|
||||
class SetInstanceInfoTask(flow_utils.MoganTask):
|
||||
"""Set instance info to ironic node and validate it."""
|
||||
|
||||
def __init__(self, ironicclient):
|
||||
@ -174,7 +174,7 @@ class SetInstanceInfoTask(flow_utils.NimbleTask):
|
||||
return False
|
||||
|
||||
|
||||
class BuildNetworkTask(flow_utils.NimbleTask):
|
||||
class BuildNetworkTask(flow_utils.MoganTask):
|
||||
"""Build network for the instance."""
|
||||
|
||||
def __init__(self, network_api, ironicclient):
|
||||
@ -273,7 +273,7 @@ class BuildNetworkTask(flow_utils.NimbleTask):
|
||||
return False
|
||||
|
||||
|
||||
class CreateInstanceTask(flow_utils.NimbleTask):
|
||||
class CreateInstanceTask(flow_utils.MoganTask):
|
||||
"""Set instance info to ironic node and validate it."""
|
||||
|
||||
def __init__(self, ironicclient):
|
||||
|
@ -136,7 +136,7 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
% {'state': node.provision_state,
|
||||
'node': node.uuid})
|
||||
LOG.error(msg)
|
||||
raise exception.NimbleException(msg)
|
||||
raise exception.MoganException(msg)
|
||||
else:
|
||||
data['tries'] += 1
|
||||
|
||||
@ -177,7 +177,7 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
except Exception:
|
||||
msg = _("Create manager instance flow failed.")
|
||||
LOG.exception(msg)
|
||||
raise exception.NimbleException(msg)
|
||||
raise exception.MoganException(msg)
|
||||
|
||||
def _run_flow():
|
||||
# This code executes create instance flow. If something goes wrong,
|
||||
|
@ -44,7 +44,7 @@ class EngineAPI(object):
|
||||
|
||||
target = messaging.Target(topic=self.topic,
|
||||
version='1.0')
|
||||
serializer = objects_base.NimbleObjectSerializer()
|
||||
serializer = objects_base.MoganObjectSerializer()
|
||||
self.client = rpc.get_client(target,
|
||||
version_cap=self.RPC_API_VERSION,
|
||||
serializer=serializer)
|
||||
|
@ -17,8 +17,8 @@ from mogan.objects import base
|
||||
from mogan.objects import fields
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
class NotificationObject(base.NimbleObject):
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class NotificationObject(base.MoganObject):
|
||||
"""Base class for every notification related versioned object."""
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
@ -32,7 +32,7 @@ class NotificationObject(base.NimbleObject):
|
||||
self.obj_reset_changes(recursive=False)
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register_notification
|
||||
@base.MoganObjectRegistry.register_notification
|
||||
class EventType(NotificationObject):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
@ -51,7 +51,7 @@ class EventType(NotificationObject):
|
||||
return s
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class NotificationPayloadBase(NotificationObject):
|
||||
"""Base class for the payload of versioned notifications."""
|
||||
# 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)
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register_notification
|
||||
@base.MoganObjectRegistry.register_notification
|
||||
class NotificationPublisher(NotificationObject):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
@ -112,7 +112,7 @@ class NotificationPublisher(NotificationObject):
|
||||
return cls(host=service.host, binary=service.binary)
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class NotificationBase(NotificationObject):
|
||||
"""Base class for versioned notifications.
|
||||
|
||||
@ -155,7 +155,7 @@ def notification_sample(sample):
|
||||
to the notification object for documentation generation purposes.
|
||||
|
||||
: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.
|
||||
"""
|
||||
|
||||
|
@ -22,7 +22,7 @@ from mogan import objects
|
||||
from mogan.objects import fields as object_fields
|
||||
|
||||
|
||||
class NimbleObjectRegistry(object_base.VersionedObjectRegistry):
|
||||
class MoganObjectRegistry(object_base.VersionedObjectRegistry):
|
||||
notification_classes = []
|
||||
|
||||
def registration_hook(self, cls, index):
|
||||
@ -59,7 +59,7 @@ class NimbleObjectRegistry(object_base.VersionedObjectRegistry):
|
||||
cls.register(notification_cls)
|
||||
|
||||
|
||||
class NimbleObject(object_base.VersionedObject):
|
||||
class MoganObject(object_base.VersionedObject):
|
||||
"""Base class and object factory.
|
||||
|
||||
This forms the base of all objects that can be remoted or instantiated
|
||||
@ -69,7 +69,7 @@ class NimbleObject(object_base.VersionedObject):
|
||||
as appropriate.
|
||||
"""
|
||||
|
||||
OBJ_SERIAL_NAMESPACE = 'nimble_object'
|
||||
OBJ_SERIAL_NAMESPACE = 'mogan_object'
|
||||
OBJ_PROJECT_NAMESPACE = 'mogan'
|
||||
|
||||
# TODO(lintan) Refactor these fields and create PersistentObject and
|
||||
@ -85,7 +85,7 @@ class NimbleObject(object_base.VersionedObject):
|
||||
if hasattr(self, k))
|
||||
|
||||
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
|
||||
the loaded object column by column in comparison with the current
|
||||
@ -112,6 +112,6 @@ class NimbleObject(object_base.VersionedObject):
|
||||
return obj
|
||||
|
||||
|
||||
class NimbleObjectSerializer(object_base.VersionedObjectSerializer):
|
||||
class MoganObjectSerializer(object_base.VersionedObjectSerializer):
|
||||
# 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()
|
||||
|
||||
|
||||
class BaseNimbleEnum(object_fields.Enum):
|
||||
class BaseMoganEnum(object_fields.Enum):
|
||||
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'
|
||||
CRITICAL = 'critical'
|
||||
DEBUG = 'debug'
|
||||
@ -128,7 +128,7 @@ class NotificationPriority(BaseNimbleEnum):
|
||||
ALL = (AUDIT, CRITICAL, DEBUG, INFO, ERROR, SAMPLE, WARN)
|
||||
|
||||
|
||||
class NotificationPhase(BaseNimbleEnum):
|
||||
class NotificationPhase(BaseMoganEnum):
|
||||
START = 'start'
|
||||
END = 'end'
|
||||
ERROR = 'error'
|
||||
@ -136,7 +136,7 @@ class NotificationPhase(BaseNimbleEnum):
|
||||
ALL = (START, END, ERROR)
|
||||
|
||||
|
||||
class NotificationAction(BaseNimbleEnum):
|
||||
class NotificationAction(BaseMoganEnum):
|
||||
UPDATE = 'update'
|
||||
EXCEPTION = 'exception'
|
||||
DELETE = 'delete'
|
||||
|
@ -21,8 +21,8 @@ from mogan.objects import base
|
||||
from mogan.objects import fields as object_fields
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register
|
||||
class Instance(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
||||
@base.MoganObjectRegistry.register
|
||||
class Instance(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
|
||||
|
@ -21,8 +21,8 @@ from mogan.objects import base
|
||||
from mogan.objects import fields as object_fields
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register
|
||||
class InstanceType(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
||||
@base.MoganObjectRegistry.register
|
||||
class InstanceType(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
|
||||
|
@ -29,7 +29,7 @@ import six
|
||||
import testscenarios
|
||||
import testtools
|
||||
|
||||
from mogan.common import config as nimble_config
|
||||
from mogan.common import config as mogan_config
|
||||
from mogan.tests import policy_fixture
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ class TestCase(base.BaseTestCase):
|
||||
sqlite_synchronous=False,
|
||||
group='database')
|
||||
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):
|
||||
"""Override config options for a test."""
|
||||
|
@ -18,7 +18,7 @@ import fixtures
|
||||
from oslo_config import cfg
|
||||
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
|
||||
|
||||
@ -39,5 +39,5 @@ class PolicyFixture(fixtures.Fixture):
|
||||
policy_file.write(policy_data)
|
||||
policy_opts.set_defaults(CONF)
|
||||
CONF.set_override('policy_file', self.policy_file_name, 'oslo_policy')
|
||||
nimble_policy._ENFORCER = None
|
||||
self.addCleanup(nimble_policy.get_enforcer().clear)
|
||||
mogan_policy._ENFORCER = None
|
||||
self.addCleanup(mogan_policy.get_enforcer().clear)
|
||||
|
@ -32,7 +32,7 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
||||
@classmethod
|
||||
def skip_checks(cls):
|
||||
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")
|
||||
|
||||
@classmethod
|
||||
|
@ -28,7 +28,7 @@ class BaremetalComputeAPITest(base.BaseBaremetalComputeTest):
|
||||
def resource_setup(cls):
|
||||
super(BaremetalComputeAPITest, cls).resource_setup()
|
||||
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",
|
||||
'is_public': bool(data_utils.rand_int_id(0, 1))}
|
||||
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')
|
||||
def test_type_create_show_delete(self):
|
||||
# Create an instance type
|
||||
body = {"name": 'nimble_type_create',
|
||||
body = {"name": 'mogan_type_create',
|
||||
"description": "mogan instance type description",
|
||||
'is_public': True}
|
||||
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',
|
||||
resp['description'])
|
||||
self.assertEqual(True, resp['is_public'])
|
||||
@ -62,7 +62,7 @@ class BaremetalComputeAPITest(base.BaseBaremetalComputeTest):
|
||||
self.assertIn('extra_specs', resp)
|
||||
self.assertIn('links', resp)
|
||||
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',
|
||||
resp['description'])
|
||||
self.assertEqual(True, resp['is_public'])
|
||||
|
@ -19,7 +19,7 @@ service_available_group = cfg.OptGroup(name="service_available",
|
||||
title="Available OpenStack Services")
|
||||
|
||||
ServiceAvailableGroup = [
|
||||
cfg.BoolOpt("nimble_plugin",
|
||||
cfg.BoolOpt("mogan_plugin",
|
||||
default=True,
|
||||
help="Whether or not Mogan is expected to be available"),
|
||||
]
|
||||
|
@ -17,11 +17,11 @@ from mogan.common import exception
|
||||
from mogan.tests import base
|
||||
|
||||
|
||||
class TestNimbleException(base.TestCase):
|
||||
class TestMoganException(base.TestCase):
|
||||
def test____init__(self):
|
||||
expected = b'\xc3\xa9\xe0\xaf\xb2\xe0\xbe\x84'
|
||||
if six.PY3:
|
||||
expected = expected.decode('utf-8')
|
||||
message = six.unichr(233) + six.unichr(0x0bf2) + six.unichr(3972)
|
||||
exc = exception.NimbleException(message)
|
||||
exc = exception.MoganException(message)
|
||||
self.assertEqual(expected, exc.__str__())
|
||||
|
@ -13,7 +13,7 @@
|
||||
import mock
|
||||
|
||||
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
|
||||
|
||||
from mogan.common import rpc
|
||||
@ -72,7 +72,7 @@ class TestRequestContextSerializer(base.TestCase):
|
||||
|
||||
self.mock_serializer = mock.MagicMock()
|
||||
self.serializer = rpc.RequestContextSerializer(self.mock_serializer)
|
||||
self.context = nimble_context.RequestContext()
|
||||
self.context = mogan_context.RequestContext()
|
||||
self.entity = {'foo': 'bar'}
|
||||
|
||||
def test_serialize_entity(self):
|
||||
|
@ -39,7 +39,7 @@ class TestRPCService(base.TestCase):
|
||||
constants.MANAGER_TOPIC)
|
||||
|
||||
@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(manager.EngineManager, 'init_host', autospec=True)
|
||||
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):
|
||||
@mock.patch.object(service.wsgi, 'Server')
|
||||
def test_workers_set_default(self, wsgi_server):
|
||||
service_name = "nimble_api"
|
||||
service_name = "mogan_api"
|
||||
test_service = service.WSGIService(service_name)
|
||||
self.assertEqual(processutils.get_worker_count(),
|
||||
test_service.workers)
|
||||
@ -68,13 +68,13 @@ class TestWSGIService(base.TestCase):
|
||||
@mock.patch.object(service.wsgi, 'Server')
|
||||
def test_workers_set_correct_setting(self, wsgi_server):
|
||||
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)
|
||||
|
||||
@mock.patch.object(service.wsgi, 'Server')
|
||||
def test_workers_set_zero_setting(self, wsgi_server):
|
||||
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)
|
||||
|
||||
@mock.patch.object(service.wsgi, 'Server')
|
||||
@ -82,14 +82,14 @@ class TestWSGIService(base.TestCase):
|
||||
self.config(api_workers=-2, group='api')
|
||||
self.assertRaises(exception.ConfigInvalid,
|
||||
service.WSGIService,
|
||||
'nimble_api')
|
||||
'mogan_api')
|
||||
self.assertFalse(wsgi_server.called)
|
||||
|
||||
@mock.patch.object(service.wsgi, 'Server')
|
||||
def test_wsgi_service_with_ssl_enabled(self, wsgi_server):
|
||||
self.config(enable_ssl_api=True, group='api')
|
||||
service_name = 'nimble_api'
|
||||
srv = service.WSGIService('nimble_api', CONF.api.enable_ssl_api)
|
||||
service_name = 'mogan_api'
|
||||
srv = service.WSGIService('mogan_api', CONF.api.enable_ssl_api)
|
||||
wsgi_server.assert_called_once_with(CONF, service_name,
|
||||
srv.app,
|
||||
host='0.0.0.0',
|
||||
|
@ -16,7 +16,7 @@ from keystoneauth1 import identity as kaidentity
|
||||
from keystoneauth1 import loading as kaloading
|
||||
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
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ class AuthConfTestCase(base.TestCase):
|
||||
group='keystone')
|
||||
self.test_group = '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',
|
||||
group=self.test_group)
|
||||
# NOTE(pas-ha) this is due to auth_plugin options
|
||||
@ -44,7 +44,7 @@ class AuthConfTestCase(base.TestCase):
|
||||
group=self.test_group)
|
||||
|
||||
def test_add_auth_opts(self):
|
||||
opts = nimble_auth.add_auth_opts([])
|
||||
opts = mogan_auth.add_auth_opts([])
|
||||
# check that there is no duplicates
|
||||
names = {o.dest for o in opts}
|
||||
self.assertEqual(len(names), len(opts))
|
||||
@ -56,7 +56,7 @@ class AuthConfTestCase(base.TestCase):
|
||||
self.assertTrue(expected.issubset(names))
|
||||
|
||||
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
|
||||
self.assertIsInstance(auth, kaidentity.generic.password.Password)
|
||||
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,
|
||||
# MissingOption is raised
|
||||
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))
|
||||
|
@ -32,8 +32,8 @@ class FakeFilterScheduler(filter_scheduler.FilterScheduler):
|
||||
self.node_manager = node_manager.NodeManager()
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register
|
||||
class FakeNode(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
||||
@base.MoganObjectRegistry.register
|
||||
class FakeNode(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
fields = {
|
||||
'id': object_fields.IntegerField(),
|
||||
'uuid': object_fields.UUIDField(nullable=True),
|
||||
|
@ -101,7 +101,7 @@ class ManageInstanceTestCase(mgr_utils.ServiceSetUpMixin,
|
||||
refresh_cache_mock.side_effect = None
|
||||
self._start_service()
|
||||
|
||||
self.assertRaises(exception.NimbleException,
|
||||
self.assertRaises(exception.MoganException,
|
||||
self.service._destroy_instance,
|
||||
self.context, instance)
|
||||
self._stop_service()
|
||||
|
@ -21,8 +21,8 @@ from mogan.tests import base as test_base
|
||||
|
||||
|
||||
class TestNotificationBase(test_base.TestCase):
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
class TestObject(base.NimbleObject):
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class TestObject(base.MoganObject):
|
||||
VERSION = '1.0'
|
||||
fields = {
|
||||
'field_1': fields.StringField(),
|
||||
@ -30,7 +30,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
'not_important_field': fields.IntegerField(),
|
||||
}
|
||||
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class TestNotificationPayload(notification.NotificationPayloadBase):
|
||||
VERSION = '1.0'
|
||||
|
||||
@ -49,7 +49,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
super(TestNotificationBase.TestNotificationPayload,
|
||||
self).populate_schema(source_field=source_field)
|
||||
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class TestNotificationPayloadEmptySchema(
|
||||
notification.NotificationPayloadBase):
|
||||
VERSION = '1.0'
|
||||
@ -60,14 +60,14 @@ class TestNotificationBase(test_base.TestCase):
|
||||
|
||||
@notification.notification_sample('test-update-1.json')
|
||||
@notification.notification_sample('test-update-2.json')
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class TestNotification(notification.NotificationBase):
|
||||
VERSION = '1.0'
|
||||
fields = {
|
||||
'payload': fields.ObjectField('TestNotificationPayload')
|
||||
}
|
||||
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class TestNotificationEmptySchema(notification.NotificationBase):
|
||||
VERSION = '1.0'
|
||||
fields = {
|
||||
@ -75,13 +75,13 @@ class TestNotificationBase(test_base.TestCase):
|
||||
}
|
||||
|
||||
expected_payload = {
|
||||
'nimble_object.name': 'TestNotificationPayload',
|
||||
'nimble_object.data': {
|
||||
'mogan_object.name': 'TestNotificationPayload',
|
||||
'mogan_object.data': {
|
||||
'extra_field': 'test string',
|
||||
'field_1': 'test1',
|
||||
'field_2': 42},
|
||||
'nimble_object.version': '1.0',
|
||||
'nimble_object.namespace': 'mogan'}
|
||||
'mogan_object.version': '1.0',
|
||||
'mogan_object.namespace': 'mogan'}
|
||||
|
||||
def setUp(self):
|
||||
super(TestNotificationBase, self).setUp()
|
||||
@ -99,7 +99,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
action=fields.NotificationAction.UPDATE,
|
||||
phase=fields.NotificationPhase.START),
|
||||
publisher=notification.NotificationPublisher(
|
||||
host='fake-host', binary='nimble-fake'),
|
||||
host='fake-host', binary='mogan-fake'),
|
||||
priority=fields.NotificationPriority.INFO,
|
||||
payload=self.payload)
|
||||
|
||||
@ -107,7 +107,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
expected_event_type,
|
||||
expected_payload):
|
||||
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
|
||||
self.assertTrue(mock_notify.called)
|
||||
self.assertEqual(mock_notify.call_args[0][0], mock_context)
|
||||
@ -135,7 +135,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
object='test_object',
|
||||
action=fields.NotificationAction.UPDATE),
|
||||
publisher=notification.NotificationPublisher(
|
||||
host='fake-host', binary='nimble-fake'),
|
||||
host='fake-host', binary='mogan-fake'),
|
||||
priority=fields.NotificationPriority.INFO,
|
||||
payload=self.payload)
|
||||
|
||||
@ -156,7 +156,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
object='test_object',
|
||||
action=fields.NotificationAction.UPDATE),
|
||||
publisher=notification.NotificationPublisher(
|
||||
host='fake-host', binary='nimble-fake'),
|
||||
host='fake-host', binary='mogan-fake'),
|
||||
priority=fields.NotificationPriority.INFO,
|
||||
payload=self.payload)
|
||||
|
||||
@ -179,7 +179,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
object='test_object',
|
||||
action=fields.NotificationAction.UPDATE),
|
||||
publisher=notification.NotificationPublisher(
|
||||
host='fake-host', binary='nimble-fake'),
|
||||
host='fake-host', binary='mogan-fake'),
|
||||
priority=fields.NotificationPriority.INFO,
|
||||
payload=non_populated_payload)
|
||||
|
||||
@ -196,7 +196,7 @@ class TestNotificationBase(test_base.TestCase):
|
||||
object='test_object',
|
||||
action=fields.NotificationAction.UPDATE),
|
||||
publisher=notification.NotificationPublisher(
|
||||
host='fake-host', binary='nimble-fake'),
|
||||
host='fake-host', binary='mogan-fake'),
|
||||
priority=fields.NotificationPriority.INFO,
|
||||
payload=non_populated_payload)
|
||||
|
||||
@ -209,10 +209,10 @@ class TestNotificationBase(test_base.TestCase):
|
||||
mock_context,
|
||||
expected_event_type='test_object.update',
|
||||
expected_payload={
|
||||
'nimble_object.name': 'TestNotificationPayloadEmptySchema',
|
||||
'nimble_object.data': {'extra_field': u'test string'},
|
||||
'nimble_object.version': '1.0',
|
||||
'nimble_object.namespace': 'mogan'})
|
||||
'mogan_object.name': 'TestNotificationPayloadEmptySchema',
|
||||
'mogan_object.data': {'extra_field': u'test string'},
|
||||
'mogan_object.version': '1.0',
|
||||
'mogan_object.namespace': 'mogan'})
|
||||
|
||||
def test_sample_decorator(self):
|
||||
self.assertEqual(2, len(self.TestNotification.samples))
|
||||
|
@ -30,8 +30,8 @@ from mogan.tests import base as test_base
|
||||
gettext.install('mogan')
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register
|
||||
class MyObj(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
||||
@base.MoganObjectRegistry.register
|
||||
class MyObj(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
VERSION = '1.1'
|
||||
|
||||
fields = {'foo': fields.IntegerField(),
|
||||
@ -88,40 +88,40 @@ class MyObj2(object):
|
||||
pass
|
||||
|
||||
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class TestSubclassedObject(MyObj):
|
||||
fields = {'new_field': fields.StringField()}
|
||||
|
||||
|
||||
class _TestObject(object):
|
||||
def test_hydration_type_error(self):
|
||||
primitive = {'nimble_object.name': 'MyObj',
|
||||
'nimble_object.namespace': 'mogan',
|
||||
'nimble_object.version': '1.5',
|
||||
'nimble_object.data': {'foo': 'a'}}
|
||||
primitive = {'mogan_object.name': 'MyObj',
|
||||
'mogan_object.namespace': 'mogan',
|
||||
'mogan_object.version': '1.5',
|
||||
'mogan_object.data': {'foo': 'a'}}
|
||||
self.assertRaises(ValueError, MyObj.obj_from_primitive, primitive)
|
||||
|
||||
def test_hydration(self):
|
||||
primitive = {'nimble_object.name': 'MyObj',
|
||||
'nimble_object.namespace': 'mogan',
|
||||
'nimble_object.version': '1.5',
|
||||
'nimble_object.data': {'foo': 1}}
|
||||
primitive = {'mogan_object.name': 'MyObj',
|
||||
'mogan_object.namespace': 'mogan',
|
||||
'mogan_object.version': '1.5',
|
||||
'mogan_object.data': {'foo': 1}}
|
||||
obj = MyObj.obj_from_primitive(primitive)
|
||||
self.assertEqual(1, obj.foo)
|
||||
|
||||
def test_hydration_bad_ns(self):
|
||||
primitive = {'nimble_object.name': 'MyObj',
|
||||
'nimble_object.namespace': 'foo',
|
||||
'nimble_object.version': '1.5',
|
||||
'nimble_object.data': {'foo': 1}}
|
||||
primitive = {'mogan_object.name': 'MyObj',
|
||||
'mogan_object.namespace': 'foo',
|
||||
'mogan_object.version': '1.5',
|
||||
'mogan_object.data': {'foo': 1}}
|
||||
self.assertRaises(object_exception.UnsupportedObjectError,
|
||||
MyObj.obj_from_primitive, primitive)
|
||||
|
||||
def test_dehydration(self):
|
||||
expected = {'nimble_object.name': 'MyObj',
|
||||
'nimble_object.namespace': 'mogan',
|
||||
'nimble_object.version': '1.5',
|
||||
'nimble_object.data': {'foo': 1}}
|
||||
expected = {'mogan_object.name': 'MyObj',
|
||||
'mogan_object.namespace': 'mogan',
|
||||
'mogan_object.version': '1.5',
|
||||
'mogan_object.data': {'foo': 1}}
|
||||
obj = MyObj(self.context)
|
||||
obj.foo = 1
|
||||
obj.obj_reset_changes()
|
||||
@ -153,8 +153,8 @@ class _TestObject(object):
|
||||
self.assertEqual('loaded!', obj.bar)
|
||||
|
||||
def test_load_in_base(self):
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
class Foo(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class Foo(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
fields = {'foobar': fields.IntegerField()}
|
||||
obj = Foo(self.context)
|
||||
|
||||
@ -167,12 +167,12 @@ class _TestObject(object):
|
||||
obj.foo = 1
|
||||
obj.obj_reset_changes()
|
||||
self.assertEqual('loaded!', obj.bar)
|
||||
expected = {'nimble_object.name': 'MyObj',
|
||||
'nimble_object.namespace': 'mogan',
|
||||
'nimble_object.version': '1.5',
|
||||
'nimble_object.changes': ['bar'],
|
||||
'nimble_object.data': {'foo': 1,
|
||||
'bar': 'loaded!'}}
|
||||
expected = {'mogan_object.name': 'MyObj',
|
||||
'mogan_object.namespace': 'mogan',
|
||||
'mogan_object.version': '1.5',
|
||||
'mogan_object.changes': ['bar'],
|
||||
'mogan_object.data': {'foo': 1,
|
||||
'bar': 'loaded!'}}
|
||||
self.assertEqual(expected, obj.obj_to_primitive())
|
||||
|
||||
def test_changes_in_primitive(self):
|
||||
@ -180,7 +180,7 @@ class _TestObject(object):
|
||||
obj.foo = 123
|
||||
self.assertEqual(set(['foo']), obj.obj_what_changed())
|
||||
primitive = obj.obj_to_primitive()
|
||||
self.assertIn('nimble_object.changes', primitive)
|
||||
self.assertIn('mogan_object.changes', primitive)
|
||||
obj2 = MyObj.obj_from_primitive(primitive)
|
||||
self.assertEqual(set(['foo']), obj2.obj_what_changed())
|
||||
obj2.obj_reset_changes()
|
||||
@ -188,7 +188,7 @@ class _TestObject(object):
|
||||
|
||||
def test_unknown_objtype(self):
|
||||
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):
|
||||
ctxt1 = context.RequestContext('foo', 'foo')
|
||||
@ -255,21 +255,21 @@ class _TestObject(object):
|
||||
obj = MyObj(self.context)
|
||||
obj.created_at = dt
|
||||
obj.updated_at = dt
|
||||
expected = {'nimble_object.name': 'MyObj',
|
||||
'nimble_object.namespace': 'mogan',
|
||||
'nimble_object.version': '1.5',
|
||||
'nimble_object.changes':
|
||||
expected = {'mogan_object.name': 'MyObj',
|
||||
'mogan_object.namespace': 'mogan',
|
||||
'mogan_object.version': '1.5',
|
||||
'mogan_object.changes':
|
||||
['created_at', 'updated_at'],
|
||||
'nimble_object.data':
|
||||
'mogan_object.data':
|
||||
{'created_at': datatime.stringify(dt),
|
||||
'updated_at': datatime.stringify(dt),
|
||||
}
|
||||
}
|
||||
actual = obj.obj_to_primitive()
|
||||
# nimble_object.changes is built from a set and order is undefined
|
||||
self.assertEqual(sorted(expected['nimble_object.changes']),
|
||||
sorted(actual['nimble_object.changes']))
|
||||
del expected['nimble_object.changes'], actual['nimble_object.changes']
|
||||
# mogan_object.changes is built from a set and order is undefined
|
||||
self.assertEqual(sorted(expected['mogan_object.changes']),
|
||||
sorted(actual['mogan_object.changes']))
|
||||
del expected['mogan_object.changes'], actual['mogan_object.changes']
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_contains(self):
|
||||
@ -303,7 +303,7 @@ class _TestObject(object):
|
||||
self.assertRaises(AttributeError, obj.get, 'nothing', 3)
|
||||
|
||||
def test_object_inheritance(self):
|
||||
base_fields = list(base.NimbleObject.fields)
|
||||
base_fields = list(base.MoganObject.fields)
|
||||
myobj_fields = ['foo', 'bar', 'missing'] + base_fields
|
||||
myobj3_fields = ['new_field']
|
||||
self.assertTrue(issubclass(TestSubclassedObject, MyObj))
|
||||
@ -325,8 +325,8 @@ class _TestObject(object):
|
||||
self.assertEqual({}, obj.obj_get_changes())
|
||||
|
||||
def test_obj_fields(self):
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||
class TestObj(base.NimbleObject,
|
||||
@base.MoganObjectRegistry.register_if(False)
|
||||
class TestObj(base.MoganObject,
|
||||
object_base.VersionedObjectDictCompat):
|
||||
fields = {'foo': fields.IntegerField()}
|
||||
obj_extra_fields = ['bar']
|
||||
@ -340,8 +340,8 @@ class _TestObject(object):
|
||||
set(obj.obj_fields))
|
||||
|
||||
def test_refresh_object(self):
|
||||
@base.NimbleObjectRegistry.register_if(False)
|
||||