Merge "Move the registration of the global env to after plugin resources"
This commit is contained in:
commit
662c0108af
@ -70,8 +70,8 @@ def _list_environment_files(env_dir):
|
||||
|
||||
|
||||
def _load_all(env):
|
||||
_load_global_environment(env)
|
||||
_load_global_resources(env)
|
||||
_load_global_environment(env)
|
||||
|
||||
|
||||
def _load_global_environment(env, env_dir=None):
|
||||
|
@ -12,8 +12,13 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import os.path
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
cfg.CONF.import_opt('environment_dir', 'heat.common.config')
|
||||
|
||||
from heat.engine import environment
|
||||
from heat.engine import resources
|
||||
@ -170,3 +175,28 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
|
||||
expected = [mock.call('%s/a.yaml' % env_dir),
|
||||
mock.call('%s/b.yaml' % env_dir)]
|
||||
self.assertEqual(expected, m_open.call_args_list)
|
||||
|
||||
def test_env_resources_override_plugins(self):
|
||||
# assertion: any template resources in the global environment
|
||||
# should override the default plugins.
|
||||
|
||||
# 1. set our own global test env
|
||||
# (with a template resource that shadows a plugin)
|
||||
g_env_content = '''
|
||||
resource_registry:
|
||||
"OS::Nova::Server": "file:///not_really_here.yaml"
|
||||
'''
|
||||
envdir = self.useFixture(fixtures.TempDir())
|
||||
#
|
||||
envfile = os.path.join(envdir.path, 'test.yaml')
|
||||
with open(envfile, 'w+') as ef:
|
||||
ef.write(g_env_content)
|
||||
cfg.CONF.set_override('environment_dir', envdir.path)
|
||||
|
||||
# 2. load global env
|
||||
g_env = environment.Environment({}, user_env=False)
|
||||
resources._load_all(g_env)
|
||||
|
||||
# 3. assert our resource is in place.
|
||||
self.assertEqual('file:///not_really_here.yaml',
|
||||
g_env.get_resource_info('OS::Nova::Server').value)
|
||||
|
Loading…
Reference in New Issue
Block a user