Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
EUCA-10748: Allow deregistered EMIs to be used for create-image
Browse files Browse the repository at this point in the history
EUCA-10716: Do not delete ELB policy if set for backend servers
  • Loading branch information
sangmin committed May 26, 2015
1 parent c80f5ed commit 1f2e510
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public ImageInfo apply( final String input ) {
try {
return LookupMachine.INSTANCE.apply( input );
} catch ( final Exception ex ) {
return LookupBlockStorage.INSTANCE.apply( input );
return LookupAvailableBlockStorage.INSTANCE.apply( input );
}
} else {
throw new NoSuchElementException( "Failed to lookup image: " + input );
Expand All @@ -158,6 +158,26 @@ public ImageInfo apply( final String input ) {
}

public enum LookupBlockStorage implements Function<String, BlockStorageImageInfo> {
INSTANCE;
@Override
public BlockStorageImageInfo apply( final String identifier ) {
final EntityTransaction db = Entities.get( BlockStorageImageInfo.class );
try {
final BlockStorageImageInfo ret = Entities.uniqueResult( Images.exampleBlockStorageWithImageId( identifier ) );
if ( Platform.windows.name( ).equals( ret.getKernelId( ) ) || ret.getImageName( ).startsWith( Platform.windows.name( ) ) ) {
ret.setPlatform( Platform.windows );
}
db.rollback( );
return ret;
} catch ( final Exception ex ) {
Logs.exhaust( ).error( ex, ex );
db.rollback( );
throw new NoSuchElementException( "Failed to lookup image: " + identifier + " because of " + ex.getMessage( ) );
}
}
}

public enum LookupAvailableBlockStorage implements Function<String, BlockStorageImageInfo> {
INSTANCE;
@Override
public BlockStorageImageInfo apply( final String identifier ) {
Expand Down Expand Up @@ -564,7 +584,7 @@ public BootableSet apply( final String input ) {
throw Exceptions.toUndeclared( ex );
} catch ( final Exception e ) {
try {
bootSet = new BootableSet( resolveDiskImage( input, LookupBlockStorage.INSTANCE ) );
bootSet = new BootableSet( resolveDiskImage( input, LookupAvailableBlockStorage.INSTANCE ) );
} catch ( final IllegalContextAccessException ex ) {
throw Exceptions.toUndeclared( new IllegalMetadataAccessException( ex ) );
} catch ( final IllegalMetadataAccessException ex ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ public static void deleteLoadBalancerPolicy(final LoadBalancer lb, final String
if(listeners!=null && listeners.size()>0)
throw new InvalidConfigurationRequestException("The policy is enabled for listeners");

// check policy - backend association
final List<LoadBalancerBackendServerDescriptionCoreView> backends = toDelete.getBackendServers();
if(backends!=null && backends.size()>0)
throw new InvalidConfigurationRequestException("The policy is enabled for backend servers");

try ( final TransactionResource db = Entities.transactionFor( LoadBalancerPolicyAttributeDescription.class ) ) {
Entities.deleteAllMatching(LoadBalancerPolicyAttributeDescription.class,
"WHERE metadata_policy_desc_fk = :metadata_policy_desc_fk",
Expand Down

0 comments on commit 1f2e510

Please sign in to comment.