Merge "fix bug to upload chef node template" into dev/experimental

This commit is contained in:
Jenkins 2014-08-22 22:01:54 +00:00 committed by Gerrit Code Review
commit 7ea34feb85
5 changed files with 26 additions and 14 deletions

View File

@ -116,15 +116,19 @@ class CobblerInstaller(OSInstaller):
} }
} }
""" """
host_ids = self.config_manager.get_host_id_list()
if not host_ids:
# No hosts need to install OS
return {}
os_version = self.config_manager.get_os_version() os_version = self.config_manager.get_os_version()
profile = self._get_profile_from_server(os_version) profile = self._get_profile_from_server(os_version)
global_vars_dict = self._get_cluster_tmpl_vars_dict() global_vars_dict = self._get_cluster_tmpl_vars_dict()
clusterhost_ids = self.config_manager.get_host_id_list()
hosts_deploy_config = {} hosts_deploy_config = {}
for host_id in clusterhost_ids: for host_id in host_ids:
hostname = self.config_manager.get_hostname(host_id) hostname = self.config_manager.get_hostname(host_id)
vars_dict = self._get_host_tmpl_vars_dict(host_id, vars_dict = self._get_host_tmpl_vars_dict(host_id,
global_vars_dict, global_vars_dict,

View File

@ -193,14 +193,16 @@ class ChefInstaller(PKInstaller):
return {} return {}
node_tmpl_dir = os.path.join(self.tmpl_dir, self.NODE_TMPL_DIR) node_tmpl_dir = os.path.join(self.tmpl_dir, self.NODE_TMPL_DIR)
node_attri = {} node_attr = {}
for role in roles: for role in roles:
role = role.replace('-', '_') role = role.replace('-', '_')
tmpl_name = '.'.join((role, 'tmpl')) tmpl_name = '.'.join((role, 'tmpl'))
node_tmpl = os.path.join(node_tmpl_dir, tmpl_name) node_tmpl = os.path.join(node_tmpl_dir, tmpl_name)
node_attri = self.get_config_from_template(node_tmpl, vars_dict) util.merge_dict(
node_attr, self.get_config_from_template(node_tmpl, vars_dict)
)
return node_attri return node_attr
def update_node(self, node, roles, vars_dict): def update_node(self, node, roles, vars_dict):
"""Update node attributes to chef server.""" """Update node attributes to chef server."""

View File

@ -73,6 +73,7 @@ class TestChefInstaller(unittest2.TestCase):
vars_dict = self.test_chef._get_host_tmpl_vars(2, cluster_dict) vars_dict = self.test_chef._get_host_tmpl_vars(2, cluster_dict)
expected_node_attr = { expected_node_attr = {
"override_attributes": { "override_attributes": {
"openstack": {
"endpoints": { "endpoints": {
"compute-vnc-bind": { "compute-vnc-bind": {
"host": "12.234.32.101" "host": "12.234.32.101"
@ -80,6 +81,7 @@ class TestChefInstaller(unittest2.TestCase):
} }
} }
} }
}
output = self.test_chef._get_node_attributes(['os-compute'], vars_dict) output = self.test_chef._get_node_attributes(['os-compute'], vars_dict)
self.maxDiff = None self.maxDiff = None
self.assertDictEqual(expected_node_attr, output) self.assertDictEqual(expected_node_attr, output)

View File

@ -1,9 +1,11 @@
{ {
"override_attributes": { "override_attributes": {
"openstack": {
"endpoints": { "endpoints": {
"compute-vnc-bind": { "compute-vnc-bind": {
"host":"$host.deployed_package_config.roles_mapping.os_compute.management.ip" "host":"$host.deployed_package_config.roles_mapping.os_compute.management.ip"
} }
} }
} }
}
} }

View File

@ -116,6 +116,7 @@ class TestChefInstaller(unittest2.TestCase):
self.assertEqual(result_node.chef_environment, env_name) self.assertEqual(result_node.chef_environment, env_name)
expected_node_attr = { expected_node_attr = {
"override_attributes": { "override_attributes": {
"openstack": {
"endpoints": { "endpoints": {
"compute-vnc-bind": { "compute-vnc-bind": {
"host": "12.234.32.101" "host": "12.234.32.101"
@ -123,6 +124,7 @@ class TestChefInstaller(unittest2.TestCase):
} }
} }
} }
}
self.maxDiff = None self.maxDiff = None
self.assertDictEqual(expected_node_attr, self.assertDictEqual(expected_node_attr,
result_node.attributes.to_dict()) result_node.attributes.to_dict())