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
bbfabae4
Commit
bbfabae4
authored
Aug 12, 2021
by
Mohamed Khalil Labidi
Browse files
Filter hardware types according to jclouds supported ones
parent
d3c1ddb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java
View file @
bbfabae4
...
...
@@ -168,8 +168,15 @@ public class PAGateway {
* @return the list of all available hardware
*/
public
List
<
Hardware
>
getHardwareList
()
{
return
EntityManagerHelper
.
createQuery
(
"SELECT hw FROM Hardware hw"
,
Hardware
.
class
).
getResultList
();
List
<
Hardware
>
allHardwares
=
EntityManagerHelper
.
createQuery
(
"SELECT hw FROM Hardware hw"
,
Hardware
.
class
).
getResultList
();
return
allHardwares
.
stream
().
filter
(
hardware
->
JCloudsInstancesUtils
.
isHandledHardwareInstanceType
(
NodeCandidate
.
findFirstNodeCandidateWithHardware
(
hardware
)
.
getCloud
()
.
getApi
()
.
getProviderName
(),
hardware
.
getName
())).
collect
(
Collectors
.
toList
());
}
/**
...
...
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/model/NodeCandidate.java
View file @
bbfabae4
...
...
@@ -5,12 +5,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import
com.fasterxml.jackson.annotation.JsonValue
;
import
lombok.AllArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
org.activeeon.morphemic.service.EntityManagerHelper
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Objects
;
import
java.util.Optional
;
/**
...
...
@@ -296,6 +299,19 @@ public class NodeCandidate implements Serializable {
return
nodeCandidateType
.
value
.
equals
(
"BYON"
);
}
/**
* Find the first node candidate that
* @param hardware A given stored hardware
* @return The first found node candidate that uses the given hardware
*/
public
static
NodeCandidate
findFirstNodeCandidateWithHardware
(
Hardware
hardware
)
{
List
<
NodeCandidate
>
nodeCandidates
=
EntityManagerHelper
.
createQuery
(
"SELECT nc FROM NodeCandidate nc"
,
NodeCandidate
.
class
).
getResultList
();
Optional
<
NodeCandidate
>
optNodeCandidate
=
nodeCandidates
.
stream
()
.
filter
(
nodeCandidate
->
hardware
.
equals
(
nodeCandidate
.
getHardware
())).
findFirst
();
return
optNodeCandidate
.
orElse
(
null
);
}
@Override
public
boolean
equals
(
java
.
lang
.
Object
o
)
{
if
(
this
==
o
)
{
...
...
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