Hi, Thanks a lot! It does help!
Yiqun Wang Ignasi Barrera <[email protected]>于2016年1月17日周日 下午8:12写道: > Hi, > > 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") > .endpoint(endpoint) > .credentials(client, clientCredential) > .overrides(props) > .modules(ImmutableSet.of(new SshjSshClientModule())) // > .buildApi(ChefApi.class); > ChefService service = api.chefService(); > > If you really need to access the injector, you can instantiate it as > follows: > > Injector injector = ContextBuilder.newBuilder("chef") > .endpoint(endpoint) > .credentials(client, clientCredential) > .overrides(props) > .modules(ImmutableSet.of(new SshjSshClientModule())) // > .buildInjector(); > ChefApi api = I.getInstance(ChefApi.class); > > > > HTH! > > I. > > > > El 17/1/2016 12:26 p. m., "王逸群" <[email protected]> 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 >
