forked from fedora-copr/copr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpmbuild, frontend: activate Red Hat subscription on demand
Fix fedora-copr#2132
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
Red Hat Subscription Management | ||
Activating Red Hat subscription may take a lot of time and historically, the | ||
subscription service used to be unreliable, so we should activate the | ||
subscription only when necessary. | ||
""" | ||
|
||
import os | ||
import shlex | ||
from copr_rpmbuild.helpers import run_cmd | ||
|
||
|
||
def activate_subscription(): | ||
""" | ||
Activate Red Hat Subscription. | ||
""" | ||
pool = "8a85f9a17c71102f017ce611251c770f" | ||
user = "copr-team" | ||
# TODO Not sure where to store this password so that it is not readable from | ||
# the builder (we give SSH access to users, so it cannot be in ENV) | ||
password = "TODO" | ||
name = os.environ.get("RESALLOC_NAME", "unknown-builder") | ||
system = name.replace("_", "-") | ||
timeout = 200 | ||
|
||
cmd = [ | ||
"/usr/local/bin/copr-rh-subscribe.sh", | ||
"--pool-id", pool, | ||
"--user", user, | ||
"--pass", shlex.quote(password), | ||
"--system", shlex.quote(system), | ||
] | ||
run_cmd(cmd, timeout=timeout) | ||
|
||
|
||
def subscription_required(task): | ||
""" | ||
Is subscription required for this task? | ||
""" | ||
return "subscription" in task["tags"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters