Juan Hernandez has posted comments on this change.

Change subject: pki: remove the need to store ssh public key
......................................................................


Patch Set 12: Looks good to me, but someone else must approve

(5 inline comments)

....................................................
File 
backend/manager/modules/root/src/main/java/org/ovirt/engine/core/pki/PKIResourceServlet.java
Line 35:     private static final Logger log = 
Logger.getLogger(PKIResourceServlet.class);
Line 36: 
Line 37:     String resourceLocation;
Line 38:     String outputFormat;
Line 39:     String outputAlias;
Add "private".
Line 40: 
Line 41:     @Override
Line 42:     public void init() throws ServletException {
Line 43:         try {


Line 42:     public void init() throws ServletException {
Line 43:         try {
Line 44:             this.resourceLocation = 
getInitParameter("resource-location");
Line 45:             this.outputFormat = getInitParameter("output-format");
Line 46:             this.outputAlias = getInitParameter("output-alias");
No need for the "this." prefix here or in the rest of the class.
Line 47: 
Line 48:             if (this.resourceLocation == null) {
Line 49:                 throw new ServletException("resourceLocation must be 
specified");
Line 50:             }


Line 45:             this.outputFormat = getInitParameter("output-format");
Line 46:             this.outputAlias = getInitParameter("output-alias");
Line 47: 
Line 48:             if (this.resourceLocation == null) {
Line 49:                 throw new ServletException("resourceLocation must be 
specified");
I would suggest a message like this:

  The parameter "resource-location" must be specified.

That gives the user reading the log file a direct hint of what is the solution, 
with the right parameter name. I would also suggest to use a constant for the 
parameter name, so you can write something like this:

  private static final String RESOURCE_LOCATION = "resource-location";

  resourceLocation = getInitParameter(RESOURCE_LOCATION);
  if (resourceLocation == null) {
    throw new ServletException("The parameter \"" + RESOURCE_LOCATION + "\" 
must be specified.");
  }

Same for "outputFormat", and maybe also check that the value is one of the 
allowed ones.
Line 50:             }
Line 51:             if (this.outputFormat == null) {
Line 52:                 throw new ServletException("outputFormat must be 
specified");
Line 53:             }


....................................................
File packaging/fedora/setup/engine-setup.py
Line 857:                 basedefs.EXEC_SSH_KEYGEN,
Line 858:                 "-yf", basedefs.FILE_PRIVATE_SSH_KEY
Line 859:             ]
Line 860:             pubkey, rc = utils.execCmd(cmdList=cmd, failOnError=True)
Line 861:             (pubtempfd, pubtemp) = tempfile.mkstemp(suffix=".pub")
Parenthesis are not needed around pubtemfd and pubtemp, the comma makes the 
tuple, not the parenthesis.
Line 862:             os.close(pubtempfd)
Line 863:             with open(pubtemp, "w") as f:
Line 864:                 f.write(pubkey)
Line 865:             cmd = [


Line 866:                 basedefs.EXEC_SSH_KEYGEN,
Line 867:                 "-lf", pubtemp
Line 868:             ]
Line 869:             finger, rc = utils.execCmd(cmdList=cmd, failOnError=True)
Line 870:             os.remove(pubtemp)
Can you put this "os.remove" in a finally block, so that the temp file is 
removed even if an exception is thrown in the middle?
Line 871:             msg = 
output_messages.INFO_CA_SSH_FINGERPRINT%(finger.split()[1])
Line 872:             controller.MESSAGES.append(msg)
Line 873: 
Line 874:             # Set right permissions


--
To view, visit http://gerrit.ovirt.org/4853
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I328baded92b2e7c5169bc87e7c19680f598389b9
Gerrit-PatchSet: 12
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Doron Fediuck <[email protected]>
Gerrit-Reviewer: Itamar Heim <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Laszlo Hornyak <[email protected]>
Gerrit-Reviewer: Ofer Schreiber <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to