jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandr Porunov <alexandr.poru...@gmail.com>
Subject Re: How to use jclouds with OpenStack Swift?
Date Wed, 14 Sep 2016 20:38:06 GMT
My OpenStack Swift works if I use curl:

//authenticate
curl -v -H 'X-Auth-User: admin:admin' -H 'X-Auth-Key: admin'
http://192.168.0.58:8080/auth/v1.0/

//check containers
curl -v -H 'X-Storage-Token: AUTH_tk1411104de43046aca9b371c27c3b1fad'
http://192.168.0.58:8080/v1/AUTH_admin/

//create a container
curl -v -H 'X-Storage-Token: AUTH_tk1411104de43046aca9b371c27c3b1fad' -X
PUT http://192.168.0.58:8080/v1/AUTH_admin/mycontainer

//upload file
swift -A http://192.168.0.58:8080/auth/v1.0/ -U admin:admin -K admin upload
mycontainer some_file

//get file
curl -v -H 'X-Auth-Token: AUTH_tk1411104de43046aca9b371c27c3b1fad' -X GET
http://192.168.0.58:8080/v1/AUTH_admin/mycontainer/some_file

On Wed, Sep 14, 2016 at 11:37 PM, Alexandr Porunov <
alexandr.porunov@gmail.com> wrote:

> Andrew,
>
> Ignasi Barrera helped me. I had to use Gson version 2.5 to handle that
> error.
>
> As you said I tried to call:
> Set<String> regions = swiftApi.getConfiguredRegions();
>
> But I got an error:
> Request processing failed; nested exception is org.jclouds.http.HttpResponseException:
> command: POST http://192.168.0.58:8080/auth/v1.0/tokens HTTP/1.1 failed
> with response: HTTP/1.1 400 Bad Request; content: [<html><h1>Bad
> Request</h1><p>The server could not comply with the request since it is
> either malformed or otherwise incorrect.</p></html>]] with root cause
> org.jclouds.http.HttpResponseException: command: POST
> http://192.168.0.58:8080/auth/v1.0/tokens HTTP/1.1 failed with response:
> HTTP/1.1 400 Bad Request; content: [<html><h1>Bad Request</h1><p>The
server
> could not comply with the request since it is either malformed or otherwise
> incorrect.</p></html>]
>         at org.jclouds.openstack.swift.v1.handlers.SwiftErrorHandler.
> handleError(SwiftErrorHandler.java:46)
>         at org.jclouds.http.handlers.DelegatingErrorHandler.handleError(
> DelegatingErrorHandler.java:65)
>         at org.jclouds.http.internal.BaseHttpCommandExecutorService
> .shouldContinue(BaseHttpCommandExecutorService.java:136)
>         at org.jclouds.http.internal.BaseHttpCommandExecutorService
> .invoke(BaseHttpCommandExecutorService.java:105)
>         at org.jclouds.rest.internal.InvokeHttpMethod.invoke(
> InvokeHttpMethod.java:90)
>         at org.jclouds.rest.internal.InvokeHttpMethod.apply(
> InvokeHttpMethod.java:73)
>         at org.jclouds.rest.internal.InvokeHttpMethod.apply(
> InvokeHttpMethod.java:44)
>         at org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(
> DelegatesToInvocationFunction.java:156)
>         at org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(
> DelegatesToInvocationFunction.java:123)
>         at com.sun.proxy.$Proxy111.authenticateWithTenantNameAndCredentials(Unknown
> Source)
>         at org.jclouds.openstack.keystone.v2_0.functions.
> AuthenticatePasswordCredentials.authenticateWithTenantName(
> AuthenticatePasswordCredentials.java:43)
>         at org.jclouds.openstack.keystone.v2_0.functions.
> AuthenticatePasswordCredentials.authenticateWithTenantName(
> AuthenticatePasswordCredentials.java:31)
>         at org.jclouds.openstack.keystone.v2_0.functions.
> internal.BaseAuthenticator.apply(BaseAuthenticator.java:79)
>         at org.jclouds.openstack.keystone.v2_0.functions.
> internal.BaseAuthenticator.apply(BaseAuthenticator.java:36)
>         at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(
> CacheLoader.java:148)
>         at com.google.common.cache.LocalCache$LoadingValueReference.
> loadFuture(LocalCache.java:3524)
>         at com.google.common.cache.LocalCache$Segment.loadSync(
> LocalCache.java:2317)
>         at com.google.common.cache.LocalCache$Segment.
> lockedGetOrLoad(LocalCache.java:2280)
>         at com.google.common.cache.LocalCache$Segment.get(
> LocalCache.java:2195)
>         at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
>         at com.google.common.cache.LocalCache.getOrLoad(
> LocalCache.java:3938)
>         at com.google.common.cache.LocalCache$LocalLoadingCache.
> get(LocalCache.java:4821)
>         at com.google.common.cache.LocalCache$LocalLoadingCache.
> getUnchecked(LocalCache.java:4827)
>         at org.jclouds.openstack.keystone.v2_0.config.
> KeystoneAuthenticationModule$2.get(KeystoneAuthenticationModule.java:234)
>         at org.jclouds.openstack.keystone.v2_0.config.
> KeystoneAuthenticationModule$2.get(KeystoneAuthenticationModule.java:231)
>         at org.jclouds.openstack.keystone.v2_0.suppliers.
> LocationIdToURIFromAccessForTypeAndVersion.get(
> LocationIdToURIFromAccessForTypeAndVersion.java:94)
>         at org.jclouds.openstack.keystone.v2_0.suppliers.
> LocationIdToURIFromAccessForTypeAndVersion.get(
> LocationIdToURIFromAccessForTypeAndVersion.java:54)
>         at org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier$SetAndThrowAuthorizationExcept
> ionSupplierBackedLoader.load(MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.java:73)
>         at org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier$SetAndThrowAuthorizationExcept
> ionSupplierBackedLoader.load(MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.java:57)
>         at com.google.common.cache.LocalCache$LoadingValueReference.
> loadFuture(LocalCache.java:3524)
>         at com.google.common.cache.LocalCache$Segment.loadSync(
> LocalCache.java:2317)
>         at com.google.common.cache.LocalCache$Segment.
> lockedGetOrLoad(LocalCache.java:2280)
>         at com.google.common.cache.LocalCache$Segment.get(
> LocalCache.java:2195)
>         at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
>         at com.google.common.cache.LocalCache.getOrLoad(
> LocalCache.java:3938)
>         at com.google.common.cache.LocalCache$LocalLoadingCache.
> get(LocalCache.java:4821)
>         at org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.get(MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.java:119)
>         at org.jclouds.location.suppliers.derived.
> RegionIdsFromRegionIdToURIKeySet.get(RegionIdsFromRegionIdToURIKeyS
> et.java:45)
>         at org.jclouds.location.suppliers.derived.
> RegionIdsFromRegionIdToURIKeySet.get(RegionIdsFromRegionIdToURIKeyS
> et.java:33)
>         at com.google.common.base.Suppliers$SupplierComposition.
> get(Suppliers.java:67)
>         at org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier$SetAndThrowAuthorizationExcept
> ionSupplierBackedLoader.load(MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.java:73)
>         at org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier$SetAndThrowAuthorizationExcept
> ionSupplierBackedLoader.load(MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.java:57)
>         at com.google.common.cache.LocalCache$LoadingValueReference.
> loadFuture(LocalCache.java:3524)
>         at com.google.common.cache.LocalCache$Segment.loadSync(
> LocalCache.java:2317)
>         at com.google.common.cache.LocalCache$Segment.
> lockedGetOrLoad(LocalCache.java:2280)
>         at com.google.common.cache.LocalCache$Segment.get(
> LocalCache.java:2195)
>         at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
>         at com.google.common.cache.LocalCache.getOrLoad(
> LocalCache.java:3938)
>         at com.google.common.cache.LocalCache$LocalLoadingCache.
> get(LocalCache.java:4821)
>         at org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.get(MemoizedRetryOnTimeOutButNotOn
> AuthorizationExceptionSupplier.java:119)
>         at org.jclouds.rest.internal.DelegatesToInvocationFunction.
> getInstanceOfTypeWithQualifier(DelegatesToInvocationFunction.java:277)
>         at org.jclouds.rest.internal.DelegatesToInvocationFunction.
> lookupValueFromGuice(DelegatesToInvocationFunction.java:234)
>         at org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(
> DelegatesToInvocationFunction.java:152)
>         at org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(
> DelegatesToInvocationFunction.java:123)
>         at com.sun.proxy.$Proxy114.getConfiguredRegions(Unknown Source)
>         at com.fyfine.loader.controller.PersonController.getRegions(
> PersonController.java:112)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:62)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:497)
>         at org.springframework.web.method.support.InvocableHandlerMethod.
> doInvoke(InvocableHandlerMethod.java:221)
>         at org.springframework.web.method.support.InvocableHandlerMethod.
> invokeForRequest(InvocableHandlerMethod.java:136)
>         at org.springframework.web.servlet.mvc.method.annotation.
> ServletInvocableHandlerMethod.invokeAndHandle(
> ServletInvocableHandlerMethod.java:114)
>         at org.springframework.web.servlet.mvc.method.annotation.
> RequestMappingHandlerAdapter.invokeHandlerMethod(
> RequestMappingHandlerAdapter.java:827)
>         at org.springframework.web.servlet.mvc.method.annotation.
> RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.
> java:738)
>         at org.springframework.web.servlet.mvc.method.
> AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
>         at org.springframework.web.servlet.DispatcherServlet.
> doDispatch(DispatcherServlet.java:963)
>         at org.springframework.web.servlet.DispatcherServlet.
> doService(DispatcherServlet.java:897)
>         at org.springframework.web.servlet.FrameworkServlet.
> processRequest(FrameworkServlet.java:970)
>         at org.springframework.web.servlet.FrameworkServlet.
> doGet(FrameworkServlet.java:861)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
>         at org.springframework.web.servlet.FrameworkServlet.
> service(FrameworkServlet.java:846)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
>         at org.apache.catalina.core.ApplicationFilterChain.
> internalDoFilter(ApplicationFilterChain.java:230)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
>         at org.apache.tomcat.websocket.server.WsFilter.doFilter(
> WsFilter.java:52)
>         at org.apache.catalina.core.ApplicationFilterChain.
> internalDoFilter(ApplicationFilterChain.java:192)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
>         at org.springframework.web.filter.RequestContextFilter.
> doFilterInternal(RequestContextFilter.java:99)
>         at org.springframework.web.filter.OncePerRequestFilter.
> doFilter(OncePerRequestFilter.java:107)
>         at org.apache.catalina.core.ApplicationFilterChain.
> internalDoFilter(ApplicationFilterChain.java:192)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
>         at org.springframework.web.filter.HttpPutFormContentFilter.
> doFilterInternal(HttpPutFormContentFilter.java:87)
>         at org.springframework.web.filter.OncePerRequestFilter.
> doFilter(OncePerRequestFilter.java:107)
>         at org.apache.catalina.core.ApplicationFilterChain.
> internalDoFilter(ApplicationFilterChain.java:192)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
>         at org.springframework.web.filter.HiddenHttpMethodFilter.
> doFilterInternal(HiddenHttpMethodFilter.java:77)
>         at org.springframework.web.filter.OncePerRequestFilter.
> doFilter(OncePerRequestFilter.java:107)
>         at org.apache.catalina.core.ApplicationFilterChain.
> internalDoFilter(ApplicationFilterChain.java:192)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
>         at org.springframework.web.filter.CharacterEncodingFilter.
> doFilterInternal(CharacterEncodingFilter.java:197)
>         at org.springframework.web.filter.OncePerRequestFilter.
> doFilter(OncePerRequestFilter.java:107)
>         at org.apache.catalina.core.ApplicationFilterChain.
> internalDoFilter(ApplicationFilterChain.java:192)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:198)
>         at org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:108)
>         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
> AuthenticatorBase.java:522)
>         at org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java:140)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java:79)
>         at org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:87)
>         at org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java:349)
>         at org.apache.coyote.http11.Http11Processor.service(
> Http11Processor.java:1110)
>         at org.apache.coyote.AbstractProcessorLight.process(
> AbstractProcessorLight.java:66)
>         at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(
> AbstractProtocol.java:785)
>         at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.
> doRun(NioEndpoint.java:1425)
>         at org.apache.tomcat.util.net.SocketProcessorBase.run(
> SocketProcessorBase.java:49)
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)
>         at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(
> TaskThread.java:61)
>         at java.lang.Thread.run(Thread.java:745)
>
> Here is an spring's output:
>
> {"timestamp":1473877865201,"status":500,"error":"Internal Server
> Error","exception":"org.jclouds.http.HttpResponseException","message":"command:
> POST http://192.168.0.58:8080/auth/v1.0/tokens HTTP/1.1 failed with
> response: HTTP/1.1 400 Bad Request; content: [<html><h1>Bad
> Request</h1><p>The server could not comply with the request since it is
> either malformed or otherwise incorrect.</p></html>]","path"
> :"/get_regions"}
>
> Do you know why am I get this error?
>
> Best regards,
> Alexandr
>
> On Wed, Sep 14, 2016 at 9:13 PM, Alexandr Porunov <
> alexandr.porunov@gmail.com> wrote:
>
>> Yes, I found Gson in the classpath. It has version 2.7
>>
>> On Wed, Sep 14, 2016 at 8:48 PM, Alexandr Porunov <
>> alexandr.porunov@gmail.com> wrote:
>>
>>> Hello Andrew,
>>>
>>> Now I cannot call that method because I cannot connect to OpenStack
>>> Swift itself. I always get next error:
>>> http://paste.openstack.org/show/576305/
>>>
>>> Here is my proxy configs:
>>> [filter:tempauth]
>>> use = egg:swift#tempauth
>>> user_admin_admin = admin .admin .reseller_admin
>>> user_test_tester = testing .admin
>>> user_test2_tester2 = testing2 .admin
>>> user_test_tester3 = testing3
>>>
>>> Here is my code:
>>> SwiftApi swiftApi = ContextBuilder.newBuilder("openstack-swift")
>>>                 .endpoint("http://192.168.0.58:8080/v1/")
>>>                 .credentials("admin:admin", "admin")
>>>                 .buildApi(SwiftApi.class);
>>>
>>> Can you help me please?
>>>
>>> Regards,
>>> Alexandr
>>>
>>> On Wed, Sep 14, 2016 at 7:21 PM, Andrew Phillips <andrewp@apache.org>
>>> wrote:
>>>
>>>> What is "RegionOne" ? First of all if we talk about regions in Swift
>>>>> then it can't be a String. It is Integer value. That is why I can't
>>>>> understand what is "RegionOne" and how to create a simple container
>>>>> with SwiftApi.
>>>>>
>>>>
>>>> Could you call "getConfiguredRegions" on your API instance to see which
>>>> regions are available?
>>>>
>>>> https://jclouds.apache.org/reference/javadoc/1.9.x/org/jclou
>>>> ds/openstack/swift/v1/SwiftApi.html#getConfiguredRegions()
>>>>
>>>> Regards
>>>>
>>>> ap
>>>>
>>>
>>>
>>
>

Mime
View raw message