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