~allenap/maas/regiond-leader

« back to all changes in this revision

Viewing changes to src/maasserver/management/commands/edit_named_options.py

  • Committer: MAAS Lander
  • Author(s): Mike Pontillo
  • Date: 2015-04-29 07:38:54 UTC
  • mfrom: (3838.1.5 wip)
  • Revision ID: maas_lander-20150429073854-q9bkd825pyvfhcuk
[r=allenap][bug=1384334][author=mpontillo] Add configuration option for dnssec-validation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    help = (
47
47
        "Edit the named.conf.options file so that it includes the "
48
48
        "named.conf.options.inside.maas file, which contains the "
49
 
        "'forwarders' setting.  A backup of the old file will be made "
50
 
        "with the suffix '.maas-YYYY-MM-DDTHH:MM:SS.mmmmmm'.  This "
51
 
        "program must be run as root.")
 
49
        "'forwarders' and 'dnssec-validation' settings.  A backup "
 
50
        "of the old file will be made with the suffix "
 
51
        "'.maas-YYYY-MM-DDTHH:MM:SS.mmmmmm'.  This program must be run as "
 
52
        "root.")
52
53
 
53
54
    def read_file(self, config_path):
54
55
        """Open the named file and return its contents as a string."""
95
96
        if 'forwarders' in options_block:
96
97
            del options_block['forwarders']
97
98
 
 
99
    def remove_dnssec_validation(self, options_block):
 
100
        """Remove existing dnssec-validation from the options block.
 
101
 
 
102
        It's a syntax error to have more than one in the combined
 
103
        configuration for named so we just remove whatever was there.
 
104
        There is no data loss due to the backup file made later.
 
105
        """
 
106
        if 'dnssec-validation' in options_block:
 
107
            del options_block['dnssec-validation']
 
108
 
98
109
    def back_up_existing_file(self, config_path):
99
110
        now = datetime.now().isoformat()
100
111
        backup_destination = config_path + '.' + now
116
127
        # Modify the config.
117
128
        self.set_up_include_statement(options_block, config_path)
118
129
        self.remove_forwarders(options_block)
 
130
        self.remove_dnssec_validation(options_block)
119
131
        new_content = MakeISC(config_dict)
120
132
 
121
133
        # Back up and write new file.