Skip to content

Commit c2ef8f6

Browse files
committed
2 parents 2b83936 + 09752d4 commit c2ef8f6

File tree

8 files changed

+178
-136
lines changed

8 files changed

+178
-136
lines changed

ceilometer-java/ceilometer-collector/src/main/java/org/openstack/ceilometer/collector/handlers/InstanceNotificationHandler.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,48 @@ public Set<MeterEvent> handle(NotificationInfo notificationInfo) {
4646

4747
events.add(m);
4848

49+
m = new MeterEvent();
50+
m.setSource("?");
51+
m.setName("vcpus");
52+
m.setUserId(notificationInfo.getUserId());
53+
m.setProjectId(notificationInfo.getProjectId());
54+
m.setResourceId((String) notificationInfo.getPayload().get("instance_id"));
55+
m.setTimestamp(notificationInfo.getTimestamp());
56+
m.setType("absolute");
57+
m.setDuration(0);
58+
m.setVolume((Number) notificationInfo.getPayload().get("vcpus"));
59+
m.setMetadata(new HashMap<String, Object>());
60+
61+
events.add(m);
62+
63+
m = new MeterEvent();
64+
m.setSource("?");
65+
m.setName("root_disk_size");
66+
m.setUserId(notificationInfo.getUserId());
67+
m.setProjectId(notificationInfo.getProjectId());
68+
m.setResourceId((String) notificationInfo.getPayload().get("instance_id"));
69+
m.setTimestamp(notificationInfo.getTimestamp());
70+
m.setType("absolute");
71+
m.setDuration(0);
72+
m.setVolume((Number) notificationInfo.getPayload().get("root_gb"));
73+
m.setMetadata(new HashMap<String, Object>());
74+
75+
events.add(m);
76+
77+
m = new MeterEvent();
78+
m.setSource("?");
79+
m.setName("ephemeral_disk_size");
80+
m.setUserId(notificationInfo.getUserId());
81+
m.setProjectId(notificationInfo.getProjectId());
82+
m.setResourceId((String) notificationInfo.getPayload().get("instance_id"));
83+
m.setTimestamp(notificationInfo.getTimestamp());
84+
m.setType("absolute");
85+
m.setDuration(0);
86+
m.setVolume((Number) notificationInfo.getPayload().get("ephemeral_gb"));
87+
m.setMetadata(new HashMap<String, Object>());
88+
89+
events.add(m);
90+
4991
return events;
5092

5193
}

keystone-model/src/main/java/org/openstack/keystone/model/Access.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.Serializable;
44
import java.util.Calendar;
55
import java.util.List;
6+
import java.util.Map;
67

78
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
89
import org.codehaus.jackson.annotate.JsonProperty;
@@ -298,6 +299,8 @@ public String toString() {
298299
private List<Service> serviceCatalog;
299300

300301
private User user;
302+
303+
private Map<String, Object> metadata;
301304

302305
/**
303306
* @return the token
@@ -320,15 +323,20 @@ public User getUser() {
320323
return user;
321324
}
322325

326+
/**
327+
* @return the metadata
328+
*/
329+
public Map<String, Object> getMetadata() {
330+
return metadata;
331+
}
332+
323333
/* (non-Javadoc)
324334
* @see java.lang.Object#toString()
325335
*/
326336
@Override
327337
public String toString() {
328338
return "Access [token=" + token + ", serviceCatalog=" + serviceCatalog
329-
+ ", user=" + user + "]";
339+
+ ", user=" + user + ", metadata=" + metadata + "]";
330340
}
331-
332-
333341

334342
}

nova-client/src/main/java/org/openstack/nova/api/extensions/VolumesExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public AttachVolumeToServer(String serverId, String volumeId, String device) {
9999

100100
@Override
101101
public Void execute(WebTarget target) {
102-
target.path("servers").path(serverId).path("os-volume-attachments").request(MediaType.APPLICATION_JSON).post(Entity.json(volumeAttachment));
102+
target.path("servers").path(serverId).path("os-volume_attachments").request(MediaType.APPLICATION_JSON).post(Entity.json(volumeAttachment));
103103
return null;
104104
}
105105

@@ -118,7 +118,7 @@ public DetachVolumeFromServer(String serverId, String volumeId) {
118118

119119
@Override
120120
public Void execute(WebTarget target) {
121-
target.path("servers").path(serverId).path("os-volume-attachments").path(volumeId).request(MediaType.APPLICATION_JSON).delete();
121+
target.path("servers").path(serverId).path("os-volume_attachments").path(volumeId).request(MediaType.APPLICATION_JSON).delete();
122122
return null;
123123
}
124124

nova-model/src/main/java/org/openstack/nova/model/Flavor.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public class Flavor implements Serializable {
3737
private Integer rxtxCap;
3838

3939
private List<Link> links;
40+
41+
@JsonProperty("os-flavor-access:is_public")
42+
private Boolean isPublic;
4043

4144
/**
4245
* @return the id
@@ -191,6 +194,20 @@ public Boolean getDisabled() {
191194
public void setDisabled(Boolean disabled) {
192195
this.disabled = disabled;
193196
}
197+
198+
/**
199+
* @return the isPublic
200+
*/
201+
public Boolean isPublic() {
202+
return isPublic;
203+
}
204+
205+
/**
206+
* @param isPublic the isPublic to set
207+
*/
208+
public void setPublic(Boolean isPublic) {
209+
this.isPublic = isPublic;
210+
}
194211

195212
/**
196213
* @return the links
@@ -215,7 +232,8 @@ public String toString() {
215232
+ ", ram=" + ram + ", disk=" + disk + ", ephemeral="
216233
+ ephemeral + ", swap=" + swap + ", rxtxFactor=" + rxtxFactor
217234
+ ", disabled=" + disabled + ", rxtxQuota=" + rxtxQuota
218-
+ ", rxtxCap=" + rxtxCap + ", links=" + links + "]";
235+
+ ", rxtxCap=" + rxtxCap + ", links=" + links + ", isPublic="
236+
+ isPublic + "]";
219237
}
220238

221239
}

openstack-client/pom.xml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,8 @@
1717
</dependency>
1818
<dependency>
1919
<groupId>org.glassfish.jersey.media</groupId>
20-
<artifactId>jersey-media-json</artifactId>
20+
<artifactId>jersey-media-json-jackson</artifactId>
2121
<version>2.0-SNAPSHOT</version>
22-
<exclusions>
23-
<exclusion>
24-
<groupId>org.codehaus.jettison</groupId>
25-
<artifactId>jettison</artifactId>
26-
</exclusion>
27-
<exclusion>
28-
<groupId>com.sun.xml.bind</groupId>
29-
<artifactId>jaxb-impl</artifactId>
30-
</exclusion>
31-
<exclusion>
32-
<groupId>org.codehaus.jackson</groupId>
33-
<artifactId>jackson-core-asl</artifactId>
34-
</exclusion>
35-
<exclusion>
36-
<groupId>org.codehaus.jackson</groupId>
37-
<artifactId>jackson-mapper-asl</artifactId>
38-
</exclusion>
39-
<exclusion>
40-
<groupId>org.codehaus.jackson</groupId>
41-
<artifactId>jackson-jaxrs</artifactId>
42-
</exclusion>
43-
<exclusion>
44-
<groupId>org.codehaus.jackson</groupId>
45-
<artifactId>jackson-xc</artifactId>
46-
</exclusion>
47-
</exclusions>
4822
</dependency>
4923
<dependency>
5024
<groupId>org.codehaus.jackson</groupId>

openstack-client/src/main/java/org/openstack/OpenStack.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.codehaus.jackson.map.annotate.JsonRootName;
1616
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
1717
import org.glassfish.jersey.filter.LoggingFilter;
18-
import org.glassfish.jersey.media.json.JsonJacksonFeature;
18+
import org.glassfish.jersey.jackson.JacksonFeature;
1919

2020
public class OpenStack {
2121

@@ -47,7 +47,7 @@ private static void initialize() {
4747
WRAPPED_MAPPER.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE);
4848
WRAPPED_MAPPER.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
4949

50-
CLIENT.configuration().register(new JsonJacksonFeature()).register(new ContextResolver<ObjectMapper>() {
50+
CLIENT.configuration().register(new JacksonFeature()).register(new ContextResolver<ObjectMapper>() {
5151

5252
public ObjectMapper getContext(Class<?> type) {
5353
return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER;
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
//package org.openstack.swift.api;
2-
//
3-
//import javax.ws.rs.client.Entity;
4-
//import javax.ws.rs.client.Invocation;
5-
//import javax.ws.rs.client.WebTarget;
6-
//import javax.ws.rs.core.MediaType;
7-
//import javax.ws.rs.core.Response;
8-
//
9-
//import org.openstack.swift.SwiftCommand;
10-
//import org.openstack.swift.model.ObjectForUpload;
11-
//
12-
//public class UploadObject implements SwiftCommand<Response>{
13-
//
14-
// private ObjectForUpload objectForUpload;
15-
//
16-
// public UploadObject(ObjectForUpload objectForUpload) {
17-
// this.objectForUpload = objectForUpload;
18-
// }
19-
//
20-
// @Override
21-
// public Response execute(WebTarget target) {
22-
// Invocation.Builder invocationBuilder = target.path(objectForUpload.getContainer()).path(objectForUpload.getName()).request(MediaType.APPLICATION_JSON);
23-
// for(String key : objectForUpload.getProperties().keySet()) {
24-
// invocationBuilder.header("x-object-meta-" + key, objectForUpload.getProperties().get(key));
25-
// }
26-
// return invocationBuilder.put(Entity.entity(objectForUpload.getInputStream(), MediaType.APPLICATION_OCTET_STREAM), Response.class);
27-
// }
28-
//
29-
//}
1+
package org.openstack.swift.api;
2+
3+
import javax.ws.rs.client.Entity;
4+
import javax.ws.rs.client.Invocation;
5+
import javax.ws.rs.client.WebTarget;
6+
import javax.ws.rs.core.MediaType;
7+
import javax.ws.rs.core.Response;
8+
9+
import org.openstack.swift.SwiftCommand;
10+
import org.openstack.swift.model.ObjectForUpload;
11+
12+
public class UploadObject implements SwiftCommand<Response>{
13+
14+
private ObjectForUpload objectForUpload;
15+
16+
public UploadObject(ObjectForUpload objectForUpload) {
17+
this.objectForUpload = objectForUpload;
18+
}
19+
20+
@Override
21+
public Response execute(WebTarget target) {
22+
Invocation.Builder invocationBuilder = target.path(objectForUpload.getContainer()).path(objectForUpload.getName()).request(MediaType.APPLICATION_JSON);
23+
for(String key : objectForUpload.getProperties().keySet()) {
24+
invocationBuilder.header("x-object-meta-" + key, objectForUpload.getProperties().get(key));
25+
}
26+
return invocationBuilder.put(Entity.entity(objectForUpload.getInputStream(), MediaType.APPLICATION_OCTET_STREAM), Response.class);
27+
}
28+
29+
}

0 commit comments

Comments
 (0)