~ubuntu-branches/ubuntu/maverick/eucalyptus/maverick

« back to all changes in this revision

Viewing changes to clc/modules/msgs/src/main/java/edu/ucsb/eucalyptus/cloud/Extra.groovy

  • Committer: Bazaar Package Importer
  • Author(s): Dave Walker (Daviey)
  • Date: 2010-07-21 17:27:10 UTC
  • mfrom: (1.1.38 upstream)
  • Revision ID: james.westby@ubuntu.com-20100721172710-7xv07dmdqgivc3t9
Tags: 2.0~bzr1211-0ubuntu1
* New major upstream version merge, 2.0 (r1211).
* debian/patches/:
  - 01-wsdl-stubs.patch, debian/wsdl.md5sums: wsdl stubs updated.
  - 02-Makefile.patch: Updated to reflect new code layout.
  - 07-local_support_euca_conf-in.patch: Updated to reflect new code layout.
  - 08-ubuntu-default-networking.patch: Refreshed.
  - 09-small-128-192MB.patch: Updated to point to new location.
  - 10-disable-iscsi.patch: Refreshed.
  - 11-state-cleanup-memleakfix.patch: Removed, fixed upstream.
  - 15-fix-default-ramdisk.patch: Updated to point to new location.
  - 16-kvm_libvirt_xml_default_use_kvm.patch: Updated to reflect changes.
  - 17-fix_walrus_OOM_errors.patch: Removed, fixed upstream.
  - 18-priv_security.patch: Updated to reflect upstream changes.
  - 20-brute-force-webui.patch: Updated to reflect upstream changes. 
  - 21-eucalyptus-1.7-with-gwt-1.6.4.patch: New patch, allows 
    eucalyptus-1.7 to be built against gwt 1.6.4. Based on patch courtesy 
    of Dmitrii Zagorodnov, upstream. (LP: #597330)
* debian/eucalyptus-java-common.links: 
  - Changed symlink for groovy, point to groovy.all.jar, making compatiable 
    with groovy versions >1.7. (LP: #595421)
  - Added ant.jar & jetty-rewrite-handler.jar as they are now required.
* debian/control
  - & debian/build-jars: Added libjavassist-java and libjetty-extra-java as 
    build dependencies.
  - Added libjetty-extra-java as a dependency of eucalyptus-java-common
* The binary resulting jar's have been renamed from eucalyptus-*-1.6.2.jar
  to eucalyptus-*-main.jar:    
  - debian/eucalyptus-cc.upstart
  - debian/eucalyptus-cloud.install
  - debian/eucalyptus-common.eucalyptus.upstart
  - debian/eucalyptus-java-common.install
  - debian/eucalyptus-network.upstart
  - debian/eucalyptus-sc.install
  - debian/eucalyptus-walrus.install
* debian/eucalyptus-java-common.install: New upstream jars that have been
  installed:
  - eucalyptus-db-hsqldb-ext-main.jar
  - eucalyptus-component-main.jar
* debian/control:
  - Updated Standards Version to 3.8.4 (no change)
  - Updated the upstream Homepage to: http://open.eucalyptus.com/
  - Changed Vcs-Bzr to reflect new location of Ubuntu hosted development branch.
  - Made the Build Dependency of groovy and the binary eucalyptus-java-common
    package depend on version >=1.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************************
2
 
*Copyright (c) 2009  Eucalyptus Systems, Inc.
3
 
4
 
*  This program is free software: you can redistribute it and/or modify
5
 
*  it under the terms of the GNU General Public License as published by
6
 
*  the Free Software Foundation, only version 3 of the License.
7
 
8
 
9
 
*  This file is distributed in the hope that it will be useful, but WITHOUT
10
 
*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 
*  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 
*  for more details.
13
 
14
 
*  You should have received a copy of the GNU General Public License along
15
 
*  with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
 
*  Please contact Eucalyptus Systems, Inc., 130 Castilian
18
 
*  Dr., Goleta, CA 93101 USA or visit <http://www.eucalyptus.com/licenses/>
19
 
*  if you need additional information or have any questions.
20
 
21
 
*  This file may incorporate work covered under the following copyright and
22
 
*  permission notice:
23
 
24
 
*    Software License Agreement (BSD License)
25
 
26
 
*    Copyright (c) 2008, Regents of the University of California
27
 
*    All rights reserved.
28
 
29
 
*    Redistribution and use of this software in source and binary forms, with
30
 
*    or without modification, are permitted provided that the following
31
 
*    conditions are met:
32
 
33
 
*      Redistributions of source code must retain the above copyright notice,
34
 
*      this list of conditions and the following disclaimer.
35
 
36
 
*      Redistributions in binary form must reproduce the above copyright
37
 
*      notice, this list of conditions and the following disclaimer in the
38
 
*      documentation and/or other materials provided with the distribution.
39
 
40
 
*    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
41
 
*    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
42
 
*    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
43
 
*    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
44
 
*    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45
 
*    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
46
 
*    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
47
 
*    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
48
 
*    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
49
 
*    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50
 
*    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. USERS OF
51
 
*    THIS SOFTWARE ACKNOWLEDGE THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE
52
 
*    LICENSED MATERIAL, COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS
53
 
*    SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
54
 
*    IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
55
 
*    BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
56
 
*    THE REGENTS’ DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
57
 
*    OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
58
 
*    WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
59
 
*    ANY SUCH LICENSES OR RIGHTS.
60
 
*******************************************************************************/
 
2
 *Copyright (c) 2009  Eucalyptus Systems, Inc.
 
3
 * 
 
4
 *  This program is free software: you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation, only version 3 of the License.
 
7
 * 
 
8
 * 
 
9
 *  This file is distributed in the hope that it will be useful, but WITHOUT
 
10
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
 *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
12
 *  for more details.
 
13
 * 
 
14
 *  You should have received a copy of the GNU General Public License along
 
15
 *  with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 * 
 
17
 *  Please contact Eucalyptus Systems, Inc., 130 Castilian
 
18
 *  Dr., Goleta, CA 93101 USA or visit <http://www.eucalyptus.com/licenses/>
 
19
 *  if you need additional information or have any questions.
 
20
 * 
 
21
 *  This file may incorporate work covered under the following copyright and
 
22
 *  permission notice:
 
23
 * 
 
24
 *    Software License Agreement (BSD License)
 
25
 * 
 
26
 *    Copyright (c) 2008, Regents of the University of California
 
27
 *    All rights reserved.
 
28
 * 
 
29
 *    Redistribution and use of this software in source and binary forms, with
 
30
 *    or without modification, are permitted provided that the following
 
31
 *    conditions are met:
 
32
 * 
 
33
 *      Redistributions of source code must retain the above copyright notice,
 
34
 *      this list of conditions and the following disclaimer.
 
35
 * 
 
36
 *      Redistributions in binary form must reproduce the above copyright
 
37
 *      notice, this list of conditions and the following disclaimer in the
 
38
 *      documentation and/or other materials provided with the distribution.
 
39
 * 
 
40
 *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 
41
 *    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 
42
 *    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 
43
 *    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 
44
 *    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
45
 *    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
46
 *    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
47
 *    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
48
 *    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
49
 *    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
50
 *    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. USERS OF
 
51
 *    THIS SOFTWARE ACKNOWLEDGE THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE
 
52
 *    LICENSED MATERIAL, COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS
 
53
 *    SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
 
54
 *    IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
 
55
 *    BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
 
56
 *    THE REGENTS’ DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
 
57
 *    OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
 
58
 *    WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
 
59
 *    ANY SUCH LICENSES OR RIGHTS.
 
60
 *******************************************************************************/
61
61
/*
62
62
 * Author: chris grzegorczyk <grze@eucalyptus.com>
63
63
 */
65
65
 
66
66
 
67
67
import edu.ucsb.eucalyptus.msgs.*
68
 
 
 
68
import com.eucalyptus.records.EventType;
69
69
import org.apache.log4j.Logger;
70
70
import java.util.ArrayList;
71
71
import java.util.List;
75
75
import java.util.concurrent.atomic.AtomicInteger
76
76
import java.util.concurrent.ConcurrentSkipListSet
77
77
import com.eucalyptus.util.LogUtil;
78
 
import com.eucalyptus.util.EucalyptusProperties;
79
78
import com.eucalyptus.util.HasName;
 
79
import com.eucalyptus.records.*;
80
80
import com.google.common.collect.*;
81
81
 
82
82
public class Pair {
83
 
 
 
83
  
84
84
  public static List<Pair> getPaired(List one, List two) {
85
85
    List<Pair> newList = new ArrayList<Pair>();
86
86
    for ( int idx = 0; idx < one.size(); idx++ )
87
87
      newList.add(new Pair(one[ idx ], two[ idx ]));
88
88
    return newList;
89
89
  }
90
 
 
 
90
  
91
91
  def String left, right;
92
 
 
 
92
  
93
93
  def Pair(final left, final right) {
94
94
    this.left = left;
95
95
    this.right = right;
96
96
  }
97
 
 
98
 
}
99
 
public interface RequestTransactionScript extends Serializable {
100
 
  public EucalyptusMessage getRequestMessage();
101
 
}
102
 
public class VmAllocationInfo implements RequestTransactionScript {
103
 
 
 
97
  
 
98
}
 
99
public class VmAllocationInfo extends EucalyptusMessage {
 
100
  
104
101
  RunInstancesType request;
105
102
  RunInstancesResponseType reply;
106
103
  String userData;
109
106
  VmImageInfo imageInfo;
110
107
  VmKeyInfo keyInfo;
111
108
  VmTypeInfo vmTypeInfo;
112
 
 
 
109
  
113
110
  List<Network> networks = new ArrayList<Network>();
114
 
 
 
111
  
115
112
  List<ResourceToken> allocationTokens = new ArrayList<ResourceToken>();
116
113
  List<String> addresses = new ArrayList<String>();
117
114
  ArrayList<Integer> networkIndexList = new ArrayList<Integer>();
118
 
 
119
 
  def VmAllocationInfo() {}
120
 
 
 
115
  
 
116
  def VmAllocationInfo() {
 
117
  }
 
118
  
121
119
  def VmAllocationInfo(final RunInstancesType request) {
122
120
    this.request = request;
123
121
    this.reply = request.getReply();
 
122
    this.setCorrelationId( request.getCorrelationId() )
124
123
  }
125
 
 
 
124
  
126
125
  public EucalyptusMessage getRequestMessage() {
127
126
    return this.getRequest();
128
127
  }
129
128
}
130
129
 
131
130
public class VmDescribeType extends EucalyptusMessage {
132
 
 
 
131
  
133
132
  ArrayList<String> instancesSet = new ArrayList<String>();
134
133
}
135
134
public class VmDescribeResponseType extends EucalyptusMessage {
136
 
 
 
135
  
137
136
  String originCluster;
138
137
  ArrayList<VmInfo> vms = new ArrayList<VmInfo>();
139
138
}
140
139
 
141
140
public class VmRunResponseType extends EucalyptusMessage {
142
 
 
 
141
  
143
142
  ArrayList<VmInfo> vms = new ArrayList<VmInfo>();
144
143
}
145
144
 
146
145
public class VmInfo extends EucalyptusData {
147
 
 
 
146
  
148
147
  String imageId;
149
148
  String kernelId;
150
149
  String ramdiskId;
159
158
  String serviceTag;
160
159
  String userData;
161
160
  String launchIndex;
162
 
  Integer networkIndex;
163
161
  ArrayList<String> groupNames = new ArrayList<String>();
164
162
  ArrayList<AttachedVolume> volumes = new ArrayList<AttachedVolume>();
165
 
 
166
163
  String placement;
167
 
 
 
164
    
168
165
  ArrayList<String> productCodes = new ArrayList<String>();
169
 
 
 
166
  
170
167
  @Override
171
168
  public String toString( ) {
172
169
    return String.format(
173
 
                          "VmInfo [groupNames=%s, imageId=%s, instanceId=%s, instanceType=%s, kernelId=%s, keyValue=%s, launchIndex=%s, launchTime=%s, netParams=%s, networkIndex=%s, ownerId=%s, placement=%s, productCodes=%s, ramdiskId=%s, reservationId=%s, serviceTag=%s, stateName=%s, userData=%s, volumes=%s]",
174
 
                          this.groupNames, this.imageId, this.instanceId, this.instanceType, this.kernelId,
175
 
                          this.keyValue, this.launchIndex, this.launchTime, this.netParams, this.networkIndex,
176
 
                          this.ownerId, this.placement, this.productCodes, this.ramdiskId, this.reservationId,
177
 
                          this.serviceTag, this.stateName, this.userData, this.volumes );
 
170
    "VmInfo [groupNames=%s, imageId=%s, instanceId=%s, instanceType=%s, kernelId=%s, keyValue=%s, launchIndex=%s, launchTime=%s, netParams=%s, ownerId=%s, placement=%s, productCodes=%s, ramdiskId=%s, reservationId=%s, serviceTag=%s, stateName=%s, userData=%s, volumes=%s]",
 
171
    this.groupNames, this.imageId, this.instanceId, this.instanceType, this.kernelId,
 
172
    this.keyValue, this.launchIndex, this.launchTime, this.netParams, 
 
173
    this.ownerId, this.placement, this.productCodes, this.ramdiskId, this.reservationId,
 
174
    this.serviceTag, this.stateName, this.userData, this.volumes );
178
175
  }
179
 
 
 
176
  
180
177
  
181
178
}
182
179
 
183
180
public class VmRunType extends EucalyptusMessage {
184
 
 
 
181
  
185
182
  /** these are for more convenient binding later on but really should be done differently... sigh    **/
186
 
 
 
183
  
187
184
  String reservationId, userData;
188
185
  int min, max, vlan, launchIndex;
189
 
 
 
186
  
190
187
  VmImageInfo imageInfo;
191
188
  VmTypeInfo vmTypeInfo;
192
189
  VmKeyInfo keyInfo;
193
 
 
 
190
  
194
191
  List<String> instanceIds = new ArrayList<String>();
195
192
  List<String> macAddresses = new ArrayList<String>();
196
193
  List<String> networkNames = new ArrayList<String>();
197
194
  ArrayList<String> networkIndexList = new ArrayList<String>();
198
 
 
199
 
 
200
 
  def VmRunType() {}
201
 
 
202
 
  def VmRunType(final RunInstancesType request,
203
 
                final String reservationId, final String userData, final int amount,
204
 
                final VmImageInfo imageInfo, final VmTypeInfo vmTypeInfo, final VmKeyInfo keyInfo,
205
 
                final List<String> instanceIds, final List<String> macAddresses,
206
 
                final int vlan, final List<String> networkNames, final List<String> networkIndexList ) {
207
 
    this.correlationId = request.correlationId;
208
 
    this.userId = request.userId;
209
 
    this.effectiveUserId = request.effectiveUserId;
 
195
  
 
196
  def VmRunType() {
 
197
  }
 
198
  
 
199
  def VmRunType(final String reservationId, final String userData, final int amount,
 
200
  final VmImageInfo imageInfo, final VmTypeInfo vmTypeInfo, final VmKeyInfo keyInfo,
 
201
  final List<String> instanceIds, final List<String> macAddresses,
 
202
  final int vlan, final List<String> networkNames, final List<String> networkIndexList ) {
210
203
    this.reservationId = reservationId;
211
204
    this.userData = userData;
212
205
    this.min = amount;
220
213
    this.networkNames = networkNames;
221
214
    this.networkIndexList = networkIndexList;
222
215
  }
223
 
 
 
216
  
224
217
  def VmRunType(RunInstancesType request) {
225
218
    this.effectiveUserId = request.effectiveUserId;
226
219
    this.correlationId = request.correlationId;
227
220
    this.userId = request.userId;
228
221
  }
229
 
 
 
222
  
230
223
  public VmRunType(RunInstancesType request, String reservationId, String userData,
231
 
                int amount, VmImageInfo imageInfo, VmTypeInfo vmTypeInfo, VmKeyInfo keyInfo,
232
 
                ArrayList<String> instanceIds, List<String> macAddresses, int vlan,
233
 
                List<String> networkNames, ArrayList<String> networkIndexList) {
234
 
            this.correlationId = request.correlationId;
235
 
            this.userId = request.userId;
236
 
            this.effectiveUserId = request.effectiveUserId;
237
 
            this.reservationId = reservationId;
238
 
            this.userData = userData;
239
 
            this.min = amount;
240
 
            this.max = amount;
241
 
            this.vlan = vlan;
242
 
            this.imageInfo = imageInfo;
243
 
            this.vmTypeInfo = vmTypeInfo;
244
 
            this.keyInfo = keyInfo;
245
 
            this.instanceIds = instanceIds;
246
 
            this.macAddresses = macAddresses;
247
 
            this.networkNames = networkNames;
248
 
            this.networkIndexList = networkIndexList;
 
224
  int amount, VmImageInfo imageInfo, VmTypeInfo vmTypeInfo, VmKeyInfo keyInfo,
 
225
  ArrayList<String> instanceIds, List<String> macAddresses, int vlan,
 
226
  List<String> networkNames, ArrayList<String> networkIndexList) {
 
227
    this.correlationId = request.correlationId;
 
228
    this.userId = request.userId;
 
229
    this.effectiveUserId = request.effectiveUserId;
 
230
    this.reservationId = reservationId;
 
231
    this.userData = userData;
 
232
    this.min = amount;
 
233
    this.max = amount;
 
234
    this.vlan = vlan;
 
235
    this.imageInfo = imageInfo;
 
236
    this.vmTypeInfo = vmTypeInfo;
 
237
    this.keyInfo = keyInfo;
 
238
    this.instanceIds = instanceIds;
 
239
    this.macAddresses = macAddresses;
 
240
    this.networkNames = networkNames;
 
241
    this.networkIndexList = networkIndexList;
249
242
  }
250
 
 
 
243
  
251
244
  @Override
252
245
  public String toString( ) {
253
246
    return String.format(
254
 
                          "VmRunType [imageInfo=%s, instanceIds=%s, keyInfo=%s, launchIndex=%s, macAddresses=%s, max=%s, min=%s, networkIndexList=%s, networkNames=%s, reservationId=%s, userData=%s, vlan=%s, vmTypeInfo=%s]",
255
 
                          this.imageInfo, this.instanceIds, this.keyInfo, this.launchIndex, this.macAddresses,
256
 
                          this.max, this.min, this.networkIndexList, this.networkNames, this.reservationId,
257
 
                          this.userData, this.vlan, this.vmTypeInfo );
 
247
    "VmRunType [imageInfo=%s, instanceIds=%s, keyInfo=%s, launchIndex=%s, macAddresses=%s, max=%s, min=%s, networkIndexList=%s, networkNames=%s, reservationId=%s, userData=%s, vlan=%s, vmTypeInfo=%s]",
 
248
    this.imageInfo, this.instanceIds, this.keyInfo, this.launchIndex, this.macAddresses,
 
249
    this.max, this.min, this.networkIndexList, this.networkNames, this.reservationId,
 
250
    this.userData, this.vlan, this.vmTypeInfo );
258
251
  }  
259
 
 
 
252
  
260
253
  
261
254
}
262
255
 
263
256
public class VmImageInfo {
264
 
 
 
257
  
265
258
  String imageId;
266
259
  String kernelId;
267
260
  String ramdiskId;
271
264
  ArrayList<String> productCodes = new ArrayList<String>();
272
265
  ArrayList<String> ancestorIds = new ArrayList<String>();
273
266
  Long size = 0l;
274
 
 
 
267
  
275
268
  def VmImageInfo(final imageId, final kernelId, final ramdiskId, final imageLocation, final kernelLocation, final ramdiskLocation, final productCodes) {
276
269
    this.imageId = imageId;
277
270
    this.kernelId = kernelId;
281
274
    this.ramdiskLocation = ramdiskLocation;
282
275
    this.productCodes = productCodes;
283
276
  }
284
 
 
285
 
  def VmImageInfo() {}
286
 
 
 
277
  
 
278
  def VmImageInfo() {
 
279
  }
 
280
  
287
281
  @Override
288
282
  public String toString( ) {
289
283
    return String.format(
290
 
                          "VmImageInfo [ancestorIds=%s, imageId=%s, imageLocation=%s, kernelId=%s, kernelLocation=%s, productCodes=%s, ramdiskId=%s, ramdiskLocation=%s, size=%s]",
291
 
                          this.ancestorIds, this.imageId, this.imageLocation, this.kernelId, this.kernelLocation,
292
 
                          this.productCodes, this.ramdiskId, this.ramdiskLocation, this.size );
 
284
    "VmImageInfo [ancestorIds=%s, imageId=%s, imageLocation=%s, kernelId=%s, kernelLocation=%s, productCodes=%s, ramdiskId=%s, ramdiskLocation=%s, size=%s]",
 
285
    this.ancestorIds, this.imageId, this.imageLocation, this.kernelId, this.kernelLocation,
 
286
    this.productCodes, this.ramdiskId, this.ramdiskLocation, this.size );
293
287
  }
294
288
  
295
 
 
 
289
  
296
290
}
297
291
 
298
292
public class VmKeyInfo {
299
 
 
 
293
  
300
294
  String name = "";
301
295
  String value = "";
302
296
  String fingerprint = "";
303
 
 
 
297
  
304
298
  def VmKeyInfo(final name, final value, final fingerprint) {
305
299
    this.name = name;
306
300
    this.value = value;
307
301
    this.fingerprint = fingerprint;
308
302
  }
309
 
 
310
 
  def VmKeyInfo() {}
311
 
 
 
303
  
 
304
  def VmKeyInfo() {
 
305
  }
 
306
  
312
307
  @Override
313
308
  public String toString( ) {
314
309
    return String.format( "VmKeyInfo [fingerprint=%s, name=%s, value=%s]", this.fingerprint, this.name, this.value );
315
310
  }
316
311
  
317
 
 
 
312
  
318
313
}
319
314
 
320
315
public class Network implements HasName {
328
323
  private NavigableSet<Integer> availableNetworkIndexes = new ConcurrentSkipListSet<Integer>();
329
324
  private NavigableSet<Integer> assignedNetworkIndexes = new ConcurrentSkipListSet<Integer>();
330
325
  AtomicInteger vlan;
331
 
 
332
 
  def Network() {}
333
 
 
 
326
  
 
327
  def Network() {
 
328
  }
 
329
  
334
330
  def Network(final String userName, final String networkName) {
335
331
    this.userName = userName;
336
332
    this.networkName = networkName;
339
335
      Network me = Networks.getInstance().lookup( this.networkName );
340
336
      this.max = me.max;
341
337
    } catch (Throwable t) {
342
 
      this.max = 256;
 
338
      this.max = 2048;
343
339
    }
344
340
    for( int i = 2; i < max; i++ ) {//FIXME: potentially a network can be more than a /24. update w/ real constraints at runtime.
345
341
      this.availableNetworkIndexes.add( i );
361
357
      this.availableNetworkIndexes.remove( index );
362
358
    } else {
363
359
      if( !this.assignedNetworkIndexes.contains( index ) && this.availableNetworkIndexes.remove( index ) ) {
364
 
        LOG.debug( EventRecord.caller( this.getClass( ), EucalyptusProperties.TokenState.allocated, "network=${this.name}","cluster=${cluster}","networkIndex=${index}") );
 
360
        EventRecord.caller( this.getClass( ), EventType.TOKEN_ALLOCATED, "network=${this.name}","cluster=${cluster}","networkIndex=${index}").debug( );
365
361
        this.assignedNetworkIndexes.add( index );
366
362
        NetworkToken token = this.getClusterToken( cluster );
367
363
        token.indexes.add( index );
393
389
  public Integer allocateNetworkIndex( String cluster ) {
394
390
    Integer nextIndex = this.availableNetworkIndexes.pollFirst( );
395
391
    if( nextIndex == null ) { 
396
 
      LOG.debug( EventRecord.caller( this.getClass( ), EucalyptusProperties.TokenState.preallocate, "network=${this.name}","cluster=${cluster}","networkIndex=${nextIndex}") );
 
392
      EventRecord.caller( this.getClass( ), EventType.TOKEN_RESERVED, "network=${this.name}","cluster=${cluster}","networkIndex=${nextIndex}").debug( );
397
393
    } else {
398
394
      this.assignedNetworkIndexes.add( nextIndex );
399
395
      this.getClusterToken( cluster )?.getIndexes().add( nextIndex );
400
 
      LOG.debug( EventRecord.caller( this.getClass( ), EucalyptusProperties.TokenState.preallocate, "network=${this.name}","cluster=${cluster}","networkIndex=${nextIndex}") );
 
396
      EventRecord.caller( this.getClass( ), EventType.TOKEN_RESERVED, "network=${this.name}","cluster=${cluster}","networkIndex=${nextIndex}").debug( );
401
397
    }
402
398
    return nextIndex;
403
399
  }
404
 
 
 
400
  
405
401
  public void returnNetworkIndexes( Collection<Integer> indexes ) {
406
402
    indexes.each{ this.returnNetworkIndex( it ); };
407
403
    LOG.debug( this.toString( ) );
408
404
  }
409
 
 
 
405
  
410
406
  public void returnNetworkIndex( Integer index ) {
411
 
    LOG.debug( EventRecord.caller( this.getClass( ), EucalyptusProperties.TokenState.returned, "network=${this.name}","networkIndex=${index}") );
 
407
    EventRecord.caller( this.getClass( ), EventType.TOKEN_RETURNED, "network=${this.name}","networkIndex=${index}").debug( );
412
408
    this.assignedNetworkIndexes.remove( index );
413
409
    this.clusterTokens.values().each { 
414
410
      it.getIndexes().remove( index );
416
412
    if( index < 2 ) return;
417
413
    this.availableNetworkIndexes.add( index );
418
414
  }
419
 
 
 
415
  
420
416
  public NetworkToken addTokenIfAbsent(NetworkToken token) {
421
417
    if( this.vlan.get() == 0 ) {
422
418
      this.vlan.compareAndSet(0,token.getVlan( ));
425
421
    if( clusterToken == null ) clusterToken = this.clusterTokens.get( token.getCluster() );
426
422
    return clusterToken;
427
423
  }
428
 
 
 
424
  
429
425
  public boolean hasToken(String cluster) {
430
426
    return this.clusterTokens.containsKey(cluster);
431
427
  }
432
 
 
 
428
  
433
429
  public boolean hasTokens() {
434
430
    this.clusterTokens.values().each { NetworkToken it ->
435
431
      if(it.getIndexes().isEmpty()) {
438
434
    }    
439
435
    return !this.clusterTokens.values( ).isEmpty( );
440
436
  }
441
 
 
 
437
  
442
438
  public void removeToken(String cluster) {
443
439
    this.clusterTokens.remove(cluster);
444
440
  }
445
 
 
 
441
  
446
442
  public boolean isPeer( String peerName, String peerNetworkName ) {
447
443
    return (Boolean) this.rules.collect{ pf -> pf.peers.contains( new VmNetworkPeer( peerName, peerNetworkName )) }.max();
448
444
  }
449
 
 
 
445
  
450
446
  public int compareTo(final Object o) {
451
447
    Network that = (Network) o;
452
448
    return this.getName().compareTo(that.getName());
453
449
  }
454
 
 
 
450
  
455
451
  @Override
456
452
  public String toString( ) {
457
 
    return String.format(
458
 
                          "Network [availableNetworkIndexes=%s, assignedNetworkIndexes=%s, name=%s, networkName=%s, clusterTokens=%s, rules=%s, userName=%s]",
459
 
                          this.availableNetworkIndexes, this.assignedNetworkIndexes, this.name, this.networkName, this.clusterTokens, this.rules,
460
 
                          this.userName );
 
453
    return String.format("Network [available=%s, assigned=%s, name=%s, networkName=%s, clusterTokens=%s, rules=%s, userName=%s]",
 
454
                         LogUtil.rangedIntegerList( this.availableNetworkIndexes ), LogUtil.rangedIntegerList( this.assignedNetworkIndexes ), 
 
455
                         this.name, this.networkName, this.clusterTokens, this.rules, this.userName );
461
456
  }
462
457
  
463
 
 
 
458
  
464
459
}
465
460
 
466
461
public class NetworkToken implements Comparable {
467
 
 
 
462
  
468
463
  String networkName;
469
464
  String cluster;
470
465
  Integer vlan;
471
466
  NavigableSet<Integer> indexes = new ConcurrentSkipListSet<Integer>( );
472
467
  String userName;
473
468
  String name;
474
 
 
 
469
  
475
470
  def NetworkToken(final String cluster, final String userName, final String networkName, final int vlan ) {
476
471
    this.networkName = networkName;
477
472
    this.cluster = cluster;
485
480
    if ( this.is( o ) ) return true;
486
481
    if ( !(o instanceof NetworkToken) ) return false;
487
482
    NetworkToken that = (NetworkToken) o;
488
 
 
 
483
    
489
484
    if ( !cluster.equals(that.cluster) ) return false;
490
485
    if ( !networkName.equals(that.networkName) ) return false;
491
486
    if ( !userName.equals(that.userName) ) return false;
492
 
 
 
487
    
493
488
    return true;
494
489
  }
495
 
 
 
490
  
496
491
  @Override
497
492
  int hashCode() {
498
493
    int result;
499
 
 
 
494
    
500
495
    result = networkName.hashCode();
501
496
    result = 31 * result + cluster.hashCode();
502
497
    result = 31 * result + userName.hashCode();
503
498
    return result;
504
499
  }
505
 
 
506
 
 
 
500
  
 
501
  
507
502
  
508
503
  @Override
509
504
  public int compareTo(Object o) {
510
505
    NetworkToken that = (NetworkToken) o;
511
506
    return (!this.cluster.equals(that.cluster) && (this.getVlan().equals( that.getVlan() ) ) ) ? this.getVlan() - that.getVlan() : this.cluster.compareTo(that.cluster);
512
507
  }
513
 
 
 
508
  
514
509
  @Override
515
510
  public String toString( ) {
516
511
    return String.format( "NetworkToken [cluster=%s, indexes=%s, name=%s, networkName=%s, userName=%s, vlan=%s]",
517
 
                          this.cluster, this.indexes, this.name, this.networkName, this.userName, this.vlan);
 
512
    this.cluster, this.indexes, this.name, this.networkName, this.userName, this.vlan);
518
513
  }
519
514
}
520
515
 
521
516
public class ResourceToken implements Comparable {
522
 
 
 
517
  
523
518
  String cluster;
524
519
  String correlationId;
525
520
  String userName;
530
525
  String vmType;
531
526
  Date creationTime;
532
527
  Integer sequenceNumber;
533
 
 
 
528
  
534
529
  public ResourceToken(final String cluster, final String correlationId, final String userName, final int amount, final int sequenceNumber, final String vmType) {
535
530
    this.cluster = cluster;
536
531
    this.correlationId = correlationId;
540
535
    this.creationTime = Calendar.getInstance().getTime();
541
536
    this.vmType = vmType;
542
537
  }
543
 
 
 
538
  
544
539
  public NetworkToken getPrimaryNetwork() {
545
540
    return this.networkTokens.size()>0?this.networkTokens.get(0):null;
546
541
  }
547
 
 
 
542
  
548
543
  @Override
549
544
  public boolean equals(final Object o) {
550
545
    if ( this.is( o ) ) return true;
551
546
    if ( !(o instanceof ResourceToken) ) return false;
552
 
 
 
547
    
553
548
    ResourceToken that = (ResourceToken) o;
554
 
 
 
549
    
555
550
    if ( !amount.equals( that.amount ) ) return false;
556
551
    if ( !cluster.equals(that.cluster) ) return false;
557
552
    if ( !correlationId.equals(that.correlationId) ) return false;
558
553
    if ( !creationTime.equals(that.creationTime) ) return false;
559
 
 
 
554
    
560
555
    return true;
561
556
  }
562
 
 
 
557
  
563
558
  @Override
564
559
  public int hashCode() {
565
560
    int result = cluster.hashCode();
568
563
    result = 31 * result + creationTime.hashCode();
569
564
    return result;
570
565
  }
571
 
 
 
566
  
572
567
  @Override
573
568
  public int compareTo(final Object o) {
574
569
    ResourceToken that = (ResourceToken) o;
575
570
    return this.getSequenceNumber() - that.getSequenceNumber();
576
571
  }
577
 
 
 
572
  
578
573
  @Override
579
574
  public String toString( ) {
580
575
    return String.format(
581
 
                          "ResourceToken [addresses=%s, amount=%s, cluster=%s, correlationId=%s, creationTime=%s, instanceIds=%s, networkTokens=%s, sequenceNumber=%s, userName=%s, vmType=%s]",
582
 
                          this.addresses, this.amount, this.cluster, this.correlationId, this.creationTime,
583
 
                          this.instanceIds, this.networkTokens, this.sequenceNumber, this.userName, this.vmType );
 
576
    "ResourceToken [addresses=%s, amount=%s, cluster=%s, correlationId=%s, creationTime=%s, instanceIds=%s, networkTokens=%s, sequenceNumber=%s, userName=%s, vmType=%s]",
 
577
    this.addresses, this.amount, this.cluster, this.correlationId, this.creationTime,
 
578
    this.instanceIds, this.networkTokens, this.sequenceNumber, this.userName, this.vmType );
584
579
  }
585
 
 
 
580
  
586
581
}
587
582
 
588
583
public class NodeInfo implements Comparable {
589
 
 
 
584
  
590
585
  String serviceTag;
591
586
  String name;
592
587
  Date lastSeen;
593
588
  NodeCertInfo certs = new NodeCertInfo();
594
589
  NodeLogInfo logs = new NodeLogInfo();
595
 
 
 
590
  
596
591
  def NodeInfo(final String serviceTag) {
597
592
    this.name = (new URI(serviceTag)).getHost();
598
593
    this.serviceTag = serviceTag;
600
595
    this.certs.setServiceTag(this.serviceTag);
601
596
    this.logs.setServiceTag(this.serviceTag);
602
597
  }
603
 
 
 
598
  
604
599
  def NodeInfo(NodeInfo orig, final NodeCertInfo certs) {
605
600
    this(orig.serviceTag);
606
601
    this.logs = orig.logs;
607
602
    this.certs = certs;
608
603
  }
609
 
 
 
604
  
610
605
  def NodeInfo(NodeInfo orig, final NodeLogInfo logs) {
611
606
    this(orig.serviceTag);
612
607
    this.certs = orig.certs;
613
608
    this.logs = logs;
614
609
  }
615
 
 
 
610
  
616
611
  def NodeInfo(final NodeCertInfo certs) {
617
612
    this(certs.getServiceTag());
618
613
    this.certs = certs;
619
614
  }
620
 
 
 
615
  
621
616
  def NodeInfo(final NodeLogInfo logs) {
622
617
    this(logs.getServiceTag());
623
618
    this.logs = logs;
624
619
  }
625
 
 
626
 
 
 
620
  
 
621
  
627
622
  public void touch() {
628
623
    this.lastSeen = new Date();
629
624
  }
630
 
 
 
625
  
631
626
  public int compareTo(Object o) {
632
627
    return this.serviceTag.compareTo(((NodeInfo) o).serviceTag);
633
628
  }
634
 
 
 
629
  
635
630
  boolean equals(final o) {
636
631
    if ( this.is( o ) ) return true;
637
632
    if ( !(o instanceof NodeInfo) ) return false;
639
634
    if ( !serviceTag.equals(nodeInfo.serviceTag) ) return false;
640
635
    return true;
641
636
  }
642
 
 
 
637
  
643
638
  int hashCode() {
644
639
    return serviceTag.hashCode();
645
640
  }
646
 
 
 
641
  
647
642
  @Override
648
643
  public String toString( ) {
649
644
    return String.format( "NodeInfo [name=%s, lastSeen=%s, serviceTag=%s]", this.name, this.lastSeen, this.serviceTag );