Skip to content
Browse files

commit suitable for intermediate to advanced

  • Loading branch information...
1 parent 8b53879 commit 0228dcdf291c49b92983d30e8dcd3ced13a164a1 @grze grze committed Aug 14, 2009
Showing with 289 additions and 153 deletions.
  1. +6 −87 clc/modules/authentication/src/main/java/com/eucalyptus/auth/Credentials.java
  2. +117 −0 clc/modules/authentication/src/main/java/com/eucalyptus/auth/SystemCredentialProvider.java
  3. +1 −1 clc/modules/bootstrap/eucalyptus-bootstrap.h
  4. +1 −1 clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HsqldbBootstrapper.java
  5. +5 −2 clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HttpServerBootstrapper.java
  6. +1 −0 clc/modules/cloud/src/main/resources/com.eucalyptus.CloudServiceProvider
  7. +4 −4 clc/modules/cloud/src/main/resources/eucalyptus-interface.xml
  8. +40 −0 clc/modules/cloud/src/main/resources/eucalyptus-services.xml
  9. +3 −1 clc/modules/dns/src/main/java/com/eucalyptus/bootstrap/DNSBootstrapper.java
  10. 0 clc/modules/{www/conf → interface/src/main/resources}/eucalyptus-jetty.xml
  11. +1 −1 clc/modules/module-inc.xml
  12. +3 −3 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/BootstrapFactory.java
  13. +3 −1 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Bootstrapper.java
  14. +21 −0 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Component.java
  15. +2 −1 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Resource.java
  16. +62 −0 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/ServiceBootstrapper.java
  17. +15 −25 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/SystemBootstrapper.java
  18. +1 −0 clc/modules/msgs/src/main/java/com/eucalyptus/util/ServiceJarFile.java
  19. +2 −0 clc/modules/msgs/src/main/resources/com.eucalyptus.CloudServiceProvider
  20. +1 −26 clc/modules/msgs/src/main/resources/eucalyptus-bootstrap.xml
View
93 clc/modules/authentication/src/main/java/com/eucalyptus/auth/Credentials.java
@@ -21,9 +21,11 @@
import com.eucalyptus.auth.util.EucaKeyStore;
import com.eucalyptus.auth.util.KeyTool;
import com.eucalyptus.bootstrap.Bootstrapper;
+import com.eucalyptus.bootstrap.Component;
import com.eucalyptus.bootstrap.Depends;
import com.eucalyptus.bootstrap.Provides;
import com.eucalyptus.bootstrap.Resource;
+import com.eucalyptus.bootstrap.Component.Name;
import com.eucalyptus.util.EntityWrapper;
import com.eucalyptus.util.EucalyptusCloudException;
import com.eucalyptus.util.EucalyptusProperties;
@@ -36,7 +38,6 @@
private static String FILENAME = "euca.p12";
public static String DB_NAME = "eucalyptus_auth";
public static User SYSTEM = getSystemUser( );
-
public static void init( ) {
Security.addProvider( new BouncyCastleProvider( ) );
@@ -50,7 +51,7 @@ public static boolean checkKeystore( ) {
try {
return EucaKeyStore.getInstance( ).check( );
} catch ( GeneralSecurityException e ) {
- LOG.debug(e,e);
+ LOG.debug( e, e );
return false;
}
}
@@ -118,8 +119,8 @@ public static User addUser( String userName, Boolean isAdmin ) throws UserExists
return new EntityWrapper<T>( Credentials.DB_NAME );
}
- @Provides(resource=Resource.UserCredentials)
- @Depends(resources={Resource.Database})
+ @Provides( resource = Resource.UserCredentials )
+ @Depends( resources = { Resource.Database } )
public static class Users extends Bootstrapper {
public static boolean hasCertificate( final String alias ) {
X509Cert certInfo = null;
@@ -270,7 +271,7 @@ public static void addCertificate( final String userName, final String alias, fi
}
@Override
- public boolean load( ) throws Exception {
+ public boolean load( Resource current, List<Resource> dependencies ) throws Exception {
return true;//TODO: check the DB connection here.
}
@@ -280,86 +281,4 @@ public boolean start( ) throws Exception {
}
}
- @Provides(resource=Resource.SystemCredentials)
- public static class System extends Bootstrapper {
- private static System singleton = new System();
- private ConcurrentMap<CertAlias,X509Certificate> certs = new ConcurrentHashMap<CertAlias, X509Certificate>( );
- private ConcurrentMap<CertAlias,KeyPair> keypairs = new ConcurrentHashMap<CertAlias, KeyPair>( );
-
- private enum CertAlias {
- eucalyptus, walrus, jetty, hsqldb;
- public X509Certificate getCertificate() {
- return System.singleton.certs.get( this );
- }
- public PrivateKey getPrivateKey() {
- return System.singleton.keypairs.get( this ).getPrivate( );
- }
- public KeyPair getKeyPair() {
- return System.singleton.keypairs.get( this );
- }
- private void init() throws Exception {
- if(EucaKeyStore.getInstance( ).containsEntry( this.name( ) )) {
- try {
- System.singleton.certs.put( this, EucaKeyStore.getInstance( ).getCertificate( this.name( ) ) );
- System.singleton.keypairs.put( this, EucaKeyStore.getInstance( ).getKeyPair( this.name( ),this.name( ) ) );
- } catch ( Exception e ) {
- System.singleton.certs.remove( this );
- System.singleton.keypairs.remove( this );
- LOG.fatal( "Failed to read keys from the keystore. Please repair the keystore by hand." );
- LOG.fatal( e, e );
- }
- } else {
- System.singleton.createSystemKey( this );
- }
- }
- public boolean check() {
- return (System.singleton.keypairs.containsKey( this ) && System.singleton.certs.containsKey( this ))&&EucaKeyStore.getInstance( ).containsEntry( this.name( ) );
- }
- }
- private System( ) {}
- private void loadSystemKey( String name ) throws Exception {
- CertAlias alias = CertAlias.valueOf( name );
- if( this.certs.containsKey( alias ) ) {
- return;
- } else {
- createSystemKey( alias );
- }
- }
- private void createSystemKey( CertAlias name ) throws Exception {
- KeyTool keyTool = new KeyTool( );
- try {
- KeyPair sysKp = keyTool.getKeyPair( );
- X509Certificate sysX509 = keyTool.getCertificate( sysKp, EucalyptusProperties.getDName( name.name( ) ) );
- System.singleton.certs.put( name, sysX509 );
- System.singleton.keypairs.put( name, sysKp );
- //TODO: might need separate keystore for euca/hsqldb/ssl/jetty/etc.
- EucaKeyStore.getInstance( ).addKeyPair( name.name( ), sysX509, sysKp.getPrivate( ), name.name( ));
- EucaKeyStore.getInstance( ).store( );
- } catch ( Exception e ) {
- System.singleton.certs.remove( name );
- System.singleton.keypairs.remove( name );
- EucaKeyStore.getInstance( ).remove( );
- throw e;
- }
- }
- @Override
- public boolean load( ) throws Exception {
- Credentials.init( );
- for( CertAlias c : CertAlias.values( ) ) {
- try {
- if(!c.check( )) c.init( );
- } catch ( Exception e ) {
- LOG.error( e );
- return false;
- }
- }
- return true;
- }
- @Override
- public boolean start( ) throws Exception {
- return true;
- }
- }
-
-
}
View
117 clc/modules/authentication/src/main/java/com/eucalyptus/auth/SystemCredentialProvider.java
@@ -0,0 +1,117 @@
+package com.eucalyptus.auth;
+
+import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.log4j.Logger;
+
+import com.eucalyptus.auth.util.EucaKeyStore;
+import com.eucalyptus.auth.util.KeyTool;
+import com.eucalyptus.bootstrap.Bootstrapper;
+import com.eucalyptus.bootstrap.Component;
+import com.eucalyptus.bootstrap.Provides;
+import com.eucalyptus.bootstrap.Resource;
+import com.eucalyptus.bootstrap.Component.Name;
+import com.eucalyptus.util.EucalyptusProperties;
+
+@Provides( resource = Resource.SystemCredentials )
+public class SystemCredentialProvider extends Bootstrapper {
+ private static Logger LOG = Logger.getLogger( SystemCredentialProvider.class );
+ private static ConcurrentMap<Component.Name, X509Certificate> certs = new ConcurrentHashMap<Component.Name, X509Certificate>( );
+ private static ConcurrentMap<Component.Name, KeyPair> keypairs = new ConcurrentHashMap<Component.Name, KeyPair>( );
+ private Component.Name name;
+
+ public SystemCredentialProvider( ) {
+ }
+
+ private SystemCredentialProvider( Name name ) {
+ this.name = name;
+ }
+
+ public X509Certificate getCertificate( ) {
+ return SystemCredentialProvider.certs.get( this );
+ }
+
+ public PrivateKey getPrivateKey( ) {
+ return SystemCredentialProvider.keypairs.get( this ).getPrivate( );
+ }
+
+ public KeyPair getKeyPair( ) {
+ return SystemCredentialProvider.keypairs.get( this );
+ }
+
+ private static void init( Component.Name name ) throws Exception {
+ new SystemCredentialProvider( name ).init( );
+ }
+
+ private void init( ) throws Exception {
+ if ( EucaKeyStore.getInstance( ).containsEntry( this.name.name( ) ) ) {
+ try {
+ SystemCredentialProvider.certs.put( this.name, EucaKeyStore.getInstance( ).getCertificate( this.name.name( ) ) );
+ SystemCredentialProvider.keypairs.put( this.name, EucaKeyStore.getInstance( ).getKeyPair( this.name.name( ), this.name.name( ) ) );
+ } catch ( Exception e ) {
+ SystemCredentialProvider.certs.remove( this );
+ SystemCredentialProvider.keypairs.remove( this );
+ LOG.fatal( "Failed to read keys from the keystore. Please repair the keystore by hand." );
+ LOG.fatal( e, e );
+ }
+ } else {
+ this.createSystemCredentialProviderKey( this.name );
+ }
+ }
+
+ private static boolean check( Component.Name name ) {
+ return ( SystemCredentialProvider.keypairs.containsKey( name.name( ) ) && SystemCredentialProvider.certs.containsKey( name.name( ) ) ) && EucaKeyStore.getInstance( ).containsEntry( name.name( ) );
+ }
+
+ private void loadSystemCredentialProviderKey( String name ) throws Exception {
+ Component.Name alias = Component.Name.valueOf( name );
+ if ( this.certs.containsKey( alias ) ) {
+ return;
+ } else {
+ createSystemCredentialProviderKey( alias );
+ }
+ }
+
+ private void createSystemCredentialProviderKey( Component.Name name ) throws Exception {
+ KeyTool keyTool = new KeyTool( );
+ try {
+ KeyPair sysKp = keyTool.getKeyPair( );
+ X509Certificate sysX509 = keyTool.getCertificate( sysKp, EucalyptusProperties.getDName( name.name( ) ) );
+ SystemCredentialProvider.certs.put( name, sysX509 );
+ SystemCredentialProvider.keypairs.put( name, sysKp );
+ //TODO: might need separate keystore for euca/hsqldb/ssl/jetty/etc.
+ EucaKeyStore.getInstance( ).addKeyPair( name.name( ), sysX509, sysKp.getPrivate( ), name.name( ) );
+ EucaKeyStore.getInstance( ).store( );
+ } catch ( Exception e ) {
+ SystemCredentialProvider.certs.remove( name );
+ SystemCredentialProvider.keypairs.remove( name );
+ EucaKeyStore.getInstance( ).remove( );
+ throw e;
+ }
+ }
+
+ @Override
+ public boolean load( Resource current, List<Resource> dependencies ) throws Exception {
+ Credentials.init( );
+ for ( Component.Name c : Component.Name.values( ) ) {
+ try {
+ if ( !SystemCredentialProvider.check( c ) ) SystemCredentialProvider.init( c );
+ } catch ( Exception e ) {
+ LOG.error( e );
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean start( ) throws Exception {
+ return true;
+ }
+}
+
View
2 clc/modules/bootstrap/eucalyptus-bootstrap.h
@@ -74,7 +74,7 @@ typedef struct {
char* method_name;
char* method_signature;
} java_method_t;
-static java_method_t euca_get_instance = { "getInstance", "()Lcom/eucalyptus/bootstrap/Bootstrapper;"};
+static java_method_t euca_get_instance = { "getInstance", "()Lcom/eucalyptus/bootstrap/SystemBootstrapper;"};
static java_method_t euca_load = { "load", "()Z" };
static java_method_t euca_init = { "init", "()Z" };
static java_method_t euca_start = { "start", "()Z" };
View
2 clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HsqldbBootstrapper.java
@@ -41,7 +41,7 @@ public boolean destroy( ) throws Exception {
}
@Override
- public boolean load( ) throws Exception {
+ public boolean load(Resource current, List<Resource> dependencies ) throws Exception {
db = new Server( );
HsqlProperties props = new HsqlProperties( );
props.setProperty( ServerConstants.SC_KEY_NO_SYSTEM_EXIT, true );
View
7 clc/modules/cloud/src/main/java/com/eucalyptus/bootstrap/HttpServerBootstrapper.java
@@ -1,6 +1,8 @@
package com.eucalyptus.bootstrap;
import java.io.File;
+import java.net.URL;
+import java.util.List;
import org.apache.log4j.Logger;
import org.mortbay.xml.XmlConfiguration;
@@ -13,9 +15,10 @@
private static org.mortbay.jetty.Server jettyServer;
@Override
- public boolean load( ) throws Exception {
+ public boolean load(Resource current, List<Resource> dependencies ) throws Exception {
jettyServer = new org.mortbay.jetty.Server();
- XmlConfiguration jettyConfig = new XmlConfiguration( new File( BaseDirectory.CONF.toString() + File.separator + "eucalyptus-jetty.xml" ).toURL() );
+ URL defaultConfig = ClassLoader.getSystemResource( "eucalyptus-jetty.xml" );
+ XmlConfiguration jettyConfig = new XmlConfiguration( defaultConfig );
jettyConfig.configure( jettyServer );
return true;
}
View
1 clc/modules/cloud/src/main/resources/com.eucalyptus.CloudServiceProvider
@@ -1,4 +1,5 @@
name=eucalyptus
+euca.model.services=eucalyptus-services.xml
euca.model.interface=eucalyptus-interface.xml
euca.model.runtime=eucalyptus-runtime.xml
euca.model.storage=eucalyptus-storage.xml
View
8 clc/modules/cloud/src/main/resources/eucalyptus-interface.xml
@@ -21,17 +21,17 @@
<vm:inbound-endpoint address="vm://HttpServer" synchronous="false"/>
</inbound>
<component class="edu.ucsb.eucalyptus.ic.HttpServer"/>
- </service><!--
-
+ </service>
<service name="Eucalyptus">
<inbound>
<inbound-endpoint ref="EucalyptusWS"/>
</inbound>
<component class="edu.ucsb.eucalyptus.ic.Eucalyptus"/>
</service>
+<!--
- --><service name="RequestQueue">
+<service name="RequestQueue">
<inbound>
<vm:inbound-endpoint address="vm://RequestQueue"/>
</inbound>
@@ -83,7 +83,7 @@
</filtering-router>
</outbound>
</service>
-
+-->
</model>
</mule>
View
40 clc/modules/cloud/src/main/resources/eucalyptus-services.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mule xmlns="http://www.mulesource.org/schema/mule/core/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:spring="http://www.springframework.org/schema/beans"
+ xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.0"
+ xmlns:euca="http://www.eucalyptus.com/schema/cloud/1.6"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd
+ http://www.mulesource.org/schema/mule/vm/2.0 http://www.mulesource.org/schema/mule/vm/2.0/mule-vm.xsd
+ http://www.eucalyptus.com/schema/cloud/1.6 http://www.eucalyptus.com/schema/cloud/1.6/euca.xsd">
+ <!--user data services-->
+ <euca:endpoint name="EucalyptusWS" connector-ref="eucaws" address="http://127.0.0.1:8773/services/Eucalyptus" synchronous="true" />
+ <endpoint name="ImageWS" address="vm://Image" synchronous="false" />
+ <endpoint name="VolumeWS" address="vm://Volume" synchronous="false" />
+ <endpoint name="SnapshotWS" address="vm://Snapshot" synchronous="false" />
+ <euca:endpoint name="KeyPairWSTest" connector-ref="eucaws" address="http://127.0.0.1:8773/services/KeyPair" synchronous="true" />
+ <endpoint name="KeyPairWS" address="vm://KeyPair" synchronous="false" />
+ <endpoint name="GroupsWS" address="vm://Groups" synchronous="false" />
+ <!--vm request verification pipeline-->
+ <endpoint name="StartVerifyWS" address="vm://VmVerify" synchronous="false" />
+ <endpoint name="ImageVerifyWS" address="vm://ImageVerify" synchronous="false" />
+ <endpoint name="KeyPairVerifyWS" address="vm://KeyPairVerify" synchronous="false" />
+ <endpoint name="GroupsVerifyWS" address="vm://GroupsVerify" synchronous="false" />
+ <endpoint name="VmTypeVerifyWS" address="vm://VmTypeVerify" synchronous="false" />
+ <endpoint name="FinishedVerifyWS" address="vm://VmVerified" synchronous="false" />
+ <endpoint name="KeyPairResolveWS" address="vm://KeyPairResolve" synchronous="true" />
+ <endpoint name="ImageResolveWS" address="vm://ImageResolve" synchronous="true" />
+ <!--run-time system state services-->
+ <endpoint name="ClusterEndpointWS" address="vm://ClusterEndpoint" synchronous="false" />
+ <endpoint name="ClusterSinkWS" address="vm://ClusterSink" synchronous="false" />
+ <endpoint name="VmMetadataWS" address="vm://VmMetadata" synchronous="true" />
+ <endpoint name="VmControlWS" address="vm://VmControl" synchronous="false" />
+ <endpoint name="AddressWS" address="vm://Address" synchronous="false" />
+ <endpoint name="UpdateSystemWS" address="vm://UpdateSystemState" synchronous="false" />
+ <endpoint name="SystemStateWS" address="vm://SystemState" synchronous="false" />
+ <endpoint name="TransformReplyWS" address="vm://TransformReply" synchronous="false" />
+</mule>
+
View
4 clc/modules/dns/src/main/java/com/eucalyptus/bootstrap/DNSBootstrapper.java
@@ -1,5 +1,7 @@
package com.eucalyptus.bootstrap;
+import java.util.List;
+
import org.apache.log4j.Logger;
import com.eucalyptus.auth.util.EucaKeyStore;
@@ -34,7 +36,7 @@ public boolean destroy( ) throws Exception {
}
@Override
- public boolean load( ) throws Exception {
+ public boolean load(Resource current, List<Resource> dependencies ) throws Exception {
SystemBootstrapper.hello();
LOG.info("Initializing DNS");
DNSControl.initialize();
View
0 clc/modules/www/conf/eucalyptus-jetty.xml → ...e/src/main/resources/eucalyptus-jetty.xml
File renamed without changes.
View
2 clc/modules/module-inc.xml
@@ -80,7 +80,7 @@
<target name="build-groovy">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="classpath"/>
<groovyc srcdir="${src.dir}" classpathref="classpath" sourcepathref="srcpath" destdir="${build.dir}" verbose="true" listfiles="true" >
- <javac target="1.5"/>
+ <javac target="1.5" debug="true"/>
</groovyc>
</target>
<target name="install" depends="copy-conf"/>
View
6 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/BootstrapFactory.java
@@ -34,9 +34,9 @@ public static void initResourceProviders( ) {
public static void initConfigurationResources( ) throws IOException {
for ( Resource r : Resource.values( ) ) {
for ( ResourceProvider p : r.initProviders( ) ) {
+ LOG.info( "Loading resource provider:" + p.getName( ) + " -- " + p.getOrigin( ) );
for( ConfigResource cfg : p.getConfigurations( ) ) {
- LOG.info( "Loading resource provider:" + p.getName( ) + " -- " + p.getOrigin( ) );
- LOG.info( "--> " + cfg.getUrl( ) );
+ LOG.info( "-> " + cfg.getUrl( ) );
}
}
}
@@ -59,7 +59,7 @@ public static void initBootstrappers( ) {
for ( Resource r : Resource.values( ) ) {
if ( r.providedBy( bootstrap.getClass( ) ) || Resource.Nothing.equals( r ) ) {
r.add( bootstrap );
- LOG.info( "--> Associated bootstrapper " + bootstrap.getClass( ).getSimpleName( ) + " with resource " + r.toString( ) );
+ LOG.info( "-> Associated bootstrapper " + bootstrap.getClass( ).getSimpleName( ) + " with resource " + r.toString( ) );
break;
}
}
View
4 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Bootstrapper.java
@@ -1,5 +1,7 @@
package com.eucalyptus.bootstrap;
+import java.util.List;
+
import org.apache.log4j.Logger;
@Provides(resource=Resource.Nothing)
@@ -15,7 +17,7 @@ public String getVersion() {
return System.getProperty( VERSION_PROPERTY );
}
- public abstract boolean load() throws Exception;
+ public abstract boolean load(Resource current, List<Resource> dependencies) throws Exception;
public abstract boolean start() throws Exception;
public boolean check() throws Exception {
return true;
View
21 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Component.java
@@ -0,0 +1,21 @@
+package com.eucalyptus.bootstrap;
+
+public class Component {
+ public enum Name {
+ eucalyptus, walrus, dns, storage, database, jetty
+ }
+ private Name name;
+ private ResourceProvider resourceProvider;
+ private Component( Name name, ResourceProvider resourceProvider ) {
+ super( );
+ this.name = name;
+ this.resourceProvider = resourceProvider;
+ }
+ public Name getName( ) {
+ return name;
+ }
+ public ResourceProvider getResourceProvider( ) {
+ return resourceProvider;
+ }
+
+}
View
3 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/Resource.java
@@ -56,7 +56,8 @@ private Resource( ) {
LOG.debug( "Found resource provider: " + u );
Properties props = new Properties( );
props.load( u.openStream( ) );
- providers.add( new ResourceProvider( this, props, u ) );
+ ResourceProvider p = new ResourceProvider( this, props, u );
+ providers.add( p );
}
} catch ( IOException e ) {
LOG.error( e, e );
View
62 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/ServiceBootstrapper.java
@@ -0,0 +1,62 @@
+package com.eucalyptus.bootstrap;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.mule.api.MuleContext;
+import org.mule.api.context.MuleContextFactory;
+import org.mule.config.ConfigResource;
+import org.mule.config.spring.SpringXmlConfigurationBuilder;
+import org.mule.context.DefaultMuleContextFactory;
+
+import com.google.common.collect.Lists;
+
+@Provides(resource=Resource.CloudService)
+public class ServiceBootstrapper extends Bootstrapper {
+ private static Logger LOG = Logger.getLogger( ServiceBootstrapper.class );
+ private MuleContext context;
+ private MuleContextFactory contextFactory;
+ private SpringXmlConfigurationBuilder builder;
+
+ public ServiceBootstrapper( ) {
+ super( );
+ this.contextFactory = new DefaultMuleContextFactory( );
+ }
+
+ @Override
+ public boolean load( Resource current, List<Resource> dependencies ) throws Exception {
+ List<ConfigResource> configs = Lists.newArrayList( );
+ for( ResourceProvider r : current.getProviders( ) ) {
+ LOG.info( "Preparing configuration for: " + r );
+ configs.addAll( r.getConfigurations( ) );
+ }
+ for( ConfigResource cfg : configs ) {
+ LOG.info( "-> Loaded cfg: " + cfg.getUrl( ) );
+ }
+ try {
+ this.builder = new SpringXmlConfigurationBuilder( configs.toArray( new ConfigResource[]{} ) );
+ } catch ( Exception e ) {
+ LOG.fatal( "Failed to bootstrap services.", e );
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean start( ) throws Exception {
+ try {
+ this.context = this.contextFactory.createMuleContext( this.builder );
+ } catch ( Exception e ) {
+ LOG.fatal( "Failed to configure services.", e );
+ return false;
+ }
+ try {
+ this.context.start( );
+ } catch ( Exception e ) {
+ LOG.fatal( "Failed to start services.", e );
+ return false;
+ }
+ return true;
+ }
+
+}
View
40 clc/modules/msgs/src/main/java/com/eucalyptus/bootstrap/SystemBootstrapper.java
@@ -1,5 +1,8 @@
package com.eucalyptus.bootstrap;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
@@ -8,7 +11,9 @@
import com.eucalyptus.util.LogUtils;
import com.google.common.collect.Lists;
-public class SystemBootstrapper extends Bootstrapper {
+import edu.emory.mathcs.backport.java.util.Arrays;
+
+public class SystemBootstrapper {
private static Logger LOG = Logger.getLogger( SystemBootstrapper.class );
static {
System.setProperty( "euca.db.host", "127.0.0.1" );
@@ -17,7 +22,7 @@
}
private static SystemBootstrapper singleton;
- public static Bootstrapper getInstance( ) {
+ public static SystemBootstrapper getInstance( ) {
synchronized ( SystemBootstrapper.class ) {
if ( singleton == null ) {
singleton = new SystemBootstrapper( );
@@ -30,16 +35,13 @@ public static Bootstrapper getInstance( ) {
}
private MuleContext context;
- private List<Bootstrapper> bootstrappers = Lists.newArrayList( );
private SystemBootstrapper( ) {}
- @Override
public boolean destroy( ) {
return true;
}
- @Override
public boolean stop( ) throws Exception {
this.context.stop( );
return true;
@@ -67,8 +69,10 @@ public boolean init() throws Exception {
* configure db/load bootstrap stack & wait for dbconfig
* TODO: discovery persistence contexts
* TODO: determine the role of this component
+ * TODO: depends callbacks
+ * TODO: remote config
+ * TODO: bootstrap bindings
*/
- @Override
public boolean load( ) throws Exception {
for( Resource r : Resource.values( ) ) {
if( r.getBootstrappers( ).isEmpty( ) ) {
@@ -79,18 +83,19 @@ public boolean load( ) throws Exception {
for( Bootstrapper b : r.getBootstrappers( ) ) {
try {
LOG.info( "-> load: " + b.getClass( ) );
-// boolean result = b.load( );
+ Depends deps = b.getClass( ).getAnnotation( Depends.class );
+ Resource[] depResources = deps!=null?deps.resources( ):new Resource[]{Resource.Nothing};
+ List<Resource> depList =Arrays.asList( depResources );
+ boolean result = b.load( r, depList );
} catch ( Exception e ) {
LOG.error( b.getClass( ).getSimpleName( ) + " threw an error in load( ): " + e.getMessage( ), e);
return false;
}
}
}
-// context = new DefaultMuleContextFactory( ).createMuleContext( new SpringXmlConfigurationBuilder( configs.toArray( new ConfigResource[] {} ) ) );
return true;
}
- @Override
public boolean start( ) throws Exception {
for( Resource r : Resource.values( ) ) {
if( r.getBootstrappers( ).isEmpty( ) ) {
@@ -101,35 +106,20 @@ public boolean start( ) throws Exception {
for( Bootstrapper b : r.getBootstrappers( ) ) {
try {
LOG.info( "-> start: " + b.getClass( ) );
-// boolean result = b.start( );
+ boolean result = b.start( );
} catch ( Exception e ) {
LOG.error( b.getClass( ).getSimpleName( ) + " threw an error in start( ): " + e.getMessage( ), e);
return false;
}
}
}
return true;
-// LOG.info( "Starting Eucalyptus." );
-// try {
-// for ( Bootstrapper b : this.bootstrappers ) {
-// LOG.info( "-> Invoking bootstrapper " + b.getClass( ).getSimpleName( ) + ".start()Z" );
-// b.start( );
-// }
-// LOG.info( LogUtils.header( "Starting Eucalyptus." ) );
-// context.start( );
-// return true;
-// } catch ( Exception e ) {
-// LOG.error( e, e );
-// return false;
-// }
}
- @Override
public String getVersion( ) {
return System.getProperty( "euca.version" );
}
- @Override
public boolean check( ) {
return true;
}
View
1 clc/modules/msgs/src/main/java/com/eucalyptus/util/ServiceJarFile.java
@@ -77,6 +77,7 @@ private Class getBootstrapper( JarEntry j ) throws Exception {
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 );
+ LOG.warn("Candidate bootstrapper: " + candidate.getName());
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;" ); }
View
2 clc/modules/msgs/src/main/resources/com.eucalyptus.CloudServiceProvider
@@ -0,0 +1,2 @@
+name=bootstrap
+euca.model.bootstrap=eucalyptus-bootstrap.xml
View
27 clc/modules/msgs/src/main/resources/eucalyptus-bootstrap.xml
@@ -12,33 +12,8 @@
<!-- TODO: remove all these forward references somehow -->
<!--interface services-->
<endpoint name="ReplyQueueWS" address="vm://ReplyQueue" synchronous="false" />
- <!--user data services-->
- <endpoint name="ImageWS" address="vm://Image" synchronous="false" />
- <endpoint name="VolumeWS" address="vm://Volume" synchronous="false" />
- <endpoint name="SnapshotWS" address="vm://Snapshot" synchronous="false" />
- <euca:endpoint name="KeyPairWSTest" connector-ref="eucaws" address="http://127.0.0.1:8773/services/KeyPair" synchronous="true" />
- <endpoint name="KeyPairWS" address="vm://KeyPair" synchronous="false" />
- <endpoint name="GroupsWS" address="vm://Groups" synchronous="false" />
- <!--vm request verification pipeline-->
- <endpoint name="StartVerifyWS" address="vm://VmVerify" synchronous="false" />
- <endpoint name="ImageVerifyWS" address="vm://ImageVerify" synchronous="false" />
- <endpoint name="KeyPairVerifyWS" address="vm://KeyPairVerify" synchronous="false" />
- <endpoint name="GroupsVerifyWS" address="vm://GroupsVerify" synchronous="false" />
- <endpoint name="VmTypeVerifyWS" address="vm://VmTypeVerify" synchronous="false" />
- <endpoint name="FinishedVerifyWS" address="vm://VmVerified" synchronous="false" />
- <endpoint name="KeyPairResolveWS" address="vm://KeyPairResolve" synchronous="true" />
- <endpoint name="ImageResolveWS" address="vm://ImageResolve" synchronous="true" />
- <!--run-time system state services-->
- <endpoint name="ClusterEndpointWS" address="vm://ClusterEndpoint" synchronous="false" />
- <endpoint name="ClusterSinkWS" address="vm://ClusterSink" synchronous="false" />
- <endpoint name="VmMetadataWS" address="vm://VmMetadata" synchronous="true" />
- <endpoint name="VmControlWS" address="vm://VmControl" synchronous="false" />
- <endpoint name="AddressWS" address="vm://Address" synchronous="false" />
- <endpoint name="UpdateSystemWS" address="vm://UpdateSystemState" synchronous="false" />
- <endpoint name="SystemStateWS" address="vm://SystemState" synchronous="false" />
- <endpoint name="TransformReplyWS" address="vm://TransformReply" synchronous="false" />
- <model name="eucalyptus-webservices">
+ <model name="eucalyptus-bootstrap">
<default-service-exception-strategy>
<outbound-endpoint ref="ReplyQueueWS" />
</default-service-exception-strategy>

0 comments on commit 0228dcd

Please sign in to comment.
Something went wrong with that request. Please try again.