> + > + // If no key has been configured and the auto-create option is set, > then generate a key pair > + if (options.getSshKeyIds().isEmpty() && > options.getShouldAutoCreateKeyPair() > + && Strings.isNullOrEmpty(options.getPublicKey())) { > + generateKeyPairAndAddKeyToSet(options, generatedSshKeyIds); > + } > + > + // If there is a script to run in the node, make sure a pivate key has > been configured so jclouds will be able to > + // access the node > + if (options.getRunScript() != null) { > + checkArgument(!Strings.isNullOrEmpty(options.getLoginPrivateKey()), > + "no private key configured for: %s; please use > options.overrideLoginPrivateKey(rsa_private_text)", group); > + } > + > + // If there is a key configured, then make sure there is a key pair > for it > + if (!Strings.isNullOrEmpty(options.getPublicKey())) {
No. The point here is that if in the previous if a key pair is automatically generated, its private key key be populated to the options, so it can be used to authenticate. That's why this check is made afterwards. If a key pair is auto-generated, the private key will always be populated, so there is no risk of leaving created key pairs and then throwing an exception. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/73/files#r17935853