def add_app_packages_mapping(project_new, pkg_def, app_types): """Add the mappings of the app types for a given project""" existing_apptypes = [x.name for x in project_new.applications] if AppDefinition.dummy not in (existing_apptypes + app_types): app_types.append(AppDefinition.dummy) for app_type in list(app_types): if app_type in existing_apptypes: if app_type == AppDefinition.dummy: app_types.remove(app_type) else: raise Exception('"%s" is already a part of "%s"', app_type, project_new.name) for app_type in app_types: try: app_def = (Session.query(AppDefinition).filter_by( app_type=app_type).one()) except sqlalchemy.orm.exc.NoResultFound: raise RepoException('App type "%s" is not found in the ' 'Application table' % app_type) package_loc = PackageLocation.get(app_name=pkg_def.name) if package_loc is not None: package_loc.app_definitions.append(app_def) # Transitional code to synchronize with new tables proj_pkg = ProjectPackage() proj_pkg.project = project_new proj_pkg.package_definition = pkg_def proj_pkg.app_definition = app_def Session.add(proj_pkg)
def add_project(name): """Add a new project to the database""" project = Project(name=name) Session.add(project) Session.flush() # Needed to get project_id generated return project
def add_project_package_mapping(project, application, app_types): """Add the mappings for a given project, application and one or more app types """ # Note: eventually an 'application' may have multiple # package definitions related to it; to be decided at # a later date for app_type in app_types: proj_pkg = ProjectPackage(project_id=project.id, pkg_def_id=application.id, app_id=app_type.id) Session.add(proj_pkg)
def add_project_package_mapping(project, application, app_types): """Add the mappings for a given project, application and one or more app types """ # Note: eventually an 'application' may have multiple # package definitions related to it; to be decided at # a later date for app_type in app_types: proj_pkg = ProjectPackage( project_id=project.id, pkg_def_id=application.id, app_id=app_type.id ) Session.add(proj_pkg)
def add_package_definition(deploy_type, validation_type, name, path, arch, build_type, build_host): """Add base definition for a package""" pkg_def = PackageDefinition(deploy_type=deploy_type, validation_type=validation_type, pkg_name=name, path=path, arch=arch, build_type=build_type, build_host=build_host, created=func.current_timestamp()) Session.add(pkg_def) Session.flush() # Needed to get pkg_ef_id generated return pkg_def
def add_host_deployment(dep_id, host_id, user, status, package_id): """Add host deployment for a given host and deployment""" host_dep = HostDeployment( deployment_id=dep_id, host_id=host_id, user=user, status=status, realized=func.current_timestamp(), package_id=package_id, ) # Commit to DB immediately Session.add(host_dep) Session.commit() return host_dep
def add_deployment(user): """Add deployment for a given package ID""" dep = Deployment( user=user, # THIS NEEDS TO BE REMOVED ONCE THE NEW DEPLOY CODE # IS IN PLACE - KEL 20150827 status='complete', declared=func.current_timestamp()) # Commit to DB immediately Session.add(dep) Session.commit() Session.flush() # Needed to get DeploymentID generated return dep
def add_deployment(user): """Add deployment for a given package ID""" dep = Deployment( user=user, # THIS NEEDS TO BE REMOVED ONCE THE NEW DEPLOY CODE # IS IN PLACE - KEL 20150827 status='complete', declared=func.current_timestamp() ) # Commit to DB immediately Session.add(dep) Session.commit() Session.flush() # Needed to get DeploymentID generated return dep
def add_package(app_name, version, revision, user): """Add the requested version for the package of a given application""" pkg_def = find_package_definition(app_name) if find_package(app_name, version, revision): raise PackageException('Current version of application "%s" ' 'already found in Package table' % app_name) pkg = Package(pkg_def_id=pkg_def.id, pkg_name=app_name, version=version, revision=revision, status='pending', created=func.current_timestamp(), creator=user, builder=pkg_def.build_type, project_type='application') Session.add(pkg)
def add_package_definition(deploy_type, validation_type, name, path, arch, build_type, build_host): """Add base definition for a package""" pkg_def = PackageDefinition( deploy_type=deploy_type, validation_type=validation_type, pkg_name=name, path=path, arch=arch, build_type=build_type, build_host=build_host, created=func.current_timestamp() ) Session.add(pkg_def) Session.flush() # Needed to get pkg_ef_id generated return pkg_def
def add_app_deployment(dep_id, app_id, user, status, environment, package_id): """Add a tier deployment for a given deployment ID""" environment_id = _calculate_environment_id(environment) app_dep = AppDeployment( deployment_id=dep_id, app_id=app_id, user=user, status=status, environment_id=environment_id, realized=func.current_timestamp(), package_id=package_id, ) # Commit to DB immediately Session.add(app_dep) Session.commit() return app_dep
def add_package(app_name, version, revision, user): """Add the requested version for the package of a given application""" pkg_def = find_package_definition(app_name) if find_package(app_name, version, revision): raise PackageException('Current version of application "%s" ' 'already found in Package table' % app_name) pkg = Package( pkg_def_id=pkg_def.id, pkg_name=app_name, version=version, revision=revision, status='pending', created=func.current_timestamp(), creator=user, builder=pkg_def.build_type, project_type='application' ) Session.add(pkg)
def add_app_location(project_type, pkg_type, pkg_name, app_name, path, arch, build_host): """Add the location of a given application""" # Ensure the environment parameter is boolean project = PackageLocation( project_type=project_type, pkg_type=pkg_type, pkg_name=pkg_name, app_name=app_name, path=path, arch=arch, build_host=build_host, environment=False ) Session.add(project) Session.flush() # Needed to get pkgLocationID generated # Transitional code to synchronize with new tables project_new = add_project(app_name) pkg_def = add_package_definition('rpm', 'matching', pkg_name, path, arch, 'jenkins', build_host) Session.add(pkg_def) Session.flush() # Needed to get pkg_def_id generated package_name = PackageName(name=pkg_name, pkg_def_id=pkg_def.id) Session.add(package_name) pkg_def.package_names.append(package_name) return project, project_new, pkg_def
def add_app_location(project_type, pkg_type, pkg_name, app_name, path, arch, build_host): """Add the location of a given application""" # Ensure the environment parameter is boolean project = PackageLocation(project_type=project_type, pkg_type=pkg_type, pkg_name=pkg_name, app_name=app_name, path=path, arch=arch, build_host=build_host, environment=False) Session.add(project) Session.flush() # Needed to get pkgLocationID generated # Transitional code to synchronize with new tables project_new = add_project(app_name) pkg_def = add_package_definition('rpm', 'matching', pkg_name, path, arch, 'jenkins', build_host) Session.add(pkg_def) Session.flush() # Needed to get pkg_def_id generated package_name = PackageName(name=pkg_name, pkg_def_id=pkg_def.id) Session.add(package_name) pkg_def.package_names.append(package_name) return project, project_new, pkg_def
def add_app_packages_mapping(project_new, pkg_def, app_types): """Add the mappings of the app types for a given project""" existing_apptypes = [x.name for x in project_new.applications] if AppDefinition.dummy not in (existing_apptypes + app_types): app_types.append(AppDefinition.dummy) for app_type in list(app_types): if app_type in existing_apptypes: if app_type == AppDefinition.dummy: app_types.remove(app_type) else: raise Exception( '"%s" is already a part of "%s"', app_type, project_new.name ) for app_type in app_types: try: app_def = (Session.query(AppDefinition) .filter_by(app_type=app_type) .one()) except sqlalchemy.orm.exc.NoResultFound: raise RepoException('App type "%s" is not found in the ' 'Application table' % app_type) package_loc = PackageLocation.get(app_name=pkg_def.name) if package_loc is not None: package_loc.app_definitions.append(app_def) # Transitional code to synchronize with new tables proj_pkg = ProjectPackage() proj_pkg.project = project_new proj_pkg.package_definition = pkg_def proj_pkg.app_definition = app_def Session.add(proj_pkg)