3

I have deployed a Ceph cluster over 3 nodes and have created msd and rgw. I have 3 machines named ceph1, ceph2 and ceph3.

  • ceph1 runs osd, mon, mds and rwg
  • ceph2 runs osd
  • ceph3 runs osd

I have created a user with radosgw-admin user create command.

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().

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Subhankar
  • 692
  • 7
  • 25

1 Answers1

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 ]

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.

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

Then, you can specify following variables:

  • config.setUsername() ... foo:swift
  • config.setPassword() ... testsecret
  • config.setAuthUrl() ... http://ceph.example.com/auth/v1
nak3
  • 116
  • 1
  • 3