Skip to content
Browse files

Merge remote-tracking branch 'origin/testing' into dev/juphoff/migration

Conflicts:
	node/handlers.c
	node/handlers_kvm.c
  • Loading branch information...
2 parents cf66456 + e538727 commit cf0fd715e3a5090c154ece9228a40567bf6c3883 @juphoff juphoff committed
Showing with 7,997 additions and 916 deletions.
  1. +1 −0 .gitignore
  2. +14 −7 clc/.classpath
  3. +2 −1 ...ules/autoscaling/src/main/java/com/eucalyptus/autoscaling/configurations/LaunchConfiguration.java
  4. +1 −0 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/SnapshotManager.java
  5. +0 −22 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmBootRecord.java
  6. +3 −3 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmInstances.java
  7. +13 −0 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/LVMVolumeInfo.java
  8. +34 −57 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/VolumeInfo.java
  9. +30 −1 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/VolumeToken.java
  10. +9 −1 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/util/SystemUtil.java
  11. +2 −2 clc/modules/dns/src/main/java/com/eucalyptus/cloud/ws/DNSControl.java
  12. +27 −0 clc/modules/dns/src/main/java/com/eucalyptus/cloud/ws/ZoneManager.java
  13. +0 −3 clc/modules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancer.java
  14. +66 −7 ...modules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancerBackendInstance.java
  15. +3 −0 clc/modules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancerCwatchMetrics.java
  16. +31 −3 clc/modules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancers.java
  17. +56 −49 clc/modules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancingService.java
  18. +32 −0 .../loadbalancing/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainDelete.java
  19. +25 −3 ...balancing/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainDisableZone.java
  20. +69 −0 ...dbalancing/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainEnableZone.java
  21. +36 −7 ...les/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainNew.java
  22. +3 −0 ...alancing/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainNewListeners.java
  23. +181 −0 ...oadbalancing/src/main/java/com/eucalyptus/loadbalancing/activities/LoadBalancerServoInstance.java
  24. +96 −0 clc/modules/msgs/src/main/java/com/eucalyptus/crypto/util/BCSslSetup.java
  25. +1 −0 clc/modules/msgs/src/main/java/com/eucalyptus/crypto/util/SslSetup.java
  26. +17 −16 clc/modules/msgs/src/main/java/com/eucalyptus/ws/protocol/SoapHandler.java
  27. +3 −1 clc/modules/msgs/src/main/java/com/eucalyptus/ws/server/ServiceContextHandler.java
  28. +4 −0 clc/modules/msgs/src/main/java/edu/ucsb/eucalyptus/msgs/Walrus.groovy
  29. +422 −0 clc/modules/msgs/src/main/java/generate-xsd.groovy
  30. +36 −0 clc/modules/msgs/src/test/java/com/eucalyptus/crypto/util/BCSslSetupTest.java
  31. +42 −22 clc/modules/msgs/src/test/java/com/eucalyptus/reporting/event/ReportingEventTest.java
  32. +28 −10 ...rting/src/test/java/com/eucalyptus/reporting/modules/address/AddressUsageEventListenerTest.groovy
  33. +62 −72 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/DASManager.java
  34. +138 −230 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/ISCSIManager.java
  35. +0 −1 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/LogicalStorageManager.java
  36. +78 −111 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/OverlayManager.java
  37. +677 −0 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/TGTWrapper.java
  38. +0 −109 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/VolumeExports.java
  39. +114 −66 clc/modules/storage-controller/src/main/java/edu/ucsb/eucalyptus/cloud/ws/BlockStorage.java
  40. +22 −0 ...les/storage-controller/src/test/java/com/eucalyptus/storage/tests/LogicalStorageManagerTests.java
  41. +289 −0 clc/modules/storage-controller/src/test/java/com/eucalyptus/storage/tests/NoOpStorageManager.java
  42. +277 −0 ...age-controller/src/test/java/com/eucalyptus/storage/tests/ProbabalisticFailureStorageManager.java
  43. +42 −0 ...ules/storage-controller/src/test/java/com/eucalyptus/storage/tests/StorageExportManagerTests.java
  44. +32 −0 clc/modules/storage-controller/src/test/java/com/eucalyptus/storage/tests/VolumeTokensTests.java
  45. +5 −0 ...modules/storage-controller/src/test/java/edu/ucsb/eucalyptus/cloud/ws/tests/BlockStorageTest.java
  46. +0 −3 clc/modules/walrus/src/main/java/edu/ucsb/eucalyptus/cloud/ws/WalrusManager.java
  47. +5 −0 cluster/handlers.c
  48. +1 −2 console/euca-console-server
  49. +5 −1 console/eucaconsole/botoclcinterface.py
  50. +10 −6 console/eucaconsole/cachingclcinterface.py
  51. +31 −29 console/static/css/eucalyptus.css
  52. +4 −0 console/static/custom/Messages.properties
  53. +2,022 −1 console/static/custom/Messages_FI.properties
  54. +721 −18 console/static/custom/Messages_es_ES.properties
  55. +725 −16 console/static/custom/Messages_fi_FI.properties
  56. +725 −18 console/static/custom/Messages_fr_FR.properties
  57. +725 −18 console/static/custom/Messages_it_IT.properties
Sorry, we could not display the entire diff because it was too big.
View
1 .gitignore
@@ -52,6 +52,7 @@ clc/modules/www/test-gwt/*
clc/modules/www/test-gwt/war/*
clc/modules/www/test-gwt/war/WEB-INF/*
clc/modules/www/webapps
+clc/modules/www/gwt-unitCache/
clc/target
config.log
config.status
View
21 clc/.classpath
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="modules/autoscaling/build" path="modules/autoscaling/src/main/java"/>
+ <classpathentry kind="src" path="modules/storage-controller/src/test/java"/>
+ <classpathentry kind="src" path="modules/bootstrap/src/test/java"/>
+ <classpathentry kind="src" path="modules/datawarehouse/src/test/java"/>
+ <classpathentry kind="src" path="modules/authentication/src/main/java"/>
+ <classpathentry kind="src" path="modules/bootstrap/src/main/java"/>
+ <classpathentry kind="src" path="modules/authentication/src/test/java"/>
<classpathentry kind="src" output="modules/autoscaling-common/build" path="modules/autoscaling-common/src/main/java"/>
<classpathentry kind="src" output="modules/cloud/build" path="modules/cloud/src/main/java"/>
<classpathentry kind="src" output="modules/cloudwatch/build" path="modules/cloudwatch/src/main/java"/>
@@ -87,12 +93,6 @@
<classpathentry kind="lib" path="lib/groovy-all-1.7.2.jar" sourcepath="/git/third-party/groovy-1.7.1"/>
<classpathentry kind="lib" path="lib/guava-14.0.1-gwt.jar"/>
<classpathentry kind="lib" path="lib/guava-14.0.1.jar"/>
- <classpathentry kind="lib" path="lib/gwt-api-checker-2.2.jar"/>
- <classpathentry kind="lib" path="lib/gwt-dev-2.2.jar"/>
- <classpathentry kind="lib" path="lib/gwt-servlet-2.2.jar"/>
- <classpathentry kind="lib" path="lib/gwt-servlet-deps-2.2.jar"/>
- <classpathentry kind="lib" path="lib/gwt-soyc-vis-2.2.jar"/>
- <classpathentry kind="lib" path="lib/gwt-user-2.2.jar"/>
<classpathentry kind="lib" path="lib/ha-jdbc-2.0.16-rc-1-jdk1.6.jar" sourcepath="/git/third-party/ha-jdbc-2.0.16-rc-1"/>
<classpathentry kind="lib" path="lib/hamcrest-all-1.2.jar"/>
<classpathentry kind="lib" path="lib/hibernate-3.5.6-Final.jar"/>
@@ -143,7 +143,6 @@
<classpathentry kind="lib" path="lib/jul-to-slf4j-1.5.2.jar"/>
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
<classpathentry kind="lib" path="lib/kahadb-5.4.1.jar"/>
- <classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/manageontap.jar"/>
<classpathentry kind="lib" path="lib/mule-core-2.0.1.jar"/>
<classpathentry kind="lib" path="lib/mule-module-builders-2.0.1.jar"/>
@@ -185,5 +184,13 @@
<classpathentry kind="lib" path="lib/xmlsec-1.4.7.jar"/>
<classpathentry kind="lib" path="lib/xom-1.2.9.jar"/>
<classpathentry kind="lib" path="lib/xpp3-1.1.4c.jar"/>
+ <classpathentry kind="lib" path="lib/gwt-api-checker-2.4.jar"/>
+ <classpathentry kind="lib" path="lib/gwt-dev-2.4.jar"/>
+ <classpathentry kind="lib" path="lib/gwt-servlet-2.4.jar"/>
+ <classpathentry kind="lib" path="lib/gwt-servlet-deps-2.4.jar"/>
+ <classpathentry kind="lib" path="lib/gwt-soyc-vis-2.4.jar"/>
+ <classpathentry kind="lib" path="lib/gwt-user-2.4.jar"/>
+ <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
+ <classpathentry kind="lib" path="lib/validation-api-1.0.0.GA.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
3 ...oscaling/src/main/java/com/eucalyptus/autoscaling/configurations/LaunchConfiguration.java
@@ -37,6 +37,7 @@
import org.hibernate.annotations.Type;
import com.eucalyptus.autoscaling.metadata.AbstractOwnedPersistent;
import com.eucalyptus.util.OwnerFullName;
+import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -319,7 +320,7 @@ protected LaunchConfiguration build() {
configuration.setRamdiskId( ramdiskId );
configuration.setKeyName( keyName );
configuration.setUserData( userData );
- configuration.setInstanceMonitoring( instanceMonitoring );
+ configuration.setInstanceMonitoring( Objects.firstNonNull( instanceMonitoring, Boolean.TRUE ) );
configuration.setIamInstanceProfile( iamInstanceProfile );
configuration.setSecurityGroups( Lists.newArrayList( securityGroups ) );
configuration.setBlockDeviceMappings( Lists.newArrayList( blockDeviceMappings ) );
View
1 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/SnapshotManager.java
@@ -256,6 +256,7 @@ public boolean apply( ServiceConfiguration arg0 ) {
public DescribeSnapshotsResponseType describe( final DescribeSnapshotsType request ) throws EucalyptusCloudException {
final DescribeSnapshotsResponseType reply = ( DescribeSnapshotsResponseType ) request.getReply( );
+ if(!request.getRestorableBySet().isEmpty()) { return reply; } //TODO:KEN EUCA-5759 Need to implement RestorableBy, for now ignore
final Context ctx = Contexts.lookup( );
final boolean showAll = request.getSnapshotSet( ).remove( "verbose" );
final AccountFullName ownerFullName = ( ctx.hasAdministrativePrivileges( ) && showAll ) ?
View
22 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmBootRecord.java
@@ -347,26 +347,4 @@ private String getSshKeyString( ) {
private void setSshKeyString( String sshKeyString ) {
this.sshKeyString = sshKeyString;
}
-
- @EntityUpgrade( entities = { VmBootRecord.class }, since = Version.v3_2_2, value = com.eucalyptus.component.id.Eucalyptus.class )
- public enum VmBootRecordUpgrade implements Predicate<Class> {
- INSTANCE;
- private static Logger LOG = Logger.getLogger( VmBootRecord.VmBootRecordUpgrade.class );
- @Override
- public boolean apply( Class arg0 ) {
- EntityTransaction db = Entities.get( VmInstance.class );
- try {
- List<VmInstance> entities = Entities.query( new VmInstance( ) );
- for ( VmInstance entry : entities ) {
- LOG.debug( "Upgrading BootRecord: " + entry.toString() );
- Entities.persist(entry);
- }
- db.commit( );
- return true;
- } catch ( Exception ex ) {
- db.rollback();
- throw Exceptions.toUndeclared( ex );
- }
- }
- }
}
View
6 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmInstances.java
@@ -588,9 +588,9 @@ public boolean apply( final VmVolumeAttachment arg0 ) {
}
try {
- //TODO: zhill - still send a cleanup to SC to guarantee cleanup?
- final ServiceConfiguration sc = Topology.lookup( Storage.class, vm.lookupPartition( ) );
- AsyncRequests.sendSync( sc, new DetachStorageVolumeType( arg0.getVolumeId( ) ) );
+ //Send forcible detach. Detach is idempotent so calling on already detached volume should be no problem
+ //final ServiceConfiguration sc = Topology.lookup( Storage.class, vm.lookupPartition( ) );
+ //AsyncRequests.sendSync( sc, new DetachStorageVolumeType( arg0.getVolumeId( ) ) );
} catch ( Exception ex ) {
LOG.debug( ex );
Logs.extreme( ).debug( ex, ex );
View
13 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/LVMVolumeInfo.java
@@ -107,6 +107,19 @@
@Column(name = "cleanup")
private Boolean cleanup;
+ public static final String LVM_ROOT_DIRECTORY = "/dev";
+ public static final String PATH_SEPARATOR = "/";
+
+ /**
+ * Returns a string representation of the path to this resource. Null if not available.
+ * @return
+ */
+ public String getAbsoluteLVPath() {
+ if(this.getVgName() != null && this.getLvName() != null)
+ return LVM_ROOT_DIRECTORY + PATH_SEPARATOR + this.getVgName() + PATH_SEPARATOR + this.getLvName();
+ return null;
+ }
+
public String toString() {
return volumeId + "," + scName + "," + loDevName + "," + loFileName + "," + pvName + "," + vgName + "," + lvName + "," + size + "," + status + "," + snapshotOf + "," + cleanup;
}
View
91 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/VolumeInfo.java
@@ -229,9 +229,6 @@ public void setAttachmentTokens(List<VolumeToken> attachmentTokens) {
* @throws EucalyptusCloudException
*/
public VolumeToken getAttachmentTokenIfValid(String tokenValue) throws EucalyptusCloudException {
- //Note: an alternate implementation is to lookup the token directly and check its volume relation and valid status directly.
- //This is preferable because we use a consistent way to lookup the currently valid token for the volume
- EntityTransaction db = Entities.get(VolumeInfo.class);
try {
VolumeToken tok = getCurrentValidToken();
if(tok == null) {
@@ -242,17 +239,12 @@ public VolumeToken getAttachmentTokenIfValid(String tokenValue) throws Eucalyptu
LOG.warn("Token requested is not the current valid token for volume " + this.getVolumeId() + " request token: " + tokenValue + " current token: " + tok.getToken());
throw new EucalyptusCloudException("Requested token is not the current valid token");
} else {
- db.commit();
return tok;
}
}
} catch(Exception e) {
LOG.error("Error checking for valid attachment token",e);
throw new EucalyptusCloudException(e);
- } finally {
- if(db.isActive()) {
- db.rollback();
- }
}
}
@@ -260,25 +252,24 @@ public VolumeToken getAttachmentTokenIfValid(String tokenValue) throws Eucalyptu
* Return the valid token if it exists or null if not.
* @return
*/
- public VolumeToken getCurrentValidToken() throws EucalyptusCloudException {
- EntityTransaction db = Entities.get(VolumeInfo.class);
- try {
- VolumeInfo volEntity = Entities.merge(this);
- for(VolumeToken tok : volEntity.getAttachmentTokens()) {
- if(tok.getIsValid()) {
- db.commit();
- return tok;
+ public VolumeToken getCurrentValidToken() throws EucalyptusCloudException {
+ Function<VolumeInfo, VolumeToken> getValidToken = new Function<VolumeInfo, VolumeToken>() {
+ @Override
+ public VolumeToken apply(VolumeInfo src) {
+ try {
+ VolumeInfo volEntity = Entities.merge(src);
+ for(VolumeToken tok : volEntity.getAttachmentTokens()) {
+ if(tok.getIsValid()) {
+ return tok;
+ }
+ }
+ } catch(Exception e) {
+ LOG.trace("Failed while looking up valid token found for volume " + src.getVolumeId(), e);
}
+ return null;
}
- db.commit();
- } catch(Exception e) {
- LOG.trace("Failed to lookup valid token found for volume " + this.getVolumeId());
- } finally {
- if(db.isActive()) {
- db.rollback();
- }
- }
- return null;
+ };
+ return Entities.asTransaction(VolumeInfo.class, getValidToken).apply(this);
}
/**
@@ -326,39 +317,25 @@ public VolumeToken apply(VolumeInfo src) {
* @param nodeIp - the node IP to use for lookup of export record
* @param nodeIqn - the iqn for the lookup of export record
*/
- public void invalidateExport(String tokenValue, String nodeIp, String nodeIqn) throws EucalyptusCloudException {
- EntityTransaction db = Entities.get(VolumeInfo.class);
- try {
- VolumeInfo volEntity = Entities.merge(this);
- volEntity.getAttachmentTokenIfValid(tokenValue).invalidateExport(nodeIp, nodeIqn);
- db.commit();
- } catch(Exception e) {
- LOG.error("Could not invalidate requested export with token " + tokenValue + " to " + nodeIp + " with iqn " + nodeIqn);
- throw new EucalyptusCloudException(e);
- } finally {
- if(db.isActive()) {
- db.rollback();
+ public void invalidateExport(final String tokenValue, final String nodeIp, final String nodeIqn) throws EucalyptusCloudException {
+ Function<VolumeInfo, VolumeToken> invalidateToken = new Function<VolumeInfo, VolumeToken>() {
+ @Override
+ public VolumeToken apply(VolumeInfo src) {
+ try {
+ VolumeInfo volEntity = Entities.merge(src);
+ VolumeToken token = volEntity.getAttachmentTokenIfValid(tokenValue);
+ token.invalidateExport(nodeIp, nodeIqn);
+ Entities.flush(token);
+ return token;
+ } catch(Exception e) {
+ LOG.error("Could not invalidate requested export with token " + tokenValue + " to " + nodeIp + " with iqn " + nodeIqn);
+ }
+ return null;
}
- }
- }
-
- /**
- * Checks validity of the token and its active status as well as doing a lookup on the
- * ip and iqn passed to verify an active export record. Returns true IFF the token is valid
- * and there is an active export for the given ip,iqn pair
- * @param tokenValue
- * @param nodeIp
- * @param nodeIqn
- * @return
- * @throws EucalyptusCloudException
- */
- public boolean canInvalidateExport(String tokenValue, String nodeIp, String nodeIqn) throws EucalyptusCloudException {
- try {
- VolumeToken tok = this.getAttachmentTokenIfValid(tokenValue);
- return (tok != null) && (tok.getValidExport(nodeIp, nodeIqn) != null);
- } catch(Exception e) {
- LOG.error("Could not invalidate requested export with token " + tokenValue + " to " + nodeIp + " with iqn " + nodeIqn);
- return false;
+ };
+
+ if(Entities.asTransaction(VolumeInfo.class, invalidateToken).apply(this) == null) {
+ throw new EucalyptusCloudException("Failed on invalidation of token");
}
}
}
View
31 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/VolumeToken.java
@@ -257,10 +257,11 @@ public boolean apply(VolumeExportRecord record) {
//Invalidate the token as well.
tok.setIsValid(Boolean.FALSE);
}
+ Entities.flush(tokenEntity);
return tokenEntity;
} catch(Exception e) {
LOG.error("Could not invalidate export record for volume " + tok.getVolume().getVolumeId() + " token " + tok.getToken() + " ip " + ip + " iqn " + iqn, e);
- }
+ }
return null;
}
};
@@ -314,4 +315,32 @@ public VolumeToken apply(VolumeToken token) {
LOG.error("Failed to add export");
}
}
+
+ public void invalidateAllExportsAndToken() throws EucalyptusCloudException {
+ Function<VolumeToken, VolumeToken> invalidateToken = new Function<VolumeToken, VolumeToken>() {
+ @Override
+ public VolumeToken apply(VolumeToken tok){
+ VolumeToken tokenEntity = Entities.merge(tok);
+ try {
+ for(VolumeExportRecord rec : tokenEntity.getExportRecords()) {
+ rec.setIsActive(Boolean.FALSE);
+ }
+ tok.setIsValid(Boolean.FALSE);
+ return tokenEntity;
+ } catch(Exception e) {
+ LOG.error("Could not invalidate export record for volume " + tok.getVolume().getVolumeId() + " token " + tok.getToken(), e);
+ }
+ return null;
+ }
+ };
+
+ try {
+ if(Entities.asTransaction(VolumeExportRecord.class, invalidateToken).apply(this) == null) {
+ throw new Exception("Failed to invalidate export, got null result from deactivation");
+ }
+ } catch(Exception e) {
+ LOG.error("Failed to invalidate export: " + e.getMessage(),e);
+ throw new EucalyptusCloudException("Failed to invalidate export");
+ }
+ }
}
View
10 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/util/SystemUtil.java
@@ -142,7 +142,15 @@ public String toString() {
}
return sb.toString();
}
- }
+
+ /**
+ * True if command returned non-zero return code
+ * @return
+ */
+ public boolean failed() {
+ return this.returnValue != 0;
+ }
+ }
public static CommandOutput runWithRawOutput(String[] command) throws Exception {
//System.out.println(Joiner.on(" ").skipNulls().join(command));
View
4 clc/modules/dns/src/main/java/com/eucalyptus/cloud/ws/DNSControl.java
@@ -311,7 +311,7 @@ public RemoveMultiARecordResponseType RemoveMultiARecord(RemoveMultiARecordType
addrInfo = Entities.uniqueResult(ARecordAddressInfo.named(nameInfo, address));
ARecord arecord = new ARecord(Name.fromString(name), DClass.IN, nameInfo.getTtl(), Address.getByAddress(addrInfo.getAddress()));
- ZoneManager.deleteRecord(zone, arecord);
+ ZoneManager.deleteARecord(zone, arecord);
Entities.delete(addrInfo);
db.commit();
}catch(NoSuchElementException ex){
@@ -357,7 +357,7 @@ public RemoveMultiANameResponseType RemoveMultiAName(RemoveMultiANameType reques
for(ARecordAddressInfo addr : addresses){
try{
ARecord arecord = new ARecord(Name.fromString(name), DClass.IN, nameInfo.getTtl(), Address.getByAddress(addr.getAddress()));
- ZoneManager.deleteRecord(zone, arecord);
+ ZoneManager.deleteARecord(zone, arecord);
}catch(Exception ex){
throw new EucalyptusCloudException("Failed to delete the record from zone", ex);
}
View
27 clc/modules/dns/src/main/java/com/eucalyptus/cloud/ws/ZoneManager.java
@@ -301,6 +301,33 @@ public static void updateCNAMERecord(String zoneName, CNAMERecord record) {
LOG.error(ex);
}
}
+
+ public static void deleteARecord(String zoneName, ARecord record){
+ try {
+ Zone zone = getZone(zoneName);
+ if(zone == null)
+ return;
+ RRset rrSet = zone.findExactMatch(record.getName(), record.getDClass());
+ if(rrSet != null) {
+ Iterator<Record> rrIterator = rrSet.rrs();
+ Record recordToRemove = null;
+ while(rrIterator.hasNext()) {
+ final Record rec = rrIterator.next();
+ if(rec instanceof ARecord){
+ ARecord aRec = (ARecord)rec;
+ if(aRec.getName().equals(record.getName()) &&
+ aRec.getAddress().equals(record.getAddress())){
+ recordToRemove = rec;
+ }
+ }
+ }
+ if(recordToRemove != null)
+ zone.removeRecord(recordToRemove);
+ }
+ } catch(Exception ex) {
+ LOG.error(ex);
+ }
+ }
public static void deleteRecord(String zoneName, Record record) {
try {
View
3 clc/modules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancer.java
@@ -132,13 +132,10 @@ static LoadBalancer namedByAccount(final String accountName, final String lbName
@Column( name = "loadbalancer_scheme", nullable=true)
private String scheme = null; // only available for LoadBalancers attached to an Amazon VPC
-// @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "loadbalancer")
-// @OneToMany(fetch = FetchType.LAZY, mappedBy = "loadbalancer")
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, mappedBy = "loadbalancer")
@Cache( usage = CacheConcurrencyStrategy.TRANSACTIONAL )
private Collection<LoadBalancerBackendInstance> backendInstances = null;
-// @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "loadbalancer")
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, mappedBy = "loadbalancer")
@Cache( usage= CacheConcurrencyStrategy.TRANSACTIONAL )
private Collection<LoadBalancerListener> listeners = null;
View
73 ...loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancerBackendInstance.java
@@ -42,8 +42,10 @@
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Entity;
+import com.eucalyptus.bootstrap.Bootstrap;
import com.eucalyptus.cloud.UserMetadata;
import com.eucalyptus.component.ComponentIds;
+import com.eucalyptus.component.Topology;
import com.eucalyptus.component.id.Eucalyptus;
import com.eucalyptus.entities.Entities;
import com.eucalyptus.event.ClockTick;
@@ -140,6 +142,8 @@ private LoadBalancerBackendInstance(final OwnerFullName userFullName, final Load
db.rollback();
throw new InternalFailure400Exception("unable to find the zone");
}finally{
+ if(db.isActive())
+ db.rollback();
if(this.zone == null)
throw new InternalFailure400Exception("unable to find the instance's zone");
}
@@ -264,14 +268,56 @@ public FullName getFullName() {
.namespace( this.getOwnerAccountNumber( ) )
.relativeId( "loadbalancer-backend-instance", this.vmInstance.getInstanceId()!=null ? this.vmInstance.getInstanceId() : "");
}
+
+ @Override
+ public boolean equals(Object obj){
+ if(obj==null)
+ return false;
+ if(obj.getClass() != LoadBalancerBackendInstance.class)
+ return false;
+ final LoadBalancerBackendInstance other = (LoadBalancerBackendInstance) obj;
+
+ if(this.loadbalancer == null){
+ if(other.loadbalancer!=null)
+ return false;
+ }else if(this.loadbalancer.getOwnerUserId() == null){
+ if(other.loadbalancer.getOwnerUserId()!=null)
+ return false;
+ }else if(! this.loadbalancer.getOwnerUserId().equals(other.loadbalancer.getOwnerUserId()))
+ return false;
+
+ if(this.loadbalancer == null){
+ if(other.loadbalancer!=null)
+ return false;
+ }else if(this.loadbalancer.getDisplayName() == null){
+ if(other.loadbalancer.getDisplayName()!=null)
+ return false;
+ }else if(! this.loadbalancer.getDisplayName().equals(other.loadbalancer.getDisplayName()))
+ return false;
+
+ if(this.displayName == null){
+ if(other.displayName != null)
+ return false;
+ }else if(!this.displayName.equals(other.displayName))
+ return false;
+
+ return true;
+ }
+
@Override
public int hashCode( ) {
final int prime = 31;
int result = super.hashCode( );
- result = prime * result + ( ( this.vmInstance == null )
+ result = prime * result + ( ( this.loadbalancer == null || this.loadbalancer.getOwnerUserId() == null )
? 0
- : this.vmInstance.hashCode( ) );
- return result;
+ : this.loadbalancer.getOwnerUserId().hashCode());
+ result = prime * result + ( ( this.loadbalancer == null || this.loadbalancer.getDisplayName() == null )
+ ? 0
+ : this.loadbalancer.getDisplayName().hashCode());
+ result = prime * result + ( ( this.displayName == null )
+ ? 0
+ : this.displayName.hashCode());
+ return result;
}
@Override
@@ -301,6 +347,11 @@ public static void register(){
@Override
public void fireEvent(ClockTick event) {
+ if (!( Bootstrap.isFinished() &&
+ Topology.isEnabledLocally( LoadBalancing.class ) &&
+ Topology.isEnabled( Eucalyptus.class ) ))
+ return;
+
/// determine the BE instances to query
final List<LoadBalancerBackendInstance> allInstances = Lists.newArrayList();
final List<LoadBalancerBackendInstance> stateOutdated = Lists.newArrayList();
@@ -311,8 +362,10 @@ public void fireEvent(ClockTick event) {
db.commit();
}catch(final Exception ex){
db.rollback();
+ }finally{
+ if(db.isActive())
+ db.rollback();
}
- final Map<String, STATE> stateMap = new HashMap<String, STATE>();
final Date current = new Date(System.currentTimeMillis());
// find the record eligible to check its status
for(final LoadBalancerBackendInstance be : allInstances){
@@ -322,7 +375,6 @@ public void fireEvent(ClockTick event) {
int elapsedSec = (int)((current.getTime() - lastUpdate.getTime())/1000.0);
if(elapsedSec > CHECK_EVERY_SECONDS){
stateOutdated.add(be);
- stateMap.put(be.getInstanceId(), be.getBackendState());
}
}
@@ -336,6 +388,9 @@ public void fireEvent(ClockTick event) {
db.commit();
}catch(final Exception ex){
db.rollback();
+ }finally{
+ if(db.isActive())
+ db.rollback();
}
final List<String> instancesToCheck =
@@ -359,6 +414,7 @@ public String apply(
return;
}
+ final Map<String, STATE> stateMap = new HashMap<String, STATE>();
for(final RunningInstancesItemType instance : result){
final String state = instance.getStateName();
if("pending".equals(state))
@@ -378,8 +434,8 @@ else if("stopped".equals(state))
db = Entities.get(LoadBalancerBackendInstance.class);
try{
for(final LoadBalancerBackendInstance be : stateOutdated){
- STATE trueState = stateMap.get(be.getInstanceId());
- if(! trueState.equals(be.getBackendState())){
+ if(stateMap.containsKey(be.getInstanceId())){ // OutOfService || Error
+ final STATE trueState = stateMap.get(be.getInstanceId());
final LoadBalancerBackendInstance update = Entities.uniqueResult(be);
update.setBackendState(trueState);
Entities.persist(update);
@@ -388,6 +444,9 @@ else if("stopped".equals(state))
db.commit();
}catch(final Exception ex){
db.rollback();
+ }finally{
+ if(db.isActive())
+ db.rollback();
}
}
}
View
3 ...s/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancerCwatchMetrics.java
@@ -88,6 +88,9 @@ public void addMetric(final String servoId, final MetricData metric){
}catch(Exception ex){
db.rollback();
throw Exceptions.toUndeclared("database error while querying "+servoId);
+ }finally{
+ if(db.isActive())
+ db.rollback();
}
LoadBalancerZone zone = null;
View
34 clc/modules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancers.java
@@ -86,6 +86,9 @@ private static LoadBalancer getLoadbalancer(final String accountName, final Stri
return lb;
else
throw Exceptions.toUndeclared(ex);
+ }finally{
+ if(db.isActive())
+ db.rollback();
}
}
@@ -153,12 +156,16 @@ public static LoadBalancer addLoadbalancer(UserFullName user, String lbName, Str
return lb;
}
}catch(LoadBalancingException ex){
+ db.rollback();
throw ex;
}catch ( Exception ex ) {
db.rollback( );
LOG.error("failed to persist a new loadbalancer", ex);
throw new LoadBalancingException("Failed to persist a new load-balancer because of: " + ex.getMessage(), ex);
- }
+ }finally{
+ if(db.isActive())
+ db.rollback();
+ }
throw new LoadBalancingException("Failed to create a new load-balancer instance");
}
@@ -287,6 +294,9 @@ public static void addZone(final String lbName, final Context ctx, final Collect
db.rollback();
LOG.error("failed to persist the zone "+zone, ex);
throw ex;
+ }finally{
+ if(db.isActive())
+ db.rollback();
}
}
}catch(Exception ex){
@@ -301,8 +311,8 @@ public static void removeZone(final String lbName, final Context ctx, final Coll
}catch(Exception ex){
throw new AccessPointNotFoundException();
}
- final EntityTransaction db = Entities.get( LoadBalancerZone.class );
for(String zone : zones){
+ final EntityTransaction db = Entities.get( LoadBalancerZone.class );
try{
final LoadBalancerZone exist = Entities.uniqueResult(LoadBalancerZone.named(lb, zone));
Entities.delete(exist);
@@ -313,6 +323,9 @@ public static void removeZone(final String lbName, final Context ctx, final Coll
}catch(Exception ex){
db.rollback();
LOG.error("failed to delete the zone "+zone, ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
@@ -329,6 +342,9 @@ public static LoadBalancerZone findZone(final LoadBalancer lb, final String zone
}catch(Exception ex){
db.rollback();
throw Exceptions.toUndeclared(ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -357,6 +373,9 @@ public static LoadBalancerDnsRecord getDnsRecord(final LoadBalancer lb) throws L
}catch(Exception ex){
db.rollback();
throw new LoadBalancingException("failed to query dns record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -371,6 +390,9 @@ public static void deleteDnsRecord(final LoadBalancerDnsRecord dns) throws LoadB
}catch(Exception ex){
db.rollback();
throw new LoadBalancingException("failed to delete dns record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -386,7 +408,10 @@ public static LoadBalancerServoInstance lookupServoInstance(final String instanc
throw ex;
}catch(Exception ex){
db.rollback();
- throw new LoadBalancingException("failed to query servo instances");
+ throw new LoadBalancingException("failed to query servo instances", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -402,6 +427,9 @@ public static LoadBalancerBackendInstance lookupBackendInstance(final LoadBalanc
}catch(final Exception ex){
db.rollback();
throw Exceptions.toUndeclared(ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
View
105 ...odules/loadbalancing/src/main/java/com/eucalyptus/loadbalancing/LoadBalancingService.java
@@ -81,17 +81,18 @@
public class LoadBalancingService {
private static Logger LOG = Logger.getLogger( LoadBalancingService.class );
- private boolean isValidServoRequest(String instanceId){
+ private void isValidServoRequest(String instanceId) throws LoadBalancingException{
final Context ctx = Contexts.lookup( );
try{
final LoadBalancerServoInstance instance = LoadBalancers.lookupServoInstance(instanceId);
InetSocketAddress remoteAddr = ( ( InetSocketAddress ) ctx.getChannel( ).getRemoteAddress( ) );
String remoteHost = remoteAddr.getAddress( ).getHostAddress( );
if(! (remoteHost.equals(instance.getAddress()) || remoteHost.equals(instance.getPrivateIp())))
- return false;
- return true;
+ throw new LoadBalancingException(String.format("IP address (%s) not match with record (%s-%s)",remoteHost, instance.getAddress(), instance.getPrivateIp()));
+ }catch(final LoadBalancingException ex){
+ throw ex;
}catch(Exception ex){
- return false;
+ throw new LoadBalancingException("unknown error", ex);
}
}
@@ -103,17 +104,14 @@ public DescribeLoadBalancersByServoResponseType describeLoadBalancersByServo(Des
LoadBalancerZoneCoreView zoneView = null;
LoadBalancerZone zone = null;
try{
- if(isValidServoRequest(instanceId)){
- final LoadBalancerServoInstance instance = LoadBalancers.lookupServoInstance(instanceId);
- zoneView = instance.getAvailabilityZone();
- zone = LoadBalancerZoneEntityTransform.INSTANCE.apply(zoneView);
- }else{
- LOG.warn("invalid servo request found");
- }
+ isValidServoRequest(instanceId);
+ final LoadBalancerServoInstance instance = LoadBalancers.lookupServoInstance(instanceId);
+ zoneView = instance.getAvailabilityZone();
+ zone = LoadBalancerZoneEntityTransform.INSTANCE.apply(zoneView);
}catch(NoSuchElementException ex){
;
}catch(Exception ex){
- LOG.warn("failed to query loadbalancer for servo instance: "+instanceId);
+ LOG.warn("failed to find loadbalancer for servo instance: "+instanceId, ex);
}
@@ -238,8 +236,10 @@ public PutServoStatesResponseType putServoStates(PutServoStatesType request){
PutServoStatesResponseType reply = request.getReply();
final String servoId = request.getInstanceId();
- if(! isValidServoRequest(servoId)){
- LOG.warn("invalid servo request found");
+ try{
+ isValidServoRequest(servoId);
+ }catch(final Exception ex){
+ LOG.warn("invalid servo request", ex);
return reply;
}
@@ -288,39 +288,31 @@ public PutServoStatesResponseType putServoStates(PutServoStatesType request){
}
}
if(found!=null){
- LoadBalancerBackendInstance sample = null;
+ final EntityTransaction db = Entities.get( LoadBalancerBackendInstance.class );
try{
- sample=LoadBalancerBackendInstanceEntityTransform.INSTANCE.apply(found);
- }catch(final Exception ex){
+ final LoadBalancerBackendInstance update = Entities.uniqueResult(
+ LoadBalancerBackendInstance.named(lb, found.getInstanceId()));
+
+ update.setState(Enum.valueOf(LoadBalancerBackendInstance.STATE.class, state));
+ if(state.equals(LoadBalancerBackendInstance.STATE.OutOfService.name())){
+ update.setReasonCode("Instance");
+ update.setDescription("Instance has failed at least the UnhealthyThreshold number of health checks consecutively.");
+ }else{
+ update.setReasonCode("");
+ update.setDescription("");
+ }
+ update.updateInstanceStateTimestamp();
+ Entities.persist(update);
+ db.commit();
+ }catch(final NoSuchElementException ex){
+ db.rollback();
LOG.error("unable to find the loadbancer backend instance", ex);
- }
- if(sample!=null){
- final EntityTransaction db = Entities.get( LoadBalancerBackendInstance.class );
- try{
- final LoadBalancerBackendInstance update = Entities.uniqueResult(sample);
- if(! state.equals( found.getBackendState().toString())){ // state changed
- update.setState(Enum.valueOf(LoadBalancerBackendInstance.STATE.class, state));
- if(state.equals(LoadBalancerBackendInstance.STATE.OutOfService.name())){
- update.setReasonCode("Instance");
- update.setDescription("Instance has failed at least the UnhealthyThreshold number of health checks consecutively.");
- }else{
- update.setReasonCode(null);
- update.setDescription(null);
- }
- }
- update.updateInstanceStateTimestamp();
- Entities.persist(update);
- db.commit();
- }catch(final NoSuchElementException ex){
- db.rollback();
- LOG.error("unable to find the loadbancer backend instance", ex);
- }catch(final Exception ex){
+ }catch(final Exception ex){
+ db.rollback();
+ LOG.error("unable to update the state of loadbalancer backend instance", ex);
+ }finally{
+ if(db.isActive())
db.rollback();
- LOG.error("unable to update the state of loadbalancer backend instance", ex);
- }finally{
- if(db.isActive())
- db.rollback();
- }
}
}
}
@@ -344,6 +336,9 @@ public PutServoStatesResponseType putServoStates(PutServoStatesType request){
}catch(Exception ex){
db.rollback();
LOG.warn("Failed to query loadbalancer backend instance", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -399,17 +394,25 @@ public LoadBalancer get() {
} catch ( Exception e ) {
handleException( e );
}
+ final Collection<String> zones = request.getAvailabilityZones().getMember();
+
Function<String, Boolean> rollback = new Function<String, Boolean>(){
@Override
public Boolean apply(String lbName){
try{
LoadBalancers.unsetForeignKeys(ctx, lbName);
- }catch(Exception ex){
+ }catch(final Exception ex){
LOG.warn("unable to unset foreign keys", ex);
}
try{
+ LoadBalancers.removeZone(lbName, ctx, zones);
+ }catch(final Exception ex){
+ LOG.error("unable to delete availability zones during rollback", ex);
+ }
+
+ try{
LoadBalancers.deleteLoadbalancer(ownerFullName, lbName);
}catch(LoadBalancingException ex){
LOG.error("failed to rollback the loadbalancer: " + lbName, ex);
@@ -426,7 +429,6 @@ public Boolean apply(String lbName){
}
- Collection<String> zones = request.getAvailabilityZones().getMember();
if(zones != null && zones.size()>0){
try{
LoadBalancers.addZone(lbName, ctx, zones);
@@ -1235,7 +1237,10 @@ public ConfigureHealthCheckResponseType configureHealthCheck(ConfigureHealthChec
db.rollback();
LOG.error("failed to persist health check config", ex);
throw new InternalFailure400Exception("Failed to persist the health check config", ex);
- }
+ }finally {
+ if(db.isActive())
+ db.rollback();
+ }
ConfigureHealthCheckResult result = new ConfigureHealthCheckResult();
result.setHealthCheck(hc);
reply.setConfigureHealthCheckResult(result);
@@ -1300,7 +1305,8 @@ public DescribeInstanceHealthResponseType describeInstanceHealth(DescribeInstanc
state.setInstanceId(instance.getDisplayName());
if(outdated){
state.setState(LoadBalancerBackendInstance.STATE.OutOfService.toString());
- state.setReasonCode("Internal error: instance health not updated for extended period of time");
+ state.setReasonCode("ELB");
+ state.setDescription("Internal error: instance health not updated for extended period of time");
}else{
state.setState(instance.getState().name());
if(instance.getState().equals(LoadBalancerBackendInstance.STATE.OutOfService) && instance.getReasonCode()!=null)
@@ -1319,7 +1325,8 @@ public DescribeInstanceHealthResponseType describeInstanceHealth(DescribeInstanc
final LoadBalancerBackendInstance sample = LoadBalancerBackendInstanceEntityTransform.INSTANCE.apply(instanceView);
final LoadBalancerBackendInstance update = Entities.uniqueResult(sample);
update.setState(LoadBalancerBackendInstance.STATE.OutOfService);
- update.setReasonCode("Internal error: instance health not updated for extended period of time");
+ update.setReasonCode("ELB");
+ update.setDescription("Internal error: instance health not updated for extended period of time");
Entities.persist(update);
}
db.commit();
View
32 ...ancing/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainDelete.java
@@ -28,11 +28,15 @@
import org.apache.log4j.Logger;
+import com.eucalyptus.bootstrap.Bootstrap;
+import com.eucalyptus.component.Topology;
+import com.eucalyptus.component.id.Eucalyptus;
import com.eucalyptus.entities.Entities;
import com.eucalyptus.event.ClockTick;
import com.eucalyptus.event.EventListener;
import com.eucalyptus.event.Listeners;
import com.eucalyptus.loadbalancing.LoadBalancer;
+import com.eucalyptus.loadbalancing.LoadBalancing;
import com.eucalyptus.loadbalancing.LoadBalancerDnsRecord.LoadBalancerDnsRecordCoreView;
import com.eucalyptus.loadbalancing.LoadBalancerSecurityGroup;
import com.eucalyptus.loadbalancing.LoadBalancerSecurityGroup.LoadBalancerSecurityGroupCoreView;
@@ -200,6 +204,9 @@ public void apply(DeleteLoadbalancerEvent evt) throws EventHandlerException{
}catch(final Exception ex){
db.rollback();
LOG.error("Failed to update servo instance record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
// AutoScalingGroup record will be deleted as a result of cascaded delete
@@ -251,6 +258,9 @@ public void apply(DeleteLoadbalancerEvent evt)
}catch(Exception ex){
db.rollback();
LOG.warn("Could not disassociate the group from loadbalancer");
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
@@ -269,6 +279,11 @@ public static void register( ) {
@Override
public void fireEvent(ClockTick event) {
+ if (!( Bootstrap.isFinished() &&
+ Topology.isEnabledLocally( LoadBalancing.class ) &&
+ Topology.isEnabled( Eucalyptus.class ) ))
+ return;
+
/// find all security group whose member instances are empty
final EntityTransaction db = Entities.get( LoadBalancerSecurityGroup.class );
List<LoadBalancerSecurityGroup> allGroups = null;
@@ -279,6 +294,9 @@ public void fireEvent(ClockTick event) {
db.rollback();
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
if(allGroups==null || allGroups.size()<=0)
return;
@@ -311,6 +329,9 @@ public void fireEvent(ClockTick event) {
}catch(Exception ex){
LOG.warn("failed to delete the securty group from entity", ex);
db2.rollback();
+ }finally {
+ if(db2.isActive())
+ db2.rollback();
}
}
}
@@ -323,6 +344,11 @@ public static void register( ) {
@Override
public void fireEvent(ClockTick event) {
+ if (!( Bootstrap.isFinished() &&
+ Topology.isEnabledLocally( LoadBalancing.class ) &&
+ Topology.isEnabled( Eucalyptus.class ) ))
+ return;
+
// find all OutOfService instances
List<LoadBalancerServoInstance> retired=null;
final EntityTransaction db = Entities.get( LoadBalancerServoInstance.class );
@@ -336,6 +362,9 @@ public void fireEvent(ClockTick event) {
}catch(Exception ex){
db.rollback();
LOG.warn("failed to query loadbalancer servo instance", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
if(retired == null || retired.size()<=0)
@@ -379,6 +408,9 @@ public void fireEvent(ClockTick event) {
db2.commit();
}catch(Exception ex){
db2.rollback();
+ }finally {
+ if(db2.isActive())
+ db2.rollback();
}
}
}
View
28 ...g/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainDisableZone.java
@@ -155,6 +155,8 @@ public void apply(DisabledZoneEvent evt) throws EventHandlerException {
}
for(final LoadBalancerServoInstanceCoreView instance : zone.getServoInstances()){
+ if(! LoadBalancerServoInstance.STATE.InService.equals(instance.getState()))
+ continue;
final String ipAddr = instance.getAddress();
ipAddressToRemove.add(ipAddr);
}
@@ -240,7 +242,10 @@ public void apply(DisabledZoneEvent evt) throws EventHandlerException {
}catch(final Exception ex){
db.rollback();
LOG.warn("Failed to update the servo instance's state", ex);
- }
+ }finally {
+ if(db.isActive())
+ db.rollback();
+ }
}
}
}
@@ -262,7 +267,10 @@ public void rollback() throws EventHandlerException {
}catch(final Exception ex){
db.rollback();
LOG.warn("Failed to update the servo instance's state", ex);
- }
+ }finally {
+ if(db.isActive())
+ db.rollback();
+ }
}
}
}
@@ -351,6 +359,9 @@ public String apply(@Nullable LoadBalancerZoneCoreView arg0) {
}catch(Exception ex){
db.rollback();
LOG.error("failed to update the autoscaling group record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}catch(final Exception ex){
throw new EventHandlerException("failed to update the autoscaling group", ex);
@@ -389,6 +400,9 @@ public void rollback() throws EventHandlerException {
}catch(Exception ex){
db.rollback();
LOG.error("failed to update the autoscaling group record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}catch(Exception ex){
throw new EventHandlerException("failed to update the zone to the original list", ex);
@@ -441,6 +455,9 @@ public void apply(DisabledZoneEvent evt)
db.rollback();
}catch(final Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
@@ -479,11 +496,13 @@ public void apply(DisabledZoneEvent evt) throws EventHandlerException {
for(final String removedZone : updated.getResult()){
final LoadBalancerZone zone = LoadBalancers.findZone(lb, removedZone);
for(final LoadBalancerBackendInstanceCoreView instance : zone.getBackendInstances()){
- final EntityTransaction db = Entities.get( LoadBalancerBackendInstanceCoreView.class );
+ final EntityTransaction db = Entities.get( LoadBalancerBackendInstance.class );
try{
final LoadBalancerBackendInstance update = Entities.uniqueResult(
LoadBalancerBackendInstance.named(lb, instance.getInstanceId()));
update.setState(LoadBalancerBackendInstance.STATE.OutOfService);
+ update.setReasonCode("ELB");
+ update.setDescription("Zone disabled");
Entities.persist(update);
db.commit();
this.updatedInstances.add(update);
@@ -493,6 +512,9 @@ public void apply(DisabledZoneEvent evt) throws EventHandlerException {
}catch(final Exception ex){
db.rollback();
LOG.warn("failed to query the backend instance", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
View
69 ...ng/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainEnableZone.java
@@ -31,7 +31,9 @@
import com.eucalyptus.entities.Entities;
import com.eucalyptus.loadbalancing.LoadBalancer;
+import com.eucalyptus.loadbalancing.LoadBalancerBackendInstance;
import com.eucalyptus.loadbalancing.LoadBalancerZone;
+import com.eucalyptus.loadbalancing.LoadBalancerBackendInstance.LoadBalancerBackendInstanceCoreView;
import com.eucalyptus.loadbalancing.LoadBalancerZone.LoadBalancerZoneCoreView;
import com.eucalyptus.loadbalancing.LoadBalancers;
import com.eucalyptus.loadbalancing.activities.LoadBalancerAutoScalingGroup.LoadBalancerAutoScalingGroupCoreView;
@@ -56,6 +58,7 @@
this.insert(new CheckAndModifyRequest(this));
this.insert(new CreateOrUpdateAutoscalingGroup(this));
this.insert(new PersistUpdatedZones(this));
+ this.insert(new PersistBackendInstanceState(this));
return this;
}
@@ -233,6 +236,9 @@ public String apply(@Nullable LoadBalancerZoneCoreView arg0) {
}catch(Exception ex){
db.rollback();
LOG.error("failed to update the autoscaling group record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
this.newZones = Lists.newArrayList(newZones);
@@ -273,6 +279,9 @@ public void rollback() throws EventHandlerException {
}catch(Exception ex){
db.rollback();
LOG.error("failed to update the autoscaling group record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}catch(Exception ex){
throw new EventHandlerException("failed to update the zone to the original list", ex);
@@ -322,6 +331,9 @@ public void apply(EnabledZoneEvent evt) throws EventHandlerException {
persistedZones.add(newZone);
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
@@ -339,9 +351,66 @@ public void rollback() throws EventHandlerException {
}catch(final Exception ex){
db.rollback();
LOG.error("could not mark out of state for the zone", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
+ }
+
+ private static class PersistBackendInstanceState extends AbstractEventHandler<EnabledZoneEvent> {
+ protected PersistBackendInstanceState(
+ EventHandlerChain<EnabledZoneEvent> chain) {
+ super(chain);
+ }
+
+ @Override
+ public void apply(EnabledZoneEvent evt) throws EventHandlerException {
+ LoadBalancer lb = null;
+ try{
+ lb = LoadBalancers.getLoadbalancer(evt.getContext(), evt.getLoadBalancer());
+ }catch(NoSuchElementException ex){
+ LOG.warn("Could not find the loadbalancer with name="+evt.getLoadBalancer(), ex);
+ return;
+ }catch(Exception ex){
+ LOG.warn("Error while looking for loadbalancer with name="+evt.getLoadBalancer(), ex);
+ return;
+ }
+
+ try{
+ for(final String enabledZone : evt.getZones()){
+ final LoadBalancerZone zone = LoadBalancers.findZone(lb, enabledZone);
+ for(final LoadBalancerBackendInstanceCoreView instance : zone.getBackendInstances()){
+ final EntityTransaction db = Entities.get( LoadBalancerBackendInstance.class );
+ try{
+ final LoadBalancerBackendInstance update = Entities.uniqueResult(
+ LoadBalancerBackendInstance.named(lb, instance.getInstanceId()));
+ update.setReasonCode("");
+ update.setDescription("");
+ Entities.persist(update);
+ db.commit();
+ }catch(final NoSuchElementException ex){
+ db.rollback();
+ LOG.warn("failed to find the backend instance");
+ }catch(final Exception ex){
+ db.rollback();
+ LOG.warn("failed to query the backend instance", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
+ }
+ }
+ }
+ }catch(final Exception ex){
+ LOG.warn("unable to update backend instances after enabling zone", ex);
+ }
+ }
+
+ @Override
+ public void rollback() throws EventHandlerException {
+ ;
+ }
}
}
View
43 ...balancing/src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainNew.java
@@ -485,6 +485,9 @@ public void apply(NewLoadbalancerEvent evt)
db.rollback();
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
// check if there's an existing group with the same name
@@ -537,6 +540,9 @@ public void apply(NewLoadbalancerEvent evt)
}catch(Exception ex){
db.rollback();
throw new EventHandlerException("Error while persisting security group", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -575,6 +581,9 @@ public void rollback()
}catch(Exception ex){
db.rollback();
LOG.error("failed to mark the security group OutOfService", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -663,6 +672,9 @@ public void fireEvent(ClockTick event) {
db.rollback();
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
Map<String, LoadBalancerAutoScalingGroup> groupToQuery = new ConcurrentHashMap<String, LoadBalancerAutoScalingGroup>();
@@ -683,6 +695,9 @@ public void fireEvent(ClockTick event) {
db.rollback();
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
groupToQuery.put(group.getName(), group);
}
@@ -718,6 +733,9 @@ public void fireEvent(ClockTick event) {
db.rollback();
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
/// for all found instances that's not in the servo instance DB
@@ -794,6 +812,9 @@ public void fireEvent(ClockTick event) {
}catch(Exception ex){
db.rollback();
LOG.error("Failed to persist the servo instance record", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
@@ -803,7 +824,7 @@ public void fireEvent(ClockTick event) {
servoRecords.addAll(group.getServos());
}
- List<LoadBalancerServoInstance> registerDnsARec = Lists.newArrayList();
+ //final List<LoadBalancerServoInstance> registerDnsARec = Lists.newArrayList();
for(LoadBalancerServoInstanceCoreView instanceView : servoRecords){
/// CASE 2: EXISTING SERVO INSTANCES ARE NOT FOUND IN THE QUERY RESPONSE
if(! foundInstances.containsKey(instanceView.getInstanceId()) &&
@@ -826,6 +847,9 @@ public void fireEvent(ClockTick event) {
db.rollback();
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}else{/// CASE 3: INSTANCE STATE UPDATED
Instance instanceCurrent = foundInstances.get(instanceView.getInstanceId());
@@ -855,10 +879,9 @@ else if(lifecycleState.equals("Terminating") || lifecycleState.equals("Terminate
}catch(final Exception ex){
LOG.error("unable to transform servo instance from the view", ex);
continue;
- }
-
- if(newState.equals(LoadBalancerServoInstance.STATE.InService))
- registerDnsARec.add(instance);
+ }
+ // if(newState.equals(LoadBalancerServoInstance.STATE.InService))
+ // registerDnsARec.add(instance);
db = Entities.get( LoadBalancerServoInstance.class );
try{
@@ -870,13 +893,16 @@ else if(lifecycleState.equals("Terminating") || lifecycleState.equals("Terminate
db.rollback();
}catch(Exception ex){
db.rollback();
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
}
/// for new servo instances, find the IP and register it with DNS
- for(final LoadBalancerServoInstance instance : registerDnsARec){
+ /* for(final LoadBalancerServoInstance instance : registerDnsARec){
String ipAddr = null;
String privateIpAddr = null;
try{
@@ -917,8 +943,11 @@ else if(lifecycleState.equals("Terminating") || lifecycleState.equals("Terminate
}catch(Exception ex){
db.rollback();
LOG.warn("failed to update servo instance's ip address", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
- }
+ }*/
}
}
}
View
3 .../src/main/java/com/eucalyptus/loadbalancing/activities/EventHandlerChainNewListeners.java
@@ -171,6 +171,9 @@ public void apply(CreateListenerEvent evt)
}catch(final Exception exx){
db.rollback();
LOG.warn("Unable to query the loadbalancer", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
}
}
}
View
181 ...cing/src/main/java/com/eucalyptus/loadbalancing/activities/LoadBalancerServoInstance.java
@@ -19,6 +19,10 @@
************************************************************************/
package com.eucalyptus.loadbalancing.activities;
+import java.util.Date;
+import java.util.List;
+import java.util.NoSuchElementException;
+
import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.EntityTransaction;
@@ -34,22 +38,35 @@
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Entity;
+import com.eucalyptus.bootstrap.Bootstrap;
+import com.eucalyptus.component.Topology;
+import com.eucalyptus.component.id.Eucalyptus;
import com.eucalyptus.entities.AbstractPersistent;
import com.eucalyptus.entities.Entities;
+import com.eucalyptus.event.ClockTick;
+import com.eucalyptus.event.EventListener;
+import com.eucalyptus.event.Listeners;
import com.eucalyptus.loadbalancing.LoadBalancer;
+import com.eucalyptus.loadbalancing.LoadBalancerBackendInstance;
import com.eucalyptus.loadbalancing.LoadBalancerDnsRecord;
+import com.eucalyptus.loadbalancing.LoadBalancing;
import com.eucalyptus.loadbalancing.LoadBalancer.LoadBalancerEntityTransform;
+import com.eucalyptus.loadbalancing.LoadBalancerBackendInstance.STATE;
import com.eucalyptus.loadbalancing.LoadBalancerDnsRecord.LoadBalancerDnsRecordCoreView;
import com.eucalyptus.loadbalancing.LoadBalancerDnsRecord.LoadBalancerDnsRecordEntityTransform;
import com.eucalyptus.loadbalancing.LoadBalancerSecurityGroup;
import com.eucalyptus.loadbalancing.LoadBalancerSecurityGroup.LoadBalancerSecurityGroupCoreView;
import com.eucalyptus.loadbalancing.LoadBalancerZone;
import com.eucalyptus.loadbalancing.LoadBalancerZone.LoadBalancerZoneCoreView;
+import com.eucalyptus.loadbalancing.activities.EventHandlerChainDelete.SecurityGroupCleanup;
import com.eucalyptus.loadbalancing.activities.LoadBalancerAutoScalingGroup.LoadBalancerAutoScalingGroupCoreView;
import com.eucalyptus.util.Exceptions;
import com.eucalyptus.util.TypeMapper;
import com.eucalyptus.util.TypeMappers;
import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import edu.ucsb.eucalyptus.msgs.RunningInstancesItemType;
/**
* @author Sang-Min Park (spark@eucalyptus.com)
@@ -76,6 +93,9 @@ private void onLoad(){
enum STATE {
Pending, InService, Error, OutOfService, Retired
}
+ enum DNS_STATE {
+ Registered, Deregistered, None
+ }
@ManyToOne
@JoinColumn( name = "metadata_zone_fk", nullable=true)
@@ -108,8 +128,12 @@ private void onLoad(){
@Column(name="metadata_private_ip", nullable=true)
private String privateIp = null;
+ @Column(name="metadata_dns_state", nullable=true)
+ private String dnsState = null;
+
private LoadBalancerServoInstance(){
}
+
private LoadBalancerServoInstance(final LoadBalancerZone lbzone){
this.state = STATE.Pending.name();
this.zone = lbzone;
@@ -148,6 +172,8 @@ public static LoadBalancerServoInstance newInstance(final LoadBalancerZone lbzon
final LoadBalancerServoInstance instance = new LoadBalancerServoInstance(lbzone, group, dns);
instance.setInstanceId(instanceId);
instance.setAutoScalingGroup(as_group);
+ instance.dnsState = DNS_STATE.None.name();
+
return instance;
}
@@ -165,6 +191,7 @@ public static LoadBalancerServoInstance named(String instanceId){
public static LoadBalancerServoInstance named(){
return new LoadBalancerServoInstance();
}
+
public static LoadBalancerServoInstance withState(String state){
final LoadBalancerServoInstance sample = new LoadBalancerServoInstance();
sample.state = state;
@@ -233,6 +260,14 @@ public void setPrivateIp(final String ipAddr){
this.privateIp = ipAddr;
}
+ public void setDnsState(final DNS_STATE dnsState){
+ this.dnsState = dnsState.toString();
+ }
+
+ public DNS_STATE getDnsState(){
+ return Enum.valueOf(DNS_STATE.class, this.dnsState);
+ }
+
@Override
public String toString(){
String id = this.instanceId==null? "unassigned" : this.instanceId;
@@ -319,4 +354,150 @@ public LoadBalancerZoneCoreView getZone(){
return this.zone;
}
}
+
+ // make sure InService servo instance has its IP registered to DNS
+ // also make sure Error or OutOfService servo instance has its IP deregistered from DNS
+ public static class ServoInstanceDnsCheck implements EventListener<ClockTick> {
+ static final int CHECK_EVERY_SECONDS = 10;
+ public static void register( ) {
+ Listeners.register( ClockTick.class, new ServoInstanceDnsCheck() );
+ }
+
+ @Override
+ public void fireEvent(ClockTick event) {
+ if (!( Bootstrap.isFinished() &&
+ Topology.isEnabledLocally( LoadBalancing.class ) &&
+ Topology.isEnabled( Eucalyptus.class ) ))
+ return;
+
+ /// determine the BE instances to query
+ final List<LoadBalancerServoInstance> allInstances = Lists.newArrayList();
+ final List<LoadBalancerServoInstance> stateOutdated = Lists.newArrayList();
+ EntityTransaction db = Entities.get(LoadBalancerServoInstance.class);
+ try{
+ allInstances.addAll(
+ Entities.query(LoadBalancerServoInstance.named()));
+ db.commit();
+ }catch(final Exception ex){
+ db.rollback();
+ }finally{
+ if(db.isActive())
+ db.rollback();
+ }
+ final Date current = new Date(System.currentTimeMillis());
+
+ for(final LoadBalancerServoInstance se : allInstances){
+ final Date lastUpdate = se.getLastUpdateTimestamp();
+ int elapsedSec = (int)((current.getTime() - lastUpdate.getTime())/1000.0);
+ if(elapsedSec > CHECK_EVERY_SECONDS){
+ stateOutdated.add(se);
+ }
+ }
+
+ db = Entities.get(LoadBalancerServoInstance.class);
+ try{
+ for(final LoadBalancerServoInstance se: stateOutdated){
+ final LoadBalancerServoInstance update = Entities.uniqueResult(se);
+ update.setLastUpdateTimestamp(current);
+ Entities.persist(update);
+ }
+ db.commit();
+ }catch(final Exception ex){
+ db.rollback();
+ }finally{
+ if(db.isActive())
+ db.rollback();
+ }
+
+ for(final LoadBalancerServoInstance instance : stateOutdated){
+ if(LoadBalancerServoInstance.STATE.InService.equals(instance.getState())){
+ if(!LoadBalancerServoInstance.DNS_STATE.Registered.equals(instance.getDnsState())){
+ String ipAddr = null;
+ String privateIpAddr = null;
+ if(instance.getAddress()==null){
+ try{
+ List<RunningInstancesItemType> result =
+ EucalyptusActivityTasks.getInstance().describeSystemInstances(Lists.newArrayList(instance.getInstanceId()));
+ if(result!=null && result.size()>0){
+ ipAddr = result.get(0).getIpAddress();
+ privateIpAddr = result.get(0).getPrivateIpAddress();
+ }
+ }catch(Exception ex){
+ LOG.warn("failed to run describe-instances", ex);
+ continue;
+ }
+ if(ipAddr == null || ipAddr.length()<=0){
+ LOG.warn("no ipaddress found for instance "+instance.getInstanceId());
+ continue;
+ }
+ }else{
+ ipAddr = instance.getAddress();
+ privateIpAddr = instance.getPrivateIp();
+ }
+
+ try{
+ final String zone = instance.getDns().getZone();
+ final String name = instance.getDns().getName();
+ EucalyptusActivityTasks.getInstance().addARecord(zone, name, ipAddr);
+ }catch(Exception ex){
+ LOG.warn("failed to register new ipaddress with dns A record", ex);
+ continue;
+ }
+
+ db = Entities.get( LoadBalancerServoInstance.class );
+ try{
+ final LoadBalancerServoInstance update = Entities.uniqueResult(instance);
+ update.setAddress(ipAddr);
+ if(privateIpAddr!=null)
+ update.setPrivateIp(privateIpAddr);
+ update.setDnsState(LoadBalancerServoInstance.DNS_STATE.Registered);
+ Entities.persist(update);
+ db.commit();
+ }catch(NoSuchElementException ex){
+ db.rollback();
+ LOG.warn("failed to find the servo instance named "+instance.getInstanceId(), ex);
+ }catch(Exception ex){
+ db.rollback();
+ LOG.warn("failed to update servo instance's ip address", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
+ }
+ }
+ }else if (LoadBalancerServoInstance.STATE.OutOfService.equals(instance.getState()) ||
+ LoadBalancerServoInstance.STATE.Error.equals(instance.getState())
+ ){
+ if(!LoadBalancerServoInstance.DNS_STATE.Deregistered.equals(instance.getDnsState())){
+ try{
+ final String ipAddr = instance.getAddress();
+ if(ipAddr==null) // IP address not found yet
+ continue;
+ final String zone = instance.getDns().getZone();
+ final String name = instance.getDns().getName();
+ EucalyptusActivityTasks.getInstance().removeARecord(zone, name, ipAddr);
+ }catch(Exception ex){
+ LOG.warn("failed to remove IP address from the dns A record", ex);
+ continue;
+ }
+ db = Entities.get( LoadBalancerServoInstance.class );
+ try{
+ final LoadBalancerServoInstance update = Entities.uniqueResult(instance);
+ update.setDnsState(LoadBalancerServoInstance.DNS_STATE.Deregistered);
+ Entities.persist(update);
+ db.commit();
+ }catch(NoSuchElementException ex){
+ db.rollback();
+ LOG.warn("failed to find the servo instance named "+instance.getInstanceId(), ex);
+ }catch(Exception ex){
+ db.rollback();
+ LOG.warn("failed to update servo instance's ip address", ex);
+ }finally {
+ if(db.isActive())
+ db.rollback();
+ }
+ }
+ }
+ }
+ }
+ }
}
View
96 clc/modules/msgs/src/main/java/com/eucalyptus/crypto/util/BCSslSetup.java
@@ -0,0 +1,96 @@
+/*************************************************************************
+ * Copyright 2009-2013 Eucalyptus Systems, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
+ * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
+ * additional information or have any questions.
+ ************************************************************************/
+package com.eucalyptus.crypto.util;
+
+import java.lang.reflect.Field;
+import java.math.BigInteger;
+import java.security.SecureRandom;
+import java.util.Hashtable;
+import javax.crypto.spec.DHParameterSpec;
+import org.apache.log4j.Logger;
+import org.bouncycastle.crypto.params.DHKeyGenerationParameters;
+import org.bouncycastle.crypto.params.DHParameters;
+import org.bouncycastle.jce.provider.JDKKeyPairGenerator;
+import com.google.common.collect.ImmutableList;
+
+/**
+ *
+ */
+class BCSslSetup {
+
+ private static Logger logger = Logger.getLogger( BCSslSetup.class );
+
+ private static final ImmutableList<DHParameterSpec> parameterSpecs = ImmutableList.of(
+ parameterSpec( // First Oakley Group - http://www.ietf.org/rfc/rfc2409.txt )(Section 6.1)
+ "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
+ + "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
+ + "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
+ + "E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF",
+ 2,
+ 768 ),
+ parameterSpec( // Second Oakley Group - http://www.ietf.org/rfc/rfc2409.txt )(Section 6.2)
+ "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
+ + "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
+ + "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
+ + "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED"
+ + "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381"
+ + "FFFFFFFF FFFFFFFF",
+ 2,
+ 1024 )
+ );
+
+ private static DHParameterSpec parameterSpec( final String primeModulusHex,
+ final int baseGenerator,
+ final int sizeInBits ) {
+ final BigInteger p = new BigInteger( primeModulusHex.replace( " ", "" ), 16 );
+ final BigInteger g = BigInteger.valueOf( baseGenerator );
+ return new DHParameterSpec( p, g, sizeInBits );
+ }
+
+ /**
+ * Initialize Diffie-Hellman parameters using standard values.
+ */
+ static void initBouncyCastleDHParams( ) {
+ try {
+ initBouncyCastleDHParamsInternal( );
+ } catch ( Throwable e ) {
+ logger.error( e, e );
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ static void initBouncyCastleDHParamsInternal( ) throws NoSuchFieldException, IllegalAccessException {
+ final Class<?> DH = JDKKeyPairGenerator.DH.class;
+ final Field paramsField = DH.getDeclaredField( "params" );
+ paramsField.setAccessible( true );
+ final Hashtable<Integer,DHKeyGenerationParameters> params =
+ (Hashtable<Integer,DHKeyGenerationParameters>) paramsField.get( null );
+ if ( params.isEmpty() ) {
+ final SecureRandom random = new SecureRandom();
+ for ( final DHParameterSpec parameterSpec : parameterSpecs ) {
+ params.put(
+ parameterSpec.getL( ),
+ new DHKeyGenerationParameters(
+ random,
+ new DHParameters( parameterSpec.getP( ), parameterSpec.getG( ), null, 0 ) ) );
+ }
+ }
+ }
+}
View
1 clc/modules/msgs/src/main/java/com/eucalyptus/crypto/util/SslSetup.java
@@ -152,6 +152,7 @@ public void fireChange( ConfigurableProperty t, String newValue ) throws Configu
}
static {
+ BCSslSetup.initBouncyCastleDHParams();
SSLContext serverContext;
SSLContext clientContext;
System.setProperty( "javax.net.ssl.trustStore", SubDirectory.KEYS.toString( ) + File.separator + "euca.p12" );
View
33 clc/modules/msgs/src/main/java/com/eucalyptus/ws/protocol/SoapHandler.java
@@ -101,11 +101,11 @@ public void incomingMessage( final MessageEvent event ) throws Exception {
message.setOmMessage( env.getBody( ).getFirstElement( ) );
} else {
final SOAPHeader header = env.getHeader( );
+ String action = "ProblemAction";
+ String relatesTo = "RelatesTo";
if ( header != null ) {
final List<SOAPHeaderBlock> headers = Lists.newArrayList( header.examineAllHeaderBlocks( ) );
// :: try to get the fault info from the soap header -- hello there? :://
- String action = "ProblemAction";
- String relatesTo = "RelatesTo";
for ( final SOAPHeaderBlock headerBlock : headers ) {
if ( action.equals( headerBlock.getLocalName( ) ) ) {
action = headerBlock.getText( );
@@ -113,21 +113,22 @@ public void incomingMessage( final MessageEvent event ) throws Exception {
relatesTo = headerBlock.getText( );
}
}
- // :: process the real fault :://
- final SOAPFault fault = env.getBody( ).getFault( );
- if ( fault != null ) {
- String faultReason = "";
- final Iterator children = fault.getChildElements( );
- while ( children.hasNext( ) ) {
- final OMElement child = ( OMElement ) children.next( );
- faultReason += child.getText( );
- }
- final String faultCode = fault.getCode( ).getText( );
- faultReason = faultReason.replaceAll( faultCode, "" );
- final String faultDetail = fault.getDetail( ).getText( );
- throw new EucalyptusRemoteFault( action, relatesTo, faultCode, faultReason, faultDetail );
- }
}
+ //faults don't need to have a header.
+ // :: process the real fault :://
+ final SOAPFault fault = env.getBody( ).getFault( );
+ if ( fault != null ) {
+ String faultReason = "";
+ final Iterator children = fault.getChildElements( );
+ while ( children.hasNext( ) ) {
+ final OMElement child = ( OMElement ) children.next( );
+ faultReason += child.getText( );
+ }
+ final String faultCode = fault.getCode( ).getText( );
+ faultReason = faultReason.replaceAll( faultCode, "" );
+ final String faultDetail = fault.getDetail( ).getText( );
+ throw new EucalyptusRemoteFault( action, relatesTo, faultCode, faultReason, faultDetail );
+ }
}
}
}
View
4 clc/modules/msgs/src/main/java/com/eucalyptus/ws/server/ServiceContextHandler.java
@@ -235,7 +235,9 @@ private void channelClosed( ChannelHandlerContext ctx, ChannelStateEvent evt ) {
}
}
try {
- Logs.extreme( ).debug( EventRecord.here( this.messageType.getClass( ), EventClass.MESSAGE, EventType.MSG_SERVICED, "rtt-ms", Long.toString( System.currentTimeMillis( ) - this.openTime.get( ctx.getChannel( ) ) ) ) );
+ if ( ctx.getChannel() != null ) {
+ Logs.extreme( ).debug( EventRecord.here( this.messageType.getClass( ), EventClass.MESSAGE, EventType.MSG_SERVICED, "rtt-ms", Long.toString( System.currentTimeMillis( ) - this.openTime.get( ctx.getChannel( ) ) ) ) );
+ }
} catch ( Exception ex ) {
Logs.extreme( ).trace( ex, ex );
}