~anso/nova/factorycleanup

« back to all changes in this revision

Viewing changes to nova/virt/xenapi/fake.py

  • Committer: Todd Willey
  • Date: 2011-01-12 19:31:28 UTC
  • mfrom: (524.1.4 wsgirouter)
  • Revision ID: todd@ansolabs.com-20110112193128-3o6yktau46w9mhzu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
 
54
54
import datetime
55
 
import logging
56
55
import uuid
57
56
 
58
57
from pprint import pformat
59
58
 
60
59
from nova import exception
 
60
from nova import log as logging
61
61
 
62
62
 
63
63
_CLASSES = ['host', 'network', 'session', 'SR', 'VBD',\
65
65
 
66
66
_db_content = {}
67
67
 
 
68
LOG = logging.getLogger("nova.virt.xenapi.fake")
 
69
 
68
70
 
69
71
def log_db_contents(msg=None):
70
 
    logging.debug(_("%s: _db_content => %s"), msg or "", pformat(_db_content))
 
72
    LOG.debug(_("%s: _db_content => %s"), msg or "", pformat(_db_content))
71
73
 
72
74
 
73
75
def reset():
242
244
            full_params = (self._session,) + params
243
245
            meth = getattr(self, methodname, None)
244
246
            if meth is None:
245
 
                logging.warn('Raising NotImplemented')
 
247
                LOG.debug(_('Raising NotImplemented'))
246
248
                raise NotImplementedError(
247
 
                    'xenapi.fake does not have an implementation for %s' %
 
249
                    _('xenapi.fake does not have an implementation for %s') %
248
250
                    methodname)
249
251
            return meth(*full_params)
250
252
 
278
280
            if impl is not None:
279
281
 
280
282
                def callit(*params):
281
 
                    logging.warn('Calling %s %s', name, impl)
 
283
                    LOG.debug(_('Calling %s %s'), name, impl)
282
284
                    self._check_session(params)
283
285
                    return impl(*params)
284
286
                return callit
285
287
        if self._is_gettersetter(name, True):
286
 
            logging.warn('Calling getter %s', name)
 
288
            LOG.debug(_('Calling getter %s'), name)
287
289
            return lambda *params: self._getter(name, params)
288
290
        elif self._is_create(name):
289
291
            return lambda *params: self._create(name, params)
333
335
                field in _db_content[cls][ref]):
334
336
                return _db_content[cls][ref][field]
335
337
 
336
 
        logging.error('Raising NotImplemented')
 
338
        LOG.debuug(_('Raising NotImplemented'))
337
339
        raise NotImplementedError(
338
 
            'xenapi.fake does not have an implementation for %s or it has '
339
 
            'been called with the wrong number of arguments' % name)
 
340
            _('xenapi.fake does not have an implementation for %s or it has '
 
341
            'been called with the wrong number of arguments') % name)
340
342
 
341
343
    def _setter(self, name, params):
342
344
        self._check_session(params)
351
353
                field in _db_content[cls][ref]):
352
354
                _db_content[cls][ref][field] = val
353
355
 
354
 
        logging.warn('Raising NotImplemented')
 
356
        LOG.debug(_('Raising NotImplemented'))
355
357
        raise NotImplementedError(
356
358
            'xenapi.fake does not have an implementation for %s or it has '
357
359
            'been called with the wrong number of arguments or the database '
399
401
            self._session not in _db_content['session']):
400
402
            raise Failure(['HANDLE_INVALID', 'session', self._session])
401
403
        if len(params) == 0 or params[0] != self._session:
402
 
            logging.warn('Raising NotImplemented')
 
404
            LOG.debug(_('Raising NotImplemented'))
403
405
            raise NotImplementedError('Call to XenAPI without using .xenapi')
404
406
 
405
407
    def _check_arg_count(self, params, expected):