use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class BugzillaTests method getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists.
protected List<List<Object>> getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists() throws JSONException, Exception {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (!isSetupBeforeSuiteComplete)
return ll;
if (clienttasks == null)
return ll;
if (sm_clientUsername == null)
return ll;
if (sm_clientPassword == null)
return ll;
// get the currently installed product certs to be used when checking
// for conditional content tagging
List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
// assure we are freshly registered and process all available
// subscription pools
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (!contentNamespace.type.equalsIgnoreCase("yum"))
continue;
if (contentNamespace.enabled && clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
String repoLabel = contentNamespace.label;
// find an available package that is uniquely provided by
// repo
String pkg = clienttasks.findUniqueAvailablePackageFromRepo(repoLabel);
if (pkg == null) {
log.warning("Could NOT find a unique available package from repo '" + repoLabel + "' after subscribing to SubscriptionPool: " + pool);
}
ll.add(Arrays.asList(new Object[] { pkg, repoLabel, pool }));
}
}
clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
// testcase development)
if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
break;
}
return ll;
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method assertEntitlementCertsInYumRepolist.
/**
* Assert that the given entitlement certs are displayed in the stdout from "yum repolist all".
* @param entitlementCerts
*/
public void assertEntitlementCertsInYumRepolist(List<EntitlementCert> entitlementCerts, boolean areReported) {
// # yum repolist all
// Loaded plugins: refresh-packagekit, rhnplugin, rhsmplugin
// Updating Red Hat repositories.
// This system is not registered with RHN.
// RHN support will be disabled.
// http://redhat.com/foo/path/never/repodata/repomd.xml: [Errno 14] HTTP Error 404 : http://www.redhat.com/foo/path/never/repodata/repomd.xml
// Trying other mirror.
// repo id repo name status
// always-enabled-content always-enabled-content disabled
// content-label content disabled
// never-enabled-content never-enabled-content enabled: 0
// rhel-beta Red Hat Enterprise Linux 5.90Workstation Beta - x86_64 disabled
// rhel-beta-debuginfo Red Hat Enterprise Linux 5.90Workstation Beta - x86_64 - Debug disabled
// rhel-beta-optional Red Hat Enterprise Linux 5.90Workstation Beta (Optional) - x86 disabled
// rhel-beta-optional-debuginfo Red Hat Enterprise Linux 5.90Workstation Beta (Optional) - x86 disabled
// rhel-beta-optional-source Red Hat Enterprise Linux 5.90Workstation Beta (Optional) - x86 disabled
// rhel-beta-source Red Hat Enterprise Linux 5.90Workstation Beta - x86_64 - Sourc disabled
// rhel-latest Latest RHEL 6 enabled: 0
// repolist: 0
// [root@jsefler-itclient01 product]# yum repolist all
// Loaded plugins: pidplugin, refresh-packagekit, rhnplugin, rhsmplugin
// Updating Red Hat repositories.
// INFO:repolib:repos updated: 0
// This system is not registered with RHN.
// RHN support will be disabled.
// red-hat-enterprise-linux-6-entitlement-alpha-rpms | 4.0 kB 00:00
// red-hat-enterprise-linux-6-entitlement-alpha-rpms-updates | 951 B 00:00
// repo id repo name status
// red-hat-enterprise-linux-6-entitlement-alpha-debug-rpms Red Hat Enterprise Linux 6 Entitlement Alpha (Debug disabled
// red-hat-enterprise-linux-6-entitlement-alpha-debug-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha (Debug disabled
// red-hat-enterprise-linux-6-entitlement-alpha-optional-debug-rpms Red Hat Enterprise Linux 6 Entitlement Alpha - Opti disabled
// red-hat-enterprise-linux-6-entitlement-alpha-optional-debug-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha - Opti disabled
// red-hat-enterprise-linux-6-entitlement-alpha-optional-rpms Red Hat Enterprise Linux 6 Entitlement Alpha - Opti disabled
// red-hat-enterprise-linux-6-entitlement-alpha-optional-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha - Opti disabled
// red-hat-enterprise-linux-6-entitlement-alpha-optional-source-rpms Red Hat Enterprise Linux 6 Entitlement Alpha - Opti disabled
// red-hat-enterprise-linux-6-entitlement-alpha-optional-source-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha - Opti disabled
// red-hat-enterprise-linux-6-entitlement-alpha-rpms Red Hat Enterprise Linux 6 Entitlement Alpha (RPMs) enabled: 3,394
// red-hat-enterprise-linux-6-entitlement-alpha-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha (RPMs) enabled: 0
// red-hat-enterprise-linux-6-entitlement-alpha-source-rpms Red Hat Enterprise Linux 6 Entitlement Alpha (Sourc disabled
// red-hat-enterprise-linux-6-entitlement-alpha-source-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha (Sourc disabled
// red-hat-enterprise-linux-6-entitlement-alpha-supplementary-debug-rpms Red Hat Enterprise Linux 6 Entitlement Alpha - Supp disabled
// red-hat-enterprise-linux-6-entitlement-alpha-supplementary-debug-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha - Supp disabled
// red-hat-enterprise-linux-6-entitlement-alpha-supplementary-rpms Red Hat Enterprise Linux 6 Entitlement Alpha - Supp disabled
// red-hat-enterprise-linux-6-entitlement-alpha-supplementary-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha - Supp disabled
// red-hat-enterprise-linux-6-entitlement-alpha-supplementary-source-rpms Red Hat Enterprise Linux 6 Entitlement Alpha - Supp disabled
// red-hat-enterprise-linux-6-entitlement-alpha-supplementary-source-rpms-updates Red Hat Enterprise Linux 6 Entitlement Alpha - Supp disabled
// repolist: 3,394
List<ProductCert> currentProductCerts = this.getCurrentProductCerts();
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=697087 - jsefler 04/27/2011
if (this.redhatRelease.contains("release 5")) {
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "697087";
// try {if (invokeWorkaroundWhileBugIsOpen/*&&BzChecker.getInstance().isBugOpen(bugId)*/) {log.fine("Invoking workaround for "+BzChecker.getInstance().getBugState(bugId).toString()+" Bugzilla "+bugId+". (https://bugzilla.redhat.com/show_bug.cgi?id="+bugId+")");SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);} else {invokeWorkaroundWhileBugIsOpen=false;}} catch (BugzillaAPIException be) {/* ignore exception */} catch (RuntimeException re) {/* ignore exception */}
if (invokeWorkaroundWhileBugIsOpen) {
List<String> yumRepoListAll = this.getYumRepolist("all");
List<String> yumRepoListEnabled = this.getYumRepolist("enabled");
List<String> yumRepoListDisabled = this.getYumRepolist("disabled");
for (EntitlementCert entitlementCert : entitlementCerts) {
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (!contentNamespace.type.equalsIgnoreCase("yum"))
continue;
if (areReported && areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
if (contentNamespace.enabled) {
Assert.assertTrue(yumRepoListEnabled.contains(contentNamespace.label), "Yum repolist enabled includes repo id/label '" + contentNamespace.label + "' that comes from entitlement cert " + entitlementCert.id + "'s content namespace: " + contentNamespace);
} else {
Assert.assertTrue(yumRepoListDisabled.contains(contentNamespace.label), "Yum repolist disabled includes repo id/label '" + contentNamespace.label + "' that comes from entitlement cert " + entitlementCert.id + "'s content namespace: " + contentNamespace);
}
} else
Assert.assertFalse(yumRepoListAll.contains(contentNamespace.label), "Yum repolist all excludes repo id/label '" + contentNamespace.label + "'.");
}
}
return;
}
}
// END OF WORKAROUND
// assert all of the entitlement certs are reported in the stdout from "yum repolist all"
sshCommandRunner.runCommandAndWaitWithoutLogging("killall -9 yum");
List<String> yumRepolistAll = getYumRepolist("all");
for (EntitlementCert entitlementCert : entitlementCerts) {
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
// Note: When the repo id and repo name are really long, the repo name in the yum repolist all gets crushed (hence the reason for .* in the regex)
boolean isReported = yumRepolistAll.contains(contentNamespace.label.trim());
boolean areAllRequiredTagsInstalled = areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts);
if (!contentNamespace.type.equalsIgnoreCase("yum")) {
Assert.assertTrue(!isReported, "ContentNamespace label '" + contentNamespace.label.trim() + "' from EntitlementCert '" + entitlementCert.serialNumber + "' is NOT reported in yum repolist all since its type '" + contentNamespace.type + "' is non-yum.");
} else if (areReported && areAllRequiredTagsInstalled) {
Assert.assertTrue(isReported, "ContentNamespace label '" + contentNamespace.label.trim() + "' from EntitlementCert '" + entitlementCert.serialNumber + "' is reported in yum repolist all.");
} else {
Assert.assertTrue(!isReported, "ContentNamespace label '" + contentNamespace.label.trim() + "' from EntitlementCert '" + entitlementCert.serialNumber + "' is NOT reported in yum repolist all" + ((areReported && !areAllRequiredTagsInstalled) ? " since all its required tags '" + contentNamespace.requiredTags + "' are NOT found among the currently installed product certs." : "."));
}
}
}
// assert that the sshCommandRunner.getStderr() does not contains an error on the entitlementCert.download_url e.g.: http://redhat.com/foo/path/never/repodata/repomd.xml: [Errno 14] HTTP Error 404 : http://www.redhat.com/foo/path/never/repodata/repomd.xml
// FIXME EVENTUALLY WE NEED TO UNCOMMENT THIS ASSERT
// Assert.assertContainsNoMatch(result.getStderr(), "HTTP Error \\d+", "HTTP Errors were encountered when runnning yum repolist all.");
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method getCurrentRhelProductCert.
/**
* @return the currently installed ProductCert that provides a known base RHEL OS tag "rhel-5", "rhel-6", "rhel-7", "rhel-alt-7", etc.
* Also asserts that at most only one RHEL product cert is installed; returns null if not found
*/
public ProductCert getCurrentRhelProductCert() {
// get the current base RHEL product cert that provides a predictable tag
String providingTag;
// consider the major rhel version tags
// Product:
// ID: 69
// Name: Red Hat Enterprise Linux 6 Server
// Version: 6.1
// Arch: i386
// Tags: rhel-6,rhel-6-server
// Brand Type:
// Brand Name:
providingTag = "rhel-" + redhatReleaseX;
// also consider rhel-5-client-workstation tag
// Product:
// ID: 71
// Name: Red Hat Enterprise Linux Workstation
// Version: 5.10
// Arch: i386
// Tags: rhel-5-client-workstation,rhel-5-workstation
providingTag += "|" + "rhel-5-client-workstation";
// also consider tags used for rhel 7 beta
// [root@ibm-p8-kvm-09-guest-08 rhel-7.0-beta]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
// Product:
// ID: 227
// Name: Red Hat Enterprise Linux 7 for IBM POWER Public Beta
// Version: 7.0 Beta
// Arch: ppc64
// Tags: rhel-7-ibm-power-everything
// Brand Type:
// Brand Name:
// Product:
// ID: 228
// Name: Red Hat Enterprise Linux 7 for IBM System z Public Beta
// Version: 7.0 Beta
// Arch: s390x
// Tags: rhel-7-ibm-system-z-everything
// Brand Type:
// Brand Name:
// Product:
// ID: 226
// Name: Red Hat Enterprise Linux 7 Public Beta
// Version: 7.0 Beta
// Arch: x86_64
// Tags: rhel-7-everything
// Brand Type:
// Brand Name:
providingTag += "|" + "rhel-7-.*everything";
// also consider tags used for rhelsa-dp Development Preview
// [root@ibm-p8-kvm-09-guest-08 rhelsa-dp]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
// Product:
// ID: 261
// Name: Red Hat Enterprise Linux Server for ARM Development Preview
// Version: Snapshot
// Arch: aarch64
// Tags: rhsa-dp-server,rhsa-dp-server-7
// Brand Type:
// Brand Name:
providingTag += "|" + "rhelsa-dp-.+";
// also consider tags used for rhel-alt
// [root@ibm-p8-kvm-09-guest-08 tmp]# git clone git://git.host.prod.eng.bos.redhat.com/rcm/rcm-metadata.git
// [root@ibm-p8-kvm-09-guest-08 tmp]# cd rcm-metadata/product_ids/rhel-alt-7.4/
// [root@ibm-p8-kvm-09-guest-08 rhel-alt-7.4]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
// Product:
// ID: 419
// Name: Red Hat Enterprise Linux for ARM 64
// Version: 7.4
// Arch: aarch64
// Tags: rhel-alt-7,rhel-alt-7-armv8-a
// Brand Type:
// Brand Name:
// Product:
// ID: 420
// Name: Red Hat Enterprise Linux for Power 9
// Version: 7.4
// Arch: ppc64le
// Tags: rhel-alt-7,rhel-alt-7-power9
// Brand Type:
// Brand Name:
providingTag += "|" + "rhel-alt-" + redhatReleaseX;
// also consider tags used for rhel-htb High Touch Beta
// [root@dell-pem610-01 tmp]# git clone git://git.host.prod.eng.bos.redhat.com/rcm/rcm-metadata.git
// [root@dell-pem610-01 tmp]# cd rcm-metadata/product_ids/rhel-7.5-htb/
// [root@dell-pem610-01 rhel-7.5-htb]# for f in $(ls *.pem); do rct cat-cert $f | egrep -A7 'Product:'; done;
// Product:
// ID: 230
// Name: Red Hat Enterprise Linux 7 Server High Touch Beta
// Version: 7.5 Beta // Ref Bug 1538957 - product-default .pem files do not contain expected data
// Arch: x86_64
// Tags: rhel-7-htb,rhel-7-server
// Brand Type:
// Brand Name:
// Product:
// ID: 231
// Name: Red Hat Enterprise Linux 7 Workstation High Touch Beta
// Version: 7.5 Beta // Ref Bug 1538957 - product-default .pem files do not contain expected data
// Arch: x86_64
// Tags: rhel-7-htb,rhel-7-workstation
// Brand Type:
// Brand Name:
providingTag += "|" + "rhel-" + redhatReleaseX + "-htb";
// get the product certs matching the rhel regex tag
List<ProductCert> rhelProductCerts = getCurrentProductCerts(providingTag);
// by a rhel product cert in /etc/pki/product, otherwise the subsequent asserts will fail
for (ProductCert productDefaultCert : getProductCerts(productCertDefaultDir)) {
if (ProductCert.findAllInstancesWithCaseInsensitiveMatchingFieldFromList("productId", productDefaultCert.productId, rhelProductCerts).size() >= 2) {
rhelProductCerts.remove(productDefaultCert);
}
}
// log a warning when more than one product cert providing tag rhel-X is installed
if (rhelProductCerts.size() > 1)
log.warning("These " + rhelProductCerts.size() + " RHEL tagged '" + providingTag + "' product certs are installed: " + rhelProductCerts);
// TEMPORARY WORKAROUND
if (rhelProductCerts.size() > 1) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1506271 - redhat-release is providing more than 1 variant specific product cert
String bugId = "1506271";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
throw new SkipException("The remainder of this test is blocked by bug '" + bugId + "' because multiple base RHEL product certs are installed.");
}
}
// END OF WORKAROUND
// assert that only one rhel product cert is installed (after purging HTB and an untrumped product-default cert)
Assert.assertEquals(rhelProductCerts.size(), 1, "Only one product cert is installed that provides RHEL tag '" + providingTag + "' (this assert tolerates /etc/pki/product-default/ certs that are trumped by /etc/pki/product/ certs)");
// return it
if (rhelProductCerts.isEmpty())
return null;
return rhelProductCerts.get(0);
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method listSubscribedRepos.
/**
* @return SSHCommandResult from "subscription-manager repos --list"
*/
public SSHCommandResult listSubscribedRepos() {
Calendar now = new GregorianCalendar();
now.setTimeInMillis(System.currentTimeMillis());
SSHCommandResult sshCommandResult = repos(true, null, null, (String) null, (String) null, null, null, null, null);
// Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "The exit code from the repos --list command indicates a success.");
// List<File> entitlementCertFiles = getCurrentEntitlementCertFiles();
List<ProductCert> productCerts = getCurrentProductCerts();
List<EntitlementCert> entitlementCerts = getCurrentEntitlementCerts();
int numContentNamespaces = 0;
for (EntitlementCert entitlementCert : entitlementCerts) {
// we should NOT count contentNamespaces from entitlement certs that are not valid now
if (entitlementCert.validityNotBefore.after(now) || entitlementCert.validityNotAfter.before(now))
continue;
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
// we should NOT count contentNamespaces from for which all required tags are not provided by the installed product certs
if (!areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, productCerts)) {
log.warning("None of the currently installed product certs provide the required tags '" + contentNamespace.requiredTags + "' for entitled content namespace: " + contentNamespace.name);
continue;
}
// we should NOT count contentNamespaces that are not of type=yum
if (!contentNamespace.type.equals("yum")) {
log.warning("Encountered the following Content Namespace whose type is not \"yum\" (it should not contribute to the list of yum repos): " + contentNamespace);
continue;
}
numContentNamespaces++;
}
}
if (numContentNamespaces == 0) {
// Assert.assertTrue(sshCommandResult.getStdout().trim().equals("The system is not entitled to use any repositories."), "The system is not entitled to use any repositories."); // changed by bug 846834
Assert.assertTrue(sshCommandResult.getStdout().trim().equals("This system has no repositories available through subscriptions."), "This system has no repositories available through subscriptions.");
} else {
String title;
// changed by bug 846834
title = "Entitled Repositories in " + redhatRepoFile;
title = "Available Repositories in " + redhatRepoFile;
Assert.assertTrue(sshCommandResult.getStdout().contains(title), "The list of repositories is entitled '" + title + "'.");
}
return sshCommandResult;
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method isRhelProductCertSubscribed.
public boolean isRhelProductCertSubscribed() {
ProductCert rhelProductCert = getCurrentRhelProductCert();
// rhel product cert cannot be subscribed if a rhel product cert is not installed
if (rhelProductCert == null)
return false;
InstalledProduct installedRhelProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductCert.productId, getCurrentlyInstalledProducts());
if (installedRhelProduct == null)
Assert.fail("Could not find the installed product corresponding to the current RHEL product cert: " + rhelProductCert);
return installedRhelProduct.status.equals("Subscribed");
}
Aggregations