· 10 years ago · Jan 29, 2016, 01:51 AM
1Properties overrides = new Properties();
2overrides.setProperty(Constants.PROPERTY_ENDPOINT, CLOUD_SERVIE_ENDPOINT);
3
4// get a context with nova that offers the portable ComputeService api
5BlobStoreContext context = new BlobStoreContextFactory().createContext("aws-s3", ident,
6 password, ImmutableSet.<Module> of(), overrides);
7
8Properties overrides = new Properties();
9overrides.setProperty("swift.endpoint", "http://1.1.1.1:8080/auth");
10
11BlobStoreContext context = new BlobStoreContextFactory().createContext("swift", "XXXXXX:YYYYY", "password", ImmutableSet.<Module> of(), overrides);
12
13import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS;
14...
15
16 Properties overrides = new Properties();
17 overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
18
19 BlobStore blobstore = ContextBuilder.newBuilder(new S3ApiMetadata()) // or "s3"
20 .endpoint("http://host:port")
21 .credentials(accessKey, secretKey)
22 .overrides(overrides)
23 .buildView(BlobStoreContext.class).getBlobStore();
24
25import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH;
26...
27
28 overrides.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus");
29...
30 .endpoint("http://host:port/services/Walrus")
31
32String username = "test:tester";
33 String password = "testing";
34 Properties overrides = new Properties();
35 overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
36
37 BlobStoreContext context = ContextBuilder.newBuilder(new S3ApiMetadata())
38 .endpoint("http://myserver:8080")
39 .credentials(username, password)
40 .overrides(overrides)
41 .buildView(BlobStoreContext.class);
42 BlobStore blobStore = context.getBlobStore();
43 String bucket="public";
44 blobStore.containerExists(bucket);
45
46 System.out.println("bucket exist "+ bucket);
47}