fix bug to upload chef node template

Change-Id: Icdac5dd78c966944c466ed7054a63b47d361666d
This commit is contained in:
grace.yu 2014-08-21 18:00:32 -07:00
parent 14eab119b3
commit 816a29364b
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()
profile = self._get_profile_from_server(os_version)
global_vars_dict = self._get_cluster_tmpl_vars_dict()
clusterhost_ids = self.config_manager.get_host_id_list()
hosts_deploy_config = {}
for host_id in clusterhost_ids:
for host_id in host_ids:
hostname = self.config_manager.get_hostname(host_id)
vars_dict = self._get_host_tmpl_vars_dict(host_id,
global_vars_dict,

View File

@ -193,14 +193,16 @@ class ChefInstaller(PKInstaller):
return {}
node_tmpl_dir = os.path.join(self.tmpl_dir, self.NODE_TMPL_DIR)
node_attri = {}
node_attr = {}
for role in roles:
role = role.replace('-', '_')
tmpl_name = '.'.join((role, 'tmpl'))
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):
"""Update node attributes to chef server."""

View File

@ -73,9 +73,11 @@ class TestChefInstaller(unittest2.TestCase):
vars_dict = self.test_chef._get_host_tmpl_vars(2, cluster_dict)
expected_node_attr = {
"override_attributes": {
"endpoints": {
"compute-vnc-bind": {
"host": "12.234.32.101"
"openstack": {
"endpoints": {
"compute-vnc-bind": {
"host": "12.234.32.101"
}
}
}
}

View File

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

View File

@ -116,9 +116,11 @@ class TestChefInstaller(unittest2.TestCase):
self.assertEqual(result_node.chef_environment, env_name)
expected_node_attr = {
"override_attributes": {
"endpoints": {
"compute-vnc-bind": {
"host": "12.234.32.101"
"openstack": {
"endpoints": {
"compute-vnc-bind": {
"host": "12.234.32.101"
}
}
}
}