Don't shadow local variables "resource"
We could rename the local variables, but it's just as easy to not use the resource module. Since the functions are not used, remove them. Change-Id: I356fbe0042f24aba78fba5deebe7fa645a035d96
This commit is contained in:
parent
89f82480c9
commit
a2a2bb407b
|
@ -45,16 +45,6 @@ cfg.CONF.import_opt('action_retry_limit', 'heat.common.config')
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_types(support_status):
|
||||
'''Return a list of valid resource types.'''
|
||||
return resources.global_env().get_types(support_status)
|
||||
|
||||
|
||||
def get_class(resource_type, resource_name=None):
|
||||
'''Return the Resource class for a given resource type.'''
|
||||
return resources.global_env().get_class(resource_type, resource_name)
|
||||
|
||||
|
||||
def _register_class(resource_type, resource_class):
|
||||
resources.global_env().register_class(resource_type, resource_class)
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ from heat.engine import environment
|
|||
from heat.engine.event import Event
|
||||
from heat.engine import parameter_groups
|
||||
from heat.engine import properties
|
||||
from heat.engine import resource
|
||||
from heat.engine import resources
|
||||
from heat.engine import stack as parser
|
||||
from heat.engine import stack_lock
|
||||
|
@ -949,7 +948,7 @@ class EngineService(service.Service):
|
|||
|
||||
:param cnxt: RPC context.
|
||||
"""
|
||||
return resource.get_types(support_status)
|
||||
return resources.global_env().get_types(support_status)
|
||||
|
||||
def resource_schema(self, cnxt, type_name):
|
||||
"""
|
||||
|
@ -959,7 +958,7 @@ class EngineService(service.Service):
|
|||
:param type_name: Name of the resource type to obtain the schema of.
|
||||
"""
|
||||
try:
|
||||
resource_class = resource.get_class(type_name)
|
||||
resource_class = resources.global_env().get_class(type_name)
|
||||
except exception.StackValidationFailed:
|
||||
raise exception.ResourceTypeNotFound(type_name=type_name)
|
||||
|
||||
|
@ -988,8 +987,8 @@ class EngineService(service.Service):
|
|||
:param type_name: Name of the resource type to generate a template for.
|
||||
"""
|
||||
try:
|
||||
return \
|
||||
resource.get_class(type_name).resource_to_template(type_name)
|
||||
return resources.global_env().get_class(
|
||||
type_name).resource_to_template(type_name)
|
||||
except exception.StackValidationFailed:
|
||||
raise exception.ResourceTypeNotFound(type_name=type_name)
|
||||
|
||||
|
|
|
@ -138,7 +138,8 @@ class InstanceGroupTest(common.HeatTestCase):
|
|||
class MyInstance(instance.Instance):
|
||||
"""A customized Instance resource."""
|
||||
|
||||
original_instance = resource.get_class("AWS::EC2::Instance")
|
||||
original_instance = resources.global_env().get_class(
|
||||
"AWS::EC2::Instance")
|
||||
resource._register_class("AWS::EC2::Instance", MyInstance)
|
||||
self.addCleanup(resource._register_class, "AWS::EC2::Instance",
|
||||
original_instance)
|
||||
|
|
|
@ -30,6 +30,7 @@ from heat.engine import dependencies
|
|||
from heat.engine import environment
|
||||
from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine import resources
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import template
|
||||
|
@ -64,11 +65,12 @@ class ResourceTest(HeatTestCase):
|
|||
self.patch('heat.engine.resource.warnings')
|
||||
|
||||
def test_get_class_ok(self):
|
||||
cls = resource.get_class('GenericResourceType')
|
||||
cls = resources.global_env().get_class('GenericResourceType')
|
||||
self.assertEqual(generic_rsrc.GenericResource, cls)
|
||||
|
||||
def test_get_class_noexist(self):
|
||||
self.assertRaises(exception.StackValidationFailed, resource.get_class,
|
||||
self.assertRaises(exception.StackValidationFailed,
|
||||
resources.global_env().get_class,
|
||||
'NoExistResourceType')
|
||||
|
||||
def test_resource_new_ok(self):
|
||||
|
|
Loading…
Reference in New Issue