~smoser/cloud-init/trunk.new-ds

« back to all changes in this revision

Viewing changes to cloudinit/config/cc_puppet.py

  • Committer: Scott Moser
  • Date: 2015-02-11 01:53:20 UTC
  • mfrom: (1052.1.45 py2-3.smoser)
  • Revision ID: smoser@ubuntu.com-20150211015320-049dv6n1mk2in7l1
python3 support.

This gives us functional python3 support.  There are likely
still bugs, but instance boot on openstack is functional now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#    You should have received a copy of the GNU General Public License
19
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
20
 
21
 
from StringIO import StringIO
 
21
from six import StringIO
22
22
 
23
23
import os
24
24
import socket
81
81
        cleaned_contents = '\n'.join(cleaned_lines)
82
82
        puppet_config.readfp(StringIO(cleaned_contents),
83
83
                             filename=PUPPET_CONF_PATH)
84
 
        for (cfg_name, cfg) in puppet_cfg['conf'].iteritems():
 
84
        for (cfg_name, cfg) in puppet_cfg['conf'].items():
85
85
            # Cert configuration is a special case
86
86
            # Dump the puppet master ca certificate in the correct place
87
87
            if cfg_name == 'ca_cert':
88
88
                # Puppet ssl sub-directory isn't created yet
89
89
                # Create it with the proper permissions and ownership
90
 
                util.ensure_dir(PUPPET_SSL_DIR, 0771)
 
90
                util.ensure_dir(PUPPET_SSL_DIR, 0o771)
91
91
                util.chownbyname(PUPPET_SSL_DIR, 'puppet', 'root')
92
92
                util.ensure_dir(PUPPET_SSL_CERT_DIR)
93
93
                util.chownbyname(PUPPET_SSL_CERT_DIR, 'puppet', 'root')
94
 
                util.write_file(PUPPET_SSL_CERT_PATH, str(cfg))
 
94
                util.write_file(PUPPET_SSL_CERT_PATH, cfg)
95
95
                util.chownbyname(PUPPET_SSL_CERT_PATH, 'puppet', 'root')
96
96
            else:
97
97
                # Iterate throug the config items, we'll use ConfigParser.set
98
98
                # to overwrite or create new items as needed
99
 
                for (o, v) in cfg.iteritems():
 
99
                for (o, v) in cfg.items():
100
100
                    if o == 'certname':
101
101
                        # Expand %f as the fqdn
102
102
                        # TODO(harlowja) should this use the cloud fqdn??