Esempio n. 1
0
    def action_configure(self, _, *args, **kwargs):
        """
        Configure.

        :param _: Unused
        :param *args: Unused
        :param **kwargs: Unused
        :returns: None
        """

        try:
            result = GlobalParameterDbApi().getParameter(
                self.session,
                'DHCPLeaseTime'
            )

            dhcp_lease_time = int(result.getValue())
        except ParameterNotFound:
            dhcp_lease_time = 2400

        try:
            result = GlobalParameterDbApi().getParameter(
                self.session,
                'DNSZone')

            dns_zone = result.getValue()
        except ParameterNotFound:
            dns_zone = ''

        installer_node = NodeApi().getInstallerNode(self.session)

        self._manager.configure(
            dhcp_lease_time,
            dns_zone,
            self._get_provisioning_nics_ip(installer_node),
            self._dhcp_subnets(),
            installerNode=installer_node,
            bUpdateSysconfig=kwargs.get('bUpdateSysconfig', True),
            kit_settings=self._get_kit_settings_dictionary
        )
Esempio n. 2
0
    def configure(self):
        fp = open(CONFIG_FILE, 'w')

        session = self.session

        try:
            print("# ", file=fp)
            print("# Dynamically generated by: genconfig (Do not edit!)",
                  file=fp)
            print("#", file=fp)
            print("", file=fp)

            try:
                result = GlobalParameterDbApi().getParameter(
                    self.session, 'DNSZone'
                )

                dnszone = result.getValue()
            except ParameterNotFound:
                dnszone = ''

            for db_nic in session.query(Nic).order_by(Nic.ip).all():
                if db_nic.node.state == 'Deleted':
                    continue

                if not db_nic.ip:
                    continue

                name = db_nic.node.name.split('.')[0]

                print('Host {}'.format(db_nic.ip), file=fp)
                print('\tStrictHostKeyChecking no', file=fp)

                print('Host {}.{}'.format(name, dnszone), file=fp)
                print('\tStrictHostKeyChecking no', file=fp)

                print('Host {}'.format(name), file=fp)
                print('\tStrictHostKeyChecking no', file=fp)

                print("", file=fp)

            print('Host *', file=fp)
            print('\t# ssh_config defaults', file=fp)
            print('\tGSSAPIAuthentication yes', file=fp)
            print('\tForwardX11Trusted yes', file=fp)
            print('\t# tortuga defaults', file=fp)
            print('\tNoHostAuthenticationForLocalhost yes', file=fp)
            print('\tStrictHostKeyChecking no', file=fp)

        finally:
            fp.close()