mirror of https://github.com/apache/jclouds.git
updated ant to work with single nodes
This commit is contained in:
parent
9b9f9c4e9c
commit
f4f79330c6
|
@ -2,4 +2,4 @@ service=ec2
|
|||
driver=aws
|
||||
account=accesskeyid
|
||||
key=secretaccesskey
|
||||
nodetag=we_create_and_delete_based_on_key_and_security_group_name_not_instance_id
|
||||
tag=we_create_and_delete_based_on_key_and_security_group_name_not_instance_id
|
||||
|
|
|
@ -2,4 +2,4 @@ service=gogrid
|
|||
driver=gogrid
|
||||
account=apikey_not_your_email
|
||||
key=shared_secret_not_your_password
|
||||
nodetag=name_of_your_server
|
||||
tag=name_of_your_server
|
||||
|
|
|
@ -2,4 +2,4 @@ service=hostingdotcom
|
|||
driver=hostingdotcom
|
||||
account=user@youregistered.com
|
||||
key=password
|
||||
nodetag=name_of_your_vapp
|
||||
tag=name_of_your_vapp
|
||||
|
|
|
@ -2,4 +2,4 @@ service=cloudservers
|
|||
driver=rackspace
|
||||
account=user
|
||||
key=your_key
|
||||
nodetag=name_of_your_server
|
||||
tag=name_of_your_server
|
||||
|
|
|
@ -2,4 +2,4 @@ service=rimuhosting
|
|||
driver=rimuhosting
|
||||
account=apikey
|
||||
key=apikey
|
||||
nodetag=name_of_your_server
|
||||
tag=name_of_your_server
|
||||
|
|
|
@ -2,4 +2,4 @@ service=terremark
|
|||
driver=terremark
|
||||
account=user@youregistered.com
|
||||
key=password
|
||||
nodetag=name_of_your_vapp
|
||||
tag=name_of_your_vapp
|
||||
|
|
|
@ -4,4 +4,4 @@ driver=vcloud
|
|||
vcloud.endpoint=https://vcloud_host_you_want/api
|
||||
account=user@youregistered.com
|
||||
key=password
|
||||
nodetag=name_of_your_vapp
|
||||
tag=name_of_your_vapp
|
||||
|
|
|
@ -93,44 +93,86 @@
|
|||
<compute actions="list-locations,list-sizes,list-images,list-details" provider="${jclouds.compute.url}" />
|
||||
</target>
|
||||
|
||||
<target name="reboot" description="reboot the node ${nodetag}">
|
||||
<target name="reboot" depends="reboot-id,reboot-tag" />
|
||||
|
||||
<target name="reboot-id" description="reboot the node ${id}" unless="tag">
|
||||
|
||||
<input
|
||||
message="Which node do you wish to reboot"
|
||||
addproperty="nodetag"
|
||||
addproperty="id"
|
||||
/>
|
||||
|
||||
<compute actions="reboot" provider="${jclouds.compute.url}">
|
||||
<nodes tag="${nodetag}" />
|
||||
<nodes id="${id}" />
|
||||
</compute>
|
||||
</target>
|
||||
|
||||
<target name="destroy" description="destroy the node ${nodetag}">
|
||||
<target name="reboot-tag" description="reboot the nodes with tag ${tag}" unless="id" >
|
||||
|
||||
<input
|
||||
message="Which tag do you wish to reboot"
|
||||
addproperty="tag"
|
||||
/>
|
||||
|
||||
<compute actions="reboot" provider="${jclouds.compute.url}">
|
||||
<nodes tag="${tag}" />
|
||||
</compute>
|
||||
</target>
|
||||
|
||||
<target name="destroy" depends="destroy-id,destroy-tag" />
|
||||
|
||||
<target name="destroy-id" description="destroy the node ${id}" unless="tag">
|
||||
|
||||
<input
|
||||
message="Which node do you wish to destroy"
|
||||
addproperty="nodetag"
|
||||
addproperty="id"
|
||||
/>
|
||||
|
||||
<compute actions="destroy" provider="${jclouds.compute.url}">
|
||||
<nodes tag="${nodetag}" />
|
||||
<nodes id="${id}" />
|
||||
</compute>
|
||||
</target>
|
||||
|
||||
<target name="get" description="get the node ${nodetag}">
|
||||
<target name="destroy-tag" description="destroy the nodes with tag ${tag}" unless="id" >
|
||||
|
||||
<input
|
||||
message="Which node do you wish to describe?"
|
||||
addproperty="nodetag"
|
||||
message="Which tag do you wish to destroy"
|
||||
addproperty="tag"
|
||||
/>
|
||||
|
||||
<compute actions="destroy" provider="${jclouds.compute.url}">
|
||||
<nodes tag="${tag}" />
|
||||
</compute>
|
||||
</target>
|
||||
|
||||
<target name="get" depends="get-tag,get-id" />
|
||||
|
||||
<target name="get-id" description="get the node ${id}" unless="tag">
|
||||
|
||||
<input
|
||||
message="Which node do you wish to get"
|
||||
addproperty="id"
|
||||
/>
|
||||
|
||||
<compute actions="get" provider="${jclouds.compute.url}">
|
||||
<nodes tag="${nodetag}" />
|
||||
<nodes id="${id}" />
|
||||
</compute>
|
||||
</target>
|
||||
|
||||
<target name="get-tag" description="get the nodes with tag ${tag}" unless="id" >
|
||||
|
||||
<input
|
||||
message="Which tag do you wish to get"
|
||||
addproperty="tag"
|
||||
/>
|
||||
|
||||
<compute actions="get" provider="${jclouds.compute.url}">
|
||||
<nodes tag="${tag}" />
|
||||
</compute>
|
||||
</target>
|
||||
|
||||
<property name="location" value="" />
|
||||
<target name="create" description="create the node ${nodetag}">
|
||||
<target name="create" description="create the node ${tag}">
|
||||
<property name="privatekeyfile" value="${user.home}/.ssh/id_rsa" />
|
||||
<property name="publickeyfile" value="${user.home}/.ssh/id_rsa.pub" />
|
||||
<property name="os" value="UBUNTU" />
|
||||
|
@ -138,11 +180,11 @@
|
|||
|
||||
<input
|
||||
message="What do you want to tag your nodes with?"
|
||||
addproperty="nodetag"
|
||||
addproperty="tag"
|
||||
/>
|
||||
|
||||
<compute actions="create" provider="${jclouds.compute.url}">
|
||||
<nodes privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}" tag="${nodetag}" count="${count}" os="${os}" size="SMALLEST" hostproperty="host" usernameproperty="username" passwordproperty="password" />
|
||||
<nodes privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}" tag="${tag}" count="${count}" os="${os}" size="SMALLEST" hostproperty="host" usernameproperty="username" passwordproperty="password" />
|
||||
</compute>
|
||||
</target>
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ComputeTask extends Task {
|
|||
}
|
||||
|
||||
public static enum Action {
|
||||
CREATE, GET, LIST, LIST_DETAILS, DESTROY, LIST_IMAGES, LIST_SIZES, LIST_LOCATIONS
|
||||
CREATE, GET, LIST, LIST_DETAILS, DESTROY, REBOOT, LIST_IMAGES, LIST_SIZES, LIST_LOCATIONS
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,6 +110,7 @@ public class ComputeTask extends Task {
|
|||
case CREATE:
|
||||
case GET:
|
||||
case DESTROY:
|
||||
case REBOOT:
|
||||
if (nodeElement != null) {
|
||||
switch (action) {
|
||||
case CREATE:
|
||||
|
@ -121,6 +122,9 @@ public class ComputeTask extends Task {
|
|||
case DESTROY:
|
||||
destroy(computeService);
|
||||
break;
|
||||
case REBOOT:
|
||||
reboot(computeService);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.log("missing node element for action: " + action, Project.MSG_ERR);
|
||||
|
@ -160,9 +164,9 @@ public class ComputeTask extends Task {
|
|||
log(String
|
||||
.format(
|
||||
" image location=%s, id=%s, name=%s, version=%s, arch=%s, osfam=%s, osdesc=%s, desc=%s",
|
||||
image.getLocation(), image.getProviderId(), image.getName(), image.getVersion(),
|
||||
image.getArchitecture(), image.getOsFamily(), image.getOsDescription(),
|
||||
image.getDescription()));
|
||||
image.getLocation(), image.getProviderId(), image.getName(), image
|
||||
.getVersion(), image.getArchitecture(), image.getOsFamily(),
|
||||
image.getOsDescription(), image.getDescription()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,8 +189,8 @@ public class ComputeTask extends Task {
|
|||
private void list(ComputeService computeService) {
|
||||
log("list");
|
||||
for (ComputeMetadata node : computeService.listNodes()) {
|
||||
log(String.format(" location=%s, id=%s, tag=%s", node.getLocation(), node.getProviderId(), node
|
||||
.getName()));
|
||||
log(String.format(" location=%s, id=%s, tag=%s", node.getLocation(), node
|
||||
.getProviderId(), node.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,19 +223,39 @@ public class ComputeTask extends Task {
|
|||
createdNode.getCredentials().account);
|
||||
}
|
||||
|
||||
private void reboot(ComputeService computeService) {
|
||||
if (nodeElement.getId() != null) {
|
||||
log(String.format("reboot id: %s", nodeElement.getId()));
|
||||
computeService.rebootNode(nodeElement.getId());
|
||||
} else {
|
||||
log(String.format("reboot tag: %s", nodeElement.getTag()));
|
||||
computeService.rebootNodesMatching(NodePredicates.withTag(nodeElement.getTag()));
|
||||
}
|
||||
}
|
||||
|
||||
private void destroy(ComputeService computeService) {
|
||||
if (nodeElement.getId() != null) {
|
||||
log(String.format("destroy id: %s", nodeElement.getId()));
|
||||
computeService.destroyNode(nodeElement.getId());
|
||||
} else {
|
||||
log(String.format("destroy tag: %s", nodeElement.getTag()));
|
||||
computeService.destroyNodesMatching(NodePredicates.withTag(nodeElement.getTag()));
|
||||
}
|
||||
}
|
||||
|
||||
private void get(ComputeService computeService) {
|
||||
if (nodeElement.getId() != null) {
|
||||
log(String.format("get id: %s", nodeElement.getId()));
|
||||
logDetails(computeService, computeService.getNodeMetadata(nodeElement.getId()));
|
||||
} else {
|
||||
log(String.format("get tag: %s", nodeElement.getTag()));
|
||||
for (ComputeMetadata node : Iterables.filter(computeService
|
||||
.listNodesDetailsMatching(NodePredicates.all()), NodePredicates.withTag(nodeElement
|
||||
.getTag()))) {
|
||||
.listNodesDetailsMatching(NodePredicates.all()), NodePredicates
|
||||
.withTag(nodeElement.getTag()))) {
|
||||
logDetails(computeService, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void logDetails(ComputeService computeService, ComputeMetadata node) {
|
||||
NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node)
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.File;
|
|||
* @author Ivan Meredith
|
||||
*/
|
||||
public class NodeElement {
|
||||
private String id;
|
||||
private String tag;
|
||||
private String size;
|
||||
private String os;
|
||||
|
@ -169,4 +170,12 @@ public class NodeElement {
|
|||
return publickeyfile;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue