Merge #228 Drop alembic fake base-runtime code.

This commit is contained in:
Ralph Bean
2016-12-01 15:56:10 +00:00
3 changed files with 102 additions and 142 deletions

View File

@@ -36,7 +36,10 @@ from module_build_service.pdc import (
get_module_tag, get_module_build_dependencies)
import module_build_service.auth
import module_build_service.scheduler.main
from module_build_service.utils import submit_module_build
from module_build_service.utils import (
submit_module_build,
insert_fake_baseruntime,
)
from module_build_service.messaging import RidaModule
@@ -99,6 +102,7 @@ def upgradedb():
""" Upgrades the database schema to the latest revision
"""
flask_migrate.upgrade()
insert_fake_baseruntime()
@manager.command
@@ -106,73 +110,6 @@ def cleardb():
models.ModuleBuild.query.delete()
models.ComponentBuild.query.delete()
def _insert_fake_baseruntime():
import sqlalchemy as sa
import modulemd
yaml = """
document: modulemd
version: 1
data:
name: base-runtime
stream: master
version: 3
summary: A fake base-runtime module, used to bootstrap the infrastructure.
description: ...
profiles:
buildroot:
rpms:
- bash
- bzip2
- coreutils
- cpio
- diffutils
- fedora-release
- findutils
- gawk
- gcc
- gcc-c++
- grep
- gzip
- info
- make
- patch
- redhat-rpm-config
- rpm-build
- sed
- shadow-utils
- tar
- unzip
- util-linux
- which
- xz
srpm-buildroot:
rpms:
- bash
- fedora-release
- fedpkg-minimal
- gnupg2
- redhat-rpm-config
- rpm-build
- shadow-utils
"""
mmd = modulemd.ModuleMetadata()
mmd.loads(yaml)
module = models.ModuleBuild.create(
db.session,
conf,
name=mmd.name,
stream=mmd.stream,
version=mmd.version,
modulemd=yaml,
scmurl='...',
username='modularity',
)
module.state = models.BUILD_STATES['done']
module.state_reason = 'Artificially created.'
db.session.commit()
@manager.command
def build_module_locally(url):
@@ -198,7 +135,7 @@ def build_module_locally(url):
# In the future, we should use PDC to get what we need from the fake module,
# so it's probably not big problem.
db.create_all()
_insert_fake_baseruntime()
insert_fake_baseruntime()
username = getpass.getuser()
submit_module_build(username, url, allow_local_url=True)

View File

@@ -1,4 +1,8 @@
"""Insert fake base-runtime.
"""Do nothing.
This used to be an upgrade that inserted a fake base-runtime module, but the
code was removed as a result of
https://pagure.io/fm-orchestrator/pull-request/225
Revision ID: 0ef60c3ed440
Revises: 145347916a56
@@ -11,79 +15,9 @@ Create Date: 2016-11-17 15:39:22.984051
revision = '0ef60c3ed440'
down_revision = '145347916a56'
from alembic import op
import sqlalchemy as sa
import os
import modulemd
yaml = """
document: modulemd
version: 1
data:
name: base-runtime
stream: master
version: 3
summary: A fake base-runtime module, used to bootstrap the infrastructure.
description: ...
profiles:
buildroot:
rpms:
- bash
- bzip2
- coreutils
- cpio
- diffutils
- fedora-release
- findutils
- gawk
- gcc
- gcc-c++
- grep
- gzip
- info
- make
- patch
- redhat-rpm-config
- rpm-build
- sed
- shadow-utils
- tar
- unzip
- util-linux
- which
- xz
srpm-buildroot:
rpms:
- bash
- fedora-release
- fedpkg-minimal
- gnupg2
- redhat-rpm-config
- rpm-build
- shadow-utils
"""
def upgrade():
from module_build_service import models, conf
engine = op.get_bind().engine
session = sa.orm.scoped_session(sa.orm.sessionmaker(bind=engine))
mmd = modulemd.ModuleMetadata()
mmd.loads(yaml)
module = models.ModuleBuild.create(
session,
conf,
name=mmd.name,
stream=mmd.stream,
version=mmd.version,
modulemd=yaml,
scmurl='...',
username='modularity',
)
module.state = models.BUILD_STATES['done']
module.state_reason = 'Artificially created.'
session.commit()
pass
def downgrade():
pass

View File

@@ -306,7 +306,7 @@ def record_component_builds(mmd, module, initial_batch = 1):
# reserved for module-build-macros. First real components must be
# planned for batch 2 and following.
batch = initial_batch
for pkg in components:
# If the pkg is another module, we fetch its modulemd file
# and record its components recursively with the initial_batch
@@ -403,3 +403,92 @@ def submit_module_build(username, url, allow_local_url = False):
log.info("%s submitted build of %s, stream=%s, version=%s", username,
mmd.name, mmd.stream, mmd.version)
return module
def insert_fake_baseruntime():
""" Insert a fake base-runtime module into our db.
This is done so that we can reference the build profiles in its modulemd.
See:
- https://pagure.io/fm-orchestrator/pull-request/228
- https://pagure.io/fm-orchestrator/pull-request/225
"""
import sqlalchemy as sa
import modulemd
yaml = """
document: modulemd
version: 1
data:
name: base-runtime
stream: master
version: 3
summary: A fake base-runtime module, used to bootstrap the infrastructure.
description: ...
profiles:
buildroot:
rpms:
- bash
- bzip2
- coreutils
- cpio
- diffutils
- fedora-release
- findutils
- gawk
- gcc
- gcc-c++
- grep
- gzip
- info
- make
- patch
- redhat-rpm-config
- rpm-build
- sed
- shadow-utils
- tar
- unzip
- util-linux
- which
- xz
srpm-buildroot:
rpms:
- bash
- fedora-release
- fedpkg-minimal
- gnupg2
- redhat-rpm-config
- rpm-build
- shadow-utils
"""
mmd = modulemd.ModuleMetadata()
mmd.loads(yaml)
# Check to see if this thing already exists...
query = models.ModuleBuild.query\
.filter_by(name=mmd.name)\
.filter_by(stream=mmd.stream)\
.filter_by(version=mmd.version)
if query.count():
logging.info('%r exists. Skipping creation.' % query.first())
return
# Otherwise, it does not exist. So, create it.
module = models.ModuleBuild.create(
db.session,
conf,
name=mmd.name,
stream=mmd.stream,
version=mmd.version,
modulemd=yaml,
scmurl='...',
username='modularity',
)
module.state = models.BUILD_STATES['done']
module.state_reason = 'Artificially created.'
db.session.commit()