1
import org.hibernate.HibernateException;
3
import com.eucalyptus.auth.CredentialProvider;
4
import com.eucalyptus.auth.Credentials;
5
import com.eucalyptus.auth.User;
6
import com.eucalyptus.auth.UserExistsException;
7
import com.eucalyptus.util.EntityWrapper;
8
import com.eucalyptus.util.EucalyptusCloudException;
9
import edu.ucsb.eucalyptus.cloud.entities.Counters;
10
import edu.ucsb.eucalyptus.cloud.entities.UserGroupInfo;
11
import edu.ucsb.eucalyptus.cloud.entities.UserInfo;
12
import edu.ucsb.eucalyptus.cloud.entities.VmType;
13
import edu.ucsb.eucalyptus.util.UserManagement;
14
import com.eucalyptus.bootstrap.DeferredInitializer;
17
EntityWrapper<User> dbu = Credentials.getEntityWrapper( );
19
for( User u : dbu.query( new User( ) ) ) {
20
if( u.getIsEnabled() != Boolean.FALSE ) {
21
u.setIsEnabled( Boolean.TRUE )
25
} catch( Throwable e ) {
28
EntityWrapper<VmType> db2 = new EntityWrapper<VmType>( );
30
if( db2.query( new VmType() ).size( ) == 0 ) {
31
db2.add( new VmType( "m1.small", 1, 2, 192 ) );
32
db2.add( new VmType( "c1.medium", 1, 5, 256 ) );
33
db2.add( new VmType( "m1.large", 2, 10, 512 ) );
34
db2.add( new VmType( "m1.xlarge", 2, 20, 1024 ) );
35
db2.add( new VmType( "c1.xlarge", 4, 20, 2048 ) );
38
} catch ( Exception e ) {
42
EntityWrapper<UserGroupInfo> db3 = new EntityWrapper<UserGroupInfo>( );
44
db3.getUnique( new UserGroupInfo( "all" ) );
46
} catch ( EucalyptusCloudException e ) {
47
db3.add( new UserGroupInfo( "all" ) );
51
UserGroupInfo.named( "all" );
52
} catch ( EucalyptusCloudException e1 ) {
54
EntityWrapper<UserInfo> db = new EntityWrapper<UserInfo>( );
56
db.getUnique( new UserInfo("admin") );
59
} catch ( Exception e ) {
60
try {//FIXME: fix this nicely
61
CredentialProvider.addUser("admin",true);
62
} catch ( UserExistsException e1 ) {
66
db.getSession( ).persist( new Counters( ) );
67
UserInfo u = UserManagement.generateAdmin( );
70
} catch ( HibernateException e1 ) {