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
morphemic-preprocessor
Commits
d269d8db
Commit
d269d8db
authored
Oct 18, 2021
by
Ali Fahs
Committed by
Marta Różańska
Oct 18, 2021
Browse files
OpenStack fix
parent
cd1c4c05
Changes
3
Hide whitespace changes
Inline
Side-by-side
scheduling-abstraction-layer/build.gradle
View file @
d269d8db
...
...
@@ -3,7 +3,7 @@ plugins {
}
group
'org.activeeon'
version
'3.
6
-SNAPSHOT'
version
'3.
7
-SNAPSHOT'
sourceCompatibility
=
1.8
...
...
scheduling-abstraction-layer/pom.xml
View file @
d269d8db
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.activeeon
</groupId>
<artifactId>
scheduling-abstraction-layer
</artifactId>
<version>
3.
6
-SNAPSHOT
</version>
<version>
3.
7
-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
org.projectlombok
</groupId>
...
...
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/NodeCandidateUtils.java
View file @
d269d8db
...
...
@@ -10,10 +10,8 @@ import org.json.JSONObject;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
...
...
@@ -257,26 +255,47 @@ public class NodeCandidateUtils {
//TODO: (Optimization) An images per region map structure <region,[image1,image2]> could be the best here.
// It can reduce the getNodeCandidates calls to PA.
List
<
String
>
entries
=
new
LinkedList
<>();
List
<
String
>
openstackOsList
=
Arrays
.
asList
(
"Ubuntu"
,
"Fedora"
,
"Centos"
,
"Debian"
);
consolidatedImages
.
forEach
(
image
->
{
String
region
=
image
.
optString
(
"location"
);
String
imageReq
;
String
os
=
(
String
)
((
JSONObject
)
image
.
get
(
"operatingSystem"
)).
get
(
"family"
);
os
=
os
.
substring
(
0
,
1
).
toUpperCase
()
+
os
.
substring
(
1
);
String
pair
=
os
+
":"
+
region
;
switch
(
paCloud
.
getCloudProviderName
())
{
case
"aws-ec2"
:
imageReq
=
"Linux"
;
break
;
case
"openstack"
:
imageReq
=
"linux"
;
imageReq
=
os
;
break
;
default
:
throw
new
IllegalArgumentException
(
"The infrastructure "
+
paCloud
.
getCloudProviderName
()
+
" is not handled yet."
);
}
JSONArray
nodeCandidates
=
connectorIaasGateway
.
getNodeCandidates
(
paCloud
.
getDummyInfrastructureName
(),
region
,
imageReq
);
nodeCandidates
.
forEach
(
nc
->
{
JSONObject
nodeCandidate
=
(
JSONObject
)
nc
;
EntityManagerHelper
.
persist
(
createLocation
(
nodeCandidate
,
paCloud
));
EntityManagerHelper
.
persist
(
createNodeCandidate
(
nodeCandidate
,
image
,
paCloud
));
});
if
(
paCloud
.
getCloudProviderName
().
equals
(
"openstack"
)){
if
((!
entries
.
contains
(
pair
))
&&
openstackOsList
.
contains
(
os
))
{
entries
.
add
(
pair
);
JSONArray
nodeCandidates
=
connectorIaasGateway
.
getNodeCandidates
(
paCloud
.
getDummyInfrastructureName
(),
region
,
imageReq
);
nodeCandidates
.
forEach
(
nc
->
{
JSONObject
nodeCandidate
=
(
JSONObject
)
nc
;
EntityManagerHelper
.
persist
(
createLocation
(
nodeCandidate
,
paCloud
));
EntityManagerHelper
.
persist
(
createNodeCandidate
(
nodeCandidate
,
image
,
paCloud
));
});
}
}
else
{
JSONArray
nodeCandidates
=
connectorIaasGateway
.
getNodeCandidates
(
paCloud
.
getDummyInfrastructureName
(),
region
,
imageReq
);
nodeCandidates
.
forEach
(
nc
->
{
JSONObject
nodeCandidate
=
(
JSONObject
)
nc
;
EntityManagerHelper
.
persist
(
createLocation
(
nodeCandidate
,
paCloud
));
EntityManagerHelper
.
persist
(
createNodeCandidate
(
nodeCandidate
,
image
,
paCloud
));
});
}
});
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment