Have you tried:
import static 
org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginCredentials;
import static 
org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginUser;

This is what I see in the example.




From: Vineet Saini [[email protected]]

Sent: Wednesday, July 09, 2014 1:47 PM

To: [email protected]

Subject: Re: How to create Winodows Compute with random or predefine password















Zack,



Not sure where this method overrideLoginUser("username") exist or which library 
provide it, as getting error this method not found.




templateBuilder.options(overrideLoginUser(loginUser))




Thank you for help.




Vineet








On Wed, Jul 9, 2014 at 1:20 PM, Zack Shoylev 
<[email protected]> wrote:


You might want to try something like



templateBuilder.options(overrideLoginUser(loginUser))



before you call templateBuilder.build();



As per this example:

https://github.com/jclouds/jclouds-examples/blob/master/compute-basics/src/main/java/org/jclouds/examples/compute/basics/MainApp.java



In any case I am thinking the idea is that you should not be able to modify the 
template (or its options) after you call build().



Let me know if this helps or not.

-Zack



From: Vineet Saini [[email protected]]



Sent: Wednesday, July 09, 2014 10:49 AM



To: 
[email protected]



Subject: Re: How to create Winodows Compute with random or predefine password






























Andrew,







Based on information you provided and using existing

example, I able to make some progress, but not able to resolved one thing, here 
is code snippet.











Iterable<Module> modules = ImmutableSet. of( new SshjSshClientModule(), new 
SLF4JLoggingModule(), new EnterpriseConfigurationModule(), new 
BouncyCastleCryptoModule();







ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2") 
.credentials(identity, credential ) 
.modules(modules).buildView(ComputeServiceContext.class);











// use image id for windows Server 2003 R2 base =  ami-9050a9f8



TemplateBuilder templateBuilder = context.getComputeService().templateBuilder();





templateBuilder.imageId("us-east-1/ami-9050a9f8") .smallest() 
.locationId("us-east-1").os64Bit(true);











// Get Template



Template template = templateBuilder.build();















// Here try to override administrator password with static password,



// This does not work







template.getOptions().overrideLoginUser("Administrator");



template.getOptions().overrideLoginPassword("test123");











// setup port for rdp







template.getOptions().inboundPorts(3389);











// Create Node: it wait for call to finish with admin user it setup. that take 
care of wait till ready.



Set<?extends NodeMetadata> nodes = computeService 
.createNodesInGroup("grouptest", 2, template);















NodeMetadata nodeMetadata = Iterables.getOnlyElement(nodes);









PasswordDataAndPrivateKey dataAndKey = new PasswordDataAndPrivateKey(



        
context.unwrapApi(EC2Api.class).getWindowsApi().get().getPasswordDataInRegion(region,
 nodeMetadata.getId()), nodeMetadata.getCredentials().getPrivateKey());









WindowsLoginCredentialsFromEncryptedData f = 
context.utils().injector().getInstance(WindowsLoginCredentialsFromEncryptedData.class);











// In this case it need parameter type to be EncryptedPasswordDataAndPrivateKey 
instead of PasswordDataAndPrivateKey, not sure how to resolve that.





LoginCredentials credentials = f.apply(dataAndKey);













// get decrypted pass



logger.info("Login name: %s", credentials.getUser());



logger.info("Password: %s", credentials.getPassword());















Thanks for all the help.































On Tue, Jul 8, 2014 at 3:53 PM, Andrew Phillips

<[email protected]> wrote:













Also if can point me how to set default password for administrator user.



that would be helpful too.













I am not sure if that is possible. The EC2 Windows Security guide [1] says 
that, during initial install, it "generates and sets a random password on the 
Administrator account", but with your own AMIs you may be able to do something 
different.







As regards retrieving the Administrator credentials: have you been able to try 
getting the WindowsApi [2] from the EC2Api [3] and using that? If you are 
working with a ComputeService view, you will need to "unwrap" the view to 
access the underlying API first

 [4].







Regards







ap







[1]

https://aws.amazon.com/articles/1767



[2]

http://javadocs.jclouds.cloudbees.net/org/jclouds/ec2/features/WindowsApi.html



[3]

http://javadocs.jclouds.cloudbees.net/org/jclouds/ec2/EC2Api.html#getWindowsApi()



[4]

http://jclouds.apache.org/start/concepts/#apis





























Reply via email to