jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject Re: [jclouds/jclouds-labs] Generate Azure VM password on the fly (#402)
Date Wed, 12 Jul 2017 11:16:10 GMT
nacx approved this pull request.



> @@ -130,6 +136,20 @@ protected CreateResourcesThenCreateNodes(
       return super.execute(group, count, template, goodNodes, badNodes, customizationResponses);
    }
 
+   // Azure requires that we pass it the VM password. Need to generate one if not overriden
by the user.
+   private void generatePasswordIfNoneProvided(Template template) {
+      TemplateOptions options = template.getOptions();
+      if (options.getLoginPassword() == null) {
+         Optional<String> passwordOptional = template.getImage().getDefaultCredentials().getOptionalPassword();
+         if (passwordOptional.isPresent()) {

More concise version: `options.overrideLoginPassword(passwordOptional.or(Passwords.generate()))`.

> + *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.arm.util;
+
+import com.google.common.io.BaseEncoding;
+
+import java.util.Random;
+
+// Seems to be a common theme between providers, perhaps should be provided by core (see
other 'Passwords' classes)

+1 to refactor all existing `Password` util classes into something reusable and moving it
to compute-core. Something like we have for dates, for example, where we have a class that
provides access to different date formatters. We could have a Passwords utils class that provided
access to a set of preconfigured password conventions.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/402#pullrequestreview-49458145
Mime
View raw message