1
package edu.ucsb.eucalyptus.msgs
3
import org.jibx.runtime.BindingDirectory
4
import org.jibx.runtime.IBindingFactory
5
import org.jibx.runtime.IMarshallingContext
7
public class INTERNAL extends EucalyptusMessage {
11
this.userId = "eucalyptus";
12
this.effectiveUserId = "eucalyptus";
16
public class EucalyptusMessage implements Cloneable, Serializable {
20
String effectiveUserId;
24
public EucalyptusMessage()
26
this.correlationId = UUID.randomUUID();
29
public EucalyptusMessage( EucalyptusMessage msg )
32
this.userId = msg.userId;
33
this.effectiveUserId = msg.effectiveUserId;
34
this.correlationId = msg.correlationId;
37
def EucalyptusMessage(final String userId) {
40
this.effectiveUserId = userId;
46
public MetaClass getMetaClass()
51
public String getEffectiveUserId()
53
if ( isAdministrator() ) return "eucalyptus";
54
return effectiveUserId;
57
public boolean isAdministrator()
59
return "eucalyptus".equals(this.effectiveUserId);
62
public String toString()
64
ByteArrayOutputStream temp = new ByteArrayOutputStream();
65
Class targetClass = this.getClass();
66
while ( !targetClass.getSimpleName().endsWith("Type") ) targetClass = targetClass.getSuperclass();
67
IBindingFactory bindingFactory = BindingDirectory.getFactory("msgs_eucalyptus_ucsb_edu", targetClass);
68
IMarshallingContext mctx = bindingFactory.createMarshallingContext();
70
mctx.marshalDocument(this, "UTF-8", null, temp);
71
return temp.toString();
74
public String toString(String namespace)
76
ByteArrayOutputStream temp = new ByteArrayOutputStream();
77
Class targetClass = this.getClass();
78
while ( !targetClass.getSimpleName().endsWith("Type") ) targetClass = targetClass.getSuperclass();
79
IBindingFactory bindingFactory = BindingDirectory.getFactory(namespace, targetClass);
80
IMarshallingContext mctx = bindingFactory.createMarshallingContext();
82
mctx.marshalDocument(this, "UTF-8", null, temp);
91
public EucalyptusMessage getReply()
93
Class msgClass = this.getClass();
94
if ( !this.getClass().getSimpleName().endsWith("Type") )
95
msgClass = msgClass.getSuperclass();
96
Class responseClass = Class.forName(msgClass.getName().replaceAll("Type", "") + "ResponseType");
97
EucalyptusMessage reply = (EucalyptusMessage) responseClass.newInstance();
98
reply.setCorrelationId(this.getCorrelationId());
99
reply.setUserId(this.getUserId());
100
reply.setEffectiveUserId(this.getEffectiveUserId());
105
public class EucalyptusErrorMessageType extends EucalyptusMessage {
109
String requestType = "not available";
111
public EucalyptusErrorMessageType() {}
113
public EucalyptusErrorMessageType(String source, String message)
115
this.source = source;
116
this.message = message;
119
public EucalyptusErrorMessageType(String source, EucalyptusMessage msg, String message)
121
this(source, message);
122
this.correlationId = msg.getCorrelationId();
123
this.userId = msg.getUserId();
124
this.requestType = msg != null ? msg.getClass().getSimpleName() : this.requestType;
127
public String toString()
129
return String.format("SERVICE: %s PROBLEM: %s MSG-TYPE: %s", this.source, this.message, this.requestType);
134
public class EucalyptusData implements Cloneable, Serializable {
135
public MetaClass getMetaClass() {
139
public String toString() {
140
return this.getProperties().toMapString();
143
public Object clone(){
144
return super.clone();
147
/** *******************************************************************************/
148
public class DescribeResourcesType extends EucalyptusMessage {
150
ArrayList<VmTypeInfo> instanceTypes = new ArrayList<VmTypeInfo>();
152
public class DescribeResourcesResponseType extends EucalyptusMessage {
154
ArrayList<ResourceType> resources = new ArrayList<ResourceType>();
155
ArrayList<String> serviceTags = new ArrayList<String>();
158
public class VmTypeInfo extends EucalyptusData {
167
def VmTypeInfo(final name, final memory, final disk, final cores)
170
this.memory = memory;
176
public String toString() {
177
return "VmTypeInfo{" +
178
"name='" + name + '\'' +
179
", memory=" + memory +
186
public class ResourceType extends EucalyptusData {
188
VmTypeInfo instanceType;
190
int availableInstances;
192
public class NetworkConfigType extends EucalyptusData {
194
String ignoredMacAddress;
196
String ignoredPublicIp;
199
def NetworkConfigType()
204
public String toString() {
205
return "NetworkConfigType{" +
206
"macAddress='" + macAddress + '\'' +
207
", ipAddress='" + ipAddress + '\'' +
208
", publicIp='" + ignoredPublicIp + '\'' +
216
public class NetworkParameters extends EucalyptusData {
218
String privateMacAddress;
219
String publicMacAddress;
224
public class PacketFilterRule {
225
public static String ACCEPT = "firewall-open";
226
public static String DENY = "firewall-close";
228
public static PacketFilterRule revoke( PacketFilterRule existingRule ) {
229
PacketFilterRule pf = new PacketFilterRule();
230
pf.destName = existingRule.getDestName();
232
pf.portMin = existingRule.getPortMin();
233
pf.portMax = existingRule.getPortMax();
234
pf.protocol = existingRule.getProtocol();
235
pf.setPeers( existingRule.getPeers() );
236
pf.setSourceCidrs( existingRule.getSourceCidrs() );
237
pf.setSourceNetworkNames( existingRule.getSourceNetworkNames() );
238
pf.setSourceUserNames( existingRule.getSourceUserNames() );
243
String policy = "firewall-open";
247
ArrayList<String> sourceCidrs = new ArrayList<String>();
248
ArrayList<VmNetworkPeer> peers = new ArrayList<VmNetworkPeer>();
249
ArrayList<String> sourceNetworkNames = new ArrayList<String>();
250
ArrayList<String> sourceUserNames = new ArrayList<String>();
252
def PacketFilterRule(final destName, final protocol, final portMin, final portMax)
254
this.destName = destName;
255
this.protocol = protocol;
256
this.portMin = portMin;
257
this.portMax = portMax;
260
def PacketFilterRule(){}
263
public String toString() {
264
return "PacketFilterRule{" +
265
"destName='" + destName + '\'' +
266
", policy='" + policy + '\'' +
267
", protocol='" + protocol + '\'' +
268
", portMin=" + portMin +
269
", portMax=" + portMax +
270
", sourceCidrs=" + sourceCidrs +
272
", sourceNetworkNames=" + sourceNetworkNames +
273
", sourceUserNames=" + sourceUserNames +
278
public void addPeer( String queryKey, String groupName )
280
VmNetworkPeer peer = new VmNetworkPeer( queryKey, groupName );
281
this.peers.add(peer);
282
this.sourceNetworkNames.add( peer.getSourceNetworkName() );
283
this.sourceUserNames.add(peer.userName);
288
public class VmNetworkPeer {
291
String sourceNetworkName;
297
def VmNetworkPeer(final userName, final sourceNetworkName)
299
this.userName = userName;
300
this.sourceNetworkName = sourceNetworkName;
307
public class EventRecord extends EucalyptusMessage {
309
String host = "cloud";
311
long timestamp = System.currentTimeMillis();
313
String eventCorrelationId;
317
def EventRecord(final service, final eventUserId, final eventCorrelationId, final eventId, final other)
319
this.service = service;
320
this.eventUserId = eventUserId;
321
this.eventCorrelationId = eventCorrelationId;
322
this.eventId = eventId;
326
public EventRecord() {}
328
public String toString()
330
return String.format("%s/%s:%s:%s:%s:%7.4f:%s", this.host, this.service, this.eventUserId, this.eventCorrelationId, this.eventId, this.timestamp / 1000.0f, this.other != null ? this.other : "");
333
public static EventRecord create(final service, final eventUserId, final eventCorrelationId, final eventId, final other)
335
return new EventRecord(service, eventUserId, eventCorrelationId, eventId, other);
340
public class GetLogsType extends EucalyptusMessage implements Comparable {
343
def GetLogsType(final serviceTag)
345
this.serviceTag = serviceTag;
347
public int compareTo(Object o)
349
return this.serviceTag.compareTo(((GetLogsType)o).serviceTag);
352
public class GetLogsResponseType extends EucalyptusMessage {
353
NodeLogInfo logs = new NodeLogInfo();
355
public class GetKeysType extends EucalyptusMessage implements Comparable {
358
def GetKeysType(final serviceTag)
360
this.serviceTag = serviceTag;
363
public int compareTo(Object o)
365
return this.serviceTag.compareTo(((GetKeysType)o).serviceTag);
369
public class GetKeysResponseType extends EucalyptusMessage {
370
NodeCertInfo certs = new NodeCertInfo();
373
public class NodeCertInfo extends EucalyptusData implements Comparable {
378
public int compareTo(Object o)
380
return this.serviceTag.compareTo(((NodeCertInfo)o).serviceTag);
384
public String toString() {
385
return "NodeCertInfo{" +
386
"serviceTag='" + serviceTag.replaceAll("services/EucalyptusNC","") + '\'' +
387
", ccCert='" + ccCert + '\'' +
388
", ncCert='" + ncCert + '\'' +
394
public class NodeLogInfo extends EucalyptusData implements Comparable {
398
String httpdLog = "";
399
String axis2Log = "";
401
public int compareTo(Object o)
403
return this.serviceTag.compareTo(((NodeLogInfo)o).serviceTag);
408
public class HeartbeatMessage implements Cloneable, Serializable {
411
def HeartbeatMessage(final String heartbeatId) {
412
this.heartbeatId = heartbeatId;
415
def HeartbeatMessage() {}