jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <n...@apache.org>
Subject Re: Create SshClientFactory without ChefContext
Date Sun, 17 Jan 2016 12:12:09 GMT

In 2.0, the ChefContext has been removed. It provided nothing but an
accessor to the ChefService and exposed too many jclouds internals
(such as the injector), that we should try to avoid using directly.

Now the ChefService is exposed in the ChefApi itself, so you can get it as:

ChefApi api = ContextBuilder.newBuilder("chef")
   .credentials(client, clientCredential)
   .modules(ImmutableSet.of(new SshjSshClientModule())) //
ChefService service = api.chefService();

If you really need to access the injector, you can instantiate it as follows:

Injector injector = ContextBuilder.newBuilder("chef")
   .credentials(client, clientCredential)
   .modules(ImmutableSet.of(new SshjSshClientModule())) //
ChefApi api = I.getInstance(ChefApi.class);



El 17/1/2016 12:26 p. m., "王逸群" <wyqqrince@gmail.com> escribió:
> Hi
> I am trying to instantiate a ssh connection without ComputeService using JCloud Chef
API. I learned that in:
>  http://stackoverflow.com/questions/24777085/jclouds-chef-illegalaccesserror-on-tokentype2/24781011#24781011
> However, since I own a private server in LAN, I need to configure the bootstrap script
with a custom SSL verify mode. However, I got a no enum constant exception. Then I check this:
> https://issues.apache.org/jira/browse/JCLOUDS-1050
> It is fixed in 2.0.0. In JCloud-chef 2.0.0, ChefContext is abandoned, So I wonder how
can I instantiate a ssh connection without ChefContext.
> P.S. In JCloud 1.9.1, the code to create a sshClientFactory is shown as below, and ssh
connection is instantiated by this factory.
> SshClient.Factory sshFactory = chefContext.unwrap().utils().injector().getInstance(Key.get(new
TypeLiteral<SshClient.Factory>() {}));
> Best Regards,
> Yiqun Wang

View raw message