~ubuntu-core-dev/ubuntu/maverick/eucalyptus/devel

« back to all changes in this revision

Viewing changes to .pc/09-small-128-192MB.patch/clc/modules/authentication/src/main/java/com/eucalyptus/auth/DatabaseAuthBootstrapper.java

  • Committer: Dustin Kirkland
  • Date: 2010-07-22 08:41:57 UTC
  • mfrom: (1050.1.19 ubuntu)
  • Revision ID: kirkland@x200-20100722084157-zh2p8dkawznvxxpn
Approving Dave Walker's merge of new upstream Eucalyptus 2.0 release.

Dustin Kirkland <kirkland@canonical.com>

* New major upstream version merge, 2.0 (r1211).
  - 01-wsdl-stubs.patch, debian/wsdl.md5sums: wsdl stubs updated.
  - 11-state-cleanup-memleakfix.patch: Removed, fixed upstream.
  - 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
package com.eucalyptus.auth;
 
2
 
 
3
import org.apache.log4j.Logger;
 
4
import com.eucalyptus.auth.util.AuthBootstrapHelper;
 
5
import com.eucalyptus.bootstrap.Bootstrap;
 
6
import com.eucalyptus.bootstrap.Bootstrapper;
 
7
import com.eucalyptus.bootstrap.Component;
 
8
import com.eucalyptus.bootstrap.DependsLocal;
 
9
import com.eucalyptus.bootstrap.Provides;
 
10
import com.eucalyptus.bootstrap.RunDuring;
 
11
import com.eucalyptus.bootstrap.Bootstrap.Stage;
 
12
import com.eucalyptus.entities.Counters;
 
13
import com.eucalyptus.entities.EntityWrapper;
 
14
import com.eucalyptus.entities.VmType;
 
15
 
 
16
@Provides( Component.bootstrap )
 
17
@RunDuring( Bootstrap.Stage.UserCredentialsInit )
 
18
public class DatabaseAuthBootstrapper extends Bootstrapper {
 
19
  private static Logger LOG = Logger.getLogger( DatabaseAuthBootstrapper.class );
 
20
  
 
21
  public static boolean ENABLE = true;
 
22
  
 
23
  public boolean load( Stage current ) throws Exception {
 
24
    if (ENABLE) {
 
25
      DatabaseAuthProvider dbAuth = new DatabaseAuthProvider( );
 
26
      Users.setUserProvider( dbAuth );
 
27
      Groups.setGroupProvider( dbAuth );
 
28
      UserInfoStore.setUserInfoProvider( dbAuth );
 
29
    }
 
30
    return true;
 
31
  }
 
32
  
 
33
  public boolean start( ) throws Exception {
 
34
    if (ENABLE) {
 
35
      this.checkUserEnabled( );
 
36
      AuthBootstrapHelper.ensureStandardGroupsExists( );
 
37
      AuthBootstrapHelper.ensureAdminExists( );
 
38
    }
 
39
    this.ensureCountersExist( );
 
40
    this.ensureVmTypesExist( );
 
41
    return true;
 
42
  }
 
43
  
 
44
  private void checkUserEnabled( ) {
 
45
    EntityWrapper<UserEntity> db = Authentication.getEntityWrapper( );
 
46
    for ( UserEntity u : db.query( new UserEntity( ) ) ) {
 
47
      if ( u.isEnabled( ) != Boolean.FALSE ) {
 
48
        u.setEnabled( Boolean.TRUE );
 
49
      }
 
50
    }
 
51
  }
 
52
  
 
53
  private void ensureVmTypesExist( ) {
 
54
    EntityWrapper<VmType> db = new EntityWrapper<VmType>( "eucalyptus_general" );
 
55
    try {
 
56
      if ( db.query( new VmType( ) ).size( ) == 0 ) { //TODO: make defaults configurable?
 
57
        db.add( new VmType( "m1.small", 1, 2, 128 ) );
 
58
        db.add( new VmType( "c1.medium", 1, 5, 256 ) );
 
59
        db.add( new VmType( "m1.large", 2, 10, 512 ) );
 
60
        db.add( new VmType( "m1.xlarge", 2, 20, 1024 ) );
 
61
        db.add( new VmType( "c1.xlarge", 4, 20, 2048 ) );
 
62
      }
 
63
      db.commit( );
 
64
    } catch ( Exception e ) {
 
65
      db.rollback( );
 
66
    }
 
67
  }
 
68
 
 
69
  private void ensureCountersExist( ) {
 
70
    Counters.getNextId( );
 
71
  }
 
72
}