import com.woorea.openstack.nova.model.HostAggregates;
public class AggregatesExtension {
-
+
private final OpenStackClient CLIENT;
-
+
public AggregatesExtension(OpenStackClient client) {
CLIENT = client;
}
-
+
public List list() {
return new List();
}
}
public UpdateAggregateMetadata updateAggregateMetadata(String id,
- String name, String availabilityZone) {
+ String name, String availabilityZone) {
return new UpdateAggregateMetadata(id, name, availabilityZone);
}
}
public class List extends OpenStackRequest<HostAggregates> {
-
+
public List() {
super(CLIENT, HttpMethod.GET, "/os-aggregates",
- null,
- HostAggregates.class);
+ null,
+ HostAggregates.class);
}
}
public ShowAggregate(String id) {
super(CLIENT, HttpMethod.GET,
- new StringBuffer("/os-aggregates/").append(id),
- null,
- HostAggregate.class);
+ new StringBuffer("/os-aggregates/").append(id),
+ null,
+ HostAggregate.class);
}
}
public UpdateAggregateMetadata(String id,
String name, String availabilityZone) {
super(CLIENT, HttpMethod.PUT,
- new StringBuffer("/os-aggregates/").append(id),
- availabilityZone == null ?
- Entity.json("{\"aggregate\": {\"name\": \"" + name + "\" }}")
- :
- Entity.json("{\"aggregate\": {\"name\": \"" +
- name +
- "\", \"availability_zone\": \"" +
- availabilityZone +
- "\" }}"),
- HostAggregate.class);
+ new StringBuffer("/os-aggregates/").append(id),
+ availabilityZone == null ?
+ Entity.json("{\"aggregate\": {\"name\": \"" + name + "\" }}")
+ :
+ Entity.json("{\"aggregate\": {\"name\": \"" +
+ name +
+ "\", \"availability_zone\": \"" +
+ availabilityZone +
+ "\" }}"),
+ HostAggregate.class);
}
}
public CreateAggregate(String name, String availabilityZone) {
super(CLIENT, HttpMethod.POST,
- new StringBuffer("/os-aggregates"),
- availabilityZone == null ?
- Entity.json("{\"aggregate\": {\"name\": \"" +
- name +
- "\", \"availability_zone\": null }}")
- :
- Entity.json("{\"aggregate\": {\"name\": \"" +
- name +
- "\", \"availability_zone\": \"" +
- availabilityZone +
- "\" }}"),
- HostAggregate.class);
+ new StringBuffer("/os-aggregates"),
+ availabilityZone == null ?
+ Entity.json("{\"aggregate\": {\"name\": \"" +
+ name +
+ "\", \"availability_zone\": null }}")
+ :
+ Entity.json("{\"aggregate\": {\"name\": \"" +
+ name +
+ "\", \"availability_zone\": \"" +
+ availabilityZone +
+ "\" }}"),
+ HostAggregate.class);
}
}
public DeleteAggregate(String id) {
super(CLIENT, HttpMethod.DELETE,
- new StringBuffer("/os-aggregates/").append(id),
- null,
- null);
+ new StringBuffer("/os-aggregates/").append(id),
+ null,
+ null);
}
}
public AddHost(String aggregateId, String hostId) {
super(CLIENT, HttpMethod.POST,
- new StringBuffer("/os-aggregates/")
- .append(aggregateId).append("/action"),
- Entity.json("{\"add_host\": {\"host\": \"" +
- hostId + "\" }}"),
- HostAggregate.class);
+ new StringBuffer("/os-aggregates/")
+ .append(aggregateId).append("/action"),
+ Entity.json("{\"add_host\": {\"host\": \"" +
+ hostId + "\" }}"),
+ HostAggregate.class);
}
}
public RemoveHost(String hostId, String aggregateId) {
super(CLIENT, HttpMethod.POST,
- new StringBuffer("/os-aggregates/")
- .append(aggregateId).append("/action"),
- Entity.json("{\"remove_host\": {\"host\": \"" +
- hostId + "\" }}"),
- HostAggregate.class);
+ new StringBuffer("/os-aggregates/")
+ .append(aggregateId).append("/action"),
+ Entity.json("{\"remove_host\": {\"host\": \"" +
+ hostId + "\" }}"),
+ HostAggregate.class);
}
}
public SetMetadata(String aggregateId, String key, String value) {
super(CLIENT, HttpMethod.POST,
- new StringBuffer("/os-aggregates/")
- .append(aggregateId).append("/action"),
- Entity.json("{\"set_metadata\": {\"metadata\": { \"" +
- key + "\": \"" + value + "\" }}}"),
- HostAggregate.class);
+ new StringBuffer("/os-aggregates/")
+ .append(aggregateId).append("/action"),
+ Entity.json("{\"set_metadata\": {\"metadata\": { \"" +
+ key + "\": \"" + value + "\" }}}"),
+ HostAggregate.class);
}
}
}
-