Esempio n. 1
0
 def write_config(self):
     """Writes configuration for DrbdResource"""
     context = {'res': self.res}
     fn = self.res.config_filename
     logger.info('Writing config for Resource "%s" to "%s".', self.res, fn)
     quick_template('drbd-resource.conf', context=context, write_file=fn)
     return True
Esempio n. 2
0
def write_network_interfaces_config(confirm=False):
    """Write out network configuration"""
    context = dict(
        ifaces=[nic.config for nic in Nic.list().values() if nic.name != 'lo' and ':' not in nic.name],
        #ifaces=NicConfig.objects.filter(is_enabled=True),
        #netconf=get_network_config(),
        floating_ips=FloatingIP.objects.all(),
    )
    if confirm:
        fn = '/etc/network/interfaces'
        if os.path.isfile(fn):
            shutil.copyfile(fn, '%s.bak' % fn)
    else:
        fn = None
    return quick_template('interfaces', context=context, write_file=fn)
Esempio n. 3
0
    def set_text(self):
        """
        Create Pool: {{ name }}

        Devices: [
            {%- for dev in devices %}
            {{ dev }}
            {%- endfor %}
        ]
        """
        context = dict(name=self.name, devices=self.devices)
        tmpl_pre = self.set_text.func_doc
        tmpl = []
        for line in tmpl_pre.splitlines()[1:]:
            tmpl.append(line[8:])
        tmpl = '\n'.join(tmpl)

        text = quick_template(tmpl, context, is_string=True)
        top_text.set_text(text)
Esempio n. 4
0
def set_text(**context):
    """
    Create Pool: {{ name }}

    Devices: [
        {%- for dev in devices %}
        {{ dev }}
        {%- endfor %}
    ]
    """
    if context:
        tmpl_context.update(context)

    tmpl_pre = set_text.func_doc
    tmpl = []
    for line in tmpl_pre.splitlines()[1:]:
        tmpl.append(line[4:])
    tmpl = '\n'.join(tmpl)

    text = quick_template(tmpl, tmpl_context, is_string=True)
    top_text.set_text(text)