mirror of https://github.com/apache/jclouds.git
Merge pull request #285 from mattstep/master
Add vcpu count to flavor domain object in nova api.
This commit is contained in:
commit
5f1d418ab9
|
@ -27,54 +27,47 @@ package org.jclouds.openstack.nova.domain;
|
||||||
*/
|
*/
|
||||||
public class Flavor extends Resource {
|
public class Flavor extends Resource {
|
||||||
|
|
||||||
public Flavor() {
|
private final int id;
|
||||||
|
private final String name;
|
||||||
|
private final Integer disk;
|
||||||
|
private final Integer ram;
|
||||||
|
private final Integer vcpus;
|
||||||
|
|
||||||
|
//Required because of how Gson is being used to do wire marshalling with the Server class
|
||||||
|
private Flavor(){
|
||||||
|
id=0;
|
||||||
|
name=null;
|
||||||
|
disk=null;
|
||||||
|
ram=null;
|
||||||
|
vcpus=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Flavor(int id, String name, Integer disk, Integer ram, Integer vcpus) {
|
||||||
public String toString() {
|
|
||||||
return "Flavor [disk=" + disk + ", id=" + id + ", name=" + name + ", ram=" + ram + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Flavor(int id, String name) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.disk = disk;
|
||||||
|
this.ram = ram;
|
||||||
|
this.vcpus = vcpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id;
|
|
||||||
private String name;
|
|
||||||
private Integer disk;
|
|
||||||
private Integer ram;
|
|
||||||
|
|
||||||
public Integer getDisk() {
|
public Integer getDisk() {
|
||||||
return disk;
|
return disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisk(Integer value) {
|
|
||||||
this.disk = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int value) {
|
|
||||||
this.id = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String value) {
|
|
||||||
this.name = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getRam() {
|
public Integer getRam() {
|
||||||
return ram;
|
return ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRam(Integer value) {
|
public Integer getVcpus() {
|
||||||
this.ram = value;
|
return vcpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,6 +78,7 @@ public class Flavor extends Resource {
|
||||||
result = prime * result + id;
|
result = prime * result + id;
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((ram == null) ? 0 : ram.hashCode());
|
result = prime * result + ((ram == null) ? 0 : ram.hashCode());
|
||||||
|
result = prime * result + ((vcpus == null) ? 0 : vcpus.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +108,16 @@ public class Flavor extends Resource {
|
||||||
return false;
|
return false;
|
||||||
} else if (!ram.equals(other.ram))
|
} else if (!ram.equals(other.ram))
|
||||||
return false;
|
return false;
|
||||||
|
if (vcpus == null) {
|
||||||
|
if (other.vcpus != null)
|
||||||
|
return false;
|
||||||
|
} else if (!vcpus.equals(other.vcpus))
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Flavor [disk=" + disk + ", id=" + id + ", name=" + name + ", ram=" + ram + ", vcpus=" + vcpus +"]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,11 @@ public class Resource {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ConcurrentSkipListMap<LinkType,URI> orderedSelfReferences = new ConcurrentSkipListMap<LinkType,URI>();
|
private final ConcurrentSkipListMap<LinkType,URI> orderedSelfReferences;
|
||||||
|
|
||||||
|
public Resource(){
|
||||||
|
orderedSelfReferences = new ConcurrentSkipListMap<LinkType,URI>();
|
||||||
|
}
|
||||||
|
|
||||||
private void populateOrderedSelfReferences() {
|
private void populateOrderedSelfReferences() {
|
||||||
for (Map<String, String> linkProperties : links) {
|
for (Map<String, String> linkProperties : links) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class FlavorToHardwareTest {
|
||||||
public void test() throws UnknownHostException, URISyntaxException {
|
public void test() throws UnknownHostException, URISyntaxException {
|
||||||
Hardware flavor = convertFlavor();
|
Hardware flavor = convertFlavor();
|
||||||
Hardware tempFlavor = new HardwareBuilder().ids("1").name("256 MB Server")
|
Hardware tempFlavor = new HardwareBuilder().ids("1").name("256 MB Server")
|
||||||
.processors(ImmutableList.of(new Processor(1.0, 1.0)))
|
.processors(ImmutableList.of(new Processor(2.0, 2.0)))
|
||||||
.ram(256)
|
.ram(256)
|
||||||
.volumes(ImmutableList.of(
|
.volumes(ImmutableList.of(
|
||||||
new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true).bootDevice(true).build()))
|
new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true).bootDevice(true).build()))
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class ParseFlavorFromJsonResponseTest {
|
||||||
assertEquals(response.getName(), "256 MB Server");
|
assertEquals(response.getName(), "256 MB Server");
|
||||||
assertEquals(response.getDisk().intValue(), 10);
|
assertEquals(response.getDisk().intValue(), 10);
|
||||||
assertEquals(response.getRam().intValue(), 256);
|
assertEquals(response.getRam().intValue(), 256);
|
||||||
|
assertEquals(response.getVcpus().intValue(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Flavor parseFlavor() {
|
public static Flavor parseFlavor() {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ParseFlavorListFromJsonResponseTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
InputStream is = getClass().getResourceAsStream("/test_list_flavors.json");
|
InputStream is = getClass().getResourceAsStream("/test_list_flavors.json");
|
||||||
|
|
||||||
List<Flavor> expects = ImmutableList.of(new Flavor(1, "256 MB Server"), new Flavor(2, "512 MB Server"));
|
List<Flavor> expects = ImmutableList.of(new Flavor(1, "256 MB Server", null, null, null), new Flavor(2, "512 MB Server", null, null, null));
|
||||||
|
|
||||||
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
|
||||||
|
@ -69,13 +69,15 @@ public class ParseFlavorListFromJsonResponseTest {
|
||||||
List<Flavor> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<Flavor> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||||
assertEquals(response.get(0).getId(), 1);
|
assertEquals(response.get(0).getId(), 1);
|
||||||
assertEquals(response.get(0).getName(), "256 MB Server");
|
assertEquals(response.get(0).getName(), "256 MB Server");
|
||||||
assertEquals(response.get(0).getDisk(), new Integer(10));
|
assertEquals(response.get(0).getDisk(), Integer.valueOf(10));
|
||||||
assertEquals(response.get(0).getRam(), new Integer(256));
|
assertEquals(response.get(0).getRam(), Integer.valueOf(256));
|
||||||
|
assertEquals(response.get(0).getVcpus(), Integer.valueOf(2));
|
||||||
|
|
||||||
assertEquals(response.get(1).getId(), 2);
|
assertEquals(response.get(1).getId(), 2);
|
||||||
assertEquals(response.get(1).getName(), "512 MB Server");
|
assertEquals(response.get(1).getName(), "512 MB Server");
|
||||||
assertEquals(response.get(1).getDisk(), new Integer(20));
|
assertEquals(response.get(1).getDisk(), Integer.valueOf(20));
|
||||||
assertEquals(response.get(1).getRam(), new Integer(512));
|
assertEquals(response.get(1).getRam(), Integer.valueOf(512));
|
||||||
|
assertEquals(response.get(1).getVcpus(), Integer.valueOf(5));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"name" : "256 MB Server",
|
"name" : "256 MB Server",
|
||||||
"ram" : 256,
|
"ram" : 256,
|
||||||
"disk" : 10,
|
"disk" : 10,
|
||||||
|
"vcpus" : 2,
|
||||||
"links": [
|
"links": [
|
||||||
{
|
{
|
||||||
"rel" : "self",
|
"rel" : "self",
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"name" : "256 MB Server",
|
"name" : "256 MB Server",
|
||||||
"ram" : 256,
|
"ram" : 256,
|
||||||
"disk" : 10,
|
"disk" : 10,
|
||||||
|
"vcpus" : 2,
|
||||||
"links": [
|
"links": [
|
||||||
{
|
{
|
||||||
"rel" : "self",
|
"rel" : "self",
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
"name" : "512 MB Server",
|
"name" : "512 MB Server",
|
||||||
"ram" : 512,
|
"ram" : 512,
|
||||||
"disk" : 20,
|
"disk" : 20,
|
||||||
|
"vcpus" : 5,
|
||||||
"links": [
|
"links": [
|
||||||
{
|
{
|
||||||
"rel" : "self",
|
"rel" : "self",
|
||||||
|
|
Loading…
Reference in New Issue