Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. diff --git a/nova/objects/resource_class_cache.py b/nova/objects/resource_class_cache.py
  2. index 244b743..dcbd50c 100644
  3. --- a/nova/objects/resource_class_cache.py
  4. +++ b/nova/objects/resource_class_cache.py
  5. @@ -12,6 +12,7 @@
  6.  
  7. import sqlalchemy as sa
  8.  
  9. +from nova.db.sqlalchemy import api as db_api
  10. from nova.db.sqlalchemy import api_models as models
  11. from nova.objects import fields
  12.  
  13. @@ -31,7 +32,9 @@ class ResourceClassCache(object):
  14. self.id_cache = {}
  15. self.str_cache = {}
  16.  
  17. - def id_from_string(self, rc_str):
  18. + @db_api.api_context_manager.reader
  19. + @staticmethod
  20. + def _id_from_string(ctx, rc_str):
  21. """Given a string representation of a resource class -- e.g. "DISK_GB"
  22. or "IRON_SILVER" -- return the integer code for the resource class. For
  23. standard resource classes, this integer code will match the list of
  24. @@ -65,6 +68,9 @@ class ResourceClassCache(object):
  25. self.id_cache[rc_str] = rc_id
  26. return rc_id
  27.  
  28. + def id_from_string(self, rc_str):
  29. + return self._id_from_string(self.ctx, rc_str)
  30. +
  31. def string_from_id(self, rc_id):
  32. """The reverse of the id_from_string() method. Given a supplied numeric
  33. identifier for a resource class, we look up the corresponding string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement