Skip to content

Commit 4405fa8

Browse files
committed
Merge pull request woorea#67 from jxiaobin/master
payload logging enhancement
2 parents 5133451 + 04f43e3 commit 4405fa8

File tree

12 files changed

+883
-11
lines changed

12 files changed

+883
-11
lines changed

nova-client/src/main/java/com/woorea/openstack/nova/Nova.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.woorea.openstack.nova.api.ExtensionsResource;
77
import com.woorea.openstack.nova.api.FlavorsResource;
88
import com.woorea.openstack.nova.api.ImagesResource;
9+
import com.woorea.openstack.nova.api.QuotaSetsResource;
910
import com.woorea.openstack.nova.api.ServersResource;
1011
import com.woorea.openstack.nova.api.extensions.AggregatesExtension;
1112
import com.woorea.openstack.nova.api.extensions.FloatingIpsExtension;
@@ -35,6 +36,8 @@ public class Nova extends OpenStackClient {
3536
private final VolumesExtension VOLUMES;
3637

3738
private final AggregatesExtension AGGREGATES;
39+
40+
private final QuotaSetsResource QUOTA_SETS;
3841

3942
public Nova(String endpoint, OpenStackClientConnector connector) {
4043
super(endpoint, connector);
@@ -48,6 +51,7 @@ public Nova(String endpoint, OpenStackClientConnector connector) {
4851
SNAPSHOTS = new SnapshotsExtension(this);
4952
VOLUMES = new VolumesExtension(this);
5053
AGGREGATES = new AggregatesExtension(this);
54+
QUOTA_SETS = new QuotaSetsResource(this);
5155
}
5256

5357
public Nova(String endpoint) {
@@ -90,4 +94,11 @@ public VolumesExtension volumes() {
9094
return VOLUMES;
9195
}
9296

97+
public AggregatesExtension aggregates() {
98+
return AGGREGATES;
99+
}
100+
101+
public QuotaSetsResource quotaSets() {
102+
return QUOTA_SETS;
103+
}
93104
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.woorea.openstack.nova.api;
2+
3+
4+
import com.woorea.openstack.base.client.Entity;
5+
import com.woorea.openstack.base.client.HttpMethod;
6+
import com.woorea.openstack.base.client.OpenStackClient;
7+
import com.woorea.openstack.base.client.OpenStackRequest;
8+
import com.woorea.openstack.nova.model.Limits;
9+
import com.woorea.openstack.nova.model.QuotaSet;
10+
import com.woorea.openstack.nova.model.SimpleTenantUsage;
11+
12+
public class QuotaSetsResource {
13+
14+
private final OpenStackClient CLIENT;
15+
16+
public QuotaSetsResource(OpenStackClient client) {
17+
CLIENT = client;
18+
}
19+
20+
public ShowQuota showQuota(String tenantId) {
21+
return new ShowQuota(tenantId);
22+
}
23+
24+
public UpdateQuota updateQuota(String tenantId, QuotaSet quotaSet) {
25+
return new UpdateQuota(tenantId, quotaSet);
26+
}
27+
28+
public ShowUsage showUsage(String tenantId) {
29+
return new ShowUsage(tenantId);
30+
}
31+
32+
public ShowUsedLimits showUsedLimits() {
33+
return new ShowUsedLimits();
34+
}
35+
36+
public class ShowQuota extends OpenStackRequest<QuotaSet> {
37+
public ShowQuota(String tenantId) {
38+
super(CLIENT, HttpMethod.GET, new StringBuilder("/os-quota-sets/").append(tenantId), null, QuotaSet.class);
39+
}
40+
41+
}
42+
43+
public class UpdateQuota extends OpenStackRequest<QuotaSet> {
44+
public UpdateQuota(String tenantId, QuotaSet quotaSet) {
45+
super(CLIENT, HttpMethod.PUT, new StringBuilder("/os-quota-sets/").append(tenantId), Entity.json(quotaSet), QuotaSet.class);
46+
}
47+
}
48+
49+
public class ShowUsage extends OpenStackRequest<SimpleTenantUsage> {
50+
public ShowUsage(String tenantId) {
51+
super(CLIENT, HttpMethod.GET, new StringBuilder("/os-simple-tenant-usage/").append(tenantId), null, SimpleTenantUsage.class);
52+
}
53+
}
54+
55+
public class ShowUsedLimits extends OpenStackRequest<Limits> {
56+
public ShowUsedLimits() {
57+
super(CLIENT, HttpMethod.GET, new StringBuilder("/limits"), null, Limits.class);
58+
}
59+
}
60+
}
61+

nova-model/src/main/java/com/woorea/openstack/nova/model/Limits.java

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public static final class LimitEntry implements Serializable {
2525

2626
private Integer available;
2727

28+
private Integer value;
29+
2830
/**
2931
* @return the nextAvailable
3032
*/
@@ -60,14 +62,20 @@ public Integer getAvailable() {
6062
return available;
6163
}
6264

65+
/**
66+
* @return the value
67+
*/
68+
public Integer getValue() {
69+
return value;
70+
}
6371
/* (non-Javadoc)
6472
* @see java.lang.Object#toString()
6573
*/
6674
@Override
6775
public String toString() {
6876
return "LimitEntry [nextAvailable=" + nextAvailable + ", unit="
6977
+ unit + ", verb=" + verb + ", remaining=" + remaining
70-
+ ", available=" + available + "]";
78+
+ ", available=" + available + ", value=" + value + "]";
7179
}
7280

7381

@@ -128,6 +136,32 @@ private static final class AbsoluteLimit {
128136

129137
private Integer maxTotalRAMSize;
130138

139+
private Integer totalVolumesUsed;
140+
141+
private Integer maxSecurityGroupRules;
142+
143+
private Integer maxTotalKeypairs;
144+
145+
private Integer totalCoresUsed;
146+
147+
private Integer maxTotalVolumes;
148+
149+
private Integer totalRAMUsed;
150+
151+
private Integer totalInstancesUsed;
152+
153+
private Integer maxSecurityGroups;
154+
155+
private Integer totalVolumeGigabytesUsed;
156+
157+
private Integer totalSecurityGroupsUsed;
158+
159+
private Integer maxTotalFloatingIps;
160+
161+
private Integer totalKeyPairsUsed;
162+
163+
private Integer maxTotalVolumeGigabytes;
164+
131165
/**
132166
* @return the maxServerMeta
133167
*/
@@ -177,6 +211,58 @@ public Integer getMaxTotalRAMSize() {
177211
return maxTotalRAMSize;
178212
}
179213

214+
public Integer getTotalVolumesUsed() {
215+
return totalVolumesUsed;
216+
}
217+
218+
public Integer getMaxSecurityGroupRules() {
219+
return maxSecurityGroupRules;
220+
}
221+
222+
public Integer getMaxTotalKeypairs() {
223+
return maxTotalKeypairs;
224+
}
225+
226+
public Integer getTotalCoresUsed() {
227+
return totalCoresUsed;
228+
}
229+
230+
public Integer getMaxTotalVolumes() {
231+
return maxTotalVolumes;
232+
}
233+
234+
public Integer getTotalRAMUsed() {
235+
return totalRAMUsed;
236+
}
237+
238+
public Integer getTotalInstancesUsed() {
239+
return totalInstancesUsed;
240+
}
241+
242+
public Integer getMaxSecurityGroups() {
243+
return maxSecurityGroups;
244+
}
245+
246+
public Integer getTotalVolumeGigabytesUsed() {
247+
return totalVolumeGigabytesUsed;
248+
}
249+
250+
public Integer getTotalSecurityGroupsUsed() {
251+
return totalSecurityGroupsUsed;
252+
}
253+
254+
public Integer getMaxTotalFloatingIps() {
255+
return maxTotalFloatingIps;
256+
}
257+
258+
public Integer getTotalKeyPairsUsed() {
259+
return totalKeyPairsUsed;
260+
}
261+
262+
public Integer getMaxTotalVolumeGigabytes() {
263+
return maxTotalVolumeGigabytes;
264+
}
265+
180266
/* (non-Javadoc)
181267
* @see java.lang.Object#toString()
182268
*/

nova-model/src/main/java/com/woorea/openstack/nova/model/QuotaSet.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public class QuotaSet {
3636
@JsonProperty("security_group_rules")
3737
private Integer securityGroupRules;
3838

39+
@JsonProperty("injected_file_path_bytes")
40+
private Integer injectedFilePathBytes;
41+
42+
@JsonProperty("key_pairs")
43+
private Integer keyPairs;
44+
3945
public String getId() {
4046
return id;
4147
}
@@ -131,5 +137,20 @@ public Integer getSecurityGroupRules() {
131137
public void setSecurityGroupRules(Integer securityGroupRules) {
132138
this.securityGroupRules = securityGroupRules;
133139
}
134-
135-
}
140+
141+
public Integer getKeyPairs() {
142+
return keyPairs;
143+
}
144+
145+
public void setKeyPairs(Integer keyPairs) {
146+
this.keyPairs = keyPairs;
147+
}
148+
149+
public Integer getInjectedFilePathBytes() {
150+
return injectedFilePathBytes;
151+
}
152+
153+
public void setInjectedFilePathBytes(Integer injectedFilePathBytes) {
154+
this.injectedFilePathBytes = injectedFilePathBytes;
155+
}
156+
}

nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsage.java

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.Serializable;
44
import java.math.BigDecimal;
5+
import java.util.List;
56

67
import org.codehaus.jackson.annotate.JsonProperty;
78
import org.codehaus.jackson.map.annotate.JsonRootName;
@@ -28,6 +29,9 @@ public class SimpleTenantUsage implements Serializable {
2829
@JsonProperty("total_hours")
2930
private String totalHours;
3031

32+
@JsonProperty("server_usages")
33+
private List<ServerUsage> serverUsages;
34+
3135
/**
3236
* @return the totalMemoryMbUsage
3337
*/
@@ -126,6 +130,14 @@ public void setTotalHours(String totalHours) {
126130
this.totalHours = totalHours;
127131
}
128132

133+
public List<ServerUsage> getServerUsages() {
134+
return serverUsages;
135+
}
136+
137+
public void setServerUsages(List<ServerUsage> serverUsages) {
138+
this.serverUsages = serverUsages;
139+
}
140+
129141
/* (non-Javadoc)
130142
* @see java.lang.Object#toString()
131143
*/
@@ -138,5 +150,83 @@ public String toString() {
138150
+ ", totalHours=" + totalHours + "]";
139151
}
140152

153+
public static final class ServerUsage implements Serializable {
154+
@JsonProperty("instance_id")
155+
private String instanceId;
156+
157+
private Integer uptime;
158+
159+
@JsonProperty("started_at")
160+
private String startedAt;
141161

162+
@JsonProperty("ended_at")
163+
private String endedAt;
164+
165+
@JsonProperty("memory_mb")
166+
private Integer memoryMb;
167+
168+
@JsonProperty("tenant_id")
169+
private String tenantId;
170+
171+
private String state;
172+
173+
private Double hours;
174+
175+
private Integer vcpus;
176+
177+
private String flavor;
178+
179+
@JsonProperty("local_gb")
180+
private Integer localDiskSize;
181+
182+
private String name;
183+
184+
public String getInstanceId() {
185+
return instanceId;
186+
}
187+
188+
public Integer getUptime() {
189+
return uptime;
190+
}
191+
192+
public String getStartedAt() {
193+
return startedAt;
194+
}
195+
196+
public String getEndedAt() {
197+
return endedAt;
198+
}
199+
200+
public Integer getMemoryMb() {
201+
return memoryMb;
202+
}
203+
204+
public String getTenantId() {
205+
return tenantId;
206+
}
207+
208+
public String getState() {
209+
return state;
210+
}
211+
212+
public Double getHours() {
213+
return hours;
214+
}
215+
216+
public Integer getVcpus() {
217+
return vcpus;
218+
}
219+
220+
public String getFlavor() {
221+
return flavor;
222+
}
223+
224+
public Integer getLocalDiskSize() {
225+
return localDiskSize;
226+
}
227+
228+
public String getName() {
229+
return name;
230+
}
231+
}
142232
}

0 commit comments

Comments
 (0)