Change repositories logic
All respositories should be independent Change-Id: I350b7866ba10941a3d1f8c036ab97b293f2fcac6 Related-bug: #1525133
This commit is contained in:
parent
4487e9ef61
commit
9bc9b160ba
|
@ -30,28 +30,14 @@ class BuildCommand(command.Command):
|
|||
help="Choose the Ubuntu release (currently supports"
|
||||
" only trusty).",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--ubuntu-repo',
|
||||
type=str,
|
||||
metavar='REPOSITORY',
|
||||
help="Use the specified Ubuntu repository. Format"
|
||||
" 'uri codename'.",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--mos-repo',
|
||||
type=str,
|
||||
metavar='REPOSITORY',
|
||||
help="Add link to repository with fuel* packages. That"
|
||||
" should either http://mirror.fuel-infra.org/mos-repos"
|
||||
" or its mirror. Format 'uri codename'.",
|
||||
)
|
||||
parser.add_argument(
|
||||
'--repo',
|
||||
dest='extra_repos',
|
||||
dest='repos',
|
||||
type=str,
|
||||
metavar='REPOSITORY',
|
||||
help="Add one more repository. format 'type uri"
|
||||
" codename [sections][,priority]'.",
|
||||
help="Add one more repository. NOTE: The first repo should be"
|
||||
" release repo. REPOSITORY format:"
|
||||
" 'type uri codename [sections][,priority]'.",
|
||||
action='append'
|
||||
)
|
||||
parser.add_argument(
|
||||
|
|
|
@ -46,8 +46,9 @@ packages:
|
|||
# Pass proxy parameters, for access to repos
|
||||
#http_proxy: "192.168.1.50:8080"
|
||||
#https_proxy: "192.168.1.50:8080"
|
||||
# Define upstream ubuntu-mirror
|
||||
#ubuntu_repos:
|
||||
# Define repos: upstream ubuntu-mirror, MirantisOpenstack mirror, extra repos.
|
||||
# First repo should be distro repo.
|
||||
#repos:
|
||||
# -
|
||||
# name: ubuntu
|
||||
# priority: null
|
||||
|
@ -69,8 +70,6 @@ packages:
|
|||
# suite: trusty-security
|
||||
# type: deb
|
||||
# uri: "http://archive.ubuntu.com/ubuntu"
|
||||
## Define MirantisOpenstack mirror
|
||||
#mos_repos:
|
||||
# -
|
||||
# name: mos
|
||||
# priority: "1050"
|
||||
|
@ -99,8 +98,6 @@ packages:
|
|||
# suite: mos9.0-holdback
|
||||
# type: deb
|
||||
# uri: "http://mirror.fuel-infra.org/mos-repos/ubuntu/9.0"
|
||||
## Define other deb repositories
|
||||
#extra_repos:
|
||||
# -
|
||||
# name: Extra_repo
|
||||
# priority: null
|
||||
|
|
|
@ -35,12 +35,9 @@ class BootstrapDataBuilder(object):
|
|||
self.container_format = consts.CONTAINER_FORMAT
|
||||
|
||||
self.ubuntu_release = \
|
||||
data.get('ubuntu_release') or \
|
||||
consts.UBUNTU_RELEASE
|
||||
data.get('ubuntu_release') or consts.UBUNTU_RELEASE
|
||||
|
||||
self.ubuntu_repo = data.get('ubuntu_repo')
|
||||
self.mos_repo = data.get('mos_repo')
|
||||
self.extra_repos = data.get('extra_repos') or []
|
||||
self.repos = data.get('repos') or []
|
||||
|
||||
self.http_proxy = data.get('http_proxy') or CONF.http_proxy
|
||||
self.https_proxy = data.get('https_proxy') or CONF.https_proxy
|
||||
|
@ -69,6 +66,7 @@ class BootstrapDataBuilder(object):
|
|||
self.output = os.path.join(output_dir, file_name)
|
||||
|
||||
def build(self):
|
||||
repos = self._get_repos()
|
||||
return {
|
||||
'bootstrap': {
|
||||
'modules': self._prepare_modules(),
|
||||
|
@ -82,7 +80,7 @@ class BootstrapDataBuilder(object):
|
|||
'format': self.container_format
|
||||
}
|
||||
},
|
||||
'repos': self._get_repos(),
|
||||
'repos': repos,
|
||||
'proxies': self._get_proxy_settings(),
|
||||
'codename': self.ubuntu_release,
|
||||
'output': self.output,
|
||||
|
@ -127,25 +125,14 @@ class BootstrapDataBuilder(object):
|
|||
|
||||
def _get_repos(self):
|
||||
repos = []
|
||||
if self.ubuntu_repo:
|
||||
repos.extend(self._parse_ubuntu_repos(self.ubuntu_repo))
|
||||
else:
|
||||
repos.extend(CONF.ubuntu_repos)
|
||||
|
||||
if self.mos_repo:
|
||||
repos.extend(self._parse_mos_repos(self.mos_repo))
|
||||
else:
|
||||
repos.extend(CONF.mos_repos)
|
||||
|
||||
repo_count = 0
|
||||
for repo in self.extra_repos:
|
||||
repo_count += 1
|
||||
for idx, repo in enumerate(self.repos):
|
||||
repos.append(self._parse_repo(
|
||||
repo,
|
||||
name="extra_repo{0}".format(repo_count)))
|
||||
name="repo_{0}".format(idx)))
|
||||
|
||||
if not self.extra_repos and CONF.extra_repos:
|
||||
repos.extend(CONF.extra_repos)
|
||||
if not self.repos and CONF.repos:
|
||||
repos.extend(CONF.repos)
|
||||
|
||||
return repos
|
||||
|
||||
|
@ -156,74 +143,10 @@ class BootstrapDataBuilder(object):
|
|||
result |= set(CONF.packages)
|
||||
return list(result)
|
||||
|
||||
def _parse_ubuntu_repos(self, repo):
|
||||
uri, suite = self._parse_not_extra_repo(repo)
|
||||
|
||||
return self._generate_repos_from_uri(
|
||||
uri=uri,
|
||||
codename=self.ubuntu_release,
|
||||
name='ubuntu',
|
||||
components=['', '-updates', '-security'],
|
||||
section='main universe multiverse'
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _parse_not_extra_repo(cls, repo):
|
||||
regexp = r"(?P<uri>[^\s]+) (?P<suite>[^\s]+)"
|
||||
|
||||
match = re.match(regexp, repo)
|
||||
|
||||
if not match:
|
||||
raise errors.IncorrectRepository(
|
||||
"Coulnd't parse ubuntu repository {0}".
|
||||
format(repo)
|
||||
)
|
||||
|
||||
return match.group('uri', 'suite')
|
||||
|
||||
@classmethod
|
||||
def _parse_mos_repos(cls, repo):
|
||||
uri, suite = cls._parse_not_extra_repo(repo)
|
||||
|
||||
result = cls._generate_repos_from_uri(
|
||||
uri=uri,
|
||||
codename=suite,
|
||||
name='mos',
|
||||
components=['', '-updates', '-security'],
|
||||
section='main restricted',
|
||||
priority='1050'
|
||||
)
|
||||
result += cls._generate_repos_from_uri(
|
||||
uri=uri,
|
||||
codename=suite,
|
||||
name='mos',
|
||||
components=['-holdback'],
|
||||
section='main restricted',
|
||||
priority='1100'
|
||||
)
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def _generate_repos_from_uri(cls, uri, codename, name, components=None,
|
||||
section=None, type_=None, priority=None):
|
||||
if not components:
|
||||
components = ['']
|
||||
result = []
|
||||
for component in components:
|
||||
result.append({
|
||||
"name": "{0}{1}".format(name, component),
|
||||
"type": type_ or "deb",
|
||||
"uri": uri,
|
||||
"priority": priority,
|
||||
"section": section,
|
||||
"suite": "{0}{1}".format(codename, component)
|
||||
})
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def _parse_repo(cls, repo, name=None):
|
||||
regexp = r"(?P<type>deb(-src)?) (?P<uri>[^\s]+) (?P<suite>[^\s]+)( "\
|
||||
r"(?P<section>[\w\s]*))?(,(?P<priority>[\d]+))?"
|
||||
regexp = (r"(?P<type>deb(-src)?) (?P<uri>[^\s]+) (?P<suite>[^\s]+)( "
|
||||
r"(?P<section>[\w\s]*))?(,(?P<priority>[\d]+))?")
|
||||
|
||||
match = re.match(regexp, repo)
|
||||
|
||||
|
|
Loading…
Reference in New Issue