|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <rados/librados.h>
|
|
|
|
int set_rados_option(rados_t cluster, const char *option, const char *value) {
|
|
printf("Set the %s option to: %s\n", option, value);
|
|
return rados_conf_set(cluster, option, value);
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
rados_t cluster;
|
|
rados_ioctx_t io;
|
|
|
|
int r;
|
|
|
|
const char *id = "admin";
|
|
const char *key = "AQB7Sg1R2DlXIxAAkbOnif9m3v/HD4QW19kNHA==";
|
|
const char *mon = "localhost";
|
|
const char *pool_name = "data";
|
|
const char *client_timeout = "5";
|
|
|
|
rados_create(&cluster, id);
|
|
printf("%s\n", "Created the RADOS cluster");
|
|
|
|
set_rados_option(cluster, "key", key);
|
|
set_rados_option(cluster, "mon_host", mon);
|
|
set_rados_option(cluster, "client_mount_timeout", client_timeout);
|
|
|
|
r = rados_connect(cluster);
|
|
if (r < 0) {
|
|
printf("%s: %d\n", "Failed to connect to the Ceph cluster", r);
|
|
} else {
|
|
printf("%s\n", "Connected to the RADOS cluster");
|
|
}
|
|
|
|
r = rados_ioctx_create(cluster, pool_name, io);
|
|
if (r < 0) {
|
|
printf("%s: %d\n", "Failed to connect to the Ceph cluster", r);
|
|
} else {
|
|
printf("%s\n", "Connected to the RADOS cluster");
|
|
}
|
|
|
|
rados_shutdown(cluster);
|
|
printf("%s\n", "Shut down the RADOS cluster");
|
|
}
|