use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class RegisterTests method testRegisterWithAutosubscribe.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19949", "RHEL7-50999" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "subscription-manager-cli: register to a Candlepin server using autosubscribe functionality", groups = { "Tier1Tests", "blockedByBug-602378", "blockedByBug-616137", "blockedByBug-678049", "blockedByBug-737762", "blockedByBug-743082", "blockedByBug-919700" }, enabled = true)
public void testRegisterWithAutosubscribe() throws JSONException, Exception {
// determine all of the productIds that are provided by available subscriptions
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
Set<String> providedProductIdsFromAvailableUnmappedGuestOnlyPools = new HashSet<String>();
// but not the unmapped_guest_only pools
Set<String> providedProductIdsFromAvailableVirtOnlyPools = new HashSet<String>();
// all the rest of the pools
Set<String> providedProductIdsFromAvailablePools = new HashSet<String>();
for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
JSONObject jsonPool = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/pools/" + pool.poolId));
JSONArray jsonProvidedProducts = jsonPool.getJSONArray("providedProducts");
for (int k = 0; k < jsonProvidedProducts.length(); k++) {
JSONObject jsonProvidedProduct = (JSONObject) jsonProvidedProducts.get(k);
String providedProductName = jsonProvidedProduct.getString("productName");
String providedProductId = jsonProvidedProduct.getString("productId");
if (CandlepinTasks.isPoolRestrictedToUnmappedVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
providedProductIdsFromAvailableUnmappedGuestOnlyPools.add(providedProductId);
}
if (CandlepinTasks.isPoolRestrictedToVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
providedProductIdsFromAvailableVirtOnlyPools.add(providedProductId);
} else {
providedProductIdsFromAvailablePools.add(providedProductId);
}
}
}
// assert that all installed products are "Not Subscribed"
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
for (InstalledProduct installedProduct : installedProducts) {
Assert.assertEquals(installedProduct.status, "Not Subscribed", "Installed product status for productId '" + installedProduct.productId + "' prior to registration with autosubscribe.");
}
// now register with --autosubscribe
SSHCommandResult registerResult = clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null);
// 201208091741:18.316 - FINE: ssh root@pogolinux-1.rhts.eng.rdu.redhat.com subscription-manager register --username=stage_test_12 --password=redhat --autosubscribe --force (com.redhat.qe.tools.SSHCommandRunner.run)
// 201208091741:50.504 - FINE: Stdout:
// The system with UUID 5e88b5ef-e218-423c-8cf1-380d37476580 has been unregistered
// The system has been registered with id: edfabea2-0bd4-4584-bb3e-f3bca9a3a442
// Installed Product Current Status:
// Product Name: Red Hat Enterprise Linux Server
// Status: Subscribed
//
// 201208091741:50.505 - FINE: Stderr:
// 201208091741:50.505 - FINE: ExitCode: 0
// IF THE INSTALLED PRODUCT ID IS PROVIDED BY AN AVAILABLE SUBSCRIPTION, THEN IT SHOULD GET AUTOSUBSCRIBED! (since no service preference level has been set)
// assert the expected installed product status in the feedback from register with --autosubscribe
List<InstalledProduct> autosubscribedProducts = InstalledProduct.parse(registerResult.getStdout());
for (InstalledProduct autosubscribedProduct : autosubscribedProducts) {
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", autosubscribedProduct.productName, installedProducts);
if (providedProductIdsFromAvailableUnmappedGuestOnlyPools.contains(installedProduct.productId) && !providedProductIdsFromAvailableVirtOnlyPools.contains(installedProduct.productId)) {
// must be "Subscribed"
Assert.assertEquals(autosubscribedProduct.status, "Partially Subscribed", "Status for productName '" + autosubscribedProduct.productName + "' in feedback from registration with autosubscribe. (Partial/yellow because this productId was only provided by an available unmapped_guests_only pool.)");
} else if (providedProductIdsFromAvailableUnmappedGuestOnlyPools.contains(installedProduct.productId) && providedProductIdsFromAvailableVirtOnlyPools.contains(installedProduct.productId)) {
// could be either "Partially Subscribed" or "Subscribed"
List<String> eitherPartiallySubscribedOrSubscribed = Arrays.asList("Partially Subscribed", "Subscribed");
Assert.assertTrue(eitherPartiallySubscribedOrSubscribed.contains(autosubscribedProduct.status), "Status for productName '" + autosubscribedProduct.productName + "' in feedback from registration (actual='" + autosubscribedProduct.status + "') with autosubscribe can be either " + eitherPartiallySubscribedOrSubscribed + ". (Either because this product id was provided by both an available unmapped_guests_only pool as well as other virt_only pools. Autosubscribe could randomly choose either.)");
} else if (providedProductIdsFromAvailablePools.contains(installedProduct.productId)) {
// TEMPORARY WORKAROUND FOR BUG
if (installedProduct.arch.contains(",")) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 951633 - installed product with comma separated arch attribute fails to go green
String bugId = "951633";
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) {
log.warning("Skipping assertion for autosubscribed status of Installed Product name='" + installedProduct.productName + "' while Bugzilla '" + bugId + "' is open.");
continue;
}
}
// END OF WORKAROUND
// must be "Subscribed"
Assert.assertEquals(autosubscribedProduct.status, "Subscribed", "Status for productName '" + autosubscribedProduct.productName + "' in feedback from registration with autosubscribe.");
} else {
// must be "Not Subscribed"
Assert.assertEquals(autosubscribedProduct.status, "Not Subscribed", "Status for productName '" + autosubscribedProduct.productName + "' in feedback from registration with autosubscribe.");
}
}
// assert the expected installed product status in the list --installed after the register with --autosubscribe
installedProducts = clienttasks.getCurrentlyInstalledProducts();
for (InstalledProduct installedProduct : installedProducts) {
if (providedProductIdsFromAvailableUnmappedGuestOnlyPools.contains(installedProduct.productId) && !providedProductIdsFromAvailableVirtOnlyPools.contains(installedProduct.productId)) {
// must be "Subscribed"
Assert.assertEquals(installedProduct.status, "Partially Subscribed", "Status for Installed Product name='" + installedProduct.productName + "' id='" + installedProduct.productId + "' in list of installed products after registration with autosubscribe (Partial/yellow because this productId '" + installedProduct.productId + "' was only provided by an available unmapped_guests_only pool.)");
} else if (providedProductIdsFromAvailableUnmappedGuestOnlyPools.contains(installedProduct.productId) && providedProductIdsFromAvailableVirtOnlyPools.contains(installedProduct.productId)) {
// could be either "Partially Subscribed" or "Subscribed"
List<String> eitherPartiallySubscribedOrSubscribed = Arrays.asList("Partially Subscribed", "Subscribed");
Assert.assertTrue(eitherPartiallySubscribedOrSubscribed.contains(installedProduct.status), "Status for productName '" + installedProduct.productName + "' in feedback from registration (actual='" + installedProduct.status + "') with autosubscribe can be either " + eitherPartiallySubscribedOrSubscribed + ". (Either because this productId '" + installedProduct.productId + "' was provided by both an available unmapped_guests_only pool as well as other virt_only pools. Autosubscribe could randomly choose either.)");
} else if (providedProductIdsFromAvailablePools.contains(installedProduct.productId)) {
// TEMPORARY WORKAROUND FOR BUG
if (installedProduct.arch.contains(",")) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 951633 - installed product with comma separated arch attribute fails to go green
String bugId = "951633";
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) {
log.warning("Skipping assertion for autosubscribed status of Installed Product name='" + installedProduct.productName + "' while Bugzilla '" + bugId + "' is open.");
continue;
}
}
// END OF WORKAROUND
// must be "Subscribed"
Assert.assertEquals(installedProduct.status, "Subscribed", "Status for Installed Product name='" + installedProduct.productName + "' id='" + installedProduct.productId + "' in list of installed products after registration with autosubscribe.");
} else {
// must be "Not Subscribed"
Assert.assertEquals(installedProduct.status, "Not Subscribed", "Status for Installed Product name='" + installedProduct.productName + "' id='" + installedProduct.productId + "' in list of installed products after registration with autosubscribe.");
}
}
Assert.assertEquals(autosubscribedProducts.size(), installedProducts.size(), "The 'Installed Product Current Status' reported during register --autosubscribe should contain the same number of products as reported by list --installed.");
// assert the feedback from RFE Bug 864195 - New String: Add string to output of 'subscription-manager subscribe --auto' if can't cover all products
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.11.1-1")) {
String autoAttachFeedbackResultMessage = "Unable to find available subscriptions for all your installed products.";
if (InstalledProduct.findAllInstancesWithMatchingFieldFromList("status", "Subscribed", installedProducts).size() == installedProducts.size()) {
Assert.assertTrue(!registerResult.getStdout().contains(autoAttachFeedbackResultMessage), "When the registration with autosubscribe succeeds in making all the installed products compliant, then feedback '" + autoAttachFeedbackResultMessage + "' is NOT reported.");
} else {
Assert.assertTrue(registerResult.getStdout().trim().endsWith(autoAttachFeedbackResultMessage), "When the registration with autosubscribe fails to make all the installed products compliant, then feedback '" + autoAttachFeedbackResultMessage + "' is the final report.");
}
}
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class IdentityTests method testIdentityIsBackedUpWhenConsumerIsDeletedServerSide.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19962", "RHEL7-51006" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "subscription-manager: assert that the consumer cert is backed up when a server-side deletion is detected.", groups = { "Tier1Tests", "VerifyIdentityIsBackedUpWhenConsumerIsDeletedServerSide_Test", "blockedByBug-814466", "blockedByBug-813296", "blockedByBug-838187", "blockedByBug-852706", "blockedByBug-872847", "blockedByBug-894633", "blockedByBug-907638", "blockedByBug-822402", "blockedByBug-986572", "blockedByBug-1000301", "blockedByBug-1026435", "blockedByBug-1019747", "blockedByBug-1026501", "blockedByBug-1366301", "blockedByBug-1397201" }, dataProvider = "getConsumerCertDirData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testIdentityIsBackedUpWhenConsumerIsDeletedServerSide(Object bugzilla, String consumerCertDir) throws Exception {
// set the rhsm.consumerCertDir (DO NOT USE SubscriptionTasks.config(...))
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "consumerCertDir", consumerCertDir);
// register and remember the original consumer identity
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
clienttasks.config(null, null, true, new String[] { "rhsmcertd", /*"certFrequency" CHANGED BY BUG 882459 TO*/
"certCheckInterval".toLowerCase(), "240" });
// make sure that rhsmcertd will not interfere with test
clienttasks.restart_rhsmcertd(null, null, true);
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
String consumerCert_md5sum = client.runCommandAndWait("md5sum " + clienttasks.consumerCertFile()).getStdout().trim();
String consumerKey_md5sum = client.runCommandAndWait("md5sum " + clienttasks.consumerKeyFile()).getStdout().trim();
// Subscribe to a randomly available pool...
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
if (pools.size() <= 0)
throw new SkipException("No susbcriptions are available for which an entitlement could be granted.");
log.info("Subscribe to a randomly available pool...");
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, /*sm_serverAdminUsername*/
sm_clientUsername, /*sm_serverAdminPassword*/
sm_clientPassword, sm_serverUrl);
// EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
// do a server-side consumer deletion
// # curl -k -u testuser1:password --request DELETE https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/consumers/8511a2a6-c2ec-4612-8186-af932a3b97cf
CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerCert.consumerid);
// give the server a chance to complete the job request // TODO change this hard sleep to wait for a finished job status
sleep(60 * 1000);
// assert that all subscription-manager calls are blocked by a message stating that the consumer has been deleted
// Original Stderr: Consumer with id b0f1ed9f-3dfa-4eea-8e04-72ab8075d533 could not be found
String expectedMsg = String.format("Consumer %s has been deleted", consumerCert.consumerid);
if (!clienttasks.workaroundForBug876764(sm_serverType))
expectedMsg = String.format("Unit %s has been deleted", consumerCert.consumerid);
String ignoreStderr = "stty: standard input: Invalid argument";
SSHCommandResult result;
Integer expectedExitCode = new Integer(255);
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
expectedExitCode = new Integer(70);
result = clienttasks.identity_(null, null, null, null, null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStdout().trim(), "", "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), expectedMsg, "Stderr expected after the consumer has been deleted on the server-side.");
result = clienttasks.refresh_(null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStdout().trim(), "", "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), expectedMsg, "Stderr expected after the consumer has been deleted on the server-side.");
result = clienttasks.service_level_(null, null, null, null, null, null, null, null, null, null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStdout().trim(), "", "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), expectedMsg, "Stderr expected after the consumer has been deleted on the server-side.");
// Bug 798788: Error updating system data, see /var/log/rhsm/rhsm.log for more details.
result = clienttasks.facts_(null, true, null, null, null, null);
// TEMPORARY WORKAROUND FOR BUG
String bugId = "798788";
boolean invokeWorkaroundWhileBugIsOpen = true;
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) {
log.warning("Skipping stderr assertion from subscription-manager facts --update.");
} else {
// END OF WORKAROUND
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStdout().trim(), "", "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), expectedMsg, "Stderr expected after the consumer has been deleted on the server-side.");
}
result = clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
// Assert.assertEquals(result.getStdout().trim(),expectedMsg,"Stdout expected after the consumer has been deleted on the server-side.");
// Assert.assertEquals(result.getStderr().trim(),"", "Stderr expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStdout().trim() + result.getStderr().trim(), expectedMsg, "Feedback expected after the consumer has been deleted on the server-side.");
result = clienttasks.list_(null, true, null, null, null, null, null, null, null, null, null, null, null, null);
// post commit 616ecda6db6ae8b054d7bbb8ba278bba242f4fd0 bug 1262989
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.4-1"))
expectedExitCode = new Integer(69);
// post commit 5c48d059bb07b64b92722f249b38aaee7219ab47 bug 1262989
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.3-1"))
expectedMsg = String.format("This consumer's profile has been deleted from the server. You can use command clean or unregister to remove local profile.", consumerCert.consumerid);
// post commit 3ad13c20f6ab34cf2621bc48cdd7d15a82791d4f bug 1262989
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.5-1"))
expectedMsg = String.format("Consumer profile \"%s\" has been deleted from the server. You can use command clean or unregister to remove local profile.", consumerCert.consumerid);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
// post commit a695ef2d1da882c5f851fde90a24f957b70a63ad
Assert.assertEquals(result.getStdout().trim(), "", "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), expectedMsg, "Stderr expected after the consumer has been deleted on the server-side.");
} else {
Assert.assertEquals(result.getStdout().trim(), expectedMsg, "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), "", "Stderr expected after the consumer has been deleted on the server-side.");
}
result = clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
// Assert.assertEquals(result.getStdout().trim(),expectedMsg,"Stdout expected after the consumer has been deleted on the server-side.");
// Assert.assertEquals(result.getStderr().trim(),"", "Stderr expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStdout().trim() + result.getStderr().trim(), expectedMsg, "Feedback expected after the consumer has been deleted on the server-side.");
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.16.3-1")) {
// pre commit 5c48d059bb07b64b92722f249b38aaee7219ab47 bug 1262989 which causes a call to unregister to effectively clean the local consumer cert
result = clienttasks.unregister_(null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Exitcode expected after the consumer has been deleted on the server-side.");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
// post commit a695ef2d1da882c5f851fde90a24f957b70a63ad
Assert.assertEquals(result.getStdout().trim(), "", "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), expectedMsg, "Stderr expected after the consumer has been deleted on the server-side.");
} else {
Assert.assertEquals(result.getStdout().trim(), expectedMsg, "Stdout expected after the consumer has been deleted on the server-side.");
Assert.assertEquals(result.getStderr().trim(), "", "Stderr expected after the consumer has been deleted on the server-side.");
}
}
// restart rhsmcertd
// assertCertificatesUpdate=false since the consumer has been deleted server side and the cert updates should fail
clienttasks.restart_rhsmcertd(null, null, false);
// assert that the consumer has been backed up and assert the md5sum matches
String consumerCertFileOld = clienttasks.consumerCertFile().replace(clienttasks.consumerCertDir, clienttasks.consumerCertDir + ".old");
String consumerCertKeyOld = clienttasks.consumerKeyFile().replace(clienttasks.consumerCertDir, clienttasks.consumerCertDir + ".old");
Assert.assertTrue(RemoteFileTasks.testExists(client, consumerCertFileOld), "For emergency recovery after rhsmcertd triggers, the server-side deleted consumer cert should be copied to: " + consumerCertFileOld);
Assert.assertTrue(RemoteFileTasks.testExists(client, consumerCertKeyOld), "For emergency recovery after rhsmcertd triggers, the server-side deleted consumer key should be copied to: " + consumerCertKeyOld);
Assert.assertEquals(client.runCommandAndWait("md5sum " + consumerCertFileOld).getStdout().replaceAll(consumerCertFileOld, "").trim(), consumerCert_md5sum.replaceAll(clienttasks.consumerCertFile(), "").trim(), "After the deleted consumer cert is backed up, its md5sum matches that from the original consumer cert.");
Assert.assertEquals(client.runCommandAndWait("md5sum " + consumerCertKeyOld).getStdout().replaceAll(consumerCertKeyOld, "").trim(), consumerKey_md5sum.replaceAll(clienttasks.consumerKeyFile(), "").trim(), "After the deleted consumer key is backed up, its md5sum matches that from the original consumer key.");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.3-1")) {
// post commit 5c48d059bb07b64b92722f249b38aaee7219ab47 bug 1262989 which causes a call to unregister to effectively clean the local consumer cert
// no longer throws an exception when consumer has been deleted consumer side - no reason to - just cleans the local consumer cert
clienttasks.unregister(null, null, null, null);
}
// assert that the system is no longer registered and no entitlements remain
result = clienttasks.identity_(null, null, null, null, null, null, null, null);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
Assert.assertEquals(result.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "The system should no longer be registered after rhsmcertd triggers following a server-side consumer deletion.");
} else {
Assert.assertEquals(result.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "The system should no longer be registered after rhsmcertd triggers following a server-side consumer deletion.");
}
Assert.assertTrue(clienttasks.getCurrentEntitlementCertFiles().isEmpty(), "The system should no longer have any entitlements after rhsmcertd triggers following a server-side consumer deletion.");
// assert that the clienttasks.consumerCertDir remains, but the cert.pem and key.pem are gone
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.14-1")) {
Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.consumerCertDir), "The original consumer cert dir '" + clienttasks.consumerCertDir + "' should remain after it has been backed up to: " + clienttasks.consumerCertDir + ".old");
Assert.assertTrue(!RemoteFileTasks.testExists(client, clienttasks.consumerCertFile()), "After rhsmcertd triggers, the consumer cert '" + clienttasks.consumerCertFile() + "' should have been deleted.");
Assert.assertTrue(!RemoteFileTasks.testExists(client, clienttasks.consumerKeyFile()), "After rhsmcertd triggers, the consumer key '" + clienttasks.consumerKeyFile() + "' should have been deleted.");
}
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class SubscriptionManagerCLITestScript method setupClient.
public void setupClient(SubscriptionManagerTasks smt, File serverCaCertFile, List<File> generatedProductCertFiles) throws IOException, JSONException {
smt.installSubscriptionManagerRPMs(sm_yumInstallOptions);
if (sm_yumInstallZStreamUpdates) {
smt.installZStreamUpdates(sm_yumInstallOptions, sm_yumInstallZStreamUpdatePackages, sm_yumInstallZStreamComposeUrl, sm_yumInstallZStreamBrewUrl, sm_ciMessage);
}
sm_rpmUpdateUrls.addAll(getRpmUpdateUrlsFromCiMessage(sm_ciMessage));
smt.installSubscriptionManagerRPMs(sm_rpmInstallUrls, sm_rpmUpdateUrls, sm_yumInstallOptions, jenkinsUsername, jenkinsPassword);
smt.initializeMsgStringsAfterInstallingSubscriptionManagerRPMs();
// rewrite rhsmcertd.certFrequency -> rhsmcertd.certCheckInterval see bug 882459
String certFrequency = smt.getConfFileParameter(smt.rhsmConfFile, "rhsmcertd", "certFrequency");
if (certFrequency != null) {
smt.commentConfFileParameter(smt.rhsmConfFile, "certFrequency");
// smt.config(null, null, true, new String[]{"rhsmcertd","certCheckInterval".toLowerCase(),certFrequency});
smt.addConfFileParameter(smt.rhsmConfFile, "rhsmcertd", "certCheckInterval", certFrequency);
}
// rewrite rhsmcertd.healFrequency -> rhsmcertd.autoAttachInterval see bug 882459
String healFrequency = smt.getConfFileParameter(smt.rhsmConfFile, "rhsmcertd", "healFrequency");
if (healFrequency != null) {
smt.commentConfFileParameter(smt.rhsmConfFile, "healFrequency");
// smt.config(null, null, true, new String[]{"rhsmcertd","autoAttachInterval".toLowerCase(),healFrequency});
smt.addConfFileParameter(smt.rhsmConfFile, "rhsmcertd", "autoAttachInterval", healFrequency);
}
// rhsm.conf [server] configurations
if (!sm_serverHostname.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "hostname", sm_serverHostname);
else
sm_serverHostname = smt.getConfFileParameter(smt.rhsmConfFile, "hostname");
if (!sm_serverPrefix.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "prefix", sm_serverPrefix);
else
sm_serverPrefix = smt.getConfFileParameter(smt.rhsmConfFile, "prefix");
if (!sm_serverPort.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "port", sm_serverPort);
else
sm_serverPort = smt.getConfFileParameter(smt.rhsmConfFile, "port");
if (!sm_serverInsecure.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "insecure", sm_serverInsecure);
else
sm_serverInsecure = smt.getConfFileParameter(smt.rhsmConfFile, "insecure");
if (!sm_serverSslVerifyDepth.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "ssl_verify_depth", sm_serverSslVerifyDepth);
else
sm_serverInsecure = smt.getConfFileParameter(smt.rhsmConfFile, "insecure");
if (!sm_serverCaCertDir.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "ca_cert_dir", sm_serverCaCertDir);
else
sm_serverCaCertDir = smt.getConfFileParameter(smt.rhsmConfFile, "ca_cert_dir");
// rhsm.conf [rhsm] configurations
if (!sm_rhsmBaseUrl.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "baseurl", sm_rhsmBaseUrl);
else
sm_rhsmBaseUrl = smt.getConfFileParameter(smt.rhsmConfFile, "baseurl");
if (!sm_rhsmRepoCaCert.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "repo_ca_cert", sm_rhsmRepoCaCert);
else
sm_rhsmRepoCaCert = smt.getConfFileParameter(smt.rhsmConfFile, "repo_ca_cert");
// if (!rhsmShowIncompatiblePools.equals("")) smt.updateConfFileParameter(smt.rhsmConfFile, "showIncompatiblePools", rhsmShowIncompatiblePools); else rhsmShowIncompatiblePools = smt.getConfFileParameter(smt.rhsmConfFile, "showIncompatiblePools");
if (!sm_rhsmProductCertDir.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "productCertDir", sm_rhsmProductCertDir);
else
sm_rhsmProductCertDir = smt.getConfFileParameter(smt.rhsmConfFile, "productCertDir");
if (!sm_rhsmEntitlementCertDir.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "entitlementCertDir", sm_rhsmEntitlementCertDir);
else
sm_rhsmEntitlementCertDir = smt.getConfFileParameter(smt.rhsmConfFile, "entitlementCertDir");
if (!sm_rhsmConsumerCertDir.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, "consumerCertDir", sm_rhsmConsumerCertDir);
else
sm_rhsmConsumerCertDir = smt.getConfFileParameter(smt.rhsmConfFile, "consumerCertDir");
// rhsm.conf [rhsmcertd] configurations
if (!sm_rhsmcertdCertFrequency.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, /*"certFrequency" CHANGED BY BUG 882459 TO*/
"certCheckInterval", sm_rhsmcertdCertFrequency);
else
sm_rhsmcertdCertFrequency = smt.getConfFileParameter(smt.rhsmConfFile, /*"certFrequency" CHANGED BY BUG 882459 TO*/
"certCheckInterval");
if (!sm_rhsmcertdHealFrequency.equals(""))
smt.updateConfFileParameter(smt.rhsmConfFile, /*"healFrequency" CHANGED BY BUG 882459 TO*/
"autoAttachInterval", sm_rhsmcertdHealFrequency);
else
sm_rhsmcertdHealFrequency = smt.getConfFileParameter(smt.rhsmConfFile, /*"healFrequency" CHANGED BY BUG 882459 TO*/
"autoAttachInterval");
smt.initializeFieldsFromConfigFile();
smt.removeAllCerts(true, true, false);
smt.removeAllFacts();
smt.initializeSystemComplianceAttributes();
smt.removeRhnSystemIdFile();
smt.installRepoCaCerts(sm_repoCaCertUrls);
smt.restartCockpitServices();
smt.setupRhnDefinitions(sm_rhnDefinitionsGitRepository);
smt.setupTranslateToolkitFromTarUrl(sm_translateToolkitTarUrl);
// create a facts file that will tell candlepin what version of x509 entitlement certificates this client understands; removeAllFacts() should be called before this block of code!
if (sm_clientCertificateVersion != null) {
Map<String, String> map = new HashMap<String, String>();
map.put("system.certificate_version", sm_clientCertificateVersion);
smt.createFactsFileWithOverridingValues(smt.certVersionFactsFilename, map);
}
// transfer a copy of the candlepin CA Cert from the candlepin server to the clients so we can test in secure mode
log.info("Copying Candlepin cert onto client to enable certificate validation...");
smt.installRepoCaCert(serverCaCertFile, sm_serverHostname.split("\\.")[0] + ".pem");
// transfer copies of all the generated product certs from the candlepin server to the clients
log.info("Copying Candlepin generated product certs onto client to simulate installed products...");
smt.installProductCerts(generatedProductCertFiles);
// initialize variables used to access CandlepinTasks from SubcriptionManagerTasks
smt.candlepinAdminUsername = sm_serverAdminUsername;
smt.candlepinAdminPassword = sm_serverAdminPassword;
smt.candlepinUrl = sm_serverUrl.isEmpty() ? getServerUrl(smt.getConfFileParameter(smt.rhsmConfFile, "hostname"), smt.getConfFileParameter(smt.rhsmConfFile, "port"), smt.getConfFileParameter(smt.rhsmConfFile, "prefix")) : sm_serverUrl;
// rewrite it back to sm_serverUrl to make it easier for tests to access
sm_serverUrl = smt.candlepinUrl;
// this is needed to enable more testing and log more useful info from SubscriptionManagerTasks.logRuntimeErrors(...)
if (smt.isPackageVersion("subscription-manager", ">=", "1.17.10-1")) {
// RHEL7.3 commit d84b15f42c2e4521e130b939039960c0846b849c 1334916: Move logging configuration to rhsm.conf
smt.updateConfFileParameter(clienttasks.rhsmConfFile, "logging", "default_log_level", "DEBUG");
// smt.config(null, null, true, new String[]{"logging","default_log_level","DEBUG"});
} else if (smt.isPackageVersion("subscription-manager", ">=", "1.14.2-1")) {
// commit 66aafd77dc629b921379f0e121421c1c21c0b787 Move to fileConfig based logging.
smt.updateConfFileParameter(clienttasks.rhsmLoggingConfFile, "handler_rhsm_log", "level", "DEBUG");
}
// TEMPORARY WORKAROUND
if (CandlepinType.hosted.equals(sm_serverType)) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1358508 - Error updating system data on the server
String bugId = "1358508";
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) {
// smt.updateConfFileParameter(smt.rhsmConfFile, "rhsm", "report_package_profile", "0");
smt.config(null, null, true, new String[] { "rhsm", "report_package_profile", "0" });
}
}
// Reference: https://mojo.redhat.com/docs/DOC-1157988
if (smt.getCurrentProductCerts().isEmpty()) {
if (polarionPlannedIn.toLowerCase().contains("Snap".toLowerCase())) {
List<File> productCertFiles = new ArrayList<File>();
if (smt.compose.startsWith("RHEL-ALT")) {
// Red Hat Enterprise Linux for ARM 64 Beta
if (smt.arch.equals("aarch64"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-alt-" + smt.redhatReleaseXY + "-beta/363_.pem"));
// Red Hat Enterprise Linux for Power 9 Beta
if (smt.arch.equals("ppc64le"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-alt-" + smt.redhatReleaseXY + "-beta/362_.pem"));
// Red Hat Enterprise Linux for IBM System z (Structure A) Beta
if (smt.arch.equals("s390x"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-alt-" + smt.redhatReleaseXY + "-beta/433_.pem"));
} else if (smt.compose.startsWith("RHEL-")) {
// Red Hat Enterprise Linux for Power, little endian
if (smt.arch.equals("ppc64le"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-" + smt.redhatReleaseXY + "-beta/279_.pem"));
// Red Hat Enterprise Linux for Power, big endian
if (smt.arch.equals("ppc64"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-" + smt.redhatReleaseXY + "-beta/74_.pem"));
// Red Hat Enterprise Linux for IBM z Systems
if (smt.arch.equals("s390x"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-" + smt.redhatReleaseXY + "-beta/72_.pem"));
// Red Hat Enterprise Linux Desktop
if (smt.arch.equals("x86_64") && smt.variant.equals("Client"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-" + smt.redhatReleaseXY + "-beta/68_.pem"));
// Red Hat Enterprise Linux for Scientific Computing
if (smt.arch.equals("x86_64") && smt.variant.equals("ComputeNode"))
productCertFiles.add(new File(getProperty("automation.dir", "/tmp") + "/certs/rhel-" + smt.redhatReleaseXY + "-beta/76_.pem"));
}
log.info("Manually placing a RHEL product cert onto the system to enable more testing...");
smt.installProductCerts(productCertFiles);
}
}
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class HelpTests method testCommandLineHelp.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21757", "RHEL7-51263" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager, subscription-manager-gui, rhn-migrate-classic-to-rhsm, and other CLI tools: assert only expected command line options are available", groups = { "Tier2Tests" }, dataProvider = "ExpectedCommandLineOptionsData")
@ImplementsNitrateTest(caseId = 46713)
public // @ImplementsNitrateTest(caseId=46707)
void testCommandLineHelp(Object bugzilla, String helpCommand, Integer exitCode, String stdoutRegex, List<String> expectedOptions) {
log.info("Testing subscription-manager-cli command line options '" + helpCommand + "' and verifying the exit code and that ONLY the expected options are available.");
SSHCommandResult result = RemoteFileTasks.runCommandAndAssert(client, helpCommand, exitCode);
Pattern pattern = Pattern.compile(stdoutRegex, Pattern.MULTILINE);
Matcher matcher = pattern.matcher(result.getStdout());
Assert.assertTrue(matcher.find(), "Available command line options matching regex '" + stdoutRegex + "' are shown with command: " + helpCommand);
// find all the matches to stderrRegex
List<String> actualOptions = new ArrayList<String>();
do {
// TEMPORARY WORKAROUND FOR BUG
if (!helpCommand.contains(" register") && !helpCommand.contains(" config") && (matcher.group().contains("--serverurl") || matcher.group().contains("--baseurl"))) {
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "842768";
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) {
log.warning("Ignoring the presence of option '" + matcher.group() + "' for command '" + helpCommand + "' while bug '" + bugId + "' is open.");
continue;
}
}
// END OF WORKAROUND
actualOptions.add(matcher.group().trim());
} while (matcher.find());
// assert all of the expectedOptions were found and that no unexpectedOptions were found
for (String expectedOption : expectedOptions) {
if (!actualOptions.contains(expectedOption)) {
log.warning("Could not find the expected command '" + helpCommand + "' option '" + expectedOption + "'.");
} else {
Assert.assertTrue(actualOptions.contains(expectedOption), "The expected command '" + helpCommand + "' option '" + expectedOption + "' is available.");
}
}
for (String actualOption : actualOptions) {
if (!expectedOptions.contains(actualOption))
log.warning("Found an unexpected command '" + helpCommand + "' option '" + actualOption + "'.");
}
Assert.assertTrue(actualOptions.containsAll(expectedOptions), "All of the expected command '" + helpCommand + "' line options are available.");
Assert.assertTrue(expectedOptions.containsAll(actualOptions), "All of the available command '" + helpCommand + "' line options are expected.");
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class HelpTests method getExpectedCommandLineOptionsDataAsListOfLists.
protected static List<List<Object>> getExpectedCommandLineOptionsDataAsListOfLists() {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (clienttasks == null)
return ll;
// String command, String stdoutRegex, List<String> expectedOptions
String command;
List<String> modules = new ArrayList<String>();
List<String> options = new ArrayList<String>();
String module;
String modulesRegex = "^ [\\w-]+";
// valid after bug 848095
modulesRegex = "^ [\\w-]+";
String optionsRegex = "^ --[\\w\\.]+(=[\\w\\.]+)*|^ -\\w(=\\w+)*, --\\w+(=\\w+)*";
optionsRegex = "^ --[\\w\\.-]+(=[\\w\\.-]+)*|^ -[\\?\\w]( \\w+)*, --[\\w\\.-]+(=\\w+)*";
optionsRegex = "^ --[\\w\\.-]+(=[\\w\\.:-]+)*|^ -[\\?\\w]( \\w+)*, --[\\w\\.:-]+(=\\w+)*";
optionsRegex = "^ --[\\w\\.-]+(=[\\w\\.:,\\-]+)*|^ -[\\?\\w]( \\w+)*, --[\\w\\.:,\\-]+(=\\w+)*";
// EXAMPLES FOR optionsRegex
// -h, --help show this help message and exit
// --list list the configuration for this system
// --remove=REMOVE remove configuration entry by section.name
// --server.hostname=SERVER.HOSTNAME
// -?, --help Show help options
// --help-all Show all help options
// -f, --force-icon=TYPE Force display of the icon (expired, partial or warning)
// -c, --check-period How often to check for validity (in seconds)
// -i INSTNUMBER, --instnumber=INSTNUMBER
// --add=NAME:VALUE name and value of the option to override separated by
// a colon (can be specified more than once)
// ========================================================================================
// subscription-manager MODULES
modules.clear();
modules.add("config");
modules.add("import");
modules.add("redeem");
modules.add("orgs");
modules.add("repos");
modules.add("clean");
modules.add("environments");
modules.add("facts");
modules.add("identity");
modules.add("list");
modules.add("refresh");
modules.add("register");
modules.add("subscribe");
modules.add("unregister");
modules.add("unsubscribe");
modules.add("service-level");
modules.add("release");
modules.add("version");
// added by bug 874804
modules.add("attach");
// added by bug 874749
modules.add("remove");
// added by https://engineering.redhat.com/trac/Entitlement/wiki/SubscriptionManagerPlugins
modules.add("plugins");
// added as part of bug 803746
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.7-1"))
modules.add("repo-override");
modules.add("status");
// modules.add("autoheal"); changed by Bug 976867 - subscription-manager autoheal needs feedback and a review of options
modules.add("auto-attach");
for (String smHelpCommand : new String[] { clienttasks.command + " -h", clienttasks.command + " --help" }) {
// coverage for bug 906124; the usage statement permits only "--help" and therefore any differing option (including "-h") should return non-zero exit code
Integer exitCode = smHelpCommand.contains("--help") ? 0 : 1;
List<String> usages = new ArrayList<String>();
// prior to Bug 796730 - subscription-manager usage statement
String usage = String.format("Usage: %s [options] MODULENAME --help", clienttasks.command);
usage = String.format("Usage: %s MODULE-NAME [MODULE-OPTIONS] [--help]", clienttasks.command);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "796730", "906124" }), smHelpCommand, exitCode, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "906124" }), smHelpCommand, exitCode, modulesRegex, new ArrayList<String>(modules) }));
}
// subscription-manager config OPTIONS
module = "config";
options.clear();
options.add("-h, --help");
options.add("--list");
options.add("--remove=REMOVE");
// add the expected default configurations
for (String section : new String[] { "server", "rhsm", "rhsmcertd", "logging" /* added by bug 1334916 */
}) {
// for (String confFileParameterName : clienttasks.defaultConfFileParameterNames(null)) { // valid before bug 988476
for (String confFileParameterName : clienttasks.defaultConfFileParameterNames(section, null)) {
options.add(String.format("--%s.%s=%s.%s", section.toLowerCase(), confFileParameterName.toLowerCase(), section.toUpperCase(), confFileParameterName.toUpperCase()));
}
}
// add the unexpected configurations that were added manually or remain as deprecated configurations from a subscription-manager upgrade
String confFileContents = RemoteFileTasks.runCommandAndAssert(client, "egrep -v \"^\\s*(#|$)\" " + clienttasks.rhsmConfFile, 0).getStdout();
String section = null;
for (String line : confFileContents.split("\n")) {
line = line.trim();
if (line.isEmpty())
continue;
if (line.matches("\\[\\w+\\]")) {
section = line.replaceFirst("\\[", "").replaceFirst("\\]", "");
continue;
}
String parameterName = line.split("=|:", 2)[0].trim();
// if (clienttasks.defaultConfFileParameterNames(true).contains(parameterName.toLowerCase())) continue; // valid before bug 988476
if (clienttasks.defaultConfFileParameterNames(section, true).contains(parameterName.toLowerCase()))
continue;
options.add(String.format("--%s.%s=%s.%s", section.toLowerCase(), parameterName.toLowerCase(), section.toUpperCase(), parameterName.toUpperCase()));
}
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("919512"), smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager import OPTIONS
module = "import";
options.clear();
options.add("-h, --help");
// options("--certificate=CERTIFICATE_FILES"); // prior to fix for Bug 735212
options.add("--certificate=CERTIFICATE_FILE");
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=733873
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "733873";
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) {
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
}
// END OF WORKAROUND
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager redeem OPTIONS
module = "redeem";
options.clear();
options.add("-h, --help");
options.add("--email=EMAIL");
options.add("--locale=LOCALE");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager orgs OPTIONS
module = "orgs";
options.clear();
options.add("-h, --help");
options.add("--serverurl=SERVER_URL");
options.add("--username=USERNAME");
options.add("--password=PASSWORD");
// added by bug 844411
options.add("--insecure");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager repos OPTIONS
module = "repos";
options.clear();
options.add("-h, --help");
options.add("--list");
options.add("--enable=REPOID");
options.add("--disable=REPOID");
// added by bug 906642
options.add("--proxy=PROXY_URL");
// added by bug 906642
options.add("--proxyuser=PROXY_USER");
// added by bug 906642
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.4-1")) {
// added by bug 1119648
options.add("--list-enabled");
// added by bug 1119648
options.add("--list-disabled");
}
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager clean OPTIONS
module = "clean";
options.clear();
options.add("-h, --help");
// options("--proxypassword=PROXY_PASSWORD");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("664581"), smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager environments OPTIONS
module = "environments";
options.clear();
options.add("-h, --help");
options.add("--serverurl=SERVER_URL");
options.add("--username=USERNAME");
options.add("--password=PASSWORD");
// changed by bug 878097 options.add("--org=ORG");
options.add("--org=ORG_KEY");
// added by bug 844411
options.add("--insecure");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager facts OPTIONS
module = "facts";
options.clear();
options.add("-h, --help");
options.add("--list");
options.add("--update");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager identity OPTIONS
module = "identity";
options.clear();
options.add("-h, --help");
options.add("--username=USERNAME");
options.add("--password=PASSWORD");
options.add("--regenerate");
options.add("--force");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager list OPTIONS
module = "list";
options.clear();
options.add("-h, --help");
// result of https://bugzilla.redhat.com/show_bug.cgi?id=634254
options.add("--installed");
options.add("--consumed");
options.add("--available");
options.add("--all");
// result of https://bugzilla.redhat.com/show_bug.cgi?id=800999
options.add("--servicelevel=SERVICE_LEVEL");
// result of https://bugzilla.redhat.com/show_bug.cgi?id=672562
options.add("--ondate=ON_DATE");
// added by Bug 654501 - [RFE] subscription-manager list should accept filtering
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.3-1"))
options.add("--no-overlap");
// added by Bug 654501 - [RFE] subscription-manager list should accept filtering
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.3-1"))
options.add("--match-installed");
// added by Bug 1146125 - [RFE] would like a --contains-text option for subscription-manager list module
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.6-1"))
options.add("--matches=FILTER_STRING");
// added by Bug 1159974 - RFE: Add a --pool-only option to the list subcommand // commit 25cb581cb6ebe13063d0f78a5020715a2854d337
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
options.add("--pool-only");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager status OPTIONS
module = "status";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
// subscription-manager commit 957f3f5fb4689f22355e0101185bd560e67f3462
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.9.2-1"))
options.add("--ondate=ON_DATE");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("977481"), smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager refresh OPTIONS
module = "refresh";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager register OPTIONS
module = "register";
options.clear();
options.add("-h, --help");
options.add("--baseurl=BASE_URL");
options.add("--serverurl=SERVER_URL");
options.add("--username=USERNAME");
// changed by bug 874816 options.add("--type=CONSUMERTYPE");
options.add("--type=UNITTYPE");
// changed by bug 874816 options.add("--name=CONSUMERNAME");
options.add("--name=SYSTEMNAME");
options.add("--password=PASSWORD");
// changed by bug 874816 options.add("--consumerid=CONSUMERID");
options.add("--consumerid=SYSTEMID");
// changed by bug 878097 options.add("--org=ORG");
options.add("--org=ORG_KEY");
options.add("--environment=ENVIRONMENT");
options.add("--autosubscribe");
// added by bug 876340
options.add("--auto-attach");
// added by bug 844411
options.add("--insecure");
options.add("--force");
// Bug 874755 - help message terminology for cli options that can be specified in multiplicity
options.add("--activationkey=ACTIVATION_KEYS");
options.add("--servicelevel=SERVICE_LEVEL");
options.add("--release=RELEASE");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
// removed by bug 1461003 commit e0c34a729e9e347ab1e0f4f5fa656c8b20205fdf
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1"))
options.remove("--type=UNITTYPE");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("628589"), smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager unregister OPTIONS
module = "unregister";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager subscribe OPTIONS
module = "subscribe";
options.clear();
options.add("-h, --help");
options.add("--pool=POOL");
options.add("--quantity=QUANTITY");
// result of https://bugzilla.redhat.com/show_bug.cgi?id=680399
options.add("--auto");
options.add("--servicelevel=SERVICE_LEVEL");
// added by Bug 1159974 // commit 3167333fc3a261de939f4aa0799b4283f2b9f4d2
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
options.add("--file=FILE");
// options("--regtoken=REGTOKEN"); // https://bugzilla.redhat.com/show_bug.cgi?id=670823
// options("--email=EMAIL"); // https://bugzilla.redhat.com/show_bug.cgi?id=670823
// options("--locale=LOCALE"); // https://bugzilla.redhat.com/show_bug.cgi?id=670823
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
// added by bug 874808
String deprecation = "Deprecated, see attach";
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, "^" + deprecation + "$", Arrays.asList(new String[] { deprecation }) }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager attach OPTIONS // added by bug 874804
module = "attach";
options.clear();
options.add("-h, --help");
options.add("--pool=POOL");
options.add("--quantity=QUANTITY");
options.add("--auto");
options.add("--servicelevel=SERVICE_LEVEL");
// added by Bug 1159974 // commit 3167333fc3a261de939f4aa0799b4283f2b9f4d2
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
options.add("--file=FILE");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
usages.add(usage);
String deprecation = "Attach a specified subscription to the registered system";
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, "^" + deprecation + "$", Arrays.asList(new String[] { deprecation }) }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager unsubscribe OPTIONS
module = "unsubscribe";
options.clear();
options.add("-h, --help");
// Bug 874755 - help message terminology for cli options that can be specified in multiplicity
options.add("--serial=SERIAL");
options.add("--all");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
// added by Bug 1198178 - [RFE] Subscription-manager unsubscribe command should support --pool option // commit 3d2eb4b8ef8e2094311e3872cdb9602b84fed9be
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.5-1"))
options.add("--pool=POOL_ID");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
// added by bug 874749
String deprecation = "Deprecated, see remove";
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, "^" + deprecation + "$", Arrays.asList(new String[] { deprecation }) }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager remove OPTIONS // added by bug 874749
module = "remove";
options.clear();
options.add("-h, --help");
options.add("--serial=SERIAL");
options.add("--all");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
// added by Bug 1198178 - [RFE] Subscription-manager unsubscribe command should support --pool option // commit 3d2eb4b8ef8e2094311e3872cdb9602b84fed9be
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.5-1"))
options.add("--pool=POOL_ID");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
usages.add(usage);
String deprecation = "Remove all or specific subscriptions from this system";
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, "^" + deprecation + "$", Arrays.asList(new String[] { deprecation }) }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager service-level OPTIONS
module = "service-level";
options.clear();
options.add("-h, --help");
options.add("--serverurl=SERVER_URL");
options.add("--username=USERNAME");
options.add("--password=PASSWORD");
// changed by bug 878097 options.add("--org=ORG");
options.add("--org=ORG_KEY");
options.add("--show");
options.add("--list");
options.add("--set=SERVICE_LEVEL");
options.add("--unset");
// added by bug 844411
options.add("--insecure");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager release OPTIONS
module = "release";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
options.add("--set=RELEASE");
options.add("--list");
options.add("--unset");
// Bug 812153 - release command should have a --show option which is the default
options.add("--show");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager plugins OPTIONS
module = "plugins";
options.clear();
options.add("-h, --help");
options.add("--list");
options.add("--listslots");
options.add("--listhooks");
options.add("--verbose");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager repo-override OPTIONS
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.7-1")) {
// introduced by RFE Bug 803746
module = "repo-override";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
options.add("--repo=REPOID");
options.add("--remove=NAME");
options.add("--add=NAME:VALUE");
options.add("--remove-all");
options.add("--list");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("977481"), smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
}
// subscription-manager version OPTIONS
module = "version";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("977481"), smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager auto-attach OPTIONS
// module = "autoheal"; // changed by Bug 976867 - subscription-manager autoheal needs feedback and a review of options
module = "auto-attach";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
options.add("--show");
options.add("--enable");
options.add("--disable");
for (String smHelpCommand : new String[] { clienttasks.command + " -h " + module, clienttasks.command + " --help " + module }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", clienttasks.command, module);
// if (clienttasks.redhatRelease.contains("release 5")) usage = usage.replaceFirst("^Usage", "usage"); // TOLERATE WORKAROUND FOR Bug 693527 ON RHEL5
usages.add(usage);
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("976867"), smHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("976867"), smHelpCommand, 0, optionsRegex, new ArrayList<String>(options) }));
}
// subscription-manager-gui OPTIONS
if (!client.runCommandAndWait("rpm -q " + clienttasks.command + "-gui").getStdout().contains("is not installed")) {
// test only when the rpm is installed
// [root@jsefler-6 ~]# subscription-manager-gui --help
// Usage: subscription-manager-gui [OPTIONS]
//
// Options:
// -h, --help show this help message and exit
// --register launches the registration dialog on startup.
command = clienttasks.command + "-gui";
options.clear();
options.add("-h, --help");
options.add("--register");
for (String commandHelp : new String[] { command + " -h", command + " --help" }) {
// solution: try several until one works and then use it
for (String exportDisplay : Arrays.asList(new String[] { "export DISPLAY=localhost:2", "export DISPLAY=localhost:10.0", "export DISPLAY=localhost:11.0", "export DISPLAY=:0" })) {
String commandHelpWithExportDisplay = exportDisplay + " && " + commandHelp;
if (client.runCommandAndWait(commandHelpWithExportDisplay).getStdout().trim().startsWith("Usage")) {
commandHelp = commandHelpWithExportDisplay;
break;
}
}
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s [OPTIONS]", command);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "881095", "905649" }), commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\|", "\\\\|").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "881095", "905649" }), commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
}
// rhsm-icon OPTIONS
if (!client.runCommandAndWait("rpm -q " + clienttasks.command + "-gui").getStdout().contains("is not installed")) {
// test only when the rpm is installed
// [root@jsefler-onprem-5server ~]# rhsm-icon -?
// Usage:
// rhsm-icon [OPTION...] rhsm icon
//
// Help Options:
// -?, --help Show help options
// --help-all Show all help options
// --help-gtk Show GTK+ Options
//
// Application Options:
// -c, --check-period How often to check for validity (in seconds)
// -d, --debug Show debug messages
// -f, --force-icon=TYPE Force display of the icon (expired, partial or warning)
// -i, --check-immediately Run the first status check right away
// --display=DISPLAY X display to use
command = "rhsm-icon";
List<String> rhsmIconOptions = new ArrayList<String>();
if (// rhel5
clienttasks.redhatReleaseX.equals("5"))
// rhel5
rhsmIconOptions.add("-?, --help");
else
// rhel6
rhsmIconOptions.add("-h, --help");
rhsmIconOptions.add("--help-all");
rhsmIconOptions.add("--help-gtk");
rhsmIconOptions.add("-c, --check-period");
rhsmIconOptions.add("-d, --debug");
rhsmIconOptions.add("-f, --force-icon=TYPE");
rhsmIconOptions.add("-i, --check-immediately");
rhsmIconOptions.add("--display=DISPLAY");
for (String helpOption : rhsmIconOptions.get(0).split(" *, *")) {
// "-?, --help"
String rhsmIconHelpCommand = command + " " + helpOption;
List<String> usages = new ArrayList<String>();
String usage = command + " [OPTIONS]";
// usage = rhsmIconCommand+" [OPTION...] rhsm icon"; // Bug 771756 - rhsm-icon --help usage message is misleading
usage = command + " [OPTION...]";
usages.add(usage);
if (// skip the following rhsmIconHelpCommand usage test since bug 771756 was not fixed until 5.9
!Arrays.asList("6.1", "5.7", "6.2", "5.8", "6.3").contains(clienttasks.redhatReleaseXY))
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("771756"), rhsmIconHelpCommand, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, rhsmIconHelpCommand, 0, optionsRegex, rhsmIconOptions }));
}
List<String> rhsmIconGtkOptions = new ArrayList<String>();
rhsmIconGtkOptions.add("--screen=SCREEN");
// GTK options are presented here: http://developer.gnome.org/gtk-tutorial/2.90/c39.html
rhsmIconGtkOptions.add("--class=CLASS");
rhsmIconGtkOptions.add("--name=NAME");
rhsmIconGtkOptions.add("--display=DISPLAY");
rhsmIconGtkOptions.add("--sync");
rhsmIconGtkOptions.add("--gtk-module=MODULES");
rhsmIconGtkOptions.add("--g-fatal-warnings");
if (!clienttasks.redhatReleaseX.equals("5"))
rhsmIconGtkOptions.add("--gdk-debug=FLAGS");
if (!clienttasks.redhatReleaseX.equals("5"))
rhsmIconGtkOptions.add("--gdk-no-debug=FLAGS");
if (!clienttasks.redhatReleaseX.equals("5"))
rhsmIconGtkOptions.add("--gtk-debug=FLAGS");
if (!clienttasks.redhatReleaseX.equals("5"))
rhsmIconGtkOptions.add("--gtk-no-debug=FLAGS");
if (client.runCommandAndWait("rpm -qf `which rhsm-icon` --requires | egrep '^(gtk|pygtk)'").getStdout().trim().startsWith("gtk3")) {
// if (clienttasks.isPackageVersion("subscription-manager",">=","1.15.3")) { // commit 3c51d2096ecdd1a7ba6981776bd9aa6959aa2e1e use gtk3 for rhsm-icon
// effectively this happens on RHEL >= 7.2
// options not offered by gtk3
rhsmIconGtkOptions.remove("--screen=SCREEN");
rhsmIconGtkOptions.remove("--sync");
}
ll.add(Arrays.asList(new Object[] { null, command + " --help-gtk", 0, optionsRegex, rhsmIconGtkOptions }));
List<String> rhsmIconAllOptions = new ArrayList<String>();
rhsmIconAllOptions.addAll(rhsmIconOptions);
rhsmIconAllOptions.addAll(rhsmIconGtkOptions);
ll.add(Arrays.asList(new Object[] { null, command + " --help-all", 0, optionsRegex, rhsmIconAllOptions }));
}
// rhn-migrate-classic-to-rhsm OPTIONS
if (!client.runCommandAndWait("rpm -q " + clienttasks.command + "-migration").getStdout().contains("is not installed")) {
// test only when the rpm is installed
// [root@jsefler-onprem-5server ~]# rhn-migrate-classic-to-rhsm -h
// usage: /usr/sbin/rhn-migrate-classic-to-rhsm [--force|--cli-only|--help|--no-auto]
//
// options:
// -f, --force Ignore Channels not available on RHSM
// -c, --cli-only Don't launch the GUI tool to subscribe the system, just use
// the CLI tool which will do it automatically
// -n, --no-auto Don't launch subscription manager at end of process.
// -h, --help show this help message and exit
command = MigrationTests.rhnMigrateTool;
options.clear();
options.add("-f, --force");
options.add("-g, --gui");
options.add("-n, --no-auto");
options.add("-s SERVICELEVEL, --servicelevel=SERVICELEVEL");
options.add("--serverurl=SERVERURL");
// added by Bug 915847 - rhn-migrate-classic-to-rhsm fails when used with a proxy with an internal SAM
options.add("--no-proxy");
// added by Bug 877331 - missing --org --environment arguments for migration script
options.add("--org=ORG");
// added by Bug 877331 - missing --org --environment arguments for migration script
options.add("--environment=ENVIRONMENT");
if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.10.3-1")) {
// added by Bug 912375 - RFE - "rhn-migrate-classic-to-rhsm" migration script to accept the expected parameter either via standard input or the equivalent of an "answer" file"
options.add("--redhat-user=REDHATUSER");
options.add("--redhat-password=REDHATPASSWORD");
options.add("--subscription-service-user=SUBSERVICEUSER");
options.add("--subscription-service-password=SUBSERVICEPASSWORD");
}
if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.1")) {
options.remove("--redhat-user=REDHATUSER");
options.remove("--redhat-password=REDHATPASSWORD");
options.remove("--subscription-service-user=SUBSERVICEUSER");
options.remove("--subscription-service-password=SUBSERVICEPASSWORD");
options.remove("--serverurl=SERVERURL");
options.remove("-s SERVICELEVEL, --servicelevel=SERVICELEVEL");
options.remove("-g, --gui");
options.add("--legacy-user=LEGACY_USER");
options.add("--legacy-password=LEGACY_PASSWORD");
options.add("--destination-user=DESTINATION_USER");
options.add("--destination-password=DESTINATION_PASSWORD");
options.add("--destination-url=DESTINATION_URL");
options.add("-s SERVICE_LEVEL, --service-level=SERVICE_LEVEL");
}
if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.8")) {
// commit e53f0369b621902b75f2dbe047d97dc9ba3cc1c0 revert for bug 1157761
options.remove("-s SERVICE_LEVEL, --service-level=SERVICE_LEVEL");
options.add("-s SERVICE_LEVEL, --servicelevel=SERVICE_LEVEL");
}
if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.14.1-1")) {
// commit 00461f3751f9db182227c9973c41b305e378638a RFE Bug 1154375: Allow use of activation keys during migration.
options.add("--activation-key=ACTIVATION_KEYS");
}
if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.14.3-1")) {
// commit 5df7aaaa69a22b9e3f771971f1aa4e58657c8377 RFE Bug 1180273 - [RFE] rhn-migrate-classic-to-rhsm should allow the user to migrate a system without requiring credentials on RHN Classic
options.add("--registration-state=keep,purge");
}
if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.14.6-1")) {
// commit 6eded942a7d184ef7ed92bbd94225120ee2f2f20 RFE Bug 1180273 - [RFE] rhn-migrate-classic-to-rhsm should allow the user to migrate a system without requiring credentials on RHN Classic
options.remove("--registration-state=keep,purge");
options.add("--keep");
}
if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.18.2-1")) {
// commit 871264dbb0cc091d3eaefabfdfd2e51d6bbc0a3c RFE Bug 1185914 - [RFE] rhn-migrate-classic-to-rhsm should give the option to remove RHN Classic related packages / daemon
options.add("--remove-rhn-packages");
}
options.add("-h, --help");
for (String commandHelp : new String[] { command + " -h", command + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("usage: %s [OPTIONS]", command);
usage = String.format("Usage: %s [OPTIONS]", command);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("1052297"), commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\|", "\\\\|").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("1052297"), commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
}
// install-num-migrate-to-rhsm OPTIONS
if (!client.runCommandAndWait("rpm -q " + clienttasks.command + "-migration").getStdout().contains("is not installed")) {
// test only when the rpm is installed
if (clienttasks.redhatReleaseX.equals("5")) {
// test only on RHEL5
if (clienttasks.isPackageVersion("subscription-manager-migration", "<=", "1.11.3-4")) {
// install-num-migrate-to-rhsm was removed by bug 1092754
// [root@jsefler-onprem-5server ~]# install-num-migrate-to-rhsm --help
// usage: install-num-migrate-to-rhsm [options]
//
// options:
// -h, --help show this help message and exit
// -i INSTNUMBER, --instnumber=INSTNUMBER
// Install number to run against
// -d, --dryrun Only print the files which would be copied over
command = MigrationTests.installNumTool;
options.clear();
options.add("-h, --help");
options.add("-i INSTNUMBER, --instnumber=INSTNUMBER");
options.add("-d, --dryrun");
for (String commandHelp : new String[] { command + " -h", command + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("usage: %s [options]", command);
// changed by bug 876692
usage = String.format("Usage: %s [OPTIONS]", command);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\|", "\\\\|").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
}
}
}
// ========================================================================================
// rhsmcertd OPTIONS
// [root@nec-em15 ~]# rhsmcertd -?
// Usage:
// rhsmcertd [OPTION...]
//
// Help Options:
// -?, --help Show help options
// --help-all Show all help options
// --help-rhsmcertd rhsmcertd
//
// Application Options:
// -c, --cert-interval=MINUTES Interval to run cert check (in minutes)
// -i, --heal-interval=MINUTES Interval to run healing (in minutes)
// -n, --now Run the initial checks immediatly, with no delay.
// -d, --debug Show debug messages
command = clienttasks.rhsmCertD;
options.clear();
if (// rhel5 // this logic is also needed in TranslationTests.getTranslatedCommandLineHelpDataAsListOfLists()
clienttasks.redhatReleaseX.equals("5"))
// rhel5 // this logic is also needed in TranslationTests.getTranslatedCommandLineHelpDataAsListOfLists()
options.add("-?, --help");
else
// rhel6
options.add("-h, --help");
// options.add("--help-all"); // removed by Bug 842020 - what is rhsmcertd --help-rhsmcertd?
// options.add("--help-rhsmcertd"); // removed by Bug 842020 - what is rhsmcertd --help-rhsmcertd?
// updated by bug 882459 options.add("-c, --cert-interval=MINUTES");
options.add("-c, --cert-check-interval=MINUTES");
// added by bug 882459 as a deprecated, see --cert-check-interval
options.add("--cert-interval=MINUTES");
// updated by bug 876753 options.add("-i, --heal-interval=MINUTES");
options.add("-i, --auto-attach-interval=MINUTES");
// added by bug 876753 as a deprecated, see --auto-attach-interval
options.add("--heal-interval=MINUTES");
options.add("-n, --now");
options.add("-d, --debug");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.19.8-1")) {
// commit e9f8421285fc6541166065a8b55ee89b9a425246 RFE Bug 1435013: Add splay option to rhsmcertd, randomize over interval
// do not add an offset to the initial checks.
options.add("-s, --no-splay");
}
for (String helpOption : options.get(0).split(" *, *")) {
// "-?, --help"
String commandHelp = command + " " + helpOption;
List<String> usages = new ArrayList<String>();
String usage = command + " [OPTIONS]";
usage = command + " [OPTION...]";
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "876753", "882459" }), commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
// ========================================================================================
// /usr/libexec/rhsmd OPTIONS
// [root@jsefler-6 ~]# /usr/libexec/rhsmd --help
// Usage: rhsmd [options]
//
// Options:
// -h, --help show this help message and exit
// -d, --debug Display debug messages
// -k, --keep-alive Stay running (don't shut down after the first dbus
// call)
// -s, --syslog Run standalone and log result to syslog
// -f FORCE_SIGNAL, --force-signal=FORCE_SIGNAL
// Force firing of a signal (valid, expired, warning,
// partial, classic or registration_required)
// -i, --immediate Fire forced signal immediately (requires --force-
// signal)
command = clienttasks.rhsmComplianceD;
options.clear();
options.add("-h, --help");
options.add("-d, --debug");
options.add("-k, --keep-alive");
options.add("-s, --syslog");
options.add("-f FORCE_SIGNAL, --force-signal=FORCE_SIGNAL");
options.add("-i, --immediate");
for (String commandHelp : new String[] { command + " -h", command + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s [options]", command.replaceFirst("/.+/", ""));
// changed by bug 876692
usage = String.format("Usage: %s [OPTIONS]", command.replaceFirst("/.+/", ""));
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
// ========================================================================================
// /usr/libexec/rhsmcertd-worker OPTIONS
// [root@jsefler-6 ~]# /usr/libexec/rhsmcertd-worker --help
// Usage: rhsmcertd-worker [options]
//
// Options:
// -h, --help show this help message and exit
// --autoheal perform an autoheal check
command = clienttasks.rhsmCertDWorker;
options.clear();
options.add("-h, --help");
options.add("--autoheal");
for (String commandHelp : new String[] { command + " -h", command + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s [options]", command.replaceFirst("/.+/", ""));
// changed by bug 876692
usage = String.format("Usage: %s [OPTIONS]", command.replaceFirst("/.+/", ""));
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
// ========================================================================================
// rct MODULES
// [root@jsefler-rhel59 ~]# rct --help
//
// Usage: rct MODULE-NAME [MODULE-OPTIONS] [--help]
//
//
// Primary Modules:
//
// cat-cert Print certificate info to standard output.
//
// Other Modules (Please consult documentation):
command = "rct";
modules.clear();
modules.add("cat-cert");
modules.add("stat-cert");
modules.add("cat-manifest");
modules.add("dump-manifest");
for (String commandHelp : new String[] { command + " -h", command + " --help" }) {
// coverage for bug 906124; the usage statement permits only "--help" and therefore any differing option (including "-h") should return non-zero exit code
Integer exitCode = commandHelp.contains("--help") ? 0 : 1;
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s MODULE-NAME [MODULE-OPTIONS] [--help]", command);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("906124"), commandHelp, exitCode, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("906124"), commandHelp, exitCode, modulesRegex, new ArrayList<String>(modules) }));
}
// rct cat-cert OPTIONS
// [root@jsefler-rhel59 ~]# rct cat-cert --help
// Usage: rct cat-cert [OPTIONS] CERT_FILE
//
// Print certificate info to standard output.
//
// options:
// -h, --help show this help message and exit
// --no-products do not show the cert's product information
// --no-content do not show the cert's content info.
module = "cat-cert";
options.clear();
options.add("-h, --help");
options.add("--no-products");
options.add("--no-content");
for (String commandHelp : new String[] { command + " " + module + " -h", command + " " + module + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS] CERT_FILE", command, module);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
// rct stat-cert OPTIONS
// [root@jsefler-6 ~]# rct stat-cert --help
// Usage: rct stat-cert [OPTIONS] CERT_FILE
//
// Print certificate statistics and sizes
//
// Options:
// -h, --help show this help message and exit
module = "stat-cert";
options.clear();
options.add("-h, --help");
for (String commandHelp : new String[] { command + " " + module + " -h", command + " " + module + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS] CERT_FILE", command, module);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
// rct cat-manifest OPTIONS
// [root@jsefler-7 ~]# rct cat-manifest --help
// Usage: rct cat-manifest [OPTIONS] MANIFEST_FILE
//
// Print manifest information
//
// Options:
// -h, --help show this help message and exit
module = "cat-manifest";
options.clear();
options.add("-h, --help");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.10-1")) {
// RHEL7.3 commit 860b178e0eb5b91df01c424dad29c521e1c23767 Bug 1336883 - [RFE] Update the 'rct' command to allow not outputting content-set data
options.add("--no-content");
}
for (String commandHelp : new String[] { command + " " + module + " -h", command + " " + module + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS] MANIFEST_FILE", command, module);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
// rct dump-manifest OPTIONS
// [root@jsefler-7 ~]# rct dump-manifest --help
// Usage: rct dump-manifest [OPTIONS] MANIFEST_FILE
//
// Dump the contents of a manifest
//
// Options:
// -h, --help show this help message and exit
// --destination=DESTINATION
// directory to extract the manifest to
module = "dump-manifest";
options.clear();
options.add("-h, --help");
options.add("--destination=DESTINATION");
// added by Bug 961124 - attempt to rct dump-manifest twice throws traceback
options.add("-f, --force");
for (String commandHelp : new String[] { command + " " + module + " -h", command + " " + module + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS] MANIFEST_FILE", command, module);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { null, commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
// ========================================================================================
// rhsm-debug MODULES
// [root@jsefler-7 ~]# rhsm-debug --help
// Usage: rhsm-debug MODULE-NAME [MODULE-OPTIONS] [--help]
//
// Other Modules:
//
// system None // Bug 1039907 - Need Description for rhsm-debug system option
command = "rhsm-debug";
modules.clear();
modules.add("system");
for (String commandHelp : new String[] { command + " -h", command + " --help" }) {
// coverage for bug 906124; the usage statement permits only "--help" and therefore any differing option (including "-h") should return non-zero exit code
Integer exitCode = commandHelp.contains("--help") ? 0 : 1;
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s MODULE-NAME [MODULE-OPTIONS] [--help]", command);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("1039653"), commandHelp, exitCode, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("1039653"), commandHelp, exitCode, modulesRegex, new ArrayList<String>(modules) }));
}
// rhsm-debug system OPTIONS
// [root@jsefler-7 ~]# rhsm-debug system --help
// Usage: rhsm-debug system [OPTIONS]
//
// Assemble system information as a tar file or directory
//
// Options:
// -h, --help show this help message and exit
// --proxy=PROXY_URL proxy URL in the form of proxy_hostname:proxy_port
// --proxyuser=PROXY_USER
// user for HTTP proxy with basic authentication
// --proxypassword=PROXY_PASSWORD
// password for HTTP proxy with basic authentication
// --destination=DESTINATION
// the destination location of the result; default is
// /tmp
// --no-archive data will be in an uncompressed directory
module = "system";
options.clear();
options.add("-h, --help");
options.add("--proxy=PROXY_URL");
options.add("--proxyuser=PROXY_USER");
options.add("--proxypassword=PROXY_PASSWORD");
// added by bug 1420533 commit bd8b0538d7b0be7ee1e666ad5a66df80962c67d9
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.19.4-1"))
options.add("--noproxy=NO_PROXY");
// https://bugzilla.redhat.com/show_bug.cgi?id=1040338#c2
options.add("--destination=DESTINATION");
options.add("--no-archive");
// added by Bug 1060727 - rhsm-debug duplicates sos data and may collect secrets
options.add("--sos");
// added by Bug 1114117 - rhsm-debug takes forever // commit 68a1a418c27172c4fb851d536813f8060f4d3d1f
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.12.7-1"))
options.add("--no-subscriptions");
// added by 1114117: Stop collecting subs info by default. // commit 029f786999f5b1cd1d9614976fb4544ca6541b3b
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.14.1-1"))
options.add("--subscriptions");
// removed by https://bugzilla.redhat.com/show_bug.cgi?id=1246680#c2 // commit 6bd472d13d88934e3a3069862e26f9e7e27bec8c
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.15.9-12")) {
options.remove("--no-subscriptions");
options.remove("--subscriptions");
}
for (String commandHelp : new String[] { command + " " + module + " -h", command + " " + module + " --help" }) {
List<String> usages = new ArrayList<String>();
String usage = String.format("Usage: %s %s [OPTIONS]", command, module);
usages.add(usage);
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("1039653"), commandHelp, 0, usage.replaceAll("\\[", "\\\\[").replaceAll("\\]", "\\\\]").replaceAll("\\?", "\\\\?") + " *$", usages }));
ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("1039653"), commandHelp, 0, optionsRegex, new ArrayList<String>(options) }));
}
return ll;
}
Aggregations