From 448ac7aa7c18d9fdc52e1ee151ba8c3d779656dc Mon Sep 17 00:00:00 2001 From: mklkun Date: Fri, 7 Aug 2020 13:08:25 +0200 Subject: [PATCH] Second sprint --- .gitignore | 2 + README.md | 23 +++++ build.gradle | 14 ++- .../org/activeeon/morphemic/AdapterDemo.java | 92 ------------------- .../deployment}/PAFactory.java | 36 +++++++- .../deployment/PASchedulerGateway.java | 51 +++++----- .../morphemic/common/PAConfiguration.java | 87 ------------------ .../deployment/PAResourceManagerGateway.java | 68 +++++++++----- .../morphemic/utils/ProtectionUtils.java | 32 ------- src/main/resources/MySQL_post_script.groovy | 10 -- src/main/resources/Start_MySQL_Script.sh | 65 ------------- src/main/resources/Start_Wordpress_Script.sh | 54 ----------- src/main/resources/check_node_name.groovy | 28 ------ src/main/resources/check_node_source.groovy | 34 ------- src/main/resources/pre_script.sh | 9 -- src/main/resources/proactive.properties | 26 ------ 16 files changed, 141 insertions(+), 490 deletions(-) create mode 100644 .gitignore delete mode 100644 src/main/java/org/activeeon/morphemic/AdapterDemo.java rename src/main/java/org/activeeon/morphemic/{utils => application/deployment}/PAFactory.java (75%) delete mode 100644 src/main/java/org/activeeon/morphemic/common/PAConfiguration.java delete mode 100644 src/main/java/org/activeeon/morphemic/utils/ProtectionUtils.java delete mode 100644 src/main/resources/MySQL_post_script.groovy delete mode 100644 src/main/resources/Start_MySQL_Script.sh delete mode 100644 src/main/resources/Start_Wordpress_Script.sh delete mode 100644 src/main/resources/check_node_name.groovy delete mode 100644 src/main/resources/check_node_source.groovy delete mode 100644 src/main/resources/pre_script.sh delete mode 100644 src/main/resources/proactive.properties diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7c9cf9c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build/ +/.gradle/ diff --git a/README.md b/README.md index e69de29b..2ad09db9 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,23 @@ +# Morphemic ProActive Client + +This module allows users to interact with a running ProActive Scheduler and Resource Manager. + +### 1. Requirements + +* An accessible ProActive server. +* Some valid ProActive credentials. + +### 2. How to build + +Just run `./gradlew clean build javadoc` + +This will generate the `Morphemic-ProActive-Client-XXX.jar` file inside the project's `build/libs` folder, and the +documentation web pages inside the `docs` folder. + +### 3. Usage + +Copy/paste and add the jar file into your project as a dependency. Enjoy! + +### 4. Example + +An example of the Morphemic-ProActive-Client usage is provided here: https://github.com/mklkun/Morphemic-Adapter-Demo diff --git a/build.gradle b/build.gradle index 8aee4ba1..67cebb82 100644 --- a/build.gradle +++ b/build.gradle @@ -14,14 +14,26 @@ repositories { maven { url 'http://repository.activeeon.com/content/groups/proactive/' } } - +jar { + from { + configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + } +} apply plugin: 'java' +javadoc { + source = sourceSets.main.allJava + classpath = configurations.compile + destinationDir = file("${buildDir}/docs/javadoc") +} + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' compile group: 'org.apache.commons', name: 'commons-configuration2', version: '2.7' compile group: 'org.ow2.proactive_grid_cloud_portal', name: 'rest-smartproxy', version: '10.1.0-SNAPSHOT' compile group: 'org.ow2.proactive_grid_cloud_portal', name: 'rest-api', version: '10.1.0-SNAPSHOT' compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4' + compile group: 'org.jasypt', name: 'jasypt', version: '1.9.2' } + diff --git a/src/main/java/org/activeeon/morphemic/AdapterDemo.java b/src/main/java/org/activeeon/morphemic/AdapterDemo.java deleted file mode 100644 index 949208ef..00000000 --- a/src/main/java/org/activeeon/morphemic/AdapterDemo.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.activeeon.morphemic; - -import org.activeeon.morphemic.infrastructure.deployment.PAResourceManagerGateway; -import org.activeeon.morphemic.application.deployment.PASchedulerGateway; -import org.activeeon.morphemic.utils.PAFactory; -import org.apache.log4j.Logger; -import org.ow2.proactive.scheduler.common.exception.UserException; -import org.ow2.proactive.scheduler.common.job.JobId; -import org.ow2.proactive.scheduler.common.job.TaskFlowJob; -import org.ow2.proactive.scheduler.common.task.ScriptTask; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class AdapterDemo { - - private static final Logger LOGGER = Logger.getLogger(AdapterDemo.class); - - private static TaskFlowJob createApplicationWF(List deployedNodes) throws UserException { - TaskFlowJob myApplication = new TaskFlowJob(); - - myApplication.setName("Morphemic_Example_1"); - Map jobVariables = new HashMap<>(); - jobVariables.put("DB_USER", "wordpress"); - jobVariables.put("DB_PASSWORD", "pressword"); - jobVariables.put("DB_NAME", "wordpress"); - myApplication.setVariables(PAFactory.variablesToJobVariables(jobVariables)); - - //Creating MySQL WF task - ScriptTask mySQLTask = PAFactory.createBashScriptTask("Start_MySQL_Component", "Start_MySQL_Script.sh"); - mySQLTask.setPreScript(PAFactory.createSimpleScriptFromFIle("pre_script.sh", "bash")); - mySQLTask.setPostScript(PAFactory.createSimpleScriptFromFIle("MySQL_post_script.groovy", "groovy")); - mySQLTask.setSelectionScript(PAFactory.createGroovySelectionScript("check_node_name.groovy", new String[]{deployedNodes.get(0)})); - Map mySQLvariables = new HashMap<>(); - mySQLvariables.put("INSTANCE_NAME", "ComponentMySql"); - mySQLTask.setVariables(PAFactory.variablesToTaskVariables(mySQLvariables)); - - //Creating Wordpress WF task - ScriptTask myWordpressTask = PAFactory.createBashScriptTask("Start_Wordpress_Component", "Start_Wordpress_Script.sh"); - myWordpressTask.setPreScript(PAFactory.createSimpleScriptFromFIle("pre_script.sh", "bash")); - myWordpressTask.setSelectionScript(PAFactory.createGroovySelectionScript("check_node_name.groovy", new String[]{deployedNodes.get(1)})); - Map taskVariables = new HashMap<>(); - taskVariables.put("INSTANCE_NAME", "ComponentMyWordpress"); - myWordpressTask.setVariables(PAFactory.variablesToTaskVariables(taskVariables)); - myWordpressTask.addDependence(mySQLTask); - - //Adding tasks to the workflow - myApplication.addTask(mySQLTask); - myApplication.addTask(myWordpressTask); - - return myApplication; - } - - public static void main(String[] args) { - - PASchedulerGateway schedulerGateway = new PASchedulerGateway(); - PAResourceManagerGateway resourceManagerGateway = new PAResourceManagerGateway(); - - String nodeSourceName = "AWSMORPHEMICUP"; - Integer numberVMs = 2; - - try { - // Connecting to the RM - resourceManagerGateway.connect(); - - // Connecting to the Scheduler - schedulerGateway.connect(); - - LOGGER.info("Deploying VMs"); - resourceManagerGateway.deploySimpleAWSNodeSource(nodeSourceName, numberVMs); - - LOGGER.info("Preparation of deployed node names."); - List deployedNodes = resourceManagerGateway.getAsyncDeployedNodesInformation(nodeSourceName); - - LOGGER.info("deployedNodes = " + deployedNodes.toString()); - - LOGGER.info("Creating application workflow."); - TaskFlowJob myApplication = createApplicationWF(deployedNodes); - - JobId jobId = schedulerGateway.submit(myApplication); - LOGGER.info("Job submitted with id = " + jobId); - - } catch (Exception e) { - LOGGER.error(" ... Error: " + e.getMessage()); - } finally { - resourceManagerGateway.disconnect(); - schedulerGateway.disconnect(); - } - LOGGER.info("End."); - } -} diff --git a/src/main/java/org/activeeon/morphemic/utils/PAFactory.java b/src/main/java/org/activeeon/morphemic/application/deployment/PAFactory.java similarity index 75% rename from src/main/java/org/activeeon/morphemic/utils/PAFactory.java rename to src/main/java/org/activeeon/morphemic/application/deployment/PAFactory.java index 143f69a3..7827b386 100644 --- a/src/main/java/org/activeeon/morphemic/utils/PAFactory.java +++ b/src/main/java/org/activeeon/morphemic/application/deployment/PAFactory.java @@ -1,4 +1,4 @@ -package org.activeeon.morphemic.utils; +package org.activeeon.morphemic.application.deployment; import org.apache.log4j.Logger; import org.ow2.proactive.scheduler.common.job.JobVariable; @@ -23,6 +23,12 @@ public class PAFactory { private PAFactory() { } + /** + * Create a simple script + * @param implementation The script implementation + * @param scriptLanguage The script language + * @return A ProActive SimpleScript instance + */ public static SimpleScript createSimpleScript(String implementation, String scriptLanguage) { SimpleScript mySQLSimpleScript = null; LOGGER.debug("Creating a simple script from its implementation "); @@ -35,6 +41,12 @@ public class PAFactory { return mySQLSimpleScript; } + /** + * Create a simple script from a file + * @param scriptFileName The script implementation file name + * @param scriptLanguage The script language + * @return A ProActive SimpleScript instance + */ public static SimpleScript createSimpleScriptFromFIle(String scriptFileName, String scriptLanguage) { SimpleScript mySQLSimpleScript = null; LOGGER.debug("Creating a simple script from the file : " + scriptFileName); @@ -49,6 +61,12 @@ public class PAFactory { return mySQLSimpleScript; } + /** + * Create a Bash script task + * @param taskName The name of the task + * @param scriptFileName The script implementation file name + * @return A ProActive ScriptTask instance + */ public static ScriptTask createBashScriptTask(String taskName, String scriptFileName) { ScriptTask mySQLTask = new ScriptTask(); mySQLTask.setName(taskName); @@ -66,6 +84,12 @@ public class PAFactory { return mySQLTask; } + /** + * Create a Groovy node selection script + * @param scriptFileName The script implementation file name + * @param parameters The selection script parameters + * @return A ProActive SelectionScript instance + */ public static SelectionScript createGroovySelectionScript(String scriptFileName, String[] parameters) { SelectionScript selectionScript = null; LOGGER.debug("Creating a groovy selection script"); @@ -80,12 +104,22 @@ public class PAFactory { return selectionScript; } + /** + * Create a Map of variables of (String (key), TaskVariable (value)) + * @param variables A Map of variables in (String (key), String (value)) + * @return A Map of variables in (String, TaskVariable) + */ public static Map variablesToTaskVariables(Map variables) { Map taskVariables = new HashMap<>(); variables.forEach((k, v) -> taskVariables.put(k, new TaskVariable(k, v))); return taskVariables; } + /** + * Create a Map of variables of (String (key), JobVariable (value)) + * @param variables A Map of variables in (String (key), String (value)) + * @return A Map of variables in (String, JobVariable) + */ public static Map variablesToJobVariables(Map variables) { Map jobVariables = new HashMap<>(); variables.forEach((k, v) -> jobVariables.put(k, new TaskVariable(k, v))); diff --git a/src/main/java/org/activeeon/morphemic/application/deployment/PASchedulerGateway.java b/src/main/java/org/activeeon/morphemic/application/deployment/PASchedulerGateway.java index 0b5460e7..c5b6651d 100644 --- a/src/main/java/org/activeeon/morphemic/application/deployment/PASchedulerGateway.java +++ b/src/main/java/org/activeeon/morphemic/application/deployment/PASchedulerGateway.java @@ -1,10 +1,5 @@ package org.activeeon.morphemic.application.deployment; -import org.activeeon.morphemic.common.PAConfiguration; -import org.activeeon.morphemic.utils.ProtectionUtils; -import org.apache.commons.configuration2.BaseConfiguration; -import org.apache.commons.configuration2.Configuration; -import org.apache.commons.configuration2.ex.ConfigurationException; import org.apache.log4j.Logger; import org.ow2.proactive.authentication.ConnectionInfo; import org.ow2.proactive.scheduler.common.exception.JobCreationException; @@ -16,31 +11,27 @@ import org.ow2.proactive.scheduler.common.job.JobId; import org.ow2.proactive_grid_cloud_portal.smartproxy.RestSmartProxyImpl; public class PASchedulerGateway { - private RestSmartProxyImpl restSmartProxy; - - private String ROOT_DIR; - private String BASE_URL; + private final String restUrl; - private Configuration config = new BaseConfiguration(); + private RestSmartProxyImpl restSmartProxy; private static final Logger LOGGER = Logger.getLogger(PASchedulerGateway.class); - - public PASchedulerGateway() { - try { - // load ProActive configuration - config = PAConfiguration.loadPAConfiguration(); - } catch (ConfigurationException ce) { - LOGGER.error("ERROR: " + ce.toString()); - } - - ROOT_DIR = System.getProperty("user.dir"); - BASE_URL = config.getString(PAConfiguration.SCHEDULER_REST_URL); - + /** + * Construct a gateway to the ProActive Scheduler + * @param restUrl ProActive rest URL (exp: http://try.activeeon.com:8080/rest) + */ + public PASchedulerGateway(String restUrl) { + this.restUrl = restUrl; restSmartProxy = new RestSmartProxyImpl(); } + /** + * Submit a ProActive job to the scheduler + * @param job A ProActive job + * @return JobId + */ public JobId submit(Job job) { JobId jobId = null; LOGGER.debug("Submitting job: " + job.toString()); @@ -58,11 +49,16 @@ public class PASchedulerGateway { return jobId; } - public void connect() { + /** + * Connect to the ProActive server + * @param username The user's username + * @param password The user's password + */ + public void connect(String username, String password) { LOGGER.debug("Connecting to Scheduler ..."); - ConnectionInfo connectionInfo = new ConnectionInfo(config.getString(PAConfiguration.REST_URL), - ProtectionUtils.decrypt(config.getString(PAConfiguration.REST_LOGIN)), - ProtectionUtils.decrypt(config.getString(PAConfiguration.REST_PASSWORD)), + ConnectionInfo connectionInfo = new ConnectionInfo(this.restUrl, + username, + password, null, true); @@ -70,6 +66,9 @@ public class PASchedulerGateway { LOGGER.info("Connected to Scheduler."); } + /** + * Disconnect from the ProActive server + */ public void disconnect() { try { LOGGER.debug("Disconnecting from Scheduler..."); diff --git a/src/main/java/org/activeeon/morphemic/common/PAConfiguration.java b/src/main/java/org/activeeon/morphemic/common/PAConfiguration.java deleted file mode 100644 index 75e85fb5..00000000 --- a/src/main/java/org/activeeon/morphemic/common/PAConfiguration.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.activeeon.morphemic.common; - -import java.io.File; - -import org.apache.commons.configuration2.Configuration; -import org.apache.commons.configuration2.PropertiesConfiguration; -import org.apache.commons.configuration2.ex.ConfigurationException; -import org.apache.commons.configuration2.builder.fluent.PropertiesBuilderParameters; -import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; -import org.apache.commons.configuration2.builder.fluent.Parameters; -import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler; -import org.apache.commons.configuration2.convert.ListDelimiterHandler; -import org.apache.log4j.Logger; - -public class PAConfiguration { - - /** - * All parameters required for IAM - * - */ - public static final String PROPERTIES_FILE = "proactive.properties"; - - public static final String REST_URL = "pa.rest.url"; - - public static final String REST_LOGIN = "pa.rest.login"; - - public static final String REST_PASSWORD = "pa.rest.password"; - - public static final String SCHEDULER_REST_URL = "pa.scheduler.rest.url"; - - public static final String RM_REST_URL = "pa.rm.rest.url"; - - private static final ListDelimiterHandler DELIMITER = new DefaultListDelimiterHandler(';'); - - private static final String SEPARATOR = File.separator; - - private static final String PA_CONFIGURATION_PATH = "src/main/resources"; - - private static final Logger LOGGER = Logger.getLogger(PAConfiguration.class); - - private PAConfiguration() { - } - - /** - * Load ProActive configuration - */ - public static Configuration loadPAConfiguration() throws ConfigurationException { - File configFile = new File(PA_CONFIGURATION_PATH + SEPARATOR + PAConfiguration.PROPERTIES_FILE); - - if (!configFile.exists()) { - throw new ConfigurationException("ProActive configuration not found in : " + configFile.getAbsolutePath()); - } - - Configuration config = loadConfig(configFile); - - LOGGER.debug("ProActive configuration loaded from file: " + configFile.getAbsolutePath()); - - return config; - } - - /** - * Loads the configuration of ProActive. - * - * @param configFile configuration file to load - * @return ProActive configuration - * @throws ConfigurationException If a problem occurs when loading ProActive configuration - */ - private static Configuration loadConfig(File configFile) throws ConfigurationException { - - Configuration config; - - PropertiesBuilderParameters propertyParameters = new Parameters().properties(); - propertyParameters.setFile(configFile); - propertyParameters.setThrowExceptionOnMissing(true); - propertyParameters.setListDelimiterHandler(DELIMITER); - - FileBasedConfigurationBuilder builder = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class); - - builder.configure(propertyParameters); - - config = builder.getConfiguration(); - - LOGGER.debug("ProActive configuration loaded"); - - return config; - } -} \ No newline at end of file diff --git a/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index bdfb9ab5..fafe84c2 100644 --- a/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -1,10 +1,5 @@ package org.activeeon.morphemic.infrastructure.deployment; -import org.activeeon.morphemic.common.PAConfiguration; -import org.activeeon.morphemic.utils.ProtectionUtils; -import org.apache.commons.configuration2.BaseConfiguration; -import org.apache.commons.configuration2.Configuration; -import org.apache.commons.configuration2.ex.ConfigurationException; import org.apache.http.conn.ConnectTimeoutException; import org.apache.log4j.Logger; import org.ow2.proactive.resourcemanager.common.event.RMNodeEvent; @@ -24,22 +19,24 @@ import java.util.concurrent.*; public class PAResourceManagerGateway { + private final String restUrl; + private RMRestInterface rmRestInterface; private String sessionId; - private String ROOT_DIR; - - private String BASE_URL; - - private Configuration config = new BaseConfiguration(); - static final int MAX_CONNECTION_RETRIES = 10; static final int INTERVAL = 10000; private static final Logger LOGGER = Logger.getLogger(PAResourceManagerGateway.class); + /** + * Get, in an asynchronous way, deployed nodes names + * @param nodeSource The name of the node source + * @return List of deployed nodes names + * @throws InterruptedException In case the process is interrupted + */ public List getAsyncDeployedNodesInformation(String nodeSource) throws InterruptedException { ExecutorService executorService = Executors.newSingleThreadExecutor(); @@ -80,28 +77,35 @@ public class PAResourceManagerGateway { return deployedNodes; } - public PAResourceManagerGateway() { - try { - // load ProActive configuration - config = PAConfiguration.loadPAConfiguration(); - } catch (ConfigurationException ce) { - LOGGER.error("ERROR: " + ce.toString()); - } - ROOT_DIR = System.getProperty("user.dir"); - BASE_URL = config.getString(PAConfiguration.RM_REST_URL); - - RMRestClient client = new RMRestClient(config.getString(PAConfiguration.REST_URL), null); + /** + * Construct a gateway to the ProActive Resource Manager + * @param restUrl ProActive rest URL (exp: http://try.activeeon.com:8080/rest) + */ + public PAResourceManagerGateway(String restUrl) { + this.restUrl = restUrl; + RMRestClient client = new RMRestClient(this.restUrl, null); rmRestInterface = client.getRm(); } - public void connect() throws LoginException, KeyException, RMException { + + /** + * Connect to the ProActive server + * @param username The user's username + * @param password The user's password + * @throws LoginException In case the login is not valid + * @throws KeyException In case the password is not valid + * @throws RMException In case an error happens in the RM + */ + public void connect(String username, String password) throws LoginException, KeyException, RMException { LOGGER.debug("Connecting to RM ..."); - sessionId = rmRestInterface.rmConnect(ProtectionUtils.decrypt(config.getString(PAConfiguration.REST_LOGIN)), - ProtectionUtils.decrypt(config.getString(PAConfiguration.REST_PASSWORD))); + sessionId = rmRestInterface.rmConnect(username, password); LOGGER.info("Connected to RM."); } + /** + * Disconnect from the ProActive server + */ public void disconnect() { try { LOGGER.debug("Disconnecting from RM..."); @@ -112,6 +116,13 @@ public class PAResourceManagerGateway { } } + /** + * Get deployed nodes names + * @param nodeSource The name of the node source + * @return List of deployed nodes names + * @throws NotConnectedException In case the user is not connected + * @throws PermissionRestException In case the user does not have valid permissions + */ private List getDeployedNodesInformation(String nodeSource) throws NotConnectedException, PermissionRestException { List deployedNodes = new ArrayList<>(); LOGGER.debug("Getting full RM state ..."); @@ -129,6 +140,13 @@ public class PAResourceManagerGateway { return deployedNodes; } + /** + * Deploy a simple AWS node source + * @param nodeSourceName The name of the node source + * @param numberVMs The number of needed VMs + * @throws NotConnectedException In case the user is not connected + * @throws PermissionRestException In case the user does not have valid permissions + */ public void deploySimpleAWSNodeSource(String nodeSourceName, Integer numberVMs) throws NotConnectedException, PermissionRestException { // Getting NS configuration settings String infrastructureType = "org.ow2.proactive.resourcemanager.nodesource.infrastructure.AWSEC2Infrastructure"; diff --git a/src/main/java/org/activeeon/morphemic/utils/ProtectionUtils.java b/src/main/java/org/activeeon/morphemic/utils/ProtectionUtils.java deleted file mode 100644 index 34da8459..00000000 --- a/src/main/java/org/activeeon/morphemic/utils/ProtectionUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.activeeon.morphemic.utils; - -import org.jasypt.util.text.AES256TextEncryptor; - -public class ProtectionUtils { - - public static final AES256TextEncryptor textEncryptor = new AES256TextEncryptor(); - - public static final String PASSWORD = "PhemicMor20."; - - private static boolean isSet = false; - - private ProtectionUtils() { - } - - public static String decrypt(String encryptedText) { - if (!isSet) { - textEncryptor.setPassword(PASSWORD); - isSet = true; - } - return textEncryptor.decrypt(encryptedText); - } - - public static String encrypt(String plainText) { - if (!isSet) { - textEncryptor.setPassword(PASSWORD); - isSet = true; - } - return textEncryptor.encrypt(plainText); - } - -} diff --git a/src/main/resources/MySQL_post_script.groovy b/src/main/resources/MySQL_post_script.groovy deleted file mode 100644 index 38edd5f3..00000000 --- a/src/main/resources/MySQL_post_script.groovy +++ /dev/null @@ -1,10 +0,0 @@ -// Acquire variables -def instanceName = variables.get("INSTANCE_NAME") - -// Handle service parameters -def ipAddr = new File(instanceName+"_dbipaddr").text.trim() -def port = new File(instanceName+"_dbport").text.trim() - -// Push variables -variables.put("DB_IPADDR", ipAddr) -variables.put("DB_PORT", port) \ No newline at end of file diff --git a/src/main/resources/Start_MySQL_Script.sh b/src/main/resources/Start_MySQL_Script.sh deleted file mode 100644 index 8a9557be..00000000 --- a/src/main/resources/Start_MySQL_Script.sh +++ /dev/null @@ -1,65 +0,0 @@ -echo BEGIN "$variables_PA_TASK_NAME" - -INSTANCE_NAME="$variables_INSTANCE_NAME" - -################################################################################ -### THIS PART IS IMAGE SPECIFIC. IF YOU NEED TO MODIFY SOMETHING, DO IT HERE ### -DOCKER_IMAGE=activeeon/mysql -PORT=3306 -ROOT_PASSWORD="root" -USER="$variables_DB_USER" -PASSWORD="$variables_DB_PASSWORD" -DATABASE="$variables_DB_NAME" -VOLUME=db_data -# Check whether USER and PASSWORD have been well entered -if [ \( ! -z "$USER" -a -z "$PASSWORD" \) -o \( -z "$USER" -a ! -z "$PASSWORD" \) ]; then - echo ERROR: "$variables_PA_JOB_NAME"_USER and "$variables_PA_JOB_NAME"_PASSWORD are used in junction. They should be either both entered or both blank. - exit 1 -fi -################################################################################ - -# Manually find a free random port to preserve it in case if docker (re)start (Pause/Resume) -GET_RANDOM_PORT(){ - read LOWERPORT UPPERPORT < /proc/sys/net/ipv4/ip_local_port_range - while : - do - RND_PORT="`shuf -i $LOWERPORT-$UPPERPORT -n 1`" - ss -lpn | grep -q ":$RND_PORT " || break - done - echo $RND_PORT -} - -echo "Pulling "$variables_PA_JOB_NAME" image" -sudo docker pull "$DOCKER_IMAGE" - -sudo docker volume create "$VOLUME" - -################################################################################ -### THIS PART IS IMAGE SPECIFIC. IF YOU NEED TO MODIFY SOMETHING, DO IT HERE ### -DB_PORT=$(GET_RANDOM_PORT) -echo "Running $INSTANCE_NAME container" -if [ "$DATABASE" == null ] && [ "$USER" == null ]; then - sudo docker run --name "$INSTANCE_NAME" -p $DB_PORT:$PORT -e MYSQL_ROOT_PASSWORD="$ROOT_PASSWORD" -v "$VOLUME":/var/lib/mysql -d "$DOCKER_IMAGE" -elif [ "$DATABASE" == null ] && [ "$USER" != null ]; then - sudo docker run --name "$INSTANCE_NAME" -p $DB_PORT:$PORT -e MYSQL_ROOT_PASSWORD="$ROOT_PASSWORD" -e MYSQL_USER="$USER" -e MYSQL_PASSWORD="$PASSWORD" -v "$VOLUME":/var/lib/mysql -d "$DOCKER_IMAGE" -elif [ "$DATABASE" != null ] && [ "$USER" == null ]; then - sudo docker run --name "$INSTANCE_NAME" -p $DB_PORT:$PORT -e MYSQL_ROOT_PASSWORD="$ROOT_PASSWORD" -e MYSQL_DATABASE="$DATABASE" -v "$VOLUME":/var/lib/mysql -d "$DOCKER_IMAGE" -else - sudo docker run --name "$INSTANCE_NAME" -p $DB_PORT:$PORT -e MYSQL_ROOT_PASSWORD="$ROOT_PASSWORD" -e MYSQL_USER="$USER" -e MYSQL_PASSWORD="$PASSWORD" -e MYSQL_DATABASE="$DATABASE" -v "$VOLUME":/var/lib/mysql -d "$DOCKER_IMAGE" -fi -################################################################################ - -if [ "$(sudo docker ps --format '{{.Names}}' | grep "^$INSTANCE_NAME$")" ]; then - RUNNING=$(sudo docker inspect --format="{{ .State.Running }}" "$INSTANCE_NAME" 2> /dev/null) - if [ "$RUNNING" == "true" ]; then - echo $INSTANCE_NAME started successfully. - IP_ADDR=$( curl api.ipify.org ) - echo "$IP_ADDR" > $INSTANCE_NAME"_dbipaddr" - echo "$DB_PORT" > $INSTANCE_NAME"_dbport" - echo "MySQL adress is http://$IP_ADDR:$DB_PORT" - - fi -else - echo ERROR: $INSTANCE_NAME could not be started properly. - exit 1 -fi \ No newline at end of file diff --git a/src/main/resources/Start_Wordpress_Script.sh b/src/main/resources/Start_Wordpress_Script.sh deleted file mode 100644 index 5b3fe307..00000000 --- a/src/main/resources/Start_Wordpress_Script.sh +++ /dev/null @@ -1,54 +0,0 @@ -echo BEGIN "$variables_PA_TASK_NAME" - -INSTANCE_NAME="$variables_INSTANCE_NAME" - -################################################################################ -### THIS PART IS IMAGE SPECIFIC. IF YOU NEED TO MODIFY SOMETHING, DO IT HERE ### -DOCKER_IMAGE=wordpress -PORT=80 -ROOT_PASSWORD="root" -DB_IPADDR="$variables_DB_IPADDR" -DB_PORT="$variables_DB_PORT" -DB_USER="$variables_DB_USER" -DB_PASSWORD="$variables_DB_PASSWORD" -DB_NAME="$variables_DB_NAME" -#DB_NET="$variables_DB_NET" -# Check whether USER and PASSWORD have been well entered -if [ \( ! -z "$DB_USER" -a -z "$DB_PASSWORD" \) -o \( -z "$DB_USER" -a ! -z "$DB_PASSWORD" \) ]; then - echo ERROR: "$variables_PA_JOB_NAME"_USER and "$variables_PA_JOB_NAME"_PASSWORD are used in junction. They should be either both entered or both blank. - exit 1 -fi -################################################################################ - -# Manually find a free random port to preserve it in case if docker (re)start (Pause/Resume) -GET_RANDOM_PORT(){ - read LOWERPORT UPPERPORT < /proc/sys/net/ipv4/ip_local_port_range - while : - do - RND_PORT="`shuf -i $LOWERPORT-$UPPERPORT -n 1`" - ss -lpn | grep -q ":$RND_PORT " || break - done - echo $RND_PORT -} - -echo "Pulling "$variables_PA_JOB_NAME" image" -sudo docker pull "$DOCKER_IMAGE" - -################################################################################ -### THIS PART IS IMAGE SPECIFIC. IF YOU NEED TO MODIFY SOMETHING, DO IT HERE ### -WP_PORT=$(GET_RANDOM_PORT) -echo "Running $INSTANCE_NAME container" -sudo docker run --name "$INSTANCE_NAME" -p $WP_PORT:$PORT -e WORDPRESS_DB_HOST=$DB_IPADDR:$DB_PORT -e WORDPRESS_DB_USER=$DB_USER -e WORDPRESS_DB_PASSWORD=$DB_PASSWORD -e WORDPRESS_DB_NAME=$DB_NAME -d $DOCKER_IMAGE -################################################################################ - -if [ "$(sudo docker ps --format '{{.Names}}' | grep "^$INSTANCE_NAME$")" ]; then - RUNNING=$(sudo docker inspect --format="{{ .State.Running }}" $INSTANCE_NAME 2> /dev/null) - if [ "$RUNNING" == "true" ]; then - echo $INSTANCE_NAME started successfully on port: $WP_PORT - IP_ADDR=$( curl api.ipify.org ) - echo "To access it go to http://$IP_ADDR:$WP_PORT" - fi -else - echo ERROR: $INSTANCE_NAME could not be started properly. - exit 1 -fi \ No newline at end of file diff --git a/src/main/resources/check_node_name.groovy b/src/main/resources/check_node_name.groovy deleted file mode 100644 index 310d5993..00000000 --- a/src/main/resources/check_node_name.groovy +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Script which checks the current node name - * - * Arguments: - * node name - */ - -import com.google.common.base.Strings; - -if (args.length != 1) { - println "Incorrect number of arguments, expected 1, received " + args.length; - selected = false; - return; -} - -providedNodeName = args[0] - -if (Strings.isNullOrEmpty(providedNodeName)) { - println "Given node name was empty"; - selected = false; - return; -} - -providedNodeName = providedNodeName.trim() - -println "Node name " + nodename + " (expected : " + providedNodeName + ")"; - -selected = (providedNodeName == nodename) \ No newline at end of file diff --git a/src/main/resources/check_node_source.groovy b/src/main/resources/check_node_source.groovy deleted file mode 100644 index b6797a14..00000000 --- a/src/main/resources/check_node_source.groovy +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Script which verifies that the current node runs in the specified node source - * - * Arguments: - * node source name - */ - -import com.google.common.base.Strings; - -if (args.length != 1) { - println "Incorrect number of arguments, expected 1, received " + args.length; - selected = false; - return; -} - -nodeSourceName = args[0] - -if (Strings.isNullOrEmpty(nodeSourceName)) { - println "Given node source name was empty"; - selected = false; - return; -} -nodeSourceName = nodeSourceName.trim() - -vmPropValue = System.getProperty("proactive.node.nodesource"); - -if (vmPropValue == null) { - // if the node source property is not defined, set it as "Default" - vmPropValue = "Default"; -} - -println "Value of property " + "proactive.node.nodesource" + ": " + vmPropValue + " (expected : " + nodeSourceName + ")"; - -selected = (nodeSourceName == vmPropValue) \ No newline at end of file diff --git a/src/main/resources/pre_script.sh b/src/main/resources/pre_script.sh deleted file mode 100644 index 06596050..00000000 --- a/src/main/resources/pre_script.sh +++ /dev/null @@ -1,9 +0,0 @@ -echo "Preparing repositories ..." -sudo apt update -sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -sudo apt update -echo "Intalling Docker ..." -sudo apt-get -y install docker-ce -echo "Docker installed." \ No newline at end of file diff --git a/src/main/resources/proactive.properties b/src/main/resources/proactive.properties deleted file mode 100644 index fe380bf1..00000000 --- a/src/main/resources/proactive.properties +++ /dev/null @@ -1,26 +0,0 @@ -# ProActive config -pa.rest.url=http://trydev.activeeon.com:8080/rest -pa.rest.login=NyA2k07sUHh3i/uRgpzJftaNgr1yFsmna9PCNGSuansTYxEjWaExFLdB5j55AzKI -pa.rest.password=nJSsku6RIf3lhUkWnGUEGPAK3dOb6gTInbf0jl+up8uFhjMYpZw8R5XTFxledwZK - - -# Scheduler config -pa.scheduler.rest.url=${pa.rest.url}/scheduler -pa.scheduler.rest.login.path=/login -pa.scheduler.rest.submit.path=/submit -pa.scheduler.rest.kill.path=/jobs/{jobId}/kill -pa.scheduler.rest.userdata.path=/logins/sessionid/{sessionId}/userdata -pa.scheduler.rest.http.multipartform.xmlfile.key=file -pa.scheduler.rest.http.multipartform.credentials.key=credential -pa.scheduler.rest.http.header.sessionid.key=sessionid - -# Resource Manager config -pa.rm.rest.url=${pa.rest.url}/rm -pa.rm.rest.monitoring.full.path=/monitoring/full -pa.rm.rest.login.path=/login -pa.rm.rest.nodesource.path=/nodesource -pa.rm.rest.node.token.path=/node/token -pa.rm.auth.cred.path=${pa.rm.home}/config/authentication/rm.cred - - -server.port=8080 -- GitLab