Ejemplo n.º 1
0
 def _customization_network(self):
     osetuphostname.Hostname(
         plugin=self,
     ).getHostname(
         envkey=owspcons.EngineConfigEnv.ENGINE_FQDN,
         whichhost=_('the engine'),
         supply_default=False,
     )
Ejemplo n.º 2
0
 def _customization(self):
     osetuphostname.Hostname(
         plugin=self,
     ).getHostname(
         envkey=osetupcons.ConfigEnv.FQDN,
         whichhost=_('this'),
         supply_default=True,
     )
Ejemplo n.º 3
0
 def _validation(self):
     if self.environment[osetupcons.RenameEnv.FQDN] is None:
         osetuphostname.Hostname(plugin=self, ).getHostname(
             envkey=osetupcons.RenameEnv.FQDN,
             whichhost=_('New'),
             supply_default=False,
             prompttext=_('New fully qualified server name: '),
         )
     self.environment[osetupcons.ConfigEnv.FQDN] = self.environment[
         osetupcons.RenameEnv.FQDN]
Ejemplo n.º 4
0
 def _customizationNetwork(self):
     osetuphostname.Hostname(plugin=self, ).getHostname(
         envkey=ovmpcons.EngineConfigEnv.ENGINE_FQDN,
         whichhost=_('the engine'),
         supply_default=True,
     )
     self.environment[osetupcons.NetEnv.FIREWALLD_SERVICES].extend([
         {
             'name': 'ovirt-vmconsole-proxy',
             'directory': 'vmconsole-proxy'
         },
     ])
     self.environment[osetupcons.NetEnv.FIREWALLD_SUBST].update({
         '@VMCONSOLE_PROXY_PORT@':
         self.environment[ovmpcons.ConfigEnv.VMCONSOLE_PROXY_PORT],
     })
Ejemplo n.º 5
0
    def _misc_deploy(self):
        import docker
        fqdn = self.environment[osetupcons.ConfigEnv.FQDN]

        envdict = {
            'ADMIN_USER_PASSWORD': odockerccons.Const.ADMIN_USER_PASSWORD,
            'ADMIN_TENANT_NAME': odockerccons.Const.ADMIN_TENANT_NAME,
            # TODO: use randomly generated passwords
            'DB_ROOT_PASSWORD': odockerccons.Const.MARIADB_ROOT_PASSWORD,
            'CINDER_DB_NAME': odockerccons.Const.CINDER_DB_NAME,
            'CINDER_DB_USER': odockerccons.Const.CINDER_DB_USER,
            'CINDER_DB_PASSWORD': odockerccons.Const.CINDER_DB_PASSWORD,
            'CINDER_KEYSTONE_USER': odockerccons.Const.CINDER_KEYSTONE_USER,
            'CINDER_ADMIN_PASSWORD': odockerccons.Const.CINDER_ADMIN_PASSWORD,
            'GLANCE_API_SERVICE_HOST': fqdn,
            'GLANCE_DB_NAME': odockerccons.Const.GLANCE_DB_NAME,
            'GLANCE_DB_PASSWORD': odockerccons.Const.GLANCE_DB_PASSWORD,
            'GLANCE_DB_USER': odockerccons.Const.GLANCE_DB_USER,
            'GLANCE_KEYSTONE_PASSWORD':
            odockerccons.Const.GLANCE_KEYSTONE_PASSWORD,
            'GLANCE_KEYSTONE_USER': odockerccons.Const.GLANCE_KEYSTONE_USER,
            'GLANCE_REGISTRY_SERVICE_HOST': fqdn,
            'KEYSTONE_ADMIN_PASSWORD':
            odockerccons.Const.KEYSTONE_ADMIN_PASSWORD,
            'KEYSTONE_ADMIN_SERVICE_HOST': fqdn,
            'KEYSTONE_ADMIN_SERVICE_PORT':
            odockerccons.Const.KEYSTONE_ADMIN_SERVICE_PORT,
            'KEYSTONE_ADMIN_TOKEN': odockerccons.Const.KEYSTONE_ADMIN_TOKEN,
            'KEYSTONE_AUTH_PROTOCOL':
            odockerccons.Const.KEYSTONE_AUTH_PROTOCOL,
            'KEYSTONE_DB_PASSWORD': odockerccons.Const.KEYSTONE_DB_PASSWORD,
            'KEYSTONE_PUBLIC_SERVICE_HOST': fqdn,
            'MARIADB_SERVICE_HOST': fqdn,
            'MARIADB_ROOT_PASSWORD': odockerccons.Const.MARIADB_ROOT_PASSWORD,
            'RABBITMQ_PASS': odockerccons.Const.RABBIT_PASSWORD,
            'RABBITMQ_SERVICE_HOST': fqdn,
            'RABBITMQ_USER': odockerccons.Const.RABBIT_USER,
            'RABBIT_PASSWORD': odockerccons.Const.RABBIT_PASSWORD,
            'RABBIT_USERID': odockerccons.Const.RABBIT_USER,
        }

        hostname = osetuphostname.Hostname(plugin=self)
        dnsresolved = hostname.isResolvedByDNS(fqdn)
        # TODO: check if we also need to force container DNS
        for cont in self._dimages:
            self.logger.info(_('Pulling {cname}').format(cname=cont['name']))
            for line in self._dcli.pull(cont['image'], stream=True):
                jline = json.loads(line)
                self.logger.debug(json.dumps(jline, indent=4))
                if 'error' in jline:
                    raise RuntimeError(
                        _("Unable to pull image {cname}: {message}").format(
                            cname=cont['image'],
                            message=jline['errorDetail']['message'],
                        ))
        for cont in self._dimages:
            self.logger.info(_('Creating {cname}').format(cname=cont['name']))
            try:
                container = self._dcli.create_container(
                    image=cont['image'],
                    name=cont['name'],
                    environment=envdict,
                )
            except docker.errors.APIError as ex:
                if ex.response.status_code == 404:
                    raise RuntimeError(
                        _('Unable to find image {image}: {explanation}'
                          ).format(image=cont['image'],
                                   explanation=ex.explanation))
                elif ex.response.status_code == 409:
                    raise RuntimeError(
                        _('Name conflict creating container {cname}: '
                          '{explanation}').format(cname=cont['name'],
                                                  explanation=ex.explanation))
                elif ex.response.status_code == 500:
                    raise RuntimeError(
                        _('docker server error creating container {cname}: '
                          '{explanation}').format(cname=cont['name'],
                                                  explanation=ex.explanation))
                else:
                    raise ex

            self.logger.info(_('Starting {cname}').format(cname=cont['name']))
            cid = container.get('Id')
            self.logger.debug('Container {cname}: {cid}'.format(
                cname=cont['name'],
                cid=cid,
            ))
            try:
                self._dcli.start(
                    container=cid,
                    restart_policy={"Name": "always"},
                    volumes_from=(
                        odockerccons.Const.C_NAME_MARIADBDATA if cont['name']
                        == odockerccons.Const.C_NAME_MARIADBAPP else None),
                    network_mode='host',
                    extra_hosts=({
                        fqdn:
                        hostname.getResolvedAddresses(fqdn).pop()
                    } if not dnsresolved else None))
            except docker.errors.APIError as ex:
                if ex.response.status_code == 404:
                    raise RuntimeError(
                        _('Unable to start container {cname}: {explanation}').
                        format(cname=cont['name'], explanation=ex.explanation))
                else:
                    raise ex

        dlist = [d['name'] for d in self._dimages]
        dlist.extend(self._already_deployed_by_me)
        self.environment[odockerccons.RemoveEnv.REMOVE_DCLIST] = ', '.join(
            set(dlist))