Exemplo n.º 1
0
 def prepare_examples(self):
     content = self._get_rules()
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=osetupcons.FileLocations.OVIRT_IPTABLES_EXAMPLE,
             content=content,
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES
             ],
         )
     )
Exemplo n.º 2
0
 def _store_iptables(self):
     self.environment[constants.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=self.REDHAT_IPTABLES,
             owner='root',
             mode=0o600,
             enforcePermissions=True,
             content=self.environment[constants.NetEnv.IPTABLES_RULES],
             modifiedList=self.environment[
                 constants.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 3
0
 def _misc(self):
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=osetupcons.FileLocations.AIO_POST_INSTALL_CONFIG,
             content=(
                 '[environment:default]',
                 'OVESETUP_AIO/enable=bool:False',
             ),
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 4
0
    def add_to_transaction(
        self,
        uninstall_group_name,
        uninstall_group_desc,
    ):
        uninstall_files = []
        self.environment[
            osetupcons.CoreEnv.REGISTER_UNINSTALL_GROUPS
        ].createGroup(
            group=uninstall_group_name,
            description=uninstall_group_desc,
            optional=True,
        ).addFiles(
            group=uninstall_group_name,
            fileList=uninstall_files,
        )
        if self._need_key:
            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
                filetransaction.FileTransaction(
                    name=self._key_file,
                    mode=0o600,
                    owner=self.environment[osetupcons.SystemEnv.USER_ENGINE],
                    enforcePermissions=True,
                    content=self._key,
                    binary=True,
                    modifiedList=uninstall_files,
                )
            )

        if self._need_cert:
            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
                filetransaction.FileTransaction(
                    name=self._cert_file,
                    mode=0o600,
                    owner=self.environment[osetupcons.SystemEnv.USER_ENGINE],
                    enforcePermissions=True,
                    content=self._cert,
                    binary=True,
                    modifiedList=uninstall_files,
                )
            )
Exemplo n.º 5
0
 def _misc(self):
     for entry in self.TOOLS_CONFIG:
         name = self._entry_filename(entry)
         self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
             filetransaction.FileTransaction(
                 name=name,
                 content=self._content_with_renamed_fqdn(name),
                 modifiedList=self.environment[
                     otopicons.CoreEnv.MODIFIED_FILES
                 ],
             )
         )
Exemplo n.º 6
0
    def _expandPKCS12(self, pkcs12, name, owner, uninstall_files):
        rc, key, stderr = self.execute(
            args=(
                self.command.get('openssl'),
                'pkcs12',
                '-in', pkcs12,
                '-passin', 'pass:%s' % self.environment[
                    oenginecons.PKIEnv.STORE_PASS
                ],
                '-nodes',
                '-nocerts',
            ),
            logStreams=False,
        )

        localtransaction = transaction.Transaction()
        with localtransaction:
            localtransaction.append(
                filetransaction.FileTransaction(
                    name=os.path.join(
                        oenginecons.FileLocations.OVIRT_ENGINE_PKICERTSDIR,
                        '%s.cer' % name,
                    ),
                    content=self._extractPKCS12CertificateString(pkcs12),
                    mode=0o644,
                    modifiedList=uninstall_files,
                )
            )
            localtransaction.append(
                filetransaction.FileTransaction(
                    name=os.path.join(
                        oenginecons.FileLocations.OVIRT_ENGINE_PKIKEYSDIR,
                        '%s.key.nopass' % name,
                    ),
                    content=key,
                    mode=0o600,
                    owner=owner,
                    modifiedList=uninstall_files,
                )
            )
Exemplo n.º 7
0
 def _misc(self):
     f = StringIO.StringIO()
     try:
         self._cfg.write(f)
         self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
             filetransaction.FileTransaction(
                 name=self._conffile,
                 content=f.getvalue(),
                 modifiedList=self.environment[
                     otopicons.CoreEnv.MODIFIED_FILES],
             ))
     finally:
         f.close()
Exemplo n.º 8
0
 def _misc(self):
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=(oclcons.FileLocations.
                   OVIRT_ENGINE_SERVICE_CONFIG_CINDERLIB_MISC),
             mode=0o640,
             owner=self.environment[oengcommcons.SystemEnv.USER_ROOT],
             group=self.environment[osetupcons.SystemEnv.GROUP_ENGINE],
             enforcePermissions=True,
             content=self.get_cinderlib_db_enable_content(),
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 9
0
    def _updatePostgresConf(
        self,
        transaction,
        maxconn,
        listenaddr,
    ):
        with open(self.environment[
                oengcommcons.ProvisioningEnv.POSTGRES_CONF]) as f:
            content = f.read().splitlines()

        needUpdate = True
        maxConnOK = False
        listenAddrOK = False
        for l in content:
            m = self._RE_KEY_VALUE.match(l)
            if m is not None:
                if m.group('key') == 'max_connections':
                    if int(m.group('value')) >= int(maxconn):
                        maxConnOK = True
                    else:
                        break
                elif m.group('key') == 'listen_addresses':
                    if m.group('value') == listenaddr:
                        listenAddrOK = True
                    else:
                        break
            if (maxConnOK and listenAddrOK):
                needUpdate = False
                break

        if needUpdate:
            content = osetuputil.editConfigContent(
                content=content,
                params={
                    'max_connections': maxconn,
                    'listen_addresses': listenaddr
                },
            )

            transaction.append(
                filetransaction.FileTransaction(
                    name=self.environment[
                        oengcommcons.ProvisioningEnv.POSTGRES_CONF],
                    content=content,
                    modifiedList=self.environment[
                        otopicons.CoreEnv.MODIFIED_FILES],
                ), )
            self.environment[
                osetupcons.CoreEnv.UNINSTALL_UNREMOVABLE_FILES].append(
                    self.environment[
                        oengcommcons.ProvisioningEnv.POSTGRES_CONF])
Exemplo n.º 10
0
 def _misc(self):
     uninstall_files = []
     self.environment[
         osetupcons.CoreEnv.REGISTER_UNINSTALL_GROUPS].createGroup(
             group='ca_config',
             description='PKI configuration',
             optional=True,
         ).addFiles(
             'ca_config',
             uninstall_files,
         )
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=(
                 osetupcons.FileLocations.OVIRT_ENGINE_SERVICE_CONFIG_PKI),
             mode=0o600,
             owner=self.environment[osetupcons.SystemEnv.USER_ENGINE],
             enforcePermissions=True,
             content=(
                 'ENGINE_PKI="{pki_dir}"\n'
                 'ENGINE_PKI_CA="{ca}"\n'
                 'ENGINE_PKI_ENGINE_CERT="{engine_cert}"\n'
                 'ENGINE_PKI_TRUST_STORE="{trust_store}"\n'
                 'ENGINE_PKI_TRUST_STORE_PASSWORD='******'"{trust_store_password}"\n') +
                 'ENGINE_PKI_ENGINE_STORE="{engine_store}"\n'
                 'ENGINE_PKI_ENGINE_STORE_PASSWORD='******'"{engine_store_password}"\n') +
                 'ENGINE_PKI_ENGINE_STORE_ALIAS="{engine_store_alias}"\n'
             ).format(
                 pki_dir=(osetupcons.FileLocations.OVIRT_ENGINE_PKIDIR),
                 ca=(osetupcons.FileLocations.
                     OVIRT_ENGINE_PKI_ENGINE_CA_CERT),
                 engine_cert=(
                     osetupcons.FileLocations.OVIRT_ENGINE_PKI_ENGINE_CERT),
                 trust_store=(osetupcons.FileLocations.
                              OVIRT_ENGINE_PKI_ENGINE_TRUST_STORE),
                 trust_store_password=osetuputil.escape(
                     osetupcons.Const.PKI_PASSWORD,
                     '"\\$',
                 ),
                 engine_store=(osetupcons.FileLocations.
                               OVIRT_ENGINE_PKI_ENGINE_STORE),
                 engine_store_password=osetuputil.escape(
                     osetupcons.Const.PKI_PASSWORD,
                     '"\\$',
                 ),
                 engine_store_alias='1',
             ),
             modifiedList=uninstall_files,
         ))
    def _process_templates(self):
        for service in self.environment[
                ohostedcons.NetworkEnv.FIREWALLD_SERVICES]:
            content = ohostedutil.processTemplate(
                template=os.path.join(
                    ohostedcons.FileLocations.
                    HOSTED_ENGINE_FIREWALLD_TEMPLATES_DIR,
                    service['directory'],
                    '%s.xml.in' % service['name'],
                ),
                subst=self.environment[ohostedcons.NetworkEnv.FIREWALLD_SUBST],
            )

            self.environment[otopicons.NetEnv.FIREWALLD_SERVICE_PREFIX +
                             service['name']] = content

            target = os.path.join(
                ohostedcons.FileLocations.HOSTED_ENGINE_FIREWALLD_EXAMPLE_DIR,
                '%s.xml' % service['name'])

            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
                filetransaction.FileTransaction(
                    name=target,
                    content=content,
                    modifiedList=self.environment[
                        otopicons.CoreEnv.MODIFIED_FILES],
                ))

        self.environment[
            otopicons.NetEnv.IPTABLES_RULES] = self._createIptablesConfig()

        self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
            filetransaction.FileTransaction(
                name=ohostedcons.FileLocations.HOSTED_ENGINE_IPTABLES_EXAMPLE,
                content=self.environment[otopicons.NetEnv.IPTABLES_RULES],
                modifiedList=self.environment[
                    otopicons.CoreEnv.MODIFIED_FILES],
            ))
Exemplo n.º 12
0
    def _misc(self):
        for e in (
            {
                'nameKey': constants.LDAPEnv.CONFIG_AUTHN_FILE_NAME,
                'contentKey': constants.LDAPEnv.CONFIG_AUTHN,
                'mode': 0o644,
                'binary': False,
                'owner': None,
            },
            {
                'nameKey': constants.LDAPEnv.CONFIG_AUTHZ_FILE_NAME,
                'contentKey': constants.LDAPEnv.CONFIG_AUTHZ,
                'mode': 0o644,
                'binary': False,
                'owner': None,
            },
            {
                'nameKey': constants.LDAPEnv.CONFIG_PROFILE_FILE_NAME,
                'contentKey': constants.LDAPEnv.CONFIG_PROFILE,
                'mode': 0o600,
                'binary': False,
                'owner': self.environment[constants.CoreEnv.USER_OVIRT],
            },
            {
                'nameKey': constants.LDAPEnv.CONFIG_JKS_FILE_NAME,
                'contentKey': constants.LDAPEnv.CONFIG_JKS,
                'mode': 0o644,
                'binary': True,
                'owner': None,
            },
        ):
            if self.environment[e['contentKey']] is not None:
                self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
                    filetransaction.FileTransaction(
                        name=os.path.join(
                            constants.FileLocations.ENGINE_ETC,
                            self.environment[e['nameKey']],
                        ),
                        mode=e['mode'],
                        owner=e['owner'],
                        enforcePermissions=True,
                        content=self.environment[e['contentKey']],
                        binary=e['binary'],
                        modifiedList=self._files,
                    )
                )

        self.environment[
            otopicons.CoreEnv.MODIFIED_FILES
        ].extend(self._files)
Exemplo n.º 13
0
    def _misc(self):
        sysctl = filetransaction.FileTransaction(
            name=osetupcons.FileLocations.OVIRT_ENGINE_SYSCTL,
            content=self._content,
            modifiedList=self.environment[otopicons.CoreEnv.MODIFIED_FILES],
        )
        self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(sysctl)

        # we must do this here as postgres requires it
        self.execute((
            self.command.get('sysctl'),
            '-p',
            sysctl.tmpname,
        ), )
Exemplo n.º 14
0
    def _misc(self):
        with open(oengcommcons.FileLocations.HTTPD_CONF_OVIRT_ROOT_TEMPLATE,
                  'r') as f:
            content = f.read()

        self.environment[oengcommcons.ApacheEnv.NEED_RESTART] = True
        self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
            filetransaction.FileTransaction(
                name=self.environment[
                    oengcommcons.ApacheEnv.HTTPD_CONF_OVIRT_ROOT],
                content=content,
                modifiedList=self.environment[
                    otopicons.CoreEnv.MODIFIED_FILES],
            ))
Exemplo n.º 15
0
    def _getSSH(self):
        pkihelper = pkissh.PKIHelper()
        authorized_keys_line = pkihelper.getSSHkey(
            fqdn=self.environment[
                ohostedcons.NetworkEnv.OVIRT_HOSTED_ENGINE_FQDN
            ],
            ca_certs=self.environment[
                ohostedcons.EngineEnv.TEMPORARY_CERT_FILE
            ],
        )

        authorized_keys_file = os.path.join(
            os.path.expanduser('~root'),
            '.ssh',
            'authorized_keys'
        )

        content = pkihelper.mergeAuthKeysFile(
            authorized_keys_file, authorized_keys_line
        )
        with transaction.Transaction() as localtransaction:
            localtransaction.append(
                filetransaction.FileTransaction(
                    name=authorized_keys_file,
                    content=content,
                    mode=0o600,
                    owner='root',
                    enforcePermissions=True,
                    modifiedList=self.environment[
                        otopicons.CoreEnv.MODIFIED_FILES
                    ],
                )
            )

        if self._selinux_enabled:
            path = os.path.join(
                os.path.expanduser('~root'),
                '.ssh'
            )
            try:
                selinux.restorecon(path, recursive=True)
            except OSError as ex:
                self.logger.error(
                    _(
                        'Failed to refresh SELINUX context for {path}: {ex}'
                    ).format(
                        path=path,
                        ex=ex.message,
                    )
                )
Exemplo n.º 16
0
    def _validation(self):
        config = configparser.ConfigParser()
        config.optionxform = str

        vars = [
            var for var in self.environment
            if var.startswith(odeploycons.VdsmEnv.CONFIG_PREFIX)
        ]

        for var in vars:
            try:
                section, key = var.replace(
                    odeploycons.VdsmEnv.CONFIG_PREFIX, ''
                ).split('/', 1)
            except ValueError:
                raise RuntimeError(
                    _('Invalid VDSM configuration entry {key}').format(
                        key=key
                    )
                )

            value = self.environment[var]

            if not config.has_section(section):
                config.add_section(section)
            config.set(section, key, value)

        class buf(object):
            """io.StringIO is not working???"""
            def __init__(self):
                self.content = ''

            def write(self, s):
                self.content += s
        b = buf()
        config.write(b)

        if b.content:
            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
                filetransaction.FileTransaction(
                    name=odeploycons.FileLocations.VDSM_CONFIG_FILE,
                    owner='root',
                    enforcePermissions=True,
                    content=b.content,
                    modifiedList=self.environment[
                        otopicons.CoreEnv.MODIFIED_FILES
                    ],
                )
            )
Exemplo n.º 17
0
 def _misc(self):
     with open(odeploycons.FileLocations.NRPE_CONFIG_FILE, 'r') as f:
         content = f.read().splitlines()
     newcontent = self._getNewFileContent(
         content,
         self.environment[odeploycons.GlusterEnv.MONITORING_SERVER])
     if content != newcontent:
         self._modified = True
         self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
             filetransaction.FileTransaction(
                 name=odeploycons.FileLocations.NRPE_CONFIG_FILE,
                 content=newcontent,
                 modifiedList=self.environment[
                     otopicons.CoreEnv.MODIFIED_FILES],
             ))
Exemplo n.º 18
0
    def _delete_path(self, path, conf, modifiedList):
        conf_content = ''
        if os.path.exists(conf):
            with open(conf, 'r') as src_file:
                conf_content = src_file.read()

            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
                filetransaction.FileTransaction(
                    name=conf,
                    # Can't compile parametric re
                    content=re.sub(pattern=r'%s\s+[^\n]+\n' % path,
                                   repl='',
                                   string=conf_content),
                    modifiedList=modifiedList,
                ))
Exemplo n.º 19
0
 def _misc(self):
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=(oenginecons.FileLocations.
                   OVIRT_ENGINE_SERVICE_CONFIG_DATABASE),
             mode=0o600,
             owner=self.environment[osetupcons.SystemEnv.USER_ENGINE],
             enforcePermissions=True,
             content=database.OvirtUtils(
                 plugin=self,
                 dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS).
             getDBConfig(prefix="ENGINE"),
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 20
0
 def _update_templates(self, aia, templates_map, uninstall_files):
     localtransaction = transaction.Transaction()
     with localtransaction:
         for in_template, outputs in templates_map.items():
             if aia is not None:
                 for output_file in outputs:
                     localtransaction.append(
                         filetransaction.FileTransaction(
                             name=output_file,
                             content=outil.processTemplate(
                                 in_template, {
                                     '@AIA@': aia,
                                 }),
                             modifiedList=uninstall_files,
                         ), )
Exemplo n.º 21
0
 def _misc(self):
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=(oenginecons.FileLocations.
                   OVIRT_ENGINE_SERVICE_CONFIG_JAVA),
             content=[
                 'ENGINE_HEAP_MIN="{heap_min}"'.format(
                     heap_min=self.environment[
                         oenginecons.ConfigEnv.ENGINE_HEAP_MIN], ),
                 'ENGINE_HEAP_MAX="{heap_max}"'.format(
                     heap_max=self.environment[
                         oenginecons.ConfigEnv.ENGINE_HEAP_MAX], ),
             ],
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 22
0
 def _misc(self):
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=(oenginecons.FileLocations.
                   OVIRT_ENGINE_SERVICE_CONFIG_DATABASE),
             mode=0o600,
             owner=self.environment[osetupcons.SystemEnv.USER_ENGINE],
             enforcePermissions=True,
             content=('ENGINE_DB_HOST="{host}"\n'
                      'ENGINE_DB_PORT="{port}"\n'
                      'ENGINE_DB_USER="******"\n'
                      'ENGINE_DB_PASSWORD="******"\n'
                      'ENGINE_DB_DATABASE="{db}"\n'
                      'ENGINE_DB_SECURED="{secured}"\n'
                      'ENGINE_DB_SECURED_VALIDATION="{securedValidation}"\n'
                      'ENGINE_DB_DRIVER="org.postgresql.Driver"\n'
                      'ENGINE_DB_URL=' +
                      ('"'
                       'jdbc:postgresql://'
                       '${{ENGINE_DB_HOST}}:${{ENGINE_DB_PORT}}'
                       '/${{ENGINE_DB_DATABASE}}'
                       '?{jdbcTlsOptions}'
                       '"\n') + '').
             format(
                 host=self.environment[oenginecons.EngineDBEnv.HOST],
                 port=self.environment[oenginecons.EngineDBEnv.PORT],
                 user=self.environment[oenginecons.EngineDBEnv.USER],
                 password=outil.escape(
                     self.environment[oenginecons.EngineDBEnv.PASSWORD],
                     '"\\$',
                 ),
                 db=self.environment[oenginecons.EngineDBEnv.DATABASE],
                 secured=self.environment[oenginecons.EngineDBEnv.SECURED],
                 securedValidation=self.environment[
                     oenginecons.EngineDBEnv.SECURED_HOST_VALIDATION],
                 jdbcTlsOptions='&'.join(s for s in (
                     'ssl=true' if self.environment[oenginecons.EngineDBEnv.
                                                    SECURED] else '',
                     ('sslfactory='
                      'org.postgresql.ssl.NonValidatingFactory') if
                     not self.environment[oenginecons.EngineDBEnv.
                                          SECURED_HOST_VALIDATION] else '')
                                         if s),
             ),
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 23
0
    def _write_new_config(self, file_name, content):
        timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
        new_file_name = "{}.new.{}".format(file_name, timestamp)

        # If we are writing a new file, write it immediately.
        # Note that this will not be rolled back by engine-setup
        # if there is some failure.
        local_transaction = transaction.Transaction()
        with local_transaction:
            local_transaction.append(
                filetransaction.FileTransaction(
                    name=new_file_name,
                    content=content,
                    modifiedList=self.environment[
                        otopicons.CoreEnv.MODIFIED_FILES],
                ))
        self._notifications.append((file_name, new_file_name))
Exemplo n.º 24
0
 def _misc(self):
     self.environment[osetupcons.ApacheEnv.NEED_RESTART] = True
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=self.environment[
                 osetupcons.ApacheEnv.HTTPD_CONF_OVIRT_ENGINE],
             content=osetuputil.processTemplate(
                 template=(osetupcons.FileLocations.
                           HTTPD_CONF_OVIRT_ENGINE_TEMPLATE),
                 subst={
                     '@JBOSS_AJP_PORT@':
                     self.environment[osetupcons.ConfigEnv.JBOSS_AJP_PORT],
                 },
             ),
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 25
0
 def _misc(self):
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=os.path.join(
                 self.environment[
                     oenginecons.AIOEnv.STORAGE_DOMAIN_DIR].rstrip('/'),
                 '.keep',
             ),
             content='',
             mode=0o644,
             dmode=0o755,
             owner=self.environment[oengcommcons.SystemEnv.USER_VDSM],
             group=self.environment[oengcommcons.SystemEnv.GROUP_KVM],
             downer=self.environment[oengcommcons.SystemEnv.USER_VDSM],
             dgroup=self.environment[oengcommcons.SystemEnv.GROUP_KVM],
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES],
         ))
Exemplo n.º 26
0
    def _misc_conffiles(self):
        self.environment[
            osetupcons.CoreEnv.REGISTER_UNINSTALL_GROUPS
        ].createGroup(
            group='ca_pki',
            description='PKI keys',
            optional=True,
        ).addFiles(
            group='ca_pki',
            fileList=self.uninstall_files,
        )

        localtransaction = transaction.Transaction()
        with localtransaction:
            for config in (
                oenginecons.FileLocations.OVIRT_ENGINE_PKI_CERT_TEMPLATE[
                    :-len('.in')],
                oenginecons.FileLocations.OVIRT_ENGINE_PKI_CERT_CONF
            ):
                with open(config, 'r') as f:
                    content = []
                    for line in f:
                        line = line.rstrip('\n')
                        if line.startswith('authorityInfoAccess'):
                            line = (
                                'authorityInfoAccess = '
                                'caIssuers;URI:http://%s:%s%s'
                            ) % (
                                self.environment[
                                    osetupcons.RenameEnv.FQDN
                                ],
                                self.environment[
                                    oengcommcons.ConfigEnv.PUBLIC_HTTP_PORT
                                ],
                                oenginecons.Const.ENGINE_PKI_CA_URI,
                            )
                        content.append(line)
                localtransaction.append(
                    filetransaction.FileTransaction(
                        name=config,
                        content=content,
                        modifiedList=self.uninstall_files,
                    ),
                )
Exemplo n.º 27
0
 def _misc(self):
     self.logger.info(
         _("Generating post install configuration file '{name}'").format(
             name=osetupcons.FileLocations.OVIRT_SETUP_POST_INSTALL_CONFIG,
         )
     )
     content = [u'[environment:default]']
     consts = []
     for constobj in self.environment[
         osetupcons.CoreEnv.SETUP_ATTRS_MODULES
     ]:
         consts.extend(constobj.__dict__['__osetup_attrs__'])
     for c in consts:
         for key in c.__dict__.values():
             if hasattr(key, '__osetup_attrs__'):
                 if key.__osetup_attrs__['postinstallfile']:
                     key = key.fget(None)
                     if key in self.environment:
                         value = self.environment[key]
                         content.append(
                             u'{key}={type}:{value}'.format(
                                 key=key,
                                 type=common.typeName(value),
                                 value=(
                                     u'\n '.join(value)
                                     # We want the next lines to be
                                     # indented, so that
                                     # configparser will treat them
                                     # as a single multi-line value.
                                     # So we join with '\n '.
                                     if isinstance(value, list)
                                     else value
                                 ),
                             )
                         )
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=osetupcons.FileLocations.OVIRT_SETUP_POST_INSTALL_CONFIG,
             content=content,
             modifiedList=self.environment[
                 otopicons.CoreEnv.MODIFIED_FILES
             ],
         )
     )
Exemplo n.º 28
0
    def _misc(self):
        def flag(o):
            return 'true' if o else 'false'

        content = (
            'ENGINE_FQDN={fqdn}\n'
            'ENGINE_PROXY_ENABLED={proxyFlag}\n'
            'ENGINE_PROXY_HTTP_PORT={proxyHttpPort}\n'
            'ENGINE_PROXY_HTTPS_PORT={proxyHttpsPort}\n'
            'ENGINE_AJP_ENABLED={proxyFlag}\n'
            'ENGINE_AJP_PORT={ajpPort}\n'
            'ENGINE_HTTP_ENABLED={directFlag}\n'
            'ENGINE_HTTPS_ENABLED={directFlag}\n'
            'ENGINE_HTTP_PORT={directHttpPort}\n'
            'ENGINE_HTTPS_PORT={directHttpsPort}\n'
        ).format(
            fqdn=self.environment[osetupcons.ConfigEnv.FQDN],
            proxyFlag=flag(
                self.environment[oengcommcons.ConfigEnv.JBOSS_AJP_PORT]),
            directFlag=flag(self.environment[
                oengcommcons.ConfigEnv.JBOSS_DIRECT_HTTP_PORT]),
            proxyHttpPort=self.environment[oengcommcons.ConfigEnv.HTTP_PORT],
            proxyHttpsPort=self.environment[oengcommcons.ConfigEnv.HTTPS_PORT],
            directHttpPort=self.environment[
                oengcommcons.ConfigEnv.JBOSS_DIRECT_HTTP_PORT],
            directHttpsPort=self.environment[
                oengcommcons.ConfigEnv.JBOSS_DIRECT_HTTPS_PORT],
            ajpPort=self.environment[oengcommcons.ConfigEnv.JBOSS_AJP_PORT],
        )

        if self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]:
            content += ('ENGINE_DEBUG_ADDRESS={debugAddress}\n').format(
                debugAddress=self.environment[
                    oengcommcons.ConfigEnv.JBOSS_DEBUG_ADDRESS], )

        self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
            filetransaction.FileTransaction(
                name=(oenginecons.FileLocations.
                      OVIRT_ENGINE_SERVICE_CONFIG_PROTOCOLS),
                content=content,
                modifiedList=self.environment[
                    otopicons.CoreEnv.MODIFIED_FILES],
            ))
Exemplo n.º 29
0
 def _misc(self):
     for f in (
         (osetupcons.FileLocations.OVIRT_ENGINE_SERVICE_CONFIG_JBOSS),
         (osetupcons.FileLocations.
          OVIRT_ENGINE_NOTIFIER_SERVICE_CONFIG_JBOSS),
     ):
         content = [
             'JBOSS_HOME="{jbossHome}"'.format(jbossHome=self.environment[
                 osetupcons.ConfigEnv.JBOSS_HOME], ),
         ]
         if self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]:
             content.append('ENGINE_LOG_TO_CONSOLE=true')
         self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
             filetransaction.FileTransaction(
                 name=f,
                 content=content,
                 modifiedList=self.environment[
                     otopicons.CoreEnv.MODIFIED_FILES],
             ))
Exemplo n.º 30
0
 def _misc(self):
     uninstall_files = []
     self.environment[
         osetupcons.CoreEnv.REGISTER_UNINSTALL_GROUPS].addFiles(
             group='ovirt_dwh_files',
             fileList=uninstall_files,
         )
     self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
         filetransaction.FileTransaction(
             name=(odwhcons.FileLocations.
                   OVIRT_ENGINE_DWHD_SERVICE_CONFIG_SCALE),
             mode=0o600,
             owner=self.environment[osetupcons.SystemEnv.USER_ENGINE],
             enforcePermissions=True,
             content=next(scale['conf'] for scale in self._DWH_SCALES
                          if scale['index'] == self.environment[
                              odwhcons.ConfigEnv.SCALE]),
             modifiedList=uninstall_files,
         ))