2.1.1.2. sle_prjmgr_tools.utils package

2.1.1.2.1. Submodules

2.1.1.2.2. sle_prjmgr_tools.utils.confluence module

This module should contain helper functionality that assists for Confluence.

2.1.1.2.3. sle_prjmgr_tools.utils.jira module

This module should contain helper functionality that assists for Jira.

class sle_prjmgr_tools.utils.jira.JiraUtils(jira_url: str, pat_token: str, ssl_options: SSLOptions)

Bases: object

This class contains the shared functions that will enable scripts to interact with JIRA.

Perform a JIRA search.

JQL documentation: https://confluence.atlassian.com/jiracoreserver073/advanced-searching-861257209.html

Parameters:
  • jql – The JQL that should be used for searching.

  • max_results – The number of results that should be

Returns:

The list of issue keys that match the filter. The number of results is limited by max_results.

jira_get_field_name(name: str) str

Retrieve the field ID by the name of the field that an end user sees.

Parameters:

name – The name of the field.

Returns:

The field ID or an emtpy string.

jira_get_field_values(field_id: str, issue: str) Dict[str, str]

Retrieves a list of all available field values in a select or multi-select.

Parameters:
  • field_id – The ID of the field that the values should be retrieved for.

  • issue – The issue that decides the field values that are available to search for.

Returns:

The dict of possible field values or an empty dict. Keys represent the names and values are the IDs.

jira_get_transition_id(jsc: str, transition_name: str) str

Retrieve the transition ID of a ticket by the transition name.

Parameters:
  • jsc – The Jira ticket number.

  • transition_name – Name of the transition.

Returns:

The target transition ID or an empty str.

jira_get_version_obj(issue: str, name: str)

Get the version object that represents a version in JIRA:

Parameters:
  • issue – The issue that decides the versions that are available to search for.

  • name – The name of the version that should be retrieved

Returns:

The full version object as returned by the JIRA library.

jira_transition_tickets(jsc: str) None

Transition an issue in the workflow if it is in the correct state. If not log a message.

Parameters:

jsc – The Jira ticket number.

class sle_prjmgr_tools.utils.jira.SSLOptions(check_cert, truststore)

Bases: tuple

property check_cert

Alias for field number 0

property truststore

Alias for field number 1

2.1.1.2.4. sle_prjmgr_tools.utils.osc module

This module should contain helper functionality that assists for the Open Build Service.

class sle_prjmgr_tools.utils.osc.BinaryParsed(package, filename, name, arch)

Bases: tuple

property arch

Alias for field number 3

property filename

Alias for field number 1

property name

Alias for field number 2

property package

Alias for field number 0

class sle_prjmgr_tools.utils.osc.OscReleaseHelper(osc_server: str = 'https://build.opensuse.org', override_config: Optional[str] = None)

Bases: OscUtils

Helper class to deduplicate between the different release scripts.

release_repo_to_publish(project: str) None

Releases a :GA:TEST to :GA:PUBLISH. This is a synchronous call that will block until it is done.

Parameters:

project – The project including the :GA suffix.

release_repo_to_test(project: str) None

Releases a :GA to :GA:TEST. This is a synchronous call that will block until it is done.

Parameters:

project – The project including the :GA suffix.

release_to_common(project: str) None

This consolidates common steps that are required to release a project. Specifics should be implemented in release_repo_to_<target>.

Parameters:

project – The project that will be released.

class sle_prjmgr_tools.utils.osc.OscUtils(osc_server: str = 'https://build.opensuse.org', override_config: Optional[str] = None)

Bases: object

This class contains the shared functions that will enable scripts to interact with an Open Build Service instance.

static convert_project_to_product(project: str) str

Assumes the following schema: RootProject:SomeSubProject:MoreProjects:SLE-<digits>-SP<digits>:SomeProject

Parameters:

project – Project to convert

Returns:

A str in the form “SLES<major>-SP<SP version>”.

get_file_from_package(project: str, package: str, revision, filename: str, target_filename: Optional[str] = None)

Retrieve a given file from a package that is text based.

Parameters:
  • project – The project the package is in.

  • package – The package the file is in.

  • revision – The file revision that should be downloaded.

  • filename – The filename that should be downloaded.

  • target_filename – If this is given, then the file will be downloaded with the specified name.

osc_do_release(project: str, package: str = '', repo: str = '', target_project: str = '', target_repository: str = '', no_delay: bool = False) None

Perform a release for a given project.

Parameters:
  • project – The project to release.

  • package – Release only a specific package.

  • repo – The repository that should be published.

  • target_project – The target project where to release to.

  • target_repository – The target repository where to release to.

  • no_delay – If the action should be regularly scheduled or if it should be performed immediately

osc_get_binary_names(project: str, repository: str, arch: str, package: str) List[BinaryParsed]

Retrieves the names of all binaries that are built from a given source package.

Parameters:
  • project – The project the source package is in.

  • repository – The repository the binaries are in.

  • arch – The architecture that the packages are built for.

  • package – The source package name.

Returns:

The list of binary packages parsed and split up in a tuple with four elements.

osc_get_containers(project: str) List[str]

Searches in a given project for the packages that correspond to containers.

Parameters:

project – The project that should be searched in.

Returns:

The list of str with package names that match the container regex.

osc_get_jsc_from_sr(sr_number: int) List[str]

Get all jsc’s from a single Submit Request in the Open Build Service.

Parameters:

sr_number – The submit request number that should be checked.

Returns:

The list of jsc’s that were mentioned.

osc_get_products(project: str) List[str]

Get all packages that belong to products being built in this project.

Parameters:

project – The project to check for.

Returns:

The list of packages that match the criteria. Might be empty.

osc_get_textfile_from_rpm(project: str, repo: str, arch: str, binary_name: str, filename: str) str

Retrieves a textfile from an RPM package.

Parameters:
  • project – The project the binary is in.

  • repo – The repository the binary is in.

  • arch – The architecture of the binary that should be retrieved.

  • binary_name – The name of the binary.

  • filename – The filename inside the binary that should be read.

Returns:

The content of the textfile.

osc_get_web_ui_url() str

Search the API for the Web UI URL.

Returns:

The URL of the WebUI for OBS.

osc_is_repo_published(project: str, repository: str) bool

Checks if the repository in the specified project is already published. This does not reflect if the current build is published just that the build available via the API is published.

Parameters:
  • project – The project that should be checked.

  • repository – The repository that should be checked.

Returns:

True if the repository is published.

osc_prepare() None

This has to be executed to the ini-style config is converted into their corresponding types.

osc_retrieve_betaversion(project: str) str

Retrieve the current beta version from the “SLES.prod” file in the “sles-release” binary.

Parameters:

project – The project the sles binary is found in.

Returns:

The current beta version. This may be different than the one that is set in the project configuration.

2.1.1.2.5. Module contents

This utils module should contain code that is shared between more than one release management CLI module.