Example #1
0
    def _set_apt_repos(chroot, repos, proxies=None, direct_repo_addrs=None):
        """Configure APT to use the specified repositories

        Set apt-sources for chroot and update metadata in Manager.

        :param chroot: path to OS to operate on
        :param repos: list of DEBRepo objects
        :param proxies: dict protocol:uri format
        :param direct_repo_addrs: list of addreses which should be bypassed by
                                  proxy
        """
        LOG.debug("For set apt repositories will be used proxies: %s and"
                  " no_proxy: %s", proxies, direct_repo_addrs)
        for repo in repos:
            LOG.debug(
                'Adding repository source: name={name}, uri={uri}, '
                'suite={suite}, section={section}'.format(
                    name=repo.name,
                    uri=repo.uri,
                    suite=repo.suite,
                    section=repo.section))
            bu.add_apt_source(name=repo.name, uri=repo.uri, suite=repo.suite,
                              section=repo.section, chroot=chroot)
            LOG.debug(
                'Adding repository preference: name={name}, '
                'priority={priority}'.format(name=repo.name,
                                             priority=repo.priority))
            if repo.priority is not None:
                bu.add_apt_preference(
                    name=repo.name, priority=repo.priority, suite=repo.suite,
                    section=repo.section, chroot=chroot, uri=repo.uri,
                    proxies=proxies, direct_repo_addrs=direct_repo_addrs)
Example #2
0
 def test_add_apt_source_no_section(self, mock_path):
     mock_path.return_value = 'fake_path'
     with mock.patch('six.moves.builtins.open', create=True) as mock_open:
         file_handle_mock = mock_open.return_value.__enter__.return_value
         bu.add_apt_source('name2', 'uri2', 'suite2', None, 'chroot')
         expected_calls = [mock.call('deb uri2 suite2\n')]
         self.assertEqual(expected_calls,
                          file_handle_mock.write.call_args_list)
     expected_mock_path_calls = [
         mock.call('chroot', 'etc/apt/sources.list.d',
                   'fuel-image-name2.list')]
     self.assertEqual(expected_mock_path_calls,
                      mock_path.join.call_args_list)
Example #3
0
 def test_add_apt_source_no_section(self, mock_path):
     mock_path.return_value = 'fake_path'
     with mock.patch('six.moves.builtins.open', create=True) as mock_open:
         file_handle_mock = mock_open.return_value.__enter__.return_value
         bu.add_apt_source('name2', 'uri2', 'suite2', None, 'chroot')
         expected_calls = [mock.call('deb uri2 suite2\n')]
         self.assertEqual(expected_calls,
                          file_handle_mock.write.call_args_list)
     expected_mock_path_calls = [
         mock.call('chroot', 'etc/apt/sources.list.d',
                   'fuel-image-name2.list')
     ]
     self.assertEqual(expected_mock_path_calls,
                      mock_path.join.call_args_list)
Example #4
0
    def _set_apt_repos(chroot, repos, proxies=None, direct_repo_addrs=None):
        """Configure APT to use the specified repositories

        Set apt-sources for chroot and update metadata in Manager.

        :param chroot: path to OS to operate on
        :param repos: list of DEBRepo objects
        :param proxies: dict protocol:uri format
        :param direct_repo_addrs: list of addreses which should be bypassed by
                                  proxy
        """
        LOG.debug(
            "For set apt repositories will be used proxies: %s and"
            " no_proxy: %s", proxies, direct_repo_addrs)
        for repo in repos:
            LOG.debug('Adding repository source: name={name}, uri={uri}, '
                      'suite={suite}, section={section}'.format(
                          name=repo.name,
                          uri=repo.uri,
                          suite=repo.suite,
                          section=repo.section))
            bu.add_apt_source(name=repo.name,
                              uri=repo.uri,
                              suite=repo.suite,
                              section=repo.section,
                              chroot=chroot)
            LOG.debug('Adding repository preference: name={name}, '
                      'priority={priority}'.format(name=repo.name,
                                                   priority=repo.priority))
            if repo.priority is not None:
                bu.add_apt_preference(name=repo.name,
                                      priority=repo.priority,
                                      suite=repo.suite,
                                      section=repo.section,
                                      chroot=chroot,
                                      uri=repo.uri,
                                      proxies=proxies,
                                      direct_repo_addrs=direct_repo_addrs)