def serialize(self):
        uids = self.get_uids()
        operating_system = self.cluster.release.operating_system
        repos = objects.Attributes.merged_attrs_values(
            self.cluster.attributes)['repo_setup']['repos']

        if operating_system == consts.RELEASE_OS.centos:
            for repo in repos:
                yield templates.make_centos_repo_task(uids, repo)
            yield templates.make_yum_clean(uids)
        elif operating_system == consts.RELEASE_OS.ubuntu:
            # NOTE(ikalnitsky):
            # We have to clear /etc/apt/sources.list, because it
            # has a lot of invalid repos right after provisioning
            # and that lead us to deployment failures.
            yield templates.make_shell_task(uids, {
                'parameters': {
                    'cmd': '> /etc/apt/sources.list',
                    'timeout': 60
                }})
            yield templates.make_ubuntu_apt_disable_ipv6(uids)
            # NOTE(kozhukalov):
            # This task is to allow installing packages from
            # unauthenticated repositories.
            yield templates.make_ubuntu_unauth_repos_task(uids)
            for repo in repos:
                yield templates.make_ubuntu_sources_task(uids, repo)

                if repo.get('priority'):
                    # do not add preferences task to task list if we can't
                    # complete it (e.g. can't retrieve or parse Release file)
                    task = templates.make_ubuntu_preferences_task(uids, repo)
                    if task is not None:
                        yield task
            yield templates.make_apt_update_task(uids)
Example #2
0
    def serialize(self):
        uids = self.get_uids()
        operating_system = self.cluster.release.operating_system
        repos = objects.Attributes.merged_attrs_values(
            self.cluster.attributes)['repo_setup']['repos']

        if operating_system == consts.RELEASE_OS.centos:
            for repo in repos:
                yield templates.make_centos_repo_task(uids, repo)
            yield templates.make_yum_clean(uids)
        elif operating_system == consts.RELEASE_OS.ubuntu:
            # NOTE(ikalnitsky):
            # We have to clear /etc/apt/sources.list, because it
            # has a lot of invalid repos right after provisioning
            # and that lead us to deployment failures.
            yield templates.make_shell_task(uids, {
                'parameters': {
                    'cmd': '> /etc/apt/sources.list',
                    'timeout': 10
                }})
            yield templates.make_ubuntu_apt_disable_ipv6(uids)
            # NOTE(kozhukalov):
            # This task is to allow installing packages from
            # unauthenticated repositories.
            yield templates.make_ubuntu_unauth_repos_task(uids)
            for repo in repos:
                yield templates.make_ubuntu_sources_task(uids, repo)

                if repo.get('priority'):
                    # do not add preferences task to task list if we can't
                    # complete it (e.g. can't retrieve or parse Release file)
                    task = templates.make_ubuntu_preferences_task(uids, repo)
                    if task is not None:
                        yield task
            yield templates.make_apt_update_task(uids)
 def test_make_ubuntu_unauth_repos_task(self):
     result = tasks_templates.make_ubuntu_unauth_repos_task([1, 2, 3])
     self.assertEqual(
         result,
         {'parameters': {
             'data': 'APT::Get::AllowUnauthenticated 1;\n',
             'path': '/etc/apt/apt.conf.d/02fuel-allow-unsigned'},
          'type': 'upload_file',
          'uids': [1, 2, 3]})
Example #4
0
 def test_make_ubuntu_unauth_repos_task(self):
     result = tasks_templates.make_ubuntu_unauth_repos_task([1, 2, 3])
     self.assertEqual(
         result,
         {'parameters': {
             'data': 'APT::Get::AllowUnauthenticated 1;\n',
             'path': '/etc/apt/apt.conf.d/02mirantis-allow-unsigned'},
          'type': 'upload_file',
          'uids': [1, 2, 3]})
Example #5
0
 def test_make_ubuntu_unauth_repos_task(self):
     result = tasks_templates.make_ubuntu_unauth_repos_task([1, 2, 3])
     self.assertEqual(
         result,
         {
             "parameters": {
                 "data": "APT::Get::AllowUnauthenticated 1;\n",
                 "path": "/etc/apt/apt.conf.d/02mirantis-allow-unsigned",
             },
             "type": "upload_file",
             "uids": [1, 2, 3],
         },
     )