mirror of https://github.com/apache/jclouds.git
Use Java and Clojure syntax highlighting in the readme file.
This commit is contained in:
parent
72deb93570
commit
d658c30fe9
86
README.md
86
README.md
|
@ -40,26 +40,30 @@ Simplifies dealing with key-value providers such as Amazon S3. For example, Blob
|
||||||
|
|
||||||
BlobStore Example (Java):
|
BlobStore Example (Java):
|
||||||
|
|
||||||
// init
|
```java
|
||||||
context = new BlobStoreContextFactory().createContext(
|
// init
|
||||||
"aws-s3",
|
context = new BlobStoreContextFactory().createContext(
|
||||||
accesskeyid,
|
"aws-s3",
|
||||||
secretaccesskey);
|
accesskeyid,
|
||||||
blobStore = context.getBlobStore();
|
secretaccesskey);
|
||||||
|
blobStore = context.getBlobStore();
|
||||||
|
|
||||||
// create container
|
// create container
|
||||||
blobStore.createContainerInLocation(null, "mycontainer");
|
blobStore.createContainerInLocation(null, "mycontainer");
|
||||||
|
|
||||||
// add blob
|
// add blob
|
||||||
blob = blobStore.blobBuilder("test").payload("testdata").build();
|
blob = blobStore.blobBuilder("test").payload("testdata").build();
|
||||||
blobStore.putBlob("mycontainer", blob);
|
blobStore.putBlob("mycontainer", blob);
|
||||||
|
```
|
||||||
|
|
||||||
BlobStore Example (Clojure):
|
BlobStore Example (Clojure):
|
||||||
|
|
||||||
(use 'org.jclouds.blobstore2)
|
```clojure
|
||||||
(def *blobstore* (blobstore "azureblob" account encodedkey))
|
(use 'org.jclouds.blobstore2)
|
||||||
(create-container *blobstore* "mycontainer")
|
(def *blobstore* (blobstore "azureblob" account encodedkey))
|
||||||
(put-blob *blobstore* "mycontainer" (blob "test" :payload "testdata"))
|
(create-container *blobstore* "mycontainer")
|
||||||
|
(put-blob *blobstore* "mycontainer" (blob "test" :payload "testdata"))
|
||||||
|
```
|
||||||
|
|
||||||
ComputeService
|
ComputeService
|
||||||
---------------
|
---------------
|
||||||
|
@ -67,41 +71,45 @@ Simplifies the task of managing machines in the cloud. For example, you can use
|
||||||
|
|
||||||
Compute Example (Java):
|
Compute Example (Java):
|
||||||
|
|
||||||
// init
|
```java
|
||||||
context = new ComputeServiceContextFactory().createContext(
|
// init
|
||||||
"aws-ec2",
|
context = new ComputeServiceContextFactory().createContext(
|
||||||
accesskeyid,
|
"aws-ec2",
|
||||||
secretaccesskey,
|
accesskeyid,
|
||||||
ImmutableSet.of(new Log4JLoggingModule(), new SshjSshClientModule()));
|
secretaccesskey,
|
||||||
|
ImmutableSet.of(new Log4JLoggingModule(), new SshjSshClientModule()));
|
||||||
|
|
||||||
client = context.getComputeService();
|
client = context.getComputeService();
|
||||||
|
|
||||||
// define the requirements of your node
|
// define the requirements of your node
|
||||||
template = client.templateBuilder().osFamily(UBUNTU).smallest().build();
|
template = client.templateBuilder().osFamily(UBUNTU).smallest().build();
|
||||||
|
|
||||||
// setup a boot user which is the same as your login
|
// setup a boot user which is the same as your login
|
||||||
template.getOptions().runScript(AdminAccess.standard());
|
template.getOptions().runScript(AdminAccess.standard());
|
||||||
|
|
||||||
// these nodes will be accessible via ssh when the call returns
|
// these nodes will be accessible via ssh when the call returns
|
||||||
nodes = client.createNodesInGroup("mycluster", 2, template);
|
nodes = client.createNodesInGroup("mycluster", 2, template);
|
||||||
|
|
||||||
// you can now run ad-hoc commands on the nodes based on predicates
|
// you can now run ad-hoc commands on the nodes based on predicates
|
||||||
responses = client.runScriptOnNodesMatching(inGroup("mycluster"), "uptime", wrapInInitScript(false));
|
responses = client.runScriptOnNodesMatching(inGroup("mycluster"), "uptime", wrapInInitScript(false));
|
||||||
|
```
|
||||||
|
|
||||||
Compute Example (Clojure):
|
Compute Example (Clojure):
|
||||||
|
|
||||||
(use 'org.jclouds.compute2)
|
```clojure
|
||||||
|
(use 'org.jclouds.compute2)
|
||||||
|
|
||||||
; create a compute service using sshj and log4j extensions
|
; create a compute service using sshj and log4j extensions
|
||||||
(def compute (*compute* "trmk`-ecloud" "user" "password" :sshj :log4j))
|
(def compute (*compute* "trmk`-ecloud" "user" "password" :sshj :log4j))
|
||||||
|
|
||||||
; launch a couple nodes with the default operating system, installing your user.
|
; launch a couple nodes with the default operating system, installing your user.
|
||||||
(create-nodes *compute* "mycluster" 2
|
(create-nodes *compute* "mycluster" 2
|
||||||
(TemplateOptions$Builder/runScript (AdminAccess/standard)))
|
(TemplateOptions$Builder/runScript (AdminAccess/standard)))
|
||||||
|
|
||||||
; run a command on that group
|
; run a command on that group
|
||||||
(run-script-on-nodes-matching *compute* (in-group? "mycluster") "uptime"
|
(run-script-on-nodes-matching *compute* (in-group? "mycluster") "uptime"
|
||||||
(RunScriptOptions$Builder/wrapInInitScript false))
|
(RunScriptOptions$Builder/wrapInInitScript false))
|
||||||
|
```
|
||||||
|
|
||||||
Check out https://github.com/jclouds/jclouds-examples for more examples!
|
Check out https://github.com/jclouds/jclouds-examples for more examples!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue