Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Melodic
melodic-upperware
Commits
01d02830
Commit
01d02830
authored
Mar 23, 2022
by
mriedl
Browse files
Merge branch 'morphemic-rc2.0' into morphemic-rc2.5
# Conflicts: # .gitlab-ci.yml # gui-backend/pom.xml
parents
3fc7c341
86de4d34
Pipeline
#20949
passed with stages
in 69 minutes and 9 seconds
Changes
360
Pipelines
3
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
01d02830
...
...
@@ -2,7 +2,7 @@ variables:
DOCKER_PUSH
:
"
false"
LOCAL_REPO
:
"
127.0.0.1:5000"
DOCKER_REPO
:
"
gitlab.ow2.org:4567"
MAVEN_IMAGE
:
"
maven:3.
5.2
-jdk-8"
MAVEN_IMAGE
:
"
maven:3.
6.3
-jdk-8"
DOCKER_DIND_IMAGE
:
"
docker:19.03.1"
DOCKER_DIND_SERVICE
:
"
$DOCKER_DIND_IMAGE-dind"
DOCKER_DRIVER
:
overlay
...
...
@@ -34,21 +34,14 @@ variables:
MCTS_SOLVER_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
zpp-solver/mcts-solver/pom.xml"
EMS_CLI
:
"
mvn
--batch-mode
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/pom.xml"
#
EMS_UTIL_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/util/pom.xml"
#
EMS_BROKER_CLIENT_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/broker-client/pom.xml"
#
EMS_BROKER_CEP_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/broker-cep/pom.xml"
#
EMS_BAGUETTE_CLIENT_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/baguette-client/pom.xml"
#
EMS_BAGUETTE_CLIENT_INSTALL_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/baguette-client-install/pom.xml"
#
EMS_BAGUETTE_SERVER_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/baguette-server/pom.xml"
#
EMS_TRANSLATOR_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/translator/pom.xml"
EMS_SERVER_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
event-management/control-service/pom.xml"
#EMS_UTIL_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/util/pom.xml"
#EMS_BROKER_CLIENT_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/broker-client/pom.xml"
#EMS_BROKER_CEP_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/broker-cep/pom.xml"
#EMS_BAGUETTE_CLIENT_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/baguette-client/pom.xml"
#EMS_BAGUETTE_CLIENT_INSTALL_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/baguette-client-install/pom.xml"
#EMS_BAGUETTE_SERVER_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/baguette-server/pom.xml"
#EMS_TRANSLATOR_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/translator/pom.xml"
#EMS_SERVER_CLI: "mvn --batch-mode -N -Dmaven.test.skip=$SKIP_TESTS -Ddocker.push=false -f event-management/control-service/pom.xml"
METASOLVER_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
meta_solver/pom.xml"
MQ_ADAPTER_CLI
:
"
mvn
--batch-mode
-N
-Dmaven.test.skip=$SKIP_TESTS
-Ddocker.push=false
-f
mq-http-adapter/pom.xml"
...
...
@@ -469,22 +462,6 @@ deploy:cp-solver:
-
docker push $CI_REGISTRY_IMAGE/cpsolver:$CI_COMMIT_BRANCH
-
$DOCKER_CLI $CP_SOLVER_CLI deploy
deploy:ems:
stage
:
deploy
only
:
-
master
-
rc3.0
-
rc3.1
-
morphemic-rc2.5
image
:
$DOCKER_DIND_IMAGE
services
:
-
$DOCKER_DIND_SERVICE
dependencies
:
-
build-required-part3:ems
script
:
-
$DOCKER_CLI $EMS_CLI deploy
deploy:ems-server:
stage
:
deploy
only
:
...
...
@@ -494,6 +471,8 @@ deploy:ems-server:
-
morphemic-rc2.5
-
proactive-dev
image
:
$DOCKER_DIND_IMAGE
dependencies
:
-
build-required-part3:ems
services
:
-
$DOCKER_DIND_SERVICE
script
:
...
...
@@ -544,16 +523,31 @@ deploy:gui-backend:
-
rc3.1
-
morphemic-rc2.5
-
proactive-dev
-
undeploy_application
image
:
$DOCKER_DIND_IMAGE
services
:
-
$DOCKER_DIND_SERVICE
script
:
-
$DOCKER_CLI $GUI_BACKEND_CLI -Ddocker.imagePrefix=melodic/ clean install
-
$DOCKER_CLI $GUI_BACKEND_CLI -Ddocker.imagePrefix=melodic/ clean install
-U
-
echo "$K8S_SECRET_DOCKER_PASSWORD" | docker login $CI_REGISTRY -u $K8S_SECRET_DOCKER_USER --password-stdin
-
docker tag $LOCAL_REPO/melodic/gui-backend:unknown $CI_REGISTRY_IMAGE/gui-backend:$CI_COMMIT_BRANCH
-
docker push $CI_REGISTRY_IMAGE/gui-backend:$CI_COMMIT_BRANCH
#deploy:functionizer-testing-tool:
# stage: deploy
# only:
# - master
# - rc3.0
# - rc3.1
# - morphemic-rc1.5
# image: $DOCKER_DIND_IMAGE
# services:
# - $DOCKER_DIND_SERVICE
# script:
# - $DOCKER_CLI $FUNCTIONIZER_TESTING_TOOL_CLI -Ddocker.imagePrefix=melodic/ clean install
# - echo "$K8S_SECRET_DOCKER_PASSWORD" | docker login $CI_REGISTRY -u $K8S_SECRET_DOCKER_USER --password-stdin
# - docker tag $LOCAL_REPO/melodic/functionizer-testing-tool:unknown $CI_REGISTRY_IMAGE/functionizer-testing-tool:$CI_COMMIT_BRANCH
# - docker push $CI_REGISTRY_IMAGE/functionizer-testing-tool:$CI_COMMIT_BRANCH
deploy:cp-parser:
stage
:
deploy
only
:
...
...
adapter/pom.xml
View file @
01d02830
...
...
@@ -194,6 +194,10 @@
<groupId>
io.github.cloudiator.client
</groupId>
<artifactId>
java-rest
</artifactId>
</dependency>
<dependency>
<groupId>
io.github.cloudiator.client
</groupId>
<artifactId>
java-rest
</artifactId>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}
</finalName>
...
...
adapter/src/main/java/eu/melodic/upperware/adapter/planexecutor/colosseum/NodeTaskExecutor.java
View file @
01d02830
...
...
@@ -59,11 +59,16 @@ public class NodeTaskExecutor extends RunnableTaskExecutor<AdapterRequirement> {
nodeJSON
.
put
(
"taskName"
,
taskBody
.
getTaskName
());
nodeJSON
.
put
(
"nodeName"
,
taskBody
.
getNodeName
());
JSONObject
nodeCandidateInformationJSON
=
new
JSONObject
();
if
(
taskBody
.
getNodeCandidate
().
getCloud
().
getApi
().
getProviderName
().
equals
(
"openstack"
)){
nodeCandidateInformationJSON
.
put
(
"hardwareProviderId"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getHardware
().
getProviderId
().
substring
(
4
),
"hardwareProviderId"
));
}
else
{
nodeCandidateInformationJSON
.
put
(
"hardwareProviderId"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getHardware
().
getProviderId
(),
"hardwareProviderId"
));
}
nodeCandidateInformationJSON
.
put
(
"hardwareProviderId"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getHardware
().
getProviderId
(),
"hardwareProviderId"
));
nodeCandidateInformationJSON
.
put
(
"ID"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getId
(),
"ID"
));
nodeCandidateInformationJSON
.
put
(
"cloudID"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getCloud
().
getId
(),
"cloudID"
));
nodeCandidateInformationJSON
.
put
(
"locationName"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getLocation
().
getName
(),
"locationName"
));
nodeCandidateInformationJSON
.
put
(
"imageProviderId"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getImage
().
getProviderId
(),
"imageProviderId"
));
nodeCandidateInformationJSON
.
put
(
"hardwareProviderId"
,
checkEmptiness
(
taskBody
.
getNodeCandidate
().
getHardware
().
getProviderId
(),
"hardwareProviderId"
));
nodeJSON
.
put
(
"nodeCandidateInformation"
,
nodeCandidateInformationJSON
);
nodesJSONArray
.
put
(
nodeJSON
);
log
.
info
(
"NodeTaskExecutor->addIAASNode: [application id: {}] ProActive node(s) (JSONArray): \n{}"
,
applicationId
,
nodesJSONArray
);
...
...
event-management/README-for-TESTING.md
0 → 100644
View file @
01d02830
This diff is collapsed.
Click to expand it.
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/ClientInstallationProperties.java
View file @
01d02830
...
...
@@ -10,6 +10,7 @@
package
eu.melodic.event.baguette.client.install
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -18,6 +19,7 @@ import org.springframework.context.annotation.PropertySource;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Pattern
;
@Data
@Configuration
...
...
@@ -35,6 +37,7 @@ public class ClientInstallationProperties {
private
String
checkInstalledFile
;
private
String
downloadUrl
;
@ToString
.
Exclude
private
String
apiKey
;
private
String
installScriptUrl
;
private
String
installScriptFile
;
...
...
@@ -66,7 +69,24 @@ public class ClientInstallationProperties {
private
long
commandExecutionTimeout
=
60000
;
private
final
Map
<
String
,
List
<
String
>>
instructions
=
new
HashMap
<>();
private
final
Map
<
String
,
String
>
parameters
=
new
HashMap
<>();
private
boolean
continueOnFail
=
false
;
private
String
sessionRecordingDir
=
"logs"
;
// ----------------------------------------------------
private
String
clientInstallVarName
=
"__EMS_CLIENT_INSTALL__"
;
private
Pattern
clientInstallSuccessPattern
=
Pattern
.
compile
(
"^INSTALLED($|[\\s:=])"
,
Pattern
.
CASE_INSENSITIVE
);
private
Pattern
clientInstallErrorPattern
=
Pattern
.
compile
(
"^ERROR($|[\\s:=])"
,
Pattern
.
CASE_INSENSITIVE
);
private
boolean
clientInstallSuccessIfVarIsMissing
=
false
;
private
boolean
clientInstallErrorIfVarIsMissing
=
true
;
private
String
skipInstallVarName
=
"__EMS_CLIENT_INSTALL__"
;
private
Pattern
skipInstallPattern
=
Pattern
.
compile
(
"^SKIPPED($|[\\s:=])"
,
Pattern
.
CASE_INSENSITIVE
);
private
boolean
skipInstallIfVarIsMissing
=
false
;
private
String
ignoreNodeVarName
=
"__EMS_IGNORE_NODE__"
;
private
Pattern
ignoreNodePattern
=
Pattern
.
compile
(
"^IGNORED($|[\\s:=])"
,
Pattern
.
CASE_INSENSITIVE
);
private
boolean
ignoreNodeIfVarIsMissing
=
false
;
}
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/ClientInstallationTask.java
View file @
01d02830
...
...
@@ -9,7 +9,8 @@
package
eu.melodic.event.baguette.client.install
;
import
eu.melodic.event.baguette.client.install.instruction.InstallationInstructions
;
import
eu.melodic.event.baguette.client.install.instruction.InstructionsSet
;
import
eu.melodic.event.baguette.server.NodeRegistryEntry
;
import
lombok.Builder
;
import
lombok.Data
;
...
...
@@ -29,5 +30,6 @@ public class ClientInstallationTask {
private
final
String
type
;
private
final
String
provider
;
private
final
SshConfig
ssh
;
private
final
List
<
InstallationInstructions
>
installationInstructions
;
private
final
NodeRegistryEntry
nodeRegistryEntry
;
private
final
List
<
InstructionsSet
>
instructionSets
;
}
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/ClientInstaller.java
View file @
01d02830
...
...
@@ -9,6 +9,8 @@
package
eu.melodic.event.baguette.client.install
;
import
eu.melodic.event.baguette.server.BaguetteServer
;
import
eu.melodic.event.baguette.server.NodeRegistryEntry
;
import
lombok.NoArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.InitializingBean
;
...
...
@@ -31,6 +33,8 @@ public class ClientInstaller implements InitializingBean {
@Autowired
private
ClientInstallationProperties
properties
;
@Autowired
private
BaguetteServer
baguetteServer
;
private
final
AtomicLong
taskCounter
=
new
AtomicLong
();
private
ExecutorService
executorService
;
...
...
@@ -57,8 +61,28 @@ public class ClientInstaller implements InitializingBean {
}
private
boolean
executeTask
(
ClientInstallationTask
task
,
long
taskCounter
)
{
if
(
baguetteServer
.
getNodeRegistry
().
getCoordinator
()==
null
)
throw
new
IllegalStateException
(
"Baguette Server Coordinator has not yet been initialized"
);
if
(
"VM"
.
equalsIgnoreCase
(
task
.
getType
()))
{
return
executeVmTask
(
task
,
taskCounter
);
NodeRegistryEntry
entry
=
baguetteServer
.
getNodeRegistry
().
getNodeByAddress
(
task
.
getAddress
());
if
(
entry
==
null
)
throw
new
IllegalStateException
(
"Node entry has been removed from Node Registry before installation: Node IP address: "
+
task
.
getAddress
());
//baguetteServer.handleNodeSituation(task.getAddress(), INTERNAL_ERROR);
entry
.
nodeInstalling
(
task
);
boolean
success
=
executeVmTask
(
task
,
taskCounter
);
log
.
debug
(
"ClientInstaller: NODE_REGISTRY_ENTRY after installation execution: \n{}"
,
task
.
getNodeRegistryEntry
());
if
(
entry
.
getState
()==
NodeRegistryEntry
.
STATE
.
INSTALLING
)
{
log
.
warn
(
"ClientInstaller: NODE_REGISTRY_ENTRY status is still INSTALLING after executing client installation. Changing to INSTALL_ERROR"
);
entry
.
nodeInstallationError
(
null
);
}
// Pre-register Node to baguette Server Coordinator
baguetteServer
.
getNodeRegistry
().
getCoordinator
().
preregister
(
entry
);
return
success
;
}
else
{
log
.
error
(
"ClientInstaller: UNSUPPORTED TASK TYPE: {}"
,
task
.
getType
());
}
...
...
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/ClientInstallerPlugin.java
View file @
01d02830
...
...
@@ -10,5 +10,14 @@
package
eu.melodic.event.baguette.client.install
;
public
interface
ClientInstallerPlugin
{
boolean
execute
();
default
boolean
execute
()
{
preProcessTask
();
boolean
result
=
executeTask
();
result
=
result
&&
postProcessTask
();
return
result
;
}
void
preProcessTask
();
// Throw exception to block task execution
boolean
executeTask
();
boolean
postProcessTask
();
}
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/SshClientInstaller.java
View file @
01d02830
This diff is collapsed.
Click to expand it.
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/helper/AbstractInstallationHelper.java
View file @
01d02830
...
...
@@ -9,11 +9,13 @@
package
eu.melodic.event.baguette.client.install.helper
;
import
com.google.gson.Gson
;
import
eu.melodic.event.baguette.client.install.ClientInstallationProperties
;
import
eu.melodic.event.baguette.client.install.instruction.
Installation
Instructions
;
import
eu.melodic.event.baguette.server.
BaguetteServer
;
import
eu.melodic.event.baguette.client.install.instruction.Instructions
Set
;
import
eu.melodic.event.baguette.server.
NodeRegistryEntry
;
import
eu.melodic.event.util.KeystoreUtil
;
import
eu.melodic.event.util.NetUtil
;
import
eu.melodic.event.util.PasswordUtil
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -53,16 +55,20 @@ public abstract class AbstractInstallationHelper implements InitializingBean, Ap
@Autowired
@Getter
@Setter
protected
ClientInstallationProperties
properties
;
@Autowired
protected
PasswordUtil
passwordUtil
;
protected
String
archiveBase64
;
protected
boolean
isServerSecure
;
protected
String
serverCert
;
public
synchronized
static
AbstractInstallationHelper
getInstance
()
{
return
instance
;
}
public
synchronized
static
AbstractInstallationHelper
getInstance
()
{
return
instance
;
}
@Override
public
void
afterPropertiesSet
()
{
log
.
info
(
"AbstractInstallationHelper.afterPropertiesSet(): configuration: {}"
,
properties
);
log
.
debug
(
"AbstractInstallationHelper.afterPropertiesSet():
class={}:
configuration: {}"
,
getClass
().
getName
(),
properties
);
AbstractInstallationHelper
.
instance
=
this
;
LINUX_OS_FAMILIES
=
properties
.
getOsFamilies
().
get
(
"LINUX"
);
WINDOWS_OS_FAMILIES
=
properties
.
getOsFamilies
().
get
(
"WINDOWS"
);
...
...
@@ -109,6 +115,7 @@ public abstract class AbstractInstallationHelper implements InitializingBean, Ap
log
.
debug
(
"AbstractInstallationHelper.initServerCertificate(): Exporting server certificate to file: {}"
,
certFileName
);
KeystoreUtil
.
getKeystore
(
keystoreFile
,
keystoreType
,
keystorePassword
)
.
passwordUtil
(
passwordUtil
)
.
exportCertToFile
(
keyAlias
,
certFileName
);
log
.
debug
(
"AbstractInstallationHelper.initServerCertificate(): Server certificate exported"
);
...
...
@@ -119,6 +126,7 @@ public abstract class AbstractInstallationHelper implements InitializingBean, Ap
}
else
{
this
.
serverCert
=
KeystoreUtil
.
getKeystore
(
keystoreFile
,
keystoreType
,
keystorePassword
)
.
passwordUtil
(
passwordUtil
)
.
getEntryCertificateAsPEM
(
keyAlias
);
}
...
...
@@ -189,27 +197,43 @@ public abstract class AbstractInstallationHelper implements InitializingBean, Ap
}
}
public
List
<
InstallationInstructions
>
prepareInstallationInstructionsForOs
(
Map
<
String
,
Object
>
nodeMap
,
Map
<
String
,
String
>
contextMap
,
BaguetteServer
baguette
)
throws
IOException
{
if
(!
baguette
.
isServerRunning
())
throw
new
RuntimeException
(
"Baguette Server is not running"
);
public
Optional
<
List
<
String
>>
getInstallationInstructionsForOs
(
NodeRegistryEntry
entry
)
throws
IOException
{
if
(!
entry
.
getBaguetteServer
().
isServerRunning
())
throw
new
RuntimeException
(
"Baguette Server is not running"
);
List
<
InstructionsSet
>
instructionsSets
=
prepareInstallationInstructionsForOs
(
entry
);
if
(
instructionsSets
==
null
)
{
String
nodeOs
=
entry
.
getPreregistration
().
get
(
"operatingSystem"
);
log
.
warn
(
"AbstractInstallationHelper.getInstallationInstructionsForOs(): ERROR: Unknown node OS: {}: node-map={}"
,
nodeOs
,
entry
.
getPreregistration
());
return
Optional
.
empty
();
}
List
<
String
>
jsonSets
=
null
;
if
(
instructionsSets
.
size
()>
0
)
{
// Convert 'instructionsSet' into json string
Gson
gson
=
new
Gson
();
jsonSets
=
instructionsSets
.
stream
().
map
(
instructionsSet
->
gson
.
toJson
(
instructionsSet
,
InstructionsSet
.
class
)).
collect
(
Collectors
.
toList
());
}
log
.
trace
(
"AbstractInstallationHelper.getInstallationInstructionsForOs(): JSON instruction sets for node: node-map={}\n{}"
,
entry
.
getPreregistration
(),
jsonSets
);
return
Optional
.
ofNullable
(
jsonSets
);
}
String
baseUrl
=
contextMap
.
get
(
"BASE_URL"
);
String
clientId
=
contextMap
.
get
(
"CLIENT_ID"
);
String
ipSetting
=
contextMap
.
get
(
"IP_SETTING"
);
log
.
trace
(
"AbstractInstallationHelper.prepareInstallationInstructionsForOs(): node-map={}, base-url={}, client-id={}"
,
nodeMap
,
baseUrl
,
clientId
);
public
List
<
InstructionsSet
>
prepareInstallationInstructionsForOs
(
NodeRegistryEntry
entry
)
throws
IOException
{
if
(!
entry
.
getBaguetteServer
().
isServerRunning
())
throw
new
RuntimeException
(
"Baguette Server is not running"
);
log
.
trace
(
"AbstractInstallationHelper.prepareInstallationInstructionsForOs(): node-map={}"
,
entry
.
getPreregistration
());
String
osFamily
=
(
String
)
nodeMap
.
get
(
"operatingSystem"
);
List
<
Installation
Instructions
>
inst
allationInst
ructionsList
=
null
;
String
osFamily
=
entry
.
getPreregistration
()
.
get
(
"operatingSystem"
);
List
<
Instructions
Set
>
instructions
Set
List
=
null
;
if
(
LINUX_OS_FAMILIES
.
contains
(
osFamily
.
toUpperCase
()))
inst
allationInst
ructionsList
=
prepareInstallationInstructionsForLinux
(
nodeMap
,
contextMap
,
baguette
);
instructions
Set
List
=
prepareInstallationInstructionsForLinux
(
entry
);
else
if
(
WINDOWS_OS_FAMILIES
.
contains
(
osFamily
.
toUpperCase
()))
inst
allationInst
ructionsList
=
prepareInstallationInstructionsForWin
(
nodeMap
,
contextMap
,
baguette
);
instructions
Set
List
=
prepareInstallationInstructionsForWin
(
entry
);
else
log
.
warn
(
"AbstractInstallationHelper.prepareInstallationInstructionsForOs(): Unsupported OS family: {}"
,
osFamily
);
return
inst
allationInst
ructionsList
;
return
instructions
Set
List
;
}
protected
Installation
Instructions
_appendCopyInstructions
(
Inst
allationInstructions
installationI
nstructions
,
protected
Instructions
Set
_appendCopyInstructions
(
Inst
ructionsSet
i
nstructions
Set
,
Path
p
,
Path
startDir
,
String
copyToClientDir
,
...
...
@@ -223,13 +247,13 @@ public abstract class AbstractInstallationHelper implements InitializingBean, Ap
String
contents
=
new
String
(
Files
.
readAllBytes
(
p
));
contents
=
StringSubstitutor
.
replace
(
contents
,
valueMap
);
String
tmpFile
=
clientTmpDir
+
"/installEMS_"
+
System
.
currentTimeMillis
();
inst
allationInst
ructions
instructions
Set
.
appendLog
(
String
.
format
(
"Copy file from server to temp to client: %s -> %s -> %s"
,
p
.
toString
(),
tmpFile
,
targetFile
));
return
_appendCopyInstructions
(
inst
allationInst
ructions
,
targetFile
,
tmpFile
,
contents
,
clientTmpDir
);
return
_appendCopyInstructions
(
instructions
Set
,
targetFile
,
tmpFile
,
contents
,
clientTmpDir
);
}
protected
Installation
Instructions
_appendCopyInstructions
(
Inst
allationInstructions
installationI
nstructions
,
protected
Instructions
Set
_appendCopyInstructions
(
Inst
ructionsSet
i
nstructions
Set
,
String
targetFile
,
String
tmpFile
,
String
contents
,
...
...
@@ -238,16 +262,16 @@ public abstract class AbstractInstallationHelper implements InitializingBean, Ap
{
if
(
StringUtils
.
isEmpty
(
tmpFile
))
tmpFile
=
clientTmpDir
+
"/installEMS_"
+
System
.
currentTimeMillis
();
inst
allationInst
ructions
instructions
Set
.
appendWriteFile
(
tmpFile
,
contents
,
false
)
.
appendExec
(
"sudo mv "
+
tmpFile
+
" "
+
targetFile
)
.
appendExec
(
"sudo chmod u+rw,og-rwx "
+
targetFile
);
return
inst
allationInst
ructions
;
return
instructions
Set
;
}
protected
String
_prepareUrl
(
String
urlTemplate
,
String
baseUrl
)
{
return
urlTemplate
.
replace
(
"%{BASE_URL}%"
,
baseUrl
)
.
replace
(
"%{BASE_URL}%"
,
Optional
.
ofNullable
(
baseUrl
).
orElse
(
""
)
)
.
replace
(
"%{PUBLIC_IP}%"
,
Optional
.
ofNullable
(
NetUtil
.
getPublicIpAddress
()).
orElse
(
""
))
.
replace
(
"%{DEFAULT_IP}%"
,
Optional
.
ofNullable
(
NetUtil
.
getDefaultIpAddress
()).
orElse
(
""
));
}
...
...
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/helper/InstallationHelper.java
View file @
01d02830
...
...
@@ -10,17 +10,19 @@
package
eu.melodic.event.baguette.client.install.helper
;
import
eu.melodic.event.baguette.client.install.ClientInstallationTask
;
import
eu.melodic.event.baguette.client.install.instruction.
Installation
Instructions
;
import
eu.melodic.event.baguette.server.
BaguetteServer
;
import
eu.melodic.event.baguette.client.install.instruction.Instructions
Set
;
import
eu.melodic.event.baguette.server.
NodeRegistryEntry
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.
Map
;
import
java.util.
Optional
;
public
interface
InstallationHelper
{
List
<
InstallationInstructions
>
prepareInstallationInstructionsForOs
(
Map
<
String
,
Object
>
nodeMap
,
Map
<
String
,
String
>
contextMap
,
BaguetteServer
baguette
)
throws
IOException
;
List
<
InstallationInstructions
>
prepareInstallationInstructionsForWin
(
Map
<
String
,
Object
>
nodeMap
,
Map
<
String
,
String
>
contextMap
,
BaguetteServer
baguette
);
List
<
InstallationInstructions
>
prepareInstallationInstructionsForLinux
(
Map
<
String
,
Object
>
nodeMap
,
Map
<
String
,
String
>
contextMap
,
BaguetteServer
baguette
)
throws
IOException
;
Optional
<
List
<
String
>>
getInstallationInstructionsForOs
(
NodeRegistryEntry
entry
)
throws
IOException
;
ClientInstallationTask
createClientInstallationTask
(
Map
<
String
,
Object
>
nodeMap
,
Map
<
String
,
String
>
contextMap
,
BaguetteServer
baguette
)
throws
Exception
;
List
<
InstructionsSet
>
prepareInstallationInstructionsForOs
(
NodeRegistryEntry
entry
)
throws
IOException
;
List
<
InstructionsSet
>
prepareInstallationInstructionsForWin
(
NodeRegistryEntry
entry
);
List
<
InstructionsSet
>
prepareInstallationInstructionsForLinux
(
NodeRegistryEntry
entry
)
throws
IOException
;
ClientInstallationTask
createClientInstallationTask
(
NodeRegistryEntry
entry
)
throws
Exception
;
}
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/helper/InstallationHelperFactory.java
View file @
01d02830
...
...
@@ -9,6 +9,7 @@
package
eu.melodic.event.baguette.client.install.helper
;
import
eu.melodic.event.baguette.server.NodeRegistryEntry
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -36,15 +37,15 @@ public class InstallationHelperFactory implements InitializingBean {
InstallationHelperFactory
.
instance
=
this
;
}
public
InstallationHelper
createInstallationHelper
(
Map
<
String
,
Object
>
nodeMap
)
{
String
nodeType
=
(
String
)
nodeMap
.
get
(
"type"
);
public
InstallationHelper
createInstallationHelper
(
NodeRegistryEntry
entry
)
{
String
nodeType
=
entry
.
getPreregistration
()
.
get
(
"type"
);
if
(
"VM"
.
equalsIgnoreCase
(
nodeType
))
{
return
createVmInstallationHelper
(
nodeMap
);
return
createVmInstallationHelper
(
entry
);
}
throw
new
IllegalArgumentException
(
"Unsupported or missing Node type: "
+
nodeType
);
}
public
InstallationHelper
createInstallationHelperBean
(
String
className
,
Map
<
String
,
Object
>
nodeMap
)
throws
ClassNotFoundException
{
public
InstallationHelper
createInstallationHelperBean
(
String
className
,
NodeRegistryEntry
entry
)
throws
ClassNotFoundException
{
Class
<?>
clzz
=
Class
.
forName
(
className
);
return
(
InstallationHelper
)
applicationContext
.
getBean
(
clzz
);
}
...
...
@@ -56,7 +57,7 @@ public class InstallationHelperFactory implements InitializingBean {
return
(
InstallationHelper
)
clzz
.
getDeclaredMethod
(
"getInstance"
).
invoke
(
null
);
}
private
InstallationHelper
createVmInstallationHelper
(
Map
<
String
,
Object
>
nodeMap
)
{
private
InstallationHelper
createVmInstallationHelper
(
NodeRegistryEntry
entry
)
{
return
VmInstallationHelper
.
getInstance
();
}
}
event-management/baguette-client-install/src/main/java/eu/melodic/event/baguette/client/install/helper/VmInstallationHelper.java
View file @
01d02830
...
...
@@ -11,17 +11,18 @@ package eu.melodic.event.baguette.client.install.helper;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
eu.melodic.event.baguette.client.install.ClientInstallationProperties
;
import
eu.melodic.event.baguette.client.install.ClientInstallationTask
;
import
eu.melodic.event.baguette.client.install.SshConfig
;
import
eu.melodic.event.baguette.client.install.instruction.
Installation
Instructions
;
import
eu.melodic.event.baguette.client.install.instruction.Instructions
Set
;
import
eu.melodic.event.baguette.client.install.instruction.Instruction
;
import
eu.melodic.event.baguette.server.BaguetteServer
;
import
eu.melodic.event.baguette.server.NodeRegistryEntry
;
import
eu.melodic.event.util.CredentialsMap
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.text.StringSubstitutor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.FileCopyUtils
;
...
...
@@ -32,6 +33,7 @@ import java.io.StringWriter;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -41,25 +43,35 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public
class
VmInstallationHelper
extends
AbstractInstallationHelper
{
private
final
static
SimpleDateFormat
tsW3C
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
);
private
final
static
SimpleDateFormat
tsUTC
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS"
);
private
final
static
SimpleDateFormat
tsFile
=
new
SimpleDateFormat
(
"yyyy.MM.dd.HH.mm.ss.SSS"
);
static
{
tsW3C
.
setTimeZone
(
TimeZone
.
getDefault
());
tsUTC
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
tsFile
.
setTimeZone
(
TimeZone
.
getDefault
());
}
@Autowired
private
ResourceLoader
resourceLoader
;
@Autowired
private
Environment
environment
;
private
ClientInstallationProperties
clientInstallationProperties
;
@Override
public
ClientInstallationTask
createClientInstallationTask
(
Map
<
String
,
Object
>
nodeMap
,
Map
<
String
,
String
>
contextMap
,
BaguetteServer
baguette
)
throws
IOException
{
String
baseUrl
=
contextMap
.
get
(
"BASE_URL"
);
String
clientId
=
contextMap
.
get
(
"CLIENT_ID"
);
String
ipSetting
=
contextMap
.
get
(
"IP_SETTING"
);
public
ClientInstallationTask
createClientInstallationTask
(
NodeRegistryEntry
entry
)
throws
IOException
{
Map
<
String
,
String
>
nodeMap
=
entry
.
getPreregistration
();
String
baseUrl
=
nodeMap
.
get
(
"BASE_URL"
);
String
clientId
=
nodeMap
.
get
(
"CLIENT_ID"
);