Advertisement
Neonian

init.py

May 10th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. # Copyright 2013 Red Hat, Inc.
  2. # All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15.  
  16. from oslo_log import log as logging
  17. import stevedore.driver
  18. import stevedore.extension
  19.  
  20. from nova.i18n import _LE
  21.  
  22. LOG = logging.getLogger(__name__)
  23.  
  24.  
  25. def load_transfer_modules():
  26.  
  27. module_dictionary = {}
  28.  
  29. ex = stevedore.extension.ExtensionManager('nova.image.download.modules')
  30. for module_name in ex.names():
  31. mgr = stevedore.driver.DriverManager(
  32. namespace='nova.image.download.modules',
  33. name=module_name,
  34. invoke_on_load=False)
  35.  
  36. schemes_list = mgr.driver.get_schemes()
  37. for scheme in schemes_list:
  38. if scheme in module_dictionary:
  39. LOG.error(_LE('%(scheme)s is registered as a module twice. '
  40. '%(module_name)s is not being used.'),
  41. {'scheme': scheme,
  42. 'module_name': module_name})
  43. else:
  44. module_dictionary[scheme] = mgr.driver
  45.  
  46. return module_dictionary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement