use of rhsm.data.ContentNamespace 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.ContentNamespace 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.ContentNamespace 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.ContentNamespace in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method getCurrentlyExpectedReleases.
/**
* @return list of the expected releases currently available based on the currently enabled repo content and this major RHEL release
*/
public List<String> getCurrentlyExpectedReleases() {
HashSet<String> expectedReleaseSet = new HashSet<String>();
String baseurl = getConfFileParameter(rhsmConfFile, "rhsm", "baseurl");
List<ProductCert> productCerts = getCurrentProductCerts();
// loop through all of the currently entitled repo urls
for (EntitlementCert entitlementCert : getCurrentEntitlementCerts()) {
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (contentNamespace.type.equalsIgnoreCase("yum")) {
if (contentNamespace.enabled) {
// Bug 820639 - subscription-manager release --list should exclude listings from disabled repos
if (areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, productCerts)) {
// Bug 861151 - subscription-manager release doesn't take variant into account
if (contentNamespace.downloadUrl.contains("$releasever")) {
if (contentNamespace.downloadUrl.contains("/" + redhatReleaseX + "/")) {
// Bug 818298 - subscription-manager release --list should not display releasever applicable to rhel-5 when only rhel-6 product is installed
// example contentNamespace.downloadUrl: /content/dist/rhel/server/5/$releasever/$basearch/iso
String listingUrl = contentNamespace.downloadUrl.startsWith("http") ? "" : baseurl;
listingUrl += contentNamespace.downloadUrl.split("/\\$releasever/")[0];
listingUrl += "/listing";
String command = String.format("curl --stderr /dev/null --insecure --tlsv1 --cert %s --key %s %s", entitlementCert.file.getPath(), getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(entitlementCert.file).getPath(), listingUrl);
SSHCommandResult result = sshCommandRunner.runCommandAndWaitWithoutLogging(command);
// process exceptional results...
if (result.getStdout().toUpperCase().contains("<HTML>")) {
// [root@jsefler-6 ~]# curl --stderr /dev/null --insecure --tlsv1 --cert /etc/pki/entitlement/3360706382464344965.pem --key /etc/pki/entitlement/3360706382464344965-key.pem https://cdn.redhat.com/content/dist/rhel/server/6/listing
// <HTML><HEAD>
// <TITLE>Access Denied</TITLE>
// </HEAD><BODY>
// <H1>Access Denied</H1>
// or should this be a failure?
log.warning("curl result: " + result);
Assert.fail("Expected to retrieve a list of available release versions. (Example: 6.1, 6.2, 6Server)");
} else if (result.getStdout().trim().startsWith("Unable to locate content")) {
// [root@jsefler-5 ~]# curl --stderr /dev/null --insecure --tlsv1 --cert /etc/pki/entitlement/6653190787244398414.pem --key /etc/pki/entitlement/6653190787244398414-key.pem https://cdn.qa.redhat.com/content/aus/rhel/server/5/listing
// Unable to locate content /content/aus/rhel/server/5/listing
// or should this be a failure?
log.warning("curl result: " + result);
log.warning("Query failed to get an expected release listing from ContentNamespace: \n" + contentNamespace);
log.warning("After setting an older release, a yum repolist of this content set will likely yield: [Errno 14] HTTP Error 404: Not Found");
} else {
expectedReleaseSet.addAll(Arrays.asList(result.getStdout().trim().split("\\s*\\n\\s*")));
}
}
}
}
}
}
}
}
return new ArrayList<String>(expectedReleaseSet);
// ^^ TODO On second thought, it would technically be more correct to loop over the current YumRepo object rather than the Entitlement Certs since a repo enablement could have been manually overridden
// TODO work in progress
// for (YumRepo yumRepo : getCurrentlySubscribedYumRepos()()) {
// if (yumRepo.enabled) { // Bug 820639 - subscription-manager release --list should exclude listings from disabled repos
// if (yumRepo.baseurl.contains("$releasever")) {
// if (yumRepo.baseurl.contains("/"+redhatReleaseX+"/")) { // Bug 818298 - subscription-manager release --list should not display releasever applicable to rhel-5 when only rhel-6 product is installed
// // example contentNamespace.downloadUrl: /content/dist/rhel/server/5/$releasever/$basearch/iso
// String listingUrl = yumRepo.baseurl.startsWith("http")? "":baseurl;
// listingUrl += yumRepo.baseurl.split("/\\$releasever/")[0];
// listingUrl += "/listing";
// String command = String.format("curl --stderr /dev/null --insecure --cert %s --key %s %s" , entitlementCert.file.getPath(), getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(entitlementCert.file).getPath(), listingUrl);
// SSHCommandResult result = sshCommandRunner.runCommandAndWaitWithoutLogging(command);
// // [root@qe-blade-13 ~]# curl --stderr /dev/null --insecure --cert /etc/pki/entitlement/2013167262444796312.pem --key /etc/pki/entitlement/2013167262444796312-key.pem https://cdn.rcm-qa.redhat.com/content/dist/rhel/server/6/listing
// // 6.1
// // 6.2
// // 6Server
// expectedReleaseSet.addAll(Arrays.asList(result.getStdout().trim().split("\\s*\\n\\s*")));
// }
// }
// }
// }
}
use of rhsm.data.ContentNamespace in project rhsm-qe by RedHatQE.
the class SubscriptionManagerCLITestScript method verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos.
protected void verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(List<ProductCert> currentProductCerts) {
if (currentProductCerts == null)
currentProductCerts = clienttasks.getCurrentProductCerts();
List<YumRepo> yumRepos = clienttasks.getCurrentlySubscribedYumRepos();
List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
int numYumReposProvided = 0;
for (EntitlementCert entitlementCert : entitlementCerts) {
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (contentNamespace.type.equals("yum")) {
if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
numYumReposProvided++;
Assert.assertNotNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", contentNamespace.label, yumRepos), "The '" + clienttasks.redhatRepoFile + "' has an entry for contentNamespace label '" + contentNamespace.label + "'.");
}
} else {
// contentNamespace types that are not "yum" should not be included in the redhat.repo file (e.g. "file" and "kickstart")
Assert.assertNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", contentNamespace.label, yumRepos), "The '" + clienttasks.redhatRepoFile + "' should NOT have an entry for contentNamespace label '" + contentNamespace.label + "' because it's type '" + contentNamespace.type + "' is not equal to 'yum'.");
}
}
}
if (entitlementCerts.isEmpty()) {
Assert.assertTrue(yumRepos.isEmpty(), "When there are no entitlement contentNamespaces, then '" + clienttasks.redhatRepoFile + "' should have no yumRepo entries.");
} else if (numYumReposProvided == 0) {
Assert.assertTrue(yumRepos.isEmpty(), "When none of the currently installed product certs provideTags matching the currently entitled content namespace requiredTags, then '" + clienttasks.redhatRepoFile + "' should have no yumRepo entries.");
}
}
Aggregations