Andrew,

Based on information you provided and using existing example
<https://github.com/jclouds/jclouds-examples/blob/master/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/WindowsInstanceStarter.java>,
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 <andr...@apache.org> 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