How to store Object in Ceph Object Store

Clash Royale CLAN TAG#URR8PPPHow to store Object in Ceph Object Store
I have deployed a Ceph cluster over 3 nodes and have created msd and rgw. I have 3 machines named ceph1, ceph2 and ceph3.
msd
rgw
I have created a user with radosgw-admin user create command.
radosgw-admin user create
Now I want to access the ceph cluster using swift api and create a container. For that I wrote following java code :
import org.javaswift.joss.client.factory.AccountConfig;
import org.javaswift.joss.client.factory.AccountFactory;
import org.javaswift.joss.client.factory.AuthenticationMethod;
import org.javaswift.joss.model.Account;
import org.javaswift.joss.model.Container;
import org.javaswift.joss.model.StoredObject;
import java.io.File;
import java.io.IOException;
import java.util.*;
public class Example {
public static void main(String args) {
String username = "sahoo";
String password = "IM8K5GAQIXHFRAKYS761";
String authUrl = "http://ceph1:7480/";
AccountConfig config = new AccountConfig();
config.setUsername(username);
config.setPassword(password);
config.setAuthUrl(authUrl);
config.setAuthenticationMethod(AuthenticationMethod.BASIC);
Account account = new AccountFactory(config).createAccount();
Container container = account.getContainer("container-name");
container.create();
}
}
But while running the code I get following exception:
Exception in thread "main" java.lang.NullPointerException
at org.javaswift.joss.command.impl.identity.BasicAuthenticationCommandImpl.getReturnObject(BasicAuthenticationCommandImpl.java:35)
at org.javaswift.joss.command.impl.identity.BasicAuthenticationCommandImpl.getReturnObject(BasicAuthenticationCommandImpl.java:18)
at org.javaswift.joss.command.impl.core.AbstractCommand.call(AbstractCommand.java:51)
at org.javaswift.joss.client.impl.ClientImpl.createAccount(ClientImpl.java:97)
at org.javaswift.joss.client.impl.ClientImpl.createAccount(ClientImpl.java:27)
at org.javaswift.joss.client.core.AbstractClient.authenticate(AbstractClient.java:35)
at org.javaswift.joss.client.factory.AccountFactory.createAccount(AccountFactory.java:30)
at Example.main(Example.java:24)
Can any one help me out with why I am getting the exception and exactly what we need to pass to config.setAuthUrl().
config.setAuthUrl()
1 Answer
1
First of all, you need to create subuser to use swift API.
sudo radosgw-admin subuser create radosgw-admin subuser create --uid={uid} --subuser={uid} --access=[ read | write | readwrite | full ]
sudo radosgw-admin subuser create radosgw-admin subuser create --uid={uid} --subuser={uid} --access=[ read | write | readwrite | full ]
REF: http://docs.ceph.com/docs/giant/radosgw/admin/
To create a subuser (Swift interface) for the user, you must specify the user ID (--uid={username}), a subuser ID and the access level for the subuser.
Then, we need to pass the URL of Ceph RGW to config.setAuthUrl(). It would be better to test with swift command quickly.
config.setAuthUrl()
swift
For example, if you could confirm to create a container by this command:
# swift -V 1.0 -A http://ceph.example.com/auth/v1 -U foo:swift -K testsecret post test-container
# swift -V 1.0 -A http://ceph.example.com/auth/v1 -U foo:swift -K testsecret post test-container
Then, you can specify following variables:
foo:swift
testsecret
http://ceph.example.com/auth/v1
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.