[node-patches] Change in ovirt-node[ovirt-3.6]: Satellite 6: Fixed registration process for Red Hat Satellit...

Code Review gerrit at ovirt.org
Fri Jan 6 17:03:25 UTC 2017


>From Douglas Schilling Landgraf <dougsland at redhat.com>:

Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: Satellite 6: Fixed registration process for Red Hat Satellite 6.2
......................................................................

Satellite 6: Fixed registration process for Red Hat Satellite 6.2

This fix handles the katello-server-ca.crt distributed by
Red Hat Satellite 6.2 or higher at http://<FQDN>/pub directory.

It also added some requirements enforced by subscription-manager
to allow a system to be registered at Satellite 6
(environment and organization).

Change-Id: Id133817a3d511c78dc5ed6b6975b6066b0f7b438
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1339883
Signed-off-by: Marcelo Moreira de Mello <mmello at redhat.com>
(cherry picked from commit 0189cbb86b171440142711d78770f41c349db590)
---
M src/ovirt/node/setup/rhn/rhn_model.py
M src/ovirt/node/setup/rhn/rhn_page.py
2 files changed, 58 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/67/69767/1

diff --git a/src/ovirt/node/setup/rhn/rhn_model.py b/src/ovirt/node/setup/rhn/rhn_model.py
index 7b0a4f9..c12b8c0 100755
--- a/src/ovirt/node/setup/rhn/rhn_model.py
+++ b/src/ovirt/node/setup/rhn/rhn_model.py
@@ -29,6 +29,8 @@
 import requests
 import urlparse
 
+DEFAULT_CA_SAT6 = 'katello-server-ca'
+
 
 class RHN(NodeConfigFileSection):
     """Configure RHN
@@ -43,12 +45,13 @@
             "OVIRT_RHN_PROFILE",
             "OVIRT_RHN_ACTIVATIONKEY",
             "OVIRT_RHN_ORG",
+            "OVIRT_RHN_ENVIRONMENT",
             "OVIRT_RHN_PROXY",
             "OVIRT_RHN_PROXYUSER")
 
     @NodeConfigFileSection.map_and_update_defaults_decorator
     def update(self, rhntype, url, ca_cert, username, profile,
-               activationkey, org, proxy, proxyuser):
+               activationkey, org, environment, proxy, proxyuser):
         pass
 
     def retrieve(self):
@@ -335,7 +338,7 @@
                     host, port, prefix = RHN().parse_host_uri(cfg["url"])
 
                     # Default to /rhsm for Satellite 6
-                    if cfg["ca_cert"].endswith(".pem") and \
+                    if DEFAULT_CA_SAT6 in cfg["ca_cert"] and \
                        cfg["rhntype"] == "satellite":
                         prefix = "/rhsm"
 
@@ -353,7 +356,7 @@
 
                 # Figure out what other arguments need to be set
                 # If there's a ca certificate or it's satellite, it's sat6
-                if cfg["ca_cert"] and not cfg["ca_cert"].endswith(".pem") or \
+                if cfg["ca_cert"] and DEFAULT_CA_SAT6 in cfg["ca_cert"] and \
                    cfg["rhntype"] == "satellite":
                     mapping["--server.prefix"] = prefix
                 else:
@@ -426,6 +429,7 @@
 
                 mapping = {"--activationkey": cfg["activationkey"],
                            "--org":           cfg["org"],
+                           "--environment":   cfg["environment"],
                            "--username":      cfg["username"],
                            "--password":      password,
                            "--name":          cfg["profile"],
@@ -446,9 +450,8 @@
                                                       "/password combination",
                                "already been taken":  "This hostname is "
                                                       "already registered",
-                               "Organization":        "Organization must be "
-                                                      "specified with "
-                                                      "Satellite 6"}
+                               "Organization":        "Organization not found "
+                                                      "on Satellite 6"}
                     for k, v in mapping.items():
                         if k in smreg_output:
                             raise RuntimeError(v)
@@ -507,17 +510,51 @@
 
         self.logger.debug(cfg)
         rhntype = cfg["rhntype"]
-        cacert = cfg["ca_cert"] or ""
         tx = utils.Transaction("Performing entitlement registration")
         tx.append(RemoveConfigs())
 
-        if rhntype == "sam" or cacert.endswith(".pem") or \
+        if rhntype == "sam" or \
+           (rhntype == "satellite" and DEFAULT_CA_SAT6 in cfg["ca_cert"]) or \
            (system.is_min_el(7) and rhntype == "rhn"):
-            if rhntype == "satellite" and not cfg["org"]:
-                del tx[0]
-                tx.extend([RaiseError("Registration to Satellite 6 requires "
-                                      "an organization to be set")])
-                return tx
+            if rhntype == "satellite":
+                if cfg["activationkey"]:
+                    if not cfg["org"]:
+                        del tx[0]
+                        tx.extend([RaiseError(
+                                        "Registration to Satellite "
+                                        "6 with activation key requires "
+                                        "an organization to be set")])
+                        return tx
+                    if cfg["environment"]:
+                        del tx[0]
+                        tx.extend([RaiseError(
+                                        "Registration to Satellite 6 with "
+                                        "activation key do not allow "
+                                        "environments to be specified")])
+                        return tx
+                    if cfg["username"] or password:
+                        del tx[0]
+                        tx.extend([RaiseError(
+                                        "Registration to Satellite 6 with an "
+                                        "activation key do not require "
+                                        "credentials")])
+                        return tx
+                else:
+                    if not cfg["org"] or not cfg["environment"]:
+                        del tx[0]
+                        tx.extend([RaiseError(
+                                        "Registration to Satellite 6 requires "
+                                        "an organization and environment to "
+                                        "be set")])
+                        return tx
+
+                    if not cfg["username"] or not password:
+                        del tx[0]
+                        tx.extend([RaiseError(
+                                        "Registration to Satellite 6 without "
+                                        "an activation key requires user "
+                                        "credentials")])
+                        return tx
 
             if cfg["proxy"]:
                 tx.append(ConfigureSAMProxy())
diff --git a/src/ovirt/node/setup/rhn/rhn_page.py b/src/ovirt/node/setup/rhn/rhn_page.py
index 74862ad..78fc96d 100755
--- a/src/ovirt/node/setup/rhn/rhn_page.py
+++ b/src/ovirt/node/setup/rhn/rhn_page.py
@@ -55,6 +55,7 @@
                  "rhn.url": cfg["url"],
                  "rhn.ca": cfg["ca_cert"],
                  "rhn.org": cfg["org"],
+                 "rhn.environment": cfg["environment"],
                  "rhn.activation_key": cfg["activationkey"],
                  "rhn.proxyuser": cfg["proxyuser"],
                  "rhn.proxyhost": "",
@@ -63,9 +64,8 @@
                  "rhn.proxypassword": "",
                  }
         try:
-            model["rhn.proxyhost"], model["rhn.proxyport"] = cfg["proxy"
-                                                                 ].rsplit(
-                ":", 1)
+            model["rhn.proxyhost"], \
+                model["rhn.proxyport"] = cfg["proxy"].rsplit(":", 1)
         except:
             # We're passing because it can't assign multiple values, reassign
             # instead of passing
@@ -82,6 +82,7 @@
                 "rhn.proxyport": valid.Port() | valid.Empty(),
                 "rhn.proxyuser": valid.Text() | valid.Empty(),
                 "rhn.org": valid.Text() | valid.Empty(),
+                "rhn.environment": valid.Text() | valid.Empty(),
                 "rhn.activation_key": valid.Text() | valid.Empty(),
                 }
 
@@ -117,6 +118,7 @@
                   ui.Entry("rhn.url", "URL:"),
                   ui.Entry("rhn.ca", "CA URL:"),
                   ui.Entry("rhn.org", "Organization:"),
+                  ui.Entry("rhn.environment", "Environment:"),
                   ui.Entry("rhn.activation_key", "Activation Key:"),
                   ui.Button("button.proxy", "HTTP Proxy Configuration"),
                   ]
@@ -135,6 +137,7 @@
                     self.widgets["rhn.url"].enabled(True)
                     self.widgets["rhn.ca"].enabled(True)
                     self.widgets["rhn.org"].enabled(True)
+                    self.widgets["rhn.environment"].enabled(True)
                     self.widgets["rhn.activation_key"].enabled(True)
                     self.stash_pop_change("rhn.url", reuse_old=True)
                     self.stash_pop_change("rhn.ca", reuse_old=True)
@@ -163,7 +166,7 @@
         rhn_keys = ["rhn.username", "rhn.password", "rhn.profilename",
                     "rhn.type", "rhn.url", "rhn.ca", "rhn.proxyhost",
                     "rhn.proxyport", "rhn.proxyuser", "rhn.proxypassword",
-                    "rhn.org", "rhn.activation_key"]
+                    "rhn.org", "rhn.environment", "rhn.activation_key"]
 
         if "button.proxy" in changes:
             description = ("Please enter the proxy details to use " +
@@ -206,7 +209,7 @@
 
             rhn_keys = ["rhn.type", "rhn.url", "rhn.ca", "rhn.username",
                         "rhn.profilename", "rhn.activation_key", "rhn.org",
-                        "rhn.proxy", "rhn.proxyuser"]
+                        "rhn.environment", "rhn.proxy", "rhn.proxyuser"]
 
             pw = effective_model["rhn.password"]
             proxypassword = effective_model["rhn.proxypassword"]


-- 
To view, visit https://gerrit.ovirt.org/69767
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id133817a3d511c78dc5ed6b6975b6066b0f7b438
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>
Gerrit-Reviewer: Marcelo Moreira de Mello <mmello at redhat.com>


More information about the node-patches mailing list