Skip to content

Commit

Permalink
Merge pull request #46 from fogbow/develop
Browse files Browse the repository at this point in the history
Implement request validity according to token validity
  • Loading branch information
abmargb committed Jun 2, 2014
2 parents 9c72b8e + 0872193 commit f45494b
Show file tree
Hide file tree
Showing 102 changed files with 8,192 additions and 1,883 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/target
/bin
.classpath
.project
.settings
4 changes: 4 additions & 0 deletions bin/fogbow-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
DIRNAME=`dirname $0`
cd $DIRNAME/..
java -Dlog4j.configuration=file:log4j.properties -cp target/manager-0.0.1-SNAPSHOT.jar:target/lib/* org.fogbowcloud.manager.cli.Main $@
2 changes: 2 additions & 0 deletions bin/fogbow-inject-tunnel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/usr/bin/ssh -y -N -f -R 0.0.0.0:#REMOTE_PORT#:localhost:22 #REMOTE_USER#@#REMOTE_HOST#
37 changes: 37 additions & 0 deletions manager.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
xmpp_jid=manager.test.com
xmpp_password=password
xmpp_host=127.0.0.1
xmpp_port=5347

rendezvous_jid=rendezvous.test.com

compute_class=org.fogbowcloud.manager.core.plugins.openstack.OpenStackComputePlugin
compute_openstack_occi_url=http://localhost:8182
compute_openstack_v2api_url=http://localhost:8182
compute_openstack_flavor_small=m1-small
compute_openstack_flavor_medium=m1-medium
compute_openstack_flavor_large=m1-large
compute_openstack_default_cirros_image=cadf2e29-7216-4a5e-9364-cf6513d5f1fd

identity_class=org.fogbowcloud.manager.core.plugins.openstack.OpenStackIdentityPlugin
identity_openstack_url=http://localhost:5000

federation_user_name=fogbow
federation_user_password=fogbow
federation_user_tenant_name=demo

member_validator=org.fogbowcloud.manager.core.DefaultMemberValidator
member_validator_ca_dir=

cert_path=

scheduler_period=30000
token_update_period=300000
instance_monitoring_period=120000

ssh_tunnel_public_host=150.165.80.1
ssh_tunnel_private_host=10.0.0.1
ssh_tunnel_user=fogbow
ssh_tunnel_port_range=50000:59999

http_port = 8182
235 changes: 155 additions & 80 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,85 +1,160 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.fogbowcloud</groupId>
<artifactId>manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.fogbowcloud</groupId>
<artifactId>manager</artifactId>
<version>0.0.1-SNAPSHOT</version>

<repositories>
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>http://maven.restlet.org</url>
</repository>
</repositories>
<repositories>
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>http://maven.restlet.org</url>
</repository>
</repositories>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
<executions>
<execution>
<id>clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>instrument</id>
<phase>package</phase>
<goals>
<goal>instrument</goal>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Dlog4j.configuration=file:log4j.properties</argument>
<argument>-cp</argument>
<argument>${project.build.directory}/${project.artifactId}-${project.version}.jar:${project.build.directory}/lib/*</argument>
<argument>org.fogbowcloud.manager.Main</argument>
<argument>manager.conf</argument>
</arguments>
</configuration>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
<executions>
<execution>
<id>clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>instrument</id>
<phase>package</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Ignore/Execute plugin execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<!-- copy-dependency plugin -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>org.jamppa</groupId>
<artifactId>jamppa</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0-alpha4</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.jamppa</groupId>
<artifactId>jamppa</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0-alpha4</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.35</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
76 changes: 71 additions & 5 deletions src/main/java/org/fogbowcloud/manager/Main.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,81 @@
package org.fogbowcloud.manager;

import java.io.FileInputStream;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.fogbowcloud.manager.core.DefaultMemberValidator;
import org.fogbowcloud.manager.core.FederationMemberValidator;
import org.fogbowcloud.manager.core.ManagerController;
import org.fogbowcloud.manager.core.plugins.ComputePlugin;
import org.fogbowcloud.manager.core.plugins.IdentityPlugin;
import org.fogbowcloud.manager.core.plugins.openstack.OpenStackComputePlugin;
import org.fogbowcloud.manager.core.plugins.openstack.OpenStackIdentityPlugin;
import org.fogbowcloud.manager.occi.OCCIApplication;
import org.fogbowcloud.manager.xmpp.ManagerXmppComponent;
import org.restlet.Component;
import org.restlet.data.Protocol;

public class Main {

private static final Logger LOGGER = Logger.getLogger(Main.class);

public static void main(String[] args) throws Exception {
Properties properties = new Properties();
FileInputStream input = new FileInputStream(args[0]);
properties.load(input);

ComputePlugin computePlugin = new OpenStackComputePlugin(properties);
try {
computePlugin = (ComputePlugin) createInstance(
"compute_class", properties);
} catch (Exception e) {
LOGGER.warn("Compute Plugin not especified in the properties.");
}
IdentityPlugin identityPlugin = new OpenStackIdentityPlugin(properties);
try {
identityPlugin = (IdentityPlugin) createInstance(
"identity_class", properties);
} catch (Exception e) {
LOGGER.warn("Identity Plugin not especified in the properties.");
}

FederationMemberValidator validator = new DefaultMemberValidator();
try {
validator = (FederationMemberValidator) createInstance(
"member_validator", properties);
} catch (Exception e) {
LOGGER.warn("Member Validator not especified in the properties.");
}

ManagerController facade = new ManagerController(properties);
facade.setComputePlugin(computePlugin);
facade.setIdentityPlugin(identityPlugin);
facade.setValidator(validator);

ManagerXmppComponent xmpp = new ManagerXmppComponent(
properties.getProperty("xmpp_jid"),
properties.getProperty("xmpp_password"),
properties.getProperty("xmpp_host"),
Integer.parseInt(properties.getProperty("xmpp_port")), facade);
xmpp.setRendezvousAddress(properties.getProperty("rendezvous_jid"));
xmpp.connect();
xmpp.process(false);
xmpp.init();
facade.setPacketSender(xmpp);

OCCIApplication application = new OCCIApplication(facade);

Component http = new Component();
http.getServers().add(Protocol.HTTP,
Integer.parseInt(properties.getProperty("http_port")));
http.getDefaultHost().attach(application);
http.start();
}

public static void main(String[] args) throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getDefaultHost().attach(new OCCIApplication());
component.start();
private static Object createInstance(String propName, Properties properties)
throws Exception {
return Class.forName(properties.getProperty(propName))
.getConstructor(Properties.class).newInstance(properties);
}
}
Loading

0 comments on commit f45494b

Please sign in to comment.