Пример #1
0
    def generate_config(self,
                        config_name,
                        service_name,
                        command,
                        autostart=True):
        """Generates config for each service

        :param str config_name: is the name of the config
        :param str service_name: is the name of the service
        :param str command: command to run
        :param bool autostart: run the service on supervisor start
        """
        config_path = os.path.join(
            self.supervisor_config_dir,
            '{0}'.format('{0}.conf'.format(config_name)))

        log_path = '/var/log/{0}.log'.format(service_name)

        params = {
            'service_name': service_name,
            'command': command,
            'log_path': log_path,
            'autostart': 'true' if autostart else 'false'
        }

        utils.render_template_to_file(self.supervisor_template_path,
                                      config_path, params)
Пример #2
0
    def test_render_template_to_file(self):
        template_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__),
                         '../templates/nailgun.repo'))

        with open(template_path, 'r') as f:
            template = f.read()

        mopen = mock.mock_open(read_data=template)
        with mock.patch('__builtin__.open', mopen, create=True):
            utils.render_template_to_file(
                'mocked', 'mocked', {
                    'name': 'mos6.1-updates',
                    'baseurl': 'http://mirror.fuel-infra.org/mos/centos-6/'
                    'mos6.1/updates/',
                    'gpgcheck': 0,
                    'skip_if_unavailable': 1,
                })

            mopen().write.assert_called_once(
                textwrap.dedent('''\
              [mos6.1-updates]
              name=mos6.1-updates
              baseurl=http://mirror.fuel-infra.org/mos/centos-6/mos6.1/updates/
              gpgcheck=0
              skip_if_unavailable=1
            '''))
Пример #3
0
    def generate_cobbler_config(self,
                                config_name,
                                service_name,
                                container_name,
                                autostart=True):
        """Generates cobbler config

        :param str config_name: is the name of the config
        :param str service_name: is the name of the service
        :param bool autostart: run the service on supervisor start
        """
        script_template_path = os.path.join(self.templates_dir,
                                            'cobbler_runner')
        script_path = os.path.join('/usr/bin', container_name)

        utils.render_template_to_file(script_template_path, script_path,
                                      {'container_name': container_name})

        self.generate_config(config_name,
                             service_name,
                             container_name,
                             autostart=autostart)

        st = os.stat(script_path)
        os.chmod(script_path, st.st_mode | stat.S_IEXEC)
 def run(self):
     """Change repo path
     """
     utils.render_template_to_file(
         self.repo_template,
         self.yum_repo_file,
         {'repo_path': self.repo_path, 'version': '5.0.1'})
    def test_render_template_to_file(self):
        template_path = os.path.abspath(os.path.join(
            os.path.dirname(__file__), '../templates/nailgun.repo'))

        with open(template_path, 'r') as f:
            template = f.read()

        mopen = mock.mock_open(read_data=template)
        with mock.patch('__builtin__.open', mopen, create=True):
            utils.render_template_to_file('mocked', 'mocked', {
                'name': 'mos7.0-updates',
                'baseurl': 'http://mirror.fuel-infra.org/mos-repos/centos/'
                           'mos7.0-centos6-fuel/updates/x86_64/',
                'gpgcheck': 0,
                'skip_if_unavailable': 1,
            })

            mopen().write.assert_called_once(textwrap.dedent('''\
              [mos7.0-updates]
              name=mos7.0-updates
              baseurl=http://mirror.fuel-infra.org/mos-repos\
/centos/mos7.0-centos6-fuel/updates/x86_64/
              gpgcheck=0
              skip_if_unavailable=1
            '''))
Пример #6
0
 def update_repo(self):
     """Add new centos repository
     """
     utils.render_template_to_file(self.repo_template_path,
                                   self.repo_config_path, {
                                       'version': self.version,
                                       'repo_path': self.repo_dst
                                   })
Пример #7
0
 def update_repo(self):
     """Add new centos repository
     """
     utils.render_template_to_file(
         self.repo_template_path,
         self.repo_config_path,
         {'version': self.version,
          'repo_path': self.repo_path})
Пример #8
0
 def update_repo(self):
     """Add new centos repository
     """
     utils.render_template_to_file(
         self.repo_template_path,
         self.repo_config_path,
         {'version': self.version,
          'repo_path': self.host_system_config['repo_master']})
     utils.exec_cmd('yum clean all')
Пример #9
0
 def update_repo(self):
     """Add new centos repository
     """
     utils.render_template_to_file(
         self.repo_template_path, self.repo_config_path, {
             'name': '{0}_nailgun'.format(self.version),
             'baseurl': self.host_system_config['repo_master'],
             'gpgcheck': 0,
             'skip_if_unavailable': 0,
         })
     utils.exec_cmd('yum clean all')
Пример #10
0
 def update_repo(self):
     """Add new centos repository"""
     utils.render_template_to_file(
         self.repo_template_path,
         self.repo_config_path,
         {
             'name': '{0}_nailgun'.format(self.version),
             'baseurl': self.host_system_config['repo_master'],
             'gpgcheck': 0,
             'skip_if_unavailable': 0,
         })
     utils.exec_cmd('yum clean all')
Пример #11
0
    def _setup_update_repos(self):
        """Setup updates/security repos on master node.
        """
        template = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'templates', 'nailgun.repo')

        for repo in self._config.master_node_repos:
            destination = '{0}.repo'.format(
                os.path.join('/etc/yum.repos.d', repo['name']))
            utils.render_template_to_file(template, destination, repo)

        logger.warning(messages.update_your_master_node)
Пример #12
0
    def _setup_update_repos(self):
        """Setup updates/security repos on master node."""
        template = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            'templates', 'nailgun.repo')

        for repo in self._config.master_node_repos:
            destination = '{0}.repo'.format(
                os.path.join('/etc/yum.repos.d', repo['name']))
            utils.render_template_to_file(template, destination, repo)

        logger.warning(messages.update_your_master_node)
Пример #13
0
    def generate_config(self, service):
        """Generates config for each service

        :param service: dict where `service_name`
                        and `command` are required fields
        """
        config_path = os.path.join(
            self.supervisor_config_dir,
            '{0}'.format('{0}.conf'.format(service['service_name'])))

        log_path = '/var/log/docker-{0}.log'.format(service['service_name'])

        params = {
            'service_name': service['service_name'],
            'command': service['command'],
            'log_path': log_path}

        utils.render_template_to_file(
            self.supervisor_template_path, config_path, params)
Пример #14
0
    def generate_config(self, service):
        """Generates config for each service

        :param service: dict where `service_name`
                        and `command` are required fields
        """
        config_path = os.path.join(
            self.supervisor_config_dir,
            '{0}'.format('{0}.conf'.format(service['service_name'])))

        log_path = '/var/log/docker-{0}.log'.format(service['service_name'])

        params = {
            'service_name': service['service_name'],
            'command': service['command'],
            'log_path': log_path
        }

        utils.render_template_to_file(self.supervisor_template_path,
                                      config_path, params)
Пример #15
0
    def generate_cobbler_config(self, container):
        """Generates cobbler config

        :param container: dict `service_name` `container_name`
        """
        container_name = container['container_name']
        script_template_path = os.path.join(self.templates_dir,
                                            'cobbler_runner')
        script_path = os.path.join('/usr/bin', container_name)

        utils.render_template_to_file(script_template_path, script_path,
                                      {'container_name': container_name})

        self.generate_config({
            'service_name': container['service_name'],
            'command': container_name
        })

        st = os.stat(script_path)
        os.chmod(script_path, st.st_mode | stat.S_IEXEC)
Пример #16
0
    def generate_cobbler_config(self, container):
        """Generates cobbler config

        :param container: dict `service_name` `container_name`
        """
        container_name = container['container_name']
        script_template_path = os.path.join(
            self.templates_dir, 'cobbler_runner')
        script_path = os.path.join('/usr/bin', container_name)

        utils.render_template_to_file(
            script_template_path,
            script_path,
            {'container_name': container_name})

        self.generate_config({
            'service_name': container['service_name'],
            'command': container_name})

        st = os.stat(script_path)
        os.chmod(script_path, st.st_mode | stat.S_IEXEC)
Пример #17
0
    def generate_cobbler_config(self, config_name, service_name,
                                container_name, autostart=True):
        """Generates cobbler config

        :param str config_name: is the name of the config
        :param str service_name: is the name of the service
        :param bool autostart: run the service on supervisor start
        """
        script_template_path = os.path.join(
            self.templates_dir, 'cobbler_runner')
        script_path = os.path.join('/usr/bin', container_name)

        utils.render_template_to_file(
            script_template_path,
            script_path,
            {'container_name': container_name})

        self.generate_config(
            config_name, service_name, container_name, autostart=autostart)

        st = os.stat(script_path)
        os.chmod(script_path, st.st_mode | stat.S_IEXEC)
Пример #18
0
    def generate_config(self, config_name, service_name,
                        command, autostart=True):
        """Generates config for each service

        :param str config_name: is the name of the config
        :param str service_name: is the name of the service
        :param str command: command to run
        :param bool autostart: run the service on supervisor start
        """
        config_path = os.path.join(
            self.supervisor_config_dir,
            '{0}'.format('{0}.conf'.format(config_name)))

        log_path = '/var/log/{0}.log'.format(service_name)

        params = {
            'service_name': service_name,
            'command': command,
            'log_path': log_path,
            'autostart': 'true' if autostart else 'false'}

        utils.render_template_to_file(
            self.supervisor_template_path, config_path, params)