Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bootstrap brings up all the needed system services

  • Loading branch information...
commit cdf9ab73cffae9a7fad11dd60f1b4629dd0d1580 1 parent f444580
@grze grze authored
Showing with 280 additions and 140 deletions.
  1. +29 −17 clc/modules/authentication/src/main/java/com/eucalyptus/auth/Credentials.java
  2. +12 −10 clc/modules/authentication/src/main/java/com/eucalyptus/auth/CredentialsBootstrapper.java
  3. +1 −2  clc/modules/authentication/src/main/java/com/eucalyptus/auth/util/EucaKeyStore.java
  4. +2 −2 clc/modules/authentication/src/main/resources/META-INF/persistence.xml
  5. +2 −0  clc/modules/bootstrap/arguments.ggo
  6. +1 −0  clc/modules/bootstrap/eucalyptus-bootstrap.c
  7. +54 −32 clc/modules/bootstrap/eucalyptus-opts.c
  8. +4 −0 clc/modules/bootstrap/eucalyptus-opts.h
  9. +28 −5 clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HsqldbBootstrapper.java
  10. +1 −0  clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HttpServerBootstrapper.java
  11. +1 −1  clc/modules/core/src/main/java/edu/ucsb/eucalyptus/Main.java
  12. +2 −2 clc/modules/core/src/main/resources/META-INF/persistence.xml
  13. +1 −1  clc/modules/core/src/main/resources/log4j.xml
  14. +2 −2 clc/modules/image-manager/src/main/resources/META-INF/persistence.xml
  15. +2 −2 clc/modules/msgs/build.xml
  16. +2 −3 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Bootstrapper.java
  17. +27 −61 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/SystemBootstrapper.java
  18. +109 −0 clc/modules/msgs/src/main/java/com/eucalyptus/util/ServiceJarFile.java
View
46 clc/modules/authentication/src/main/java/com/eucalyptus/auth/Credentials.java
@@ -18,31 +18,40 @@
import org.hibernate.criterion.MatchMode;
import com.eucalyptus.auth.util.AbstractKeyStore;
+import com.eucalyptus.auth.util.EucaKeyStore;
import com.eucalyptus.auth.util.KeyTool;
import com.eucalyptus.util.EntityWrapper;
import com.eucalyptus.util.EucalyptusCloudException;
import com.eucalyptus.util.EucalyptusProperties;
import com.google.common.collect.Lists;
-
-
public class Credentials {
private static Logger LOG = Logger.getLogger( Credentials.class );
private static String FORMAT = "pkcs12";
private static String KEY_STORE_PASS = "eucalyptus"; //TODO: change the way this is handled
private static String FILENAME = "euca.p12";
public static String DB_NAME = "eucalyptus_auth";
- public static User SYSTEM = getSystemUser();
+ public static User SYSTEM = getSystemUser( );
+
public static void init( ) {
Security.addProvider( new BouncyCastleProvider( ) );
org.apache.xml.security.Init.init( );
- WSSConfig.getDefaultWSConfig( ).addJceProvider( "BC", BouncyCastleProvider.class.getCanonicalName( ) );
- WSSConfig.getDefaultWSConfig( ).setTimeStampStrict( true );
- WSSConfig.getDefaultWSConfig( ).setEnableSignatureConfirmation( true );
+ WSSConfig.getDefaultWSConfig( ).addJceProvider( "BC", BouncyCastleProvider.class.getCanonicalName( ) );
+ WSSConfig.getDefaultWSConfig( ).setTimeStampStrict( true );
+ WSSConfig.getDefaultWSConfig( ).setEnableSignatureConfirmation( true );
}
-
- public static void check() {
+
+ public static boolean checkKeystore( ) {
+ try {
+ return EucaKeyStore.getInstance( ).check( );
+ } catch ( GeneralSecurityException e ) {
+ LOG.debug(e,e);
+ return false;
+ }
+ }
+
+ public static boolean checkAdmin( ) {
try {
getUser( "admin" );
} catch ( NoSuchUserException e ) {
@@ -50,21 +59,19 @@ public static void check() {
addUser( "admin", Boolean.TRUE );
} catch ( UserExistsException e1 ) {
LOG.fatal( e1, e1 );
+ return false;
}
}
+ return true;
}
-
-
private static User getSystemUser( ) {
- User system = new User();
+ User system = new User( );
system.setUserName( EucalyptusProperties.NAME );
system.setIsAdministrator( Boolean.TRUE );
return system;
}
-
-
public static User getUser( String userName ) throws NoSuchUserException {
User user = null;
EntityWrapper<User> db = getEntityWrapper( );
@@ -102,7 +109,8 @@ public static User addUser( String userName, Boolean isAdmin ) throws UserExists
}
return newUser;
}
- public static <T> EntityWrapper<T> getEntityWrapper() {
+
+ public static <T> EntityWrapper<T> getEntityWrapper( ) {
return new EntityWrapper<T>( Credentials.DB_NAME );
}
@@ -222,7 +230,7 @@ public static String getUserName( X509Certificate cert ) throws GeneralSecurityE
public static String getCertificateAlias( final X509Certificate cert ) throws GeneralSecurityException {
return getCertificateAlias( new String( Hashes.getPemBytes( cert ) ) );
}
-
+
public static void addCertificate( final String userName, final String alias, final X509Certificate cert ) throws GeneralSecurityException {
String certPem = new String( UrlBase64.encode( Hashes.getPemBytes( cert ) ) );
EntityWrapper<User> db = getEntityWrapper( );
@@ -234,7 +242,7 @@ public static void addCertificate( final String userName, final String alias, fi
u.getCertificates( ).add( x509cert );
db.commit( );
} catch ( EucalyptusCloudException e ) {
- LOG.error( e,e );
+ LOG.error( e, e );
LOG.error( "username=" + userName + " \nalias=" + alias + " \ncert=" + cert );
db.rollback( );
throw new GeneralSecurityException( e );
@@ -256,7 +264,8 @@ public static void addCertificate( final String userName, final String alias, fi
}
}
- public static void createSystemKeys( AbstractKeyStore eucaKeyStore ) throws IOException, GeneralSecurityException {
+ protected static void createSystemKeys( ) throws IOException, GeneralSecurityException {
+ AbstractKeyStore eucaKeyStore = EucaKeyStore.getInstance( );
KeyTool keyTool = new KeyTool( );
KeyPair sysKp = keyTool.getKeyPair( );
X509Certificate sysX509 = keyTool.getCertificate( sysKp, EucalyptusProperties.getDName( EucalyptusProperties.NAME ) );
@@ -265,6 +274,9 @@ public static void createSystemKeys( AbstractKeyStore eucaKeyStore ) throws IOEx
eucaKeyStore.addKeyPair( EucalyptusProperties.NAME, sysX509, sysKp.getPrivate( ), EucalyptusProperties.NAME );
eucaKeyStore.addKeyPair( EucalyptusProperties.WWW_NAME, wwwX509, wwwKp.getPrivate( ), EucalyptusProperties.NAME );
eucaKeyStore.store( );
+ if( !eucaKeyStore.check( ) ) {
+ throw new GeneralSecurityException( "Created new keystore, but check still fails. eeek." );
+ }
}
}
View
22 clc/modules/authentication/src/main/java/com/eucalyptus/auth/CredentialsBootstrapper.java
@@ -1,12 +1,15 @@
package com.eucalyptus.auth;
-import com.eucalyptus.bootstrap.Bootstrapper;
+import org.apache.log4j.Logger;
-public class CredentialsBootstrapper implements Bootstrapper {
+import com.eucalyptus.auth.util.EucaKeyStore;
+import com.eucalyptus.bootstrap.Bootstrapper;
+public class CredentialsBootstrapper extends Bootstrapper {
+ private static Logger LOG = Logger.getLogger( CredentialsBootstrapper.class );
@Override
public boolean check( ) throws Exception {
- return true;
+ return Credentials.checkKeystore( );
}
@Override
@@ -15,21 +18,20 @@ public boolean destroy( ) throws Exception {
}
@Override
- public String getVersion( ) {
- return "";
- }
-
- @Override
public boolean load( ) throws Exception {
Credentials.init( );
- //TODO: first time start up check
+ if( !Credentials.checkKeystore( ) ) {
+ LOG.info("Looks like this is the first time?");//TODO: need to handle distinction between Cloud and Walrus/EBS here?!
+ LOG.info("Generating system keys.");
+ Credentials.createSystemKeys( );
+ }
return false;
}
@Override
public boolean start( ) throws Exception {
//TODO: this depends on the DB
- Credentials.check( );
+// Credentials.checkAdmin( );
return true;
}
View
3  clc/modules/authentication/src/main/java/com/eucalyptus/auth/util/EucaKeyStore.java
@@ -37,7 +37,6 @@ private EucaKeyStore( ) throws GeneralSecurityException, IOException {
@Override
public boolean check( ) throws GeneralSecurityException {
- final X509Certificate cert = this.getCertificate( EucalyptusProperties.WWW_NAME );
- return cert != null;
+ return (this.getCertificate( EucalyptusProperties.WWW_NAME )!= null)&&(this.getCertificate( EucalyptusProperties.NAME )!=null);
}
}
View
4 clc/modules/authentication/src/main/resources/META-INF/persistence.xml
@@ -49,9 +49,9 @@
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
- <property name="hibernate.connection.url" value="jdbc:hsqldb:file:${euca.var.dir}/db/eucalyptus_auth;shutdown=true"/>
+ <property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://${euca.db.host}:${euca.db.port}/eucalyptus_auth"/>
<property name="hibernate.connection.username" value="sa"/>
- <property name="hibernate.connection.password" value=""/>
+ <property name="hibernate.connection.password" value="eucalyptus"/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.c3p0.min_size" value="16"/>
<property name="hibernate.c3p0.max_size" value="16384"/>
View
2  clc/modules/bootstrap/arguments.ggo
@@ -5,10 +5,12 @@ section "Eucalyptus Configuration & Environment"
option "user" u "User to drop privs to after starting." string typestr="username" default="eucalyptus" no
option "home" h "Eucalyptus home directory." string typestr="directory" default="/" no
option "define" D "Set system properties." string optional multiple
+option "bootstrap-config" c "Use this file as the configuration for early runtime service bootstrapping." string typestr="config.xml" default="eucalyptus-bootstrap.xml" no
option "verbose" v "Verbose console output. Note: log file output is not controlled by this flag." flag off
option "out" o "Redirect standard out to file." string typestr="filename" default="&1" no
option "err" e "Redirect standard error to file." string typestr="filename" default="&2" no
+
section "Eucalyptus Runtime Options"
option "check" C "Check on Eucalyptus." flag off
option "stop" S "Stop Eucalyptus." flag off
View
1  clc/modules/bootstrap/eucalyptus-bootstrap.c
@@ -503,6 +503,7 @@ int java_init(euca_opts *args, java_home_t *data) {
int x = -1, i;
opt=(JavaVMOption *)malloc(JVM_MAX_OPTS*sizeof(JavaVMOption));
for(i=0;i<JVM_MAX_OPTS;i++) opt[i].extraInfo=NULL;
+ JVM_ARG(opt[++x],"-Deuca.bootstrap.config=%1$s",GETARG(args,bootstrap_config));
if(args->debug_flag) {
JVM_ARG(opt[++x],"-Xdebug");
JVM_ARG(opt[++x],"-Xrunjdwp:transport=dt_socket,server=y,suspend=%2$s,address=%1$d",GETARG(args,debug_port),(args->debug_suspend_flag?"y":"n"));
View
86 clc/modules/bootstrap/eucalyptus-opts.c
@@ -28,27 +28,28 @@ const char *eucalyptus_opts_usage = "Usage: Eucalyptus [OPTIONS]...";
const char *eucalyptus_opts_description = "";
const char *eucalyptus_opts_help[] = {
- " --help Print help and exit",
- " -V, --version Print version and exit",
+ " --help Print help and exit",
+ " -V, --version Print version and exit",
"\nEucalyptus Configuration & Environment:",
- " -u, --user=username User to drop privs to after starting. \n (default=`eucalyptus')",
- " -h, --home=directory Eucalyptus home directory. (default=`/')",
- " -D, --define=STRING Set system properties.",
- " -v, --verbose Verbose console output. Note: log file output is \n not controlled by this flag. (default=off)",
- " -o, --out=filename Redirect standard out to file. (default=`&1')",
- " -e, --err=filename Redirect standard error to file. (default=`&2')",
+ " -u, --user=username User to drop privs to after starting. \n (default=`eucalyptus')",
+ " -h, --home=directory Eucalyptus home directory. (default=`/')",
+ " -D, --define=STRING Set system properties.",
+ " -c, --bootstrap-config=config.xml\n Use this file as the configuration for early \n runtime service bootstrapping. \n (default=`eucalyptus-bootstrap.xml')",
+ " -v, --verbose Verbose console output. Note: log file output \n is not controlled by this flag. \n (default=off)",
+ " -o, --out=filename Redirect standard out to file. (default=`&1')",
+ " -e, --err=filename Redirect standard error to file. \n (default=`&2')",
"\nEucalyptus Runtime Options:",
- " -C, --check Check on Eucalyptus. (default=off)",
- " -S, --stop Stop Eucalyptus. (default=off)",
- " -f, --fork Fork and daemonize Eucalyptus. (default=on)",
- " --pidfile=filename Location for the pidfile. \n (default=`/var/run/eucalyptus-cloud.pid')",
+ " -C, --check Check on Eucalyptus. (default=off)",
+ " -S, --stop Stop Eucalyptus. (default=off)",
+ " -f, --fork Fork and daemonize Eucalyptus. (default=on)",
+ " --pidfile=filename Location for the pidfile. \n (default=`/var/run/eucalyptus-cloud.pid')",
"\nJava VM Options:",
- " -j, --java-home=directory Alternative way to specify JAVA_HOME. \n (default=`/usr/lib/jvm/java-6-openjdk')",
- " -J, --jvm-name=jvm-name Which JVM type to run (see jvm.cfg). \n (default=`-server')",
- " -X, --jvm-args=STRING Arguments to pass to the JVM.",
- " -d, --debug Launch with debugger enabled. (default=off)",
- " --debug-port=INT Set the port to use for the debugger. \n (default=`5005')",
- " --debug-suspend Set the port to use for the debugger. \n (default=off)",
+ " -j, --java-home=directory Alternative way to specify JAVA_HOME. \n (default=`/usr/lib/jvm/java-6-openjdk')",
+ " -J, --jvm-name=jvm-name Which JVM type to run (see jvm.cfg). \n (default=`-server')",
+ " -X, --jvm-args=STRING Arguments to pass to the JVM.",
+ " -d, --debug Launch with debugger enabled. (default=off)",
+ " --debug-port=INT Set the port to use for the debugger. \n (default=`5005')",
+ " --debug-suspend Set the port to use for the debugger. \n (default=off)",
0
};
@@ -81,6 +82,7 @@ void clear_given (struct eucalyptus_opts *args_info)
args_info->user_given = 0 ;
args_info->home_given = 0 ;
args_info->define_given = 0 ;
+ args_info->bootstrap_config_given = 0 ;
args_info->verbose_given = 0 ;
args_info->out_given = 0 ;
args_info->err_given = 0 ;
@@ -105,6 +107,8 @@ void clear_args (struct eucalyptus_opts *args_info)
args_info->home_orig = NULL;
args_info->define_arg = NULL;
args_info->define_orig = NULL;
+ args_info->bootstrap_config_arg = gengetopt_strdup ("eucalyptus-bootstrap.xml");
+ args_info->bootstrap_config_orig = NULL;
args_info->verbose_flag = 0;
args_info->out_arg = gengetopt_strdup ("&1");
args_info->out_orig = NULL;
@@ -140,21 +144,22 @@ void init_args_info(struct eucalyptus_opts *args_info)
args_info->define_help = eucalyptus_opts_help[5] ;
args_info->define_min = 0;
args_info->define_max = 0;
- args_info->verbose_help = eucalyptus_opts_help[6] ;
- args_info->out_help = eucalyptus_opts_help[7] ;
- args_info->err_help = eucalyptus_opts_help[8] ;
- args_info->check_help = eucalyptus_opts_help[10] ;
- args_info->stop_help = eucalyptus_opts_help[11] ;
- args_info->fork_help = eucalyptus_opts_help[12] ;
- args_info->pidfile_help = eucalyptus_opts_help[13] ;
- args_info->java_home_help = eucalyptus_opts_help[15] ;
- args_info->jvm_name_help = eucalyptus_opts_help[16] ;
- args_info->jvm_args_help = eucalyptus_opts_help[17] ;
+ args_info->bootstrap_config_help = eucalyptus_opts_help[6] ;
+ args_info->verbose_help = eucalyptus_opts_help[7] ;
+ args_info->out_help = eucalyptus_opts_help[8] ;
+ args_info->err_help = eucalyptus_opts_help[9] ;
+ args_info->check_help = eucalyptus_opts_help[11] ;
+ args_info->stop_help = eucalyptus_opts_help[12] ;
+ args_info->fork_help = eucalyptus_opts_help[13] ;
+ args_info->pidfile_help = eucalyptus_opts_help[14] ;
+ args_info->java_home_help = eucalyptus_opts_help[16] ;
+ args_info->jvm_name_help = eucalyptus_opts_help[17] ;
+ args_info->jvm_args_help = eucalyptus_opts_help[18] ;
args_info->jvm_args_min = 0;
args_info->jvm_args_max = 0;
- args_info->debug_help = eucalyptus_opts_help[18] ;
- args_info->debug_port_help = eucalyptus_opts_help[19] ;
- args_info->debug_suspend_help = eucalyptus_opts_help[20] ;
+ args_info->debug_help = eucalyptus_opts_help[19] ;
+ args_info->debug_port_help = eucalyptus_opts_help[20] ;
+ args_info->debug_suspend_help = eucalyptus_opts_help[21] ;
}
@@ -282,6 +287,8 @@ arguments_release (struct eucalyptus_opts *args_info)
free_string_field (&(args_info->home_arg));
free_string_field (&(args_info->home_orig));
free_multiple_string_field (args_info->define_given, &(args_info->define_arg), &(args_info->define_orig));
+ free_string_field (&(args_info->bootstrap_config_arg));
+ free_string_field (&(args_info->bootstrap_config_orig));
free_string_field (&(args_info->out_arg));
free_string_field (&(args_info->out_orig));
free_string_field (&(args_info->err_arg));
@@ -340,6 +347,8 @@ arguments_dump(FILE *outfile, struct eucalyptus_opts *args_info)
if (args_info->home_given)
write_into_file(outfile, "home", args_info->home_orig, 0);
write_multiple_into_file(outfile, args_info->define_given, "define", args_info->define_orig, 0);
+ if (args_info->bootstrap_config_given)
+ write_into_file(outfile, "bootstrap-config", args_info->bootstrap_config_orig, 0);
if (args_info->verbose_given)
write_into_file(outfile, "verbose", 0, 0 );
if (args_info->out_given)
@@ -922,6 +931,7 @@ arguments_internal (int argc, char * const *argv, struct eucalyptus_opts *args_i
{ "user", 1, NULL, 'u' },
{ "home", 1, NULL, 'h' },
{ "define", 1, NULL, 'D' },
+ { "bootstrap-config", 1, NULL, 'c' },
{ "verbose", 0, NULL, 'v' },
{ "out", 1, NULL, 'o' },
{ "err", 1, NULL, 'e' },
@@ -938,7 +948,7 @@ arguments_internal (int argc, char * const *argv, struct eucalyptus_opts *args_i
{ NULL, 0, NULL, 0 }
};
- c = getopt_long (argc, argv, "Vu:h:D:vo:e:CSfj:J:X:d", long_options, &option_index);
+ c = getopt_long (argc, argv, "Vu:h:D:c:vo:e:CSfj:J:X:d", long_options, &option_index);
if (c == -1) break; /* Exit from `while (1)' loop. */
@@ -982,6 +992,18 @@ arguments_internal (int argc, char * const *argv, struct eucalyptus_opts *args_i
goto failure;
break;
+ case 'c': /* Use this file as the configuration for early runtime service bootstrapping.. */
+
+
+ if (update_arg( (void *)&(args_info->bootstrap_config_arg),
+ &(args_info->bootstrap_config_orig), &(args_info->bootstrap_config_given),
+ &(local_args_info.bootstrap_config_given), optarg, 0, "eucalyptus-bootstrap.xml", ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "bootstrap-config", 'c',
+ additional_error))
+ goto failure;
+
+ break;
case 'v': /* Verbose console output. Note: log file output is not controlled by this flag.. */
View
4 clc/modules/bootstrap/eucalyptus-opts.h
@@ -45,6 +45,9 @@ struct eucalyptus_opts
unsigned int define_min; /**< @brief Set system properties.'s minimum occurreces */
unsigned int define_max; /**< @brief Set system properties.'s maximum occurreces */
const char *define_help; /**< @brief Set system properties. help description. */
+ char * bootstrap_config_arg; /**< @brief Use this file as the configuration for early runtime service bootstrapping. (default='eucalyptus-bootstrap.xml'). */
+ char * bootstrap_config_orig; /**< @brief Use this file as the configuration for early runtime service bootstrapping. original value given at command line. */
+ const char *bootstrap_config_help; /**< @brief Use this file as the configuration for early runtime service bootstrapping. help description. */
int verbose_flag; /**< @brief Verbose console output. Note: log file output is not controlled by this flag. (default=off). */
const char *verbose_help; /**< @brief Verbose console output. Note: log file output is not controlled by this flag. help description. */
char * out_arg; /**< @brief Redirect standard out to file. (default='&1'). */
@@ -86,6 +89,7 @@ struct eucalyptus_opts
unsigned int user_given ; /**< @brief Whether user was given. */
unsigned int home_given ; /**< @brief Whether home was given. */
unsigned int define_given ; /**< @brief Whether define was given. */
+ unsigned int bootstrap_config_given ; /**< @brief Whether bootstrap-config was given. */
unsigned int verbose_given ; /**< @brief Whether verbose was given. */
unsigned int out_given ; /**< @brief Whether out was given. */
unsigned int err_given ; /**< @brief Whether err was given. */
View
33 clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HsqldbBootstrapper.java
@@ -1,5 +1,6 @@
package com.eucalyptus.bootstrap;
+import java.io.File;
import java.util.List;
import org.apache.log4j.Logger;
@@ -9,10 +10,18 @@
import com.eucalyptus.bootstrap.Bootstrapper;
import com.eucalyptus.util.EucalyptusProperties;
+import com.eucalyptus.util.SubDirectory;
-public class HsqldbBootstrapper extends Bootstrapper {
+public class HsqldbBootstrapper extends Bootstrapper implements Runnable {
private static Logger LOG = Logger.getLogger( HsqldbBootstrapper.class );
private static HsqldbBootstrapper singleton;
+ /**
+ *
+ * ${euca.db.host}
+ * ${euca.db.port}
+ * ${euca.db.name}
+ * ${euca.db.jpaname}
+ */
public static HsqldbBootstrapper getInstance( ) {
synchronized ( HsqldbBootstrapper.class ) {
@@ -22,6 +31,7 @@ public static HsqldbBootstrapper getInstance( ) {
}
return singleton;
}
+
private Server db;
private String fileName;
private HsqldbBootstrapper( ) {}
@@ -40,16 +50,29 @@ public boolean destroy( ) throws Exception {
public boolean load( ) throws Exception {
db = new Server( );
HsqlProperties props = new HsqlProperties( );
- props.setProperty( ServerConstants.SC_KEY_DATABASE, EucalyptusProperties.NAME );
- props.setProperty( ServerConstants.SC_KEY_DBNAME, EucalyptusProperties.NAME );
+ props.setProperty( ServerConstants.SC_KEY_NO_SYSTEM_EXIT, true );
+ props.setProperty( ServerConstants.SC_KEY_PORT, 9001 );
+ props.setProperty( ServerConstants.SC_KEY_REMOTE_OPEN_DB, true );
+ props.setProperty( ServerConstants.SC_KEY_DATABASE+".0", SubDirectory.DB.toString( ) + File.separator + EucalyptusProperties.NAME );
+ props.setProperty( ServerConstants.SC_KEY_DBNAME+".0", EucalyptusProperties.NAME );
+ String vol = "_volumes";
+ props.setProperty( ServerConstants.SC_KEY_DATABASE+".1", SubDirectory.DB.toString( ) + File.separator + EucalyptusProperties.NAME + vol );
+ props.setProperty( ServerConstants.SC_KEY_DBNAME+".1", EucalyptusProperties.NAME + vol );
+ String auth = "_auth";
+ props.setProperty( ServerConstants.SC_KEY_DATABASE+".2", SubDirectory.DB.toString( ) + File.separator + EucalyptusProperties.NAME + auth );
+ props.setProperty( ServerConstants.SC_KEY_DBNAME+".2", EucalyptusProperties.NAME + auth );
db.setProperties( props );
return true;
}
@Override
public boolean start( ) throws Exception {
- db.start( );
- return false;
+ (new Thread(this)).start( );
+ return true;
+ }
+
+ public void run() {
+ this.db.start( );
}
@Override
View
1  clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HttpServerBootstrapper.java
@@ -25,6 +25,7 @@ public boolean destroy( ) throws Exception {
public boolean load( ) throws Exception {
jettyServer = new org.mortbay.jetty.Server();
XmlConfiguration jettyConfig = new XmlConfiguration( new File( BaseDirectory.CONF.toString() + File.separator + "eucalyptus-jetty.xml" ).toURL() );
+ jettyConfig.configure( jettyServer );
return true;
}
View
2  clc/modules/core/src/main/java/edu/ucsb/eucalyptus/Main.java
@@ -53,7 +53,7 @@ public static void main( String[] args ) throws Exception
{
Credentials.init( );
- Credentials.check( );
+ Credentials.checkAdmin( );
StartupChecks.doChecks();
View
4 clc/modules/core/src/main/resources/META-INF/persistence.xml
@@ -79,9 +79,9 @@
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
- <property name="hibernate.connection.url" value="jdbc:hsqldb:file:${euca.var.dir}/db/eucalyptus;shutdown=true"/>
+ <property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://${euca.db.host}:${euca.db.port}/eucalyptus"/>
<property name="hibernate.connection.username" value="sa"/>
- <property name="hibernate.connection.password" value=""/>
+ <property name="hibernate.connection.password" value="eucalyptus"/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.c3p0.min_size" value="16"/>
<property name="hibernate.c3p0.max_size" value="16384"/>
View
2  clc/modules/core/src/main/resources/log4j.xml
@@ -38,7 +38,7 @@
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
- <param name="Threshold" value="DEBUG"/>
+ <param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%c{1}:%t] %m%n"/>
</layout>
View
4 clc/modules/image-manager/src/main/resources/META-INF/persistence.xml
@@ -50,9 +50,9 @@
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
- <property name="hibernate.connection.url" value="jdbc:hsqldb:file:${euca.var.dir}/db/eucalyptus_volumes;shutdown=true;hsqldb.log_size=10"/>
+ <property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://${euca.db.host}:${euca.db.port}/eucalyptus_volumes"/>
<property name="hibernate.connection.username" value="sa"/>
- <property name="hibernate.connection.password" value=""/>
+ <property name="hibernate.connection.password" value="eucalyptus"/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.c3p0.min_size" value="16"/>
<property name="hibernate.c3p0.max_size" value="16384"/>
View
4 clc/modules/msgs/build.xml
@@ -40,10 +40,10 @@
<srcfiles dir="${rsrc.dir}" includes="**/*-binding.xml"/>
</uptodate>
<!--================================== BUILD TARGETS ==================================-->
- <target name="build" depends="init,compile-src,compile-jibx,jar" description=" build the jar file from source." unless="groovyc.notRequired"/>
<!--
- <target name="build" depends="init,compile-src,jar" description=" build the jar file from source." unless="groovyc.notRequired"/>
+ <target name="build" depends="init,compile-src,compile-jibx,jar" description=" build the jar file from source." unless="groovyc.notRequired"/>
-->
+ <target name="build" depends="init,compile-src,jar" description=" build the jar file from source." unless="groovyc.notRequired"/>
<target name="install" depends="copy-conf"/>
<target name="clean">
<delete dir="${build.dir}"/>
View
5 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Bootstrapper.java
@@ -14,11 +14,13 @@
public abstract class Bootstrapper {
private static Logger LOG = Logger.getLogger( Bootstrapper.class );
+ public static String BOOTSTRAP_CONFIG_PROPERTY = "euca.bootstrap.config";
public static String BASEDIR = "META-INF/";
public static String PROPERTIES = BASEDIR + "eucalyptus-bootstrap.properties";
public static String SERVICES_PROPERTY = "euca.services";
public static String MODEL_PROPERTY = "euca.model";
public static String VERSION_PROPERTY = "euca.version";
+
public String getVersion() {
return System.getProperty( VERSION_PROPERTY );
}
@@ -27,8 +29,5 @@ public String getVersion() {
public abstract boolean stop() throws Exception;
public abstract boolean start() throws Exception;
public abstract boolean load() throws Exception;
- public static List<ConfigResource> loadConfigResources( JarFile jar ) throws IOException {
- return null;
- }
}
View
88 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/SystemBootstrapper.java
@@ -19,6 +19,7 @@
import com.eucalyptus.util.BaseDirectory;
import com.eucalyptus.util.EucalyptusProperties;
+import com.eucalyptus.util.ServiceJarFile;
import com.google.common.collect.Lists;
public class SystemBootstrapper extends Bootstrapper {
@@ -63,7 +64,7 @@ public boolean start( ) throws Exception {
LOG.info( "Starting Eucalyptus." );
try {
for ( Bootstrapper b : this.bootstrappers ) {
- LOG.info( "-> Invoking bootsrapper " + b.getClass( ).getSimpleName( ) + ".start()" );
+ LOG.info( "-> Invoking bootsrapper " + b.getClass( ).getSimpleName( ) + ".start()Z" );
b.start( );
}
context.start( );
@@ -77,67 +78,31 @@ public boolean start( ) throws Exception {
@SuppressWarnings( "deprecation" )
@Override
public boolean load( ) throws Exception {
- LOG.info( "Looking for Eucalyptus components in: " + BaseDirectory.LIB.toString( ) );
+ String bootstrapConfig = System.getProperty( Bootstrapper.BOOTSTRAP_CONFIG_PROPERTY );
+ if( bootstrapConfig == null ) {
+ LOG.fatal( "Bootstrap configuration property is undefined: " + Bootstrapper.BOOTSTRAP_CONFIG_PROPERTY );
+ return false;
+ }
+ try {
+ this.configs.add( new ConfigResource( bootstrapConfig ) );
+ } catch ( Exception e ) {
+ LOG.fatal( "Couldn't load bootstrap configuration file: " + bootstrapConfig, e );
+ return false;
+ }
+ LOG.info( "Eucalyptus component discovery [" + BaseDirectory.LIB.toString( ) +"]" );
File libDir = new File( BaseDirectory.LIB.toString( ) );
for ( File f : libDir.listFiles( ) ) {
- if ( f.getName( ).startsWith( EucalyptusProperties.NAME ) ) {
- JarFile jar = new JarFile( f );
-
- LOG.info( "Found eucalyptus component jar: " + f.getName( ) );
- URLClassLoader classLoader = URLClassLoader.newInstance( new URL[] { f.getAbsoluteFile( ).toURL( ) } );
- Enumeration<JarEntry> jarList = jar.entries( );
- while ( jarList.hasMoreElements( ) ) {
- JarEntry j = jarList.nextElement( );
- if ( j.getName( ).endsWith( ".class" ) ) {
- String classGuess = j.getName( ).replaceAll( "/", "." ).replaceAll( ".class", "" );
- try {
- Class c = classLoader.loadClass( classGuess );
- if ( Bootstrapper.class.isAssignableFrom( c ) && !Bootstrapper.class.equals( c ) ) {
- try {
- Bootstrapper b = ( Bootstrapper ) c.newInstance( );
- this.bootstrappers.add( b );
- LOG.info( "-> Registered bootsrapper instance: " + c.getSimpleName( ) );
- } catch ( Exception e ) {
- LOG.info( "-> Failed to create bootstrapper instance: " + c.getSimpleName( ), e );
- }
- }
- } catch ( Exception e ) {
- LOG.error("Error occurred while trying to process class: " + classGuess );
- }
- }
- }
-
- LOG.info( "-> Loaded properties..." );
- JarEntry entry = jar.getJarEntry( Bootstrapper.PROPERTIES );
- InputStream in = jar.getInputStream( entry );
- List<ConfigResource> conf = Lists.newArrayList( );
- Properties props = new Properties( );
- props.load( in );
- props.list( System.out );
- String servicesEntryPath = null;
- try {
- servicesEntryPath = props.getProperty( Bootstrapper.SERVICES_PROPERTY );//TODO: null check hi
- JarEntry servicesEntry = jar.getJarEntry( Bootstrapper.BASEDIR + servicesEntryPath );
- ConfigResource servicesResource = new ConfigResource( servicesEntryPath, jar.getInputStream( servicesEntry ) );
- conf.add( servicesResource );
- LOG.info( "-> Added configuration " + servicesEntryPath + "..." );
- } catch ( Exception e ) {
- if ( servicesEntryPath != null ) {
- LOG.info( "-> Skipping " + servicesEntryPath + "..." );
- }
- }
- String modelEntryPath = null;
+ if ( f.getName( ).startsWith( EucalyptusProperties.NAME ) && f.getName( ).endsWith( ".jar" ) ) {
try {
- modelEntryPath = props.getProperty( Bootstrapper.MODEL_PROPERTY );
- JarEntry modelEntry = jar.getJarEntry( Bootstrapper.BASEDIR + modelEntryPath );
- ConfigResource modelResource = new ConfigResource( modelEntryPath, jar.getInputStream( modelEntry ) );
- conf.add( modelResource );
- LOG.info( "-> Added configuration " + modelEntryPath + "..." );
- } catch ( Exception e ) {
- if ( modelEntryPath != null ) {
- LOG.info( "-> Skipping " + modelEntryPath + "..." );
- }
+ LOG.info( "Found eucalyptus component jar: " + f.getName( ) );
+ ServiceJarFile jar = new ServiceJarFile( f );
+ this.bootstrappers.addAll( jar.getBootstrappers( this.getClass( ) ) );
+ this.configs.addAll( jar.getConfigResources( ) );
+ } catch ( IOException e ) {
+ LOG.fatal( e,e );
+ SystemBootstrapper.shutdown( false );
+ return false;
}
}
}
@@ -145,10 +110,12 @@ public boolean load( ) throws Exception {
//bind DNS
try {
LOG.info( "-> Configuring..." );
- configs.add( new ConfigResource( "eucalyptus-bootstrap.xml" ) );
context = new DefaultMuleContextFactory( ).createMuleContext( new SpringXmlConfigurationBuilder( configs.toArray( new ConfigResource[] {} ) ) );
for ( Bootstrapper b : this.bootstrappers ) {
- LOG.info( "-> Invoking bootsrapper " + b.getClass( ).getSimpleName( ) + ".load()" );
+ LOG.info( "-> Found bootsrapper " + b.getClass( ).getSimpleName( ) + ".load()Z" );
+ }
+ for ( Bootstrapper b : this.bootstrappers ) {
+ LOG.info( "-> Invoking bootsrapper " + b.getClass( ).getSimpleName( ) + ".load()Z" );
b.load( );
}
} catch ( Exception e ) {
@@ -157,7 +124,6 @@ public boolean load( ) throws Exception {
return true;
}
-
@Override
public String getVersion( ) {
return System.getProperty( "euca.version" );
View
109 clc/modules/msgs/src/main/java/com/eucalyptus/util/ServiceJarFile.java
@@ -0,0 +1,109 @@
+package com.eucalyptus.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.log4j.Logger;
+import org.mule.config.ConfigResource;
+
+import com.eucalyptus.bootstrap.Bootstrapper;
+import com.google.common.collect.Lists;
+
+public class ServiceJarFile extends JarFile {
+ private static Logger LOG = Logger.getLogger( ServiceJarFile.class );
+ private URLClassLoader classLoader;
+ private List<Class> bootstrappers;
+ private Map<String, String> components;
+
+ @SuppressWarnings( { "deprecation", "unchecked" } )
+ public ServiceJarFile( File f ) throws IOException {
+ super( f );
+ Properties props = new Properties( );
+ this.bootstrappers = Lists.newArrayList( );
+ Enumeration<JarEntry> jarList = this.entries( );
+ this.classLoader = URLClassLoader.newInstance( new URL[] { f.getAbsoluteFile( ).toURL( ) } );
+ while ( jarList.hasMoreElements( ) ) {
+ JarEntry j = jarList.nextElement( );
+ if ( Bootstrapper.PROPERTIES.equals( j.getName( ) ) ) {
+ try {
+ InputStream in = this.getInputStream( j );
+ props.load( in );
+ } catch ( IOException e ) {
+ }
+ } else if ( j.getName( ).endsWith( ".class" ) ) {
+ try {
+ Class c = ServiceJarFile.this.getBootstrapper( j );
+ this.bootstrappers.add( c );
+ } catch ( Exception e ) {
+ LOG.trace(e);
+ }
+ }
+ }
+ this.components = new HashMap<String, String>( ( Hashtable ) props );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public List<Bootstrapper> getBootstrappers( Class excludeClass ) {
+ List<Bootstrapper> ret = Lists.newArrayList( );
+ for ( Class c : this.bootstrappers ) {
+ if( c.equals( excludeClass ) ) continue;
+ try {
+ LOG.debug( "-> Calling <init>()V on bootstrapper: " + c.getCanonicalName( ) );
+ try {
+ ret.add( ( Bootstrapper ) c.newInstance( ) );
+ } catch ( Exception e ) {
+ LOG.debug( "-> Calling getInstance()L; on bootstrapper: " + c.getCanonicalName( ) );
+ Method m = c.getDeclaredMethod( "getInstance", new Class[]{} );
+ ret.add( ( Bootstrapper ) m.invoke( null, new Object[]{} ) );
+ }
+ } catch ( Exception e ) {
+ LOG.warn( "Error in <init>()V and getInstance()L; in bootstrapper: " + c.getCanonicalName( ) );
+ LOG.warn( e.getMessage( ) );
+ LOG.debug( e,e );
+ }
+ }
+ return ret;
+ }
+
+ public List<ConfigResource> getConfigResources( ) {
+ List<ConfigResource> ret = Lists.newArrayList( );
+ for ( String configKey : this.components.keySet( ) ) {
+ try {
+ LOG.debug( "-> Loading config resource: " + this.components.get( configKey ) );
+ ConfigResource rsrc = new ConfigResource( configKey, this.getInputStream( this.getEntry( Bootstrapper.BASEDIR + this.components.get( configKey ) ) ) );
+ ret.add( rsrc );
+ } catch ( IOException e ) {
+ LOG.debug( "Error loading config resource indicated by properties file: " + Bootstrapper.BASEDIR + this.components.get( configKey ) );
+ }
+ }
+ return ret;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private Class getBootstrapper( JarEntry j ) throws Exception {
+ String classGuess = j.getName( ).replaceAll( "/", "." ).replaceAll( ".class", "" );
+ Class candidate = this.classLoader.loadClass( classGuess );
+ if ( Bootstrapper.class.equals( candidate ) ) throw new InstantiationException( Bootstrapper.class + " is abstract." );
+ if ( !Bootstrapper.class.isAssignableFrom( candidate ) ) throw new InstantiationException( candidate + " does not conform to " + Bootstrapper.class );
+ if ( !Modifier.isPublic( candidate.getDeclaredConstructor( new Class[] {} ).getModifiers( ) ) ) {
+ Method factory = candidate.getDeclaredMethod( "getInstance", new Class[] {} );
+ if ( !Modifier.isStatic( factory.getModifiers( ) ) || !Modifier.isPublic( factory.getModifiers( ) ) ) {
+ throw new InstantiationException( candidate.getCanonicalName( ) + " does not declare public <init>()V or public static getInstance()L;" );
+ }
+ }
+ return candidate;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.