diff --git a/src/policy/pom.xml b/src/policy/pom.xml index 003c3d48bc6edc8c32f0ad02009dc9eb6577f4cc..531cc7ecf96424b3180c1f4471ae0d002de85acc 100644 --- a/src/policy/pom.xml +++ b/src/policy/pom.xml @@ -302,6 +302,7 @@ <exclude>monitoring/*</exclude> <exclude>service/*</exclude> <exclude>kpi_sample_types/*</exclude> + <exclude>acl/*</exclude> </excludes> </configuration> <executions> diff --git a/src/policy/src/main/java/eu/teraflow/policy/acl/AclAction.java b/src/policy/src/main/java/eu/teraflow/policy/acl/AclAction.java new file mode 100644 index 0000000000000000000000000000000000000000..66771968ceb5525558bebfd95c3e13af24b4d2dd --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/acl/AclAction.java @@ -0,0 +1,43 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.acl; + +public class AclAction { + + private final AclForwardActionEnum aclForwardActionEnum; + private final AclLogActionEnum aclLogActionEnum; + + public AclAction(AclForwardActionEnum aclForwardActionEnum, AclLogActionEnum aclLogActionEnum) { + this.aclForwardActionEnum = aclForwardActionEnum; + this.aclLogActionEnum = aclLogActionEnum; + } + + public AclForwardActionEnum getAclForwardActionEnum() { + return aclForwardActionEnum; + } + + public AclLogActionEnum getAclLogActionEnum() { + return aclLogActionEnum; + } + + @Override + public String toString() { + return String.format( + "%s:{aclForwardActionEnum:\"%s\", aclLogActionEnum:\"%s\"}", + getClass().getSimpleName(), aclForwardActionEnum.toString(), aclLogActionEnum.toString()); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/acl/AclEntry.java b/src/policy/src/main/java/eu/teraflow/policy/acl/AclEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..a85aff9e6c28b1a63e28d62de22e01e354b47ce3 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/acl/AclEntry.java @@ -0,0 +1,55 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.acl; + +public class AclEntry { + + private final int sequenceId; + private final String description; + private final AclMatch match; + private final AclAction action; + + public AclEntry(int sequenceId, String description, AclMatch match, AclAction action) { + this.sequenceId = sequenceId; + this.description = description; + this.match = match; + this.action = action; + } + + public int getSequenceId() { + return sequenceId; + } + + public String getDescription() { + return description; + } + + public AclMatch getMatch() { + return match; + } + + public AclAction getAction() { + return action; + } + + @Override + public String toString() { + return String.format( + "%s:{sequenceId:\"%d\", description:\"%s\", %s, %s}", + getClass().getSimpleName(), sequenceId, description, match, action); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/acl/AclForwardActionEnum.java b/src/policy/src/main/java/eu/teraflow/policy/acl/AclForwardActionEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..be2a896b48a77543232bdd41685d9d0ed8290711 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/acl/AclForwardActionEnum.java @@ -0,0 +1,24 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.acl; + +public enum AclForwardActionEnum { + UNDEFINED, + DROP, + ACCEPT, + REJECT, +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/acl/AclLogActionEnum.java b/src/policy/src/main/java/eu/teraflow/policy/acl/AclLogActionEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..e0ff362e7154307f934ed0afbfcfa77adcd49acb --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/acl/AclLogActionEnum.java @@ -0,0 +1,23 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.acl; + +public enum AclLogActionEnum { + UNDEFINED, + NO_LOG, + SYSLOG +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/acl/AclMatch.java b/src/policy/src/main/java/eu/teraflow/policy/acl/AclMatch.java new file mode 100644 index 0000000000000000000000000000000000000000..89528a58dde8d39c6bc777fe9220dce85c855a65 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/acl/AclMatch.java @@ -0,0 +1,95 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.acl; + +public class AclMatch { + + private final int dscp; + private final int protocol; + private final String srcAddress; + private final String dstAddress; + private final int srcPort; + private final int dstPort; + private final int startMplsLabel; + private final int endMplsLabel; + + public AclMatch( + int dscp, + int protocol, + String srcAddress, + String dstAddress, + int srcPort, + int dstPort, + int startMplsLabel, + int endMplsLabel) { + this.dscp = dscp; + this.protocol = protocol; + this.srcAddress = srcAddress; + this.dstAddress = dstAddress; + this.srcPort = srcPort; + this.dstPort = dstPort; + this.startMplsLabel = startMplsLabel; + this.endMplsLabel = endMplsLabel; + } + + public int getDscp() { + return dscp; + } + + public int getProtocol() { + return protocol; + } + + public String getSrcAddress() { + return srcAddress; + } + + public String getDstAddress() { + return dstAddress; + } + + public int getSrcPort() { + return srcPort; + } + + public int getDstPort() { + return dstPort; + } + + public int getStartMplsLabel() { + return startMplsLabel; + } + + public int getEndMplsLabel() { + return endMplsLabel; + } + + @Override + public String toString() { + return String.format( + "%s:{dscp:\"%d\", protocol:\"%d\", srcAddress:\"%s\", dstAddress:\"%s\", srcPort:\"%d\", dstPort:\"%d\", startMplsLabel:\"%d\", endMplsLabel:\"%d\"}", + getClass().getSimpleName(), + dscp, + protocol, + srcAddress, + dstAddress, + srcPort, + dstPort, + startMplsLabel, + endMplsLabel); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/acl/AclRuleSet.java b/src/policy/src/main/java/eu/teraflow/policy/acl/AclRuleSet.java new file mode 100644 index 0000000000000000000000000000000000000000..4eec8e7a31fb8bad151f6ad9f7704a8246d78d1e --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/acl/AclRuleSet.java @@ -0,0 +1,74 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.acl; + +import eu.teraflow.policy.common.Util; +import java.util.List; + +public class AclRuleSet { + + private final String name; + private final AclRuleTypeEnum type; + private final String description; + private final String userId; + private final List<AclEntry> entries; + + public AclRuleSet( + String name, + AclRuleTypeEnum type, + String description, + String userId, + List<AclEntry> entries) { + this.name = name; + this.type = type; + this.description = description; + this.userId = userId; + this.entries = entries; + } + + public String getName() { + return name; + } + + public AclRuleTypeEnum getType() { + return type; + } + + public String getDescription() { + return description; + } + + public String getUserId() { + return userId; + } + + public List<AclEntry> getEntries() { + return entries; + } + + @Override + public String toString() { + return String.format( + "%s:{name:\"%s\", type:\"%s\", description:\"%s\", userId:\"%s\", [%s]}", + getClass().getSimpleName(), + name, + type.toString(), + description, + userId, + Util.toString(entries)); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/acl/AclRuleTypeEnum.java b/src/policy/src/main/java/eu/teraflow/policy/acl/AclRuleTypeEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..0dc11277140d5d092cbc3d4dd0b23f21ce855e65 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/acl/AclRuleTypeEnum.java @@ -0,0 +1,26 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.acl; + +public enum AclRuleTypeEnum { + UNDEFINED, + IPV4, + IPV6, + L2, + MPLS, + MIXED +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRule.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRule.java index 906acf1a3ff121584321551de6baf260f0bb7cf3..38b2aa29bba6e43c736f0d9abd9b3243c5470d56 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRule.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRule.java @@ -18,32 +18,26 @@ package eu.teraflow.policy.context.model; public class ConfigRule { - private final ConfigActionEnum action; - private final String resourceKey; - private final String resourceValue; + private final ConfigActionEnum configActionEnum; + private final ConfigRuleType<?> configRuleType; - public ConfigRule(ConfigActionEnum action, String resourceKey, String resourceValue) { - this.action = action; - this.resourceKey = resourceKey; - this.resourceValue = resourceValue; + public ConfigRule(ConfigActionEnum configActionEnum, ConfigRuleType<?> configRuleType) { + this.configActionEnum = configActionEnum; + this.configRuleType = configRuleType; } - public ConfigActionEnum getAction() { - return action; + public ConfigActionEnum getConfigActionEnum() { + return configActionEnum; } - public String getResourceKey() { - return resourceKey; - } - - public String getResourceValue() { - return resourceValue; + public ConfigRuleType getConfigRuleType() { + return configRuleType; } @Override public String toString() { return String.format( - "%s:{action:\"%s\", resourceKey:\"%s\", resourceValue:\"%s\"}", - getClass().getSimpleName(), action.toString(), resourceKey, resourceValue); + "%s:{configActionEnum:\"%s\", %s}", + getClass().getSimpleName(), configActionEnum.toString(), configRuleType); } } diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleAcl.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleAcl.java new file mode 100644 index 0000000000000000000000000000000000000000..ab05331c76f7daa178bd748cfb62dd1b7c3e915a --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleAcl.java @@ -0,0 +1,43 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +import eu.teraflow.policy.acl.AclRuleSet; + +public class ConfigRuleAcl { + + private final EndPointId endPointId; + private final AclRuleSet ruleSet; + + public ConfigRuleAcl(EndPointId endPointId, AclRuleSet ruleSet) { + this.endPointId = endPointId; + this.ruleSet = ruleSet; + } + + public EndPointId getEndPointId() { + return endPointId; + } + + public AclRuleSet getRuleSet() { + return ruleSet; + } + + @Override + public String toString() { + return String.format("%s:{%s, %s}", getClass().getSimpleName(), endPointId, ruleSet); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleCustom.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleCustom.java new file mode 100644 index 0000000000000000000000000000000000000000..0046286179c4c20425bd028ede2465d2604d534f --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleCustom.java @@ -0,0 +1,43 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConfigRuleCustom { + + private final String resourceKey; + private final String resourceValue; + + public ConfigRuleCustom(String resourceKey, String resourceValue) { + this.resourceKey = resourceKey; + this.resourceValue = resourceValue; + } + + public String getResourceKey() { + return resourceKey; + } + + public String getResourceValue() { + return resourceValue; + } + + @Override + public String toString() { + return String.format( + "%s:{resourceKey:\"%s\", resourceValue:\"%s\"}", + getClass().getSimpleName(), resourceKey, resourceValue); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleType.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleType.java new file mode 100644 index 0000000000000000000000000000000000000000..6b7daa12893fc75fdb797ec5e20e2300850ec146 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleType.java @@ -0,0 +1,22 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public interface ConfigRuleType<T> { + + public T getConfigRuleType(); +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleTypeAcl.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleTypeAcl.java new file mode 100644 index 0000000000000000000000000000000000000000..3a93cc7f33f1e60f9d36b6fae333556339298207 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleTypeAcl.java @@ -0,0 +1,36 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConfigRuleTypeAcl implements ConfigRuleType<ConfigRuleAcl> { + + private final ConfigRuleAcl configRuleAcl; + + public ConfigRuleTypeAcl(ConfigRuleAcl configRuleAcl) { + this.configRuleAcl = configRuleAcl; + } + + @Override + public ConfigRuleAcl getConfigRuleType() { + return this.configRuleAcl; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), configRuleAcl); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleTypeCustom.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleTypeCustom.java new file mode 100644 index 0000000000000000000000000000000000000000..c98df91c4027f9ea0089261504ffeeda23d56aea --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConfigRuleTypeCustom.java @@ -0,0 +1,36 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConfigRuleTypeCustom implements ConfigRuleType<ConfigRuleCustom> { + + private final ConfigRuleCustom configRuleCustom; + + public ConfigRuleTypeCustom(ConfigRuleCustom configRuleCustom) { + this.configRuleCustom = configRuleCustom; + } + + @Override + public ConfigRuleCustom getConfigRuleType() { + return this.configRuleCustom; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), configRuleCustom); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/Constraint.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/Constraint.java index edc5c0df7b789f97475d934bacb87b47792d2b01..a7097bc0bfe9ac72e1dd74ed272559ad8bc3e231 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/Constraint.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/Constraint.java @@ -18,26 +18,18 @@ package eu.teraflow.policy.context.model; public class Constraint { - private final String constraintType; - private final String constraintValue; + private final ConstraintType<?> constraintType; - public Constraint(String constraintType, String constraintValue) { + public Constraint(ConstraintType<?> constraintType) { this.constraintType = constraintType; - this.constraintValue = constraintValue; } - public String getConstraintType() { + public ConstraintType getConstraintType() { return constraintType; } - public String getConstraintValue() { - return constraintValue; - } - @Override public String toString() { - return String.format( - "%s:{constraintType:\"%s\", constraintValue:\"%s\"}", - getClass().getSimpleName(), constraintType, constraintValue); + return String.format("%s:{%s}", getClass().getSimpleName(), constraintType); } } diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintCustom.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintCustom.java new file mode 100644 index 0000000000000000000000000000000000000000..3fe3443cca7315613784781040d4be7a988daa54 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintCustom.java @@ -0,0 +1,43 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintCustom { + + private final String constraintType; + private final String constraintValue; + + public ConstraintCustom(String constraintType, String constraintValue) { + this.constraintType = constraintType; + this.constraintValue = constraintValue; + } + + public String getConstraintType() { + return constraintType; + } + + public String getConstraintValue() { + return constraintValue; + } + + @Override + public String toString() { + return String.format( + "%s:{constraintType:\"%s\", constraintValue:\"%s\"}", + getClass().getSimpleName(), constraintType, constraintValue); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintEndPointLocation.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintEndPointLocation.java new file mode 100644 index 0000000000000000000000000000000000000000..12e6ec41c3095529f9807b5449309d966814e3c1 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintEndPointLocation.java @@ -0,0 +1,41 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintEndPointLocation { + + private final EndPointId endPointId; + private final Location location; + + public ConstraintEndPointLocation(EndPointId endPointId, Location location) { + this.endPointId = endPointId; + this.location = location; + } + + public EndPointId getEndPointId() { + return endPointId; + } + + public Location getLocation() { + return location; + } + + @Override + public String toString() { + return String.format("%s:{%s, %s}", getClass().getSimpleName(), endPointId, location); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSchedule.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSchedule.java new file mode 100644 index 0000000000000000000000000000000000000000..b374c022cf85c27f191e3d2607ed13b8078241ba --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSchedule.java @@ -0,0 +1,43 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintSchedule { + + private final float startTimestamp; + private final float durationDays; + + public ConstraintSchedule(float startTimestamp, float durationDays) { + this.startTimestamp = startTimestamp; + this.durationDays = durationDays; + } + + public float getStartTimestamp() { + return startTimestamp; + } + + public float getDurationDays() { + return durationDays; + } + + @Override + public String toString() { + return String.format( + "%s:{startTimestamp:\"%f\", durationDays:\"%f\"}", + getClass().getSimpleName(), startTimestamp, durationDays); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaAvailability.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaAvailability.java new file mode 100644 index 0000000000000000000000000000000000000000..c8a69f3120eb183f5d0b34c73d9653afe1bd7ce3 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaAvailability.java @@ -0,0 +1,43 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintSlaAvailability { + + private final int numDisjointPaths; + private final boolean allActive; + + public ConstraintSlaAvailability(int numDisjointPaths, boolean allActive) { + this.numDisjointPaths = numDisjointPaths; + this.allActive = allActive; + } + + public int getNumDisjointPaths() { + return numDisjointPaths; + } + + public boolean isAllActive() { + return allActive; + } + + @Override + public String toString() { + return String.format( + "%s:{numDisjointPaths:%d, allActive:%b}", + getClass().getSimpleName(), numDisjointPaths, allActive); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaCapacity.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaCapacity.java new file mode 100644 index 0000000000000000000000000000000000000000..3d3f9a25b6dd7eae7dd27a846549b325b72b6cd2 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaCapacity.java @@ -0,0 +1,35 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintSlaCapacity { + + private final float capacityGbps; + + public ConstraintSlaCapacity(float capacityGbps) { + this.capacityGbps = capacityGbps; + } + + public float getCapacityGbps() { + return capacityGbps; + } + + @Override + public String toString() { + return String.format("%s:{capacityGbps:\"%f\"}", getClass().getSimpleName(), capacityGbps); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaIsolationLevel.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaIsolationLevel.java new file mode 100644 index 0000000000000000000000000000000000000000..adb55bff458c49c9189cd10b19d905dd865758d7 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaIsolationLevel.java @@ -0,0 +1,37 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintSlaIsolationLevel { + + private final IsolationLevelEnum isolationLevelEnum; + + public ConstraintSlaIsolationLevel(IsolationLevelEnum isolationLevelEnum) { + this.isolationLevelEnum = isolationLevelEnum; + } + + public IsolationLevelEnum getIsolationLevelEnum() { + return isolationLevelEnum; + } + + @Override + public String toString() { + return String.format( + "%s:{isolationLevelEnum:\"%s\"}", + getClass().getSimpleName(), isolationLevelEnum.toString()); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaLatency.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaLatency.java new file mode 100644 index 0000000000000000000000000000000000000000..0f0c8fe20816394b450bdcd092206b3d7c257b89 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintSlaLatency.java @@ -0,0 +1,35 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintSlaLatency { + + private final float e2eLatencyMs; + + public ConstraintSlaLatency(float e2eLatencyMs) { + this.e2eLatencyMs = e2eLatencyMs; + } + + public float getE2eLatencyMs() { + return e2eLatencyMs; + } + + @Override + public String toString() { + return String.format("%s:{e2eLatencyMs:\"%f\"}", getClass().getSimpleName(), e2eLatencyMs); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintType.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintType.java new file mode 100644 index 0000000000000000000000000000000000000000..e582859e6858a531e3a2c918deaed4d12d8618e4 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintType.java @@ -0,0 +1,22 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public interface ConstraintType<T> { + + public T getConstraintType(); +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeCustom.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeCustom.java new file mode 100644 index 0000000000000000000000000000000000000000..94d0052a9ee4faef3c65856f59c5d1b7e8448b99 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeCustom.java @@ -0,0 +1,36 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintTypeCustom implements ConstraintType<ConstraintCustom> { + + private final ConstraintCustom constraintCustom; + + public ConstraintTypeCustom(ConstraintCustom constraintCustom) { + this.constraintCustom = constraintCustom; + } + + @Override + public ConstraintCustom getConstraintType() { + return this.constraintCustom; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), constraintCustom); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeEndPointLocation.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeEndPointLocation.java new file mode 100644 index 0000000000000000000000000000000000000000..197bea58a6c9471a0ff1d50815cbb5ca75db9392 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeEndPointLocation.java @@ -0,0 +1,35 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintTypeEndPointLocation implements ConstraintType<ConstraintEndPointLocation> { + private final ConstraintEndPointLocation constraintEndPointLocation; + + public ConstraintTypeEndPointLocation(ConstraintEndPointLocation constraintEndPointLocation) { + this.constraintEndPointLocation = constraintEndPointLocation; + } + + @Override + public ConstraintEndPointLocation getConstraintType() { + return this.constraintEndPointLocation; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), constraintEndPointLocation); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSchedule.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSchedule.java new file mode 100644 index 0000000000000000000000000000000000000000..20169427ac81d5d631cf92faf33b13f06947468c --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSchedule.java @@ -0,0 +1,35 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintTypeSchedule implements ConstraintType<ConstraintSchedule> { + private final ConstraintSchedule constraintSchedule; + + public ConstraintTypeSchedule(ConstraintSchedule constraintSchedule) { + this.constraintSchedule = constraintSchedule; + } + + @Override + public ConstraintSchedule getConstraintType() { + return this.constraintSchedule; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), constraintSchedule); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaAvailability.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaAvailability.java new file mode 100644 index 0000000000000000000000000000000000000000..10a60e8dce42a3031cac0a666ee1f4decc9814c8 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaAvailability.java @@ -0,0 +1,36 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintTypeSlaAvailability implements ConstraintType<ConstraintSlaAvailability> { + + private final ConstraintSlaAvailability constraintSlaAvailability; + + public ConstraintTypeSlaAvailability(ConstraintSlaAvailability constraintSlaAvailability) { + this.constraintSlaAvailability = constraintSlaAvailability; + } + + @Override + public ConstraintSlaAvailability getConstraintType() { + return this.constraintSlaAvailability; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), constraintSlaAvailability); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaCapacity.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaCapacity.java new file mode 100644 index 0000000000000000000000000000000000000000..c43cc5948c31317226cd3233b5c63ab7716222ed --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaCapacity.java @@ -0,0 +1,36 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintTypeSlaCapacity implements ConstraintType<ConstraintSlaCapacity> { + + private final ConstraintSlaCapacity constraintSlaCapacity; + + public ConstraintTypeSlaCapacity(ConstraintSlaCapacity constraintSlaCapacity) { + this.constraintSlaCapacity = constraintSlaCapacity; + } + + @Override + public ConstraintSlaCapacity getConstraintType() { + return this.constraintSlaCapacity; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), constraintSlaCapacity); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaIsolationLevel.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaIsolationLevel.java new file mode 100644 index 0000000000000000000000000000000000000000..572df6e45a11ccb4f9a6ef55bad26ec512e0e8f3 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaIsolationLevel.java @@ -0,0 +1,37 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintTypeSlaIsolationLevel + implements ConstraintType<ConstraintSlaIsolationLevel> { + + private final ConstraintSlaIsolationLevel constraintSlaIsolationLevel; + + public ConstraintTypeSlaIsolationLevel(ConstraintSlaIsolationLevel constraintSlaIsolationLevel) { + this.constraintSlaIsolationLevel = constraintSlaIsolationLevel; + } + + @Override + public ConstraintSlaIsolationLevel getConstraintType() { + return this.constraintSlaIsolationLevel; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), constraintSlaIsolationLevel); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaLatency.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaLatency.java new file mode 100644 index 0000000000000000000000000000000000000000..2ff80daa53283e0ed3f80095d61c55626093fb64 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ConstraintTypeSlaLatency.java @@ -0,0 +1,36 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class ConstraintTypeSlaLatency implements ConstraintType<ConstraintSlaLatency> { + + private final ConstraintSlaLatency constraintSlaLatency; + + public ConstraintTypeSlaLatency(ConstraintSlaLatency constraintSlaLatency) { + this.constraintSlaLatency = constraintSlaLatency; + } + + @Override + public ConstraintSlaLatency getConstraintType() { + return this.constraintSlaLatency; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), constraintSlaLatency); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/GpsPosition.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/GpsPosition.java new file mode 100644 index 0000000000000000000000000000000000000000..f5d7b488490c08a2c049ef301b3ecb3290da4ccc --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/GpsPosition.java @@ -0,0 +1,42 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class GpsPosition { + + private final float latitude; + private final float longitude; + + public GpsPosition(float latitude, float longitude) { + this.latitude = latitude; + this.longitude = longitude; + } + + public float getLatitude() { + return latitude; + } + + public float getLongitude() { + return longitude; + } + + @Override + public String toString() { + return String.format( + "%s:{latitude:\"%f\", longitude:\"%f\"}", getClass().getSimpleName(), latitude, longitude); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/IsolationLevelEnum.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/IsolationLevelEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..f7c3a12673ea1e12d2a82e3ddf3c6f8f916ee0db --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/IsolationLevelEnum.java @@ -0,0 +1,29 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public enum IsolationLevelEnum { + NO_ISOLATION, + PHYSICAL_ISOLATION, + LOGICAL_ISOLATION, + PROCESS_ISOLATION, + PHYSICAL_MEMORY_ISOLATION, + PHYSICAL_NETWORK_ISOLATION, + VIRTUAL_RESOURCE_ISOLATION, + NETWORK_FUNCTIONS_ISOLATION, + SERVICE_ISOLATION +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/Location.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/Location.java new file mode 100644 index 0000000000000000000000000000000000000000..692e1f01b71d6205d2b6eb9d78dad2b0d3e1bcf4 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/Location.java @@ -0,0 +1,35 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class Location { + + private final LocationType<?> locationType; + + public Location(LocationType<?> locationType) { + this.locationType = locationType; + } + + public LocationType getLocationType() { + return locationType; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), locationType); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationType.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationType.java new file mode 100644 index 0000000000000000000000000000000000000000..49bf9e9af37eff86a1a6717d0bbd8924f01e2d31 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationType.java @@ -0,0 +1,22 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public interface LocationType<T> { + + public T getLocationType(); +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationTypeGpsPosition.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationTypeGpsPosition.java new file mode 100644 index 0000000000000000000000000000000000000000..4bc44cc4e8c098e1347f43f38f6eafae325da1ee --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationTypeGpsPosition.java @@ -0,0 +1,19 @@ +package eu.teraflow.policy.context.model; + +public class LocationTypeGpsPosition implements LocationType<GpsPosition> { + private final GpsPosition gpsPosition; + + public LocationTypeGpsPosition(GpsPosition gpsPosition) { + this.gpsPosition = gpsPosition; + } + + @Override + public GpsPosition getLocationType() { + return this.gpsPosition; + } + + @Override + public String toString() { + return String.format("%s:{%s}", getClass().getSimpleName(), gpsPosition); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationTypeRegion.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationTypeRegion.java new file mode 100644 index 0000000000000000000000000000000000000000..f857aa507439465dc3c3d7b3e514b8ed1185b532 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/LocationTypeRegion.java @@ -0,0 +1,35 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class LocationTypeRegion implements LocationType<String> { + private final String region; + + public LocationTypeRegion(String region) { + this.region = region; + } + + @Override + public String getLocationType() { + return this.region; + } + + @Override + public String toString() { + return String.format("%s:{region:\"%s\"}", getClass().getSimpleName(), region); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/SliceId.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/SliceId.java new file mode 100644 index 0000000000000000000000000000000000000000..57dbe5ff9fac4e88560f8d1ccecf4b2113705afc --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/SliceId.java @@ -0,0 +1,41 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.context.model; + +public class SliceId { + private final String contextId; + private final String id; + + public SliceId(String contextId, String id) { + this.contextId = contextId; + this.id = id; + } + + public String getContextId() { + return contextId; + } + + public String getId() { + return id; + } + + @Override + public String toString() { + return String.format( + "%s:{contextId:\"%s\", id:\"%s\"}", getClass().getSimpleName(), contextId, id); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java index 714cc5582cce4ce3e606851acb2f2f2b62614e29..df92c5c1af8a5bf47df980dcea4db1d2309351b4 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java @@ -24,7 +24,8 @@ public class PolicyRuleCondition { private final NumericalOperator numericalOperator; private final KpiValue<?> kpiValue; - public PolicyRuleCondition(String kpiId, NumericalOperator numericalOperator, KpiValue kpiValue) { + public PolicyRuleCondition( + String kpiId, NumericalOperator numericalOperator, KpiValue<?> kpiValue) { this.kpiId = kpiId; this.numericalOperator = numericalOperator; this.kpiValue = kpiValue; diff --git a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/AlarmDescriptor.java b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/AlarmDescriptor.java new file mode 100644 index 0000000000000000000000000000000000000000..ac216ee7cec55efbd7f169679b4e0eebad0f3950 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/AlarmDescriptor.java @@ -0,0 +1,65 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.monitoring.model; + +public class AlarmDescriptor { + private final String alarmDescription; + private final String name; + private final String kpiId; + private final KpiValueRange kpiValueRange; + private final String timestamp; + + public AlarmDescriptor( + String alarmDescription, + String name, + String kpiId, + KpiValueRange kpiValueRange, + String timestamp) { + this.alarmDescription = alarmDescription; + this.name = name; + this.kpiId = kpiId; + this.kpiValueRange = kpiValueRange; + this.timestamp = timestamp; + } + + public String getAlarmDescription() { + return alarmDescription; + } + + public String getName() { + return name; + } + + public String getKpiId() { + return kpiId; + } + + public KpiValueRange getKpiValueRange() { + return kpiValueRange; + } + + public String getTimestamp() { + return timestamp; + } + + @Override + public String toString() { + return String.format( + "%s:{alarmDescription:\"%s\", name:\"%s\", kpiId:\"%s\", %s, timestamp:\"%s\"}", + getClass().getSimpleName(), alarmDescription, name, kpiId, kpiValueRange, timestamp); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/AlarmResponse.java b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/AlarmResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..4730c18d068e2372dffee9507d0d74f9208abae9 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/AlarmResponse.java @@ -0,0 +1,49 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.monitoring.model; + +public class AlarmResponse { + + private final String alarmId; + private final String text; + private final KpiValue<?> kpiValue; + + public AlarmResponse(String alarmId, String text, KpiValue<?> kpiValue) { + this.alarmId = alarmId; + this.text = text; + this.kpiValue = kpiValue; + } + + public String getAlarmId() { + return alarmId; + } + + public String getText() { + return text; + } + + public KpiValue getKpiValue() { + return kpiValue; + } + + @Override + public String toString() { + return String.format( + "%s:{alarmId:\"%s\", text:\"%s\", %s}", + getClass().getSimpleName(), alarmId, text, kpiValue); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/Kpi.java b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/Kpi.java index 4d84c29d4f32cd2605cf2d20a67b0fa41f801ab1..c042240298fdea49ca1509ac2563e849b16575c5 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/Kpi.java +++ b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/Kpi.java @@ -20,9 +20,9 @@ public class Kpi { private final String kpiId; private final String timestamp; - private final String kpiValue; + private final KpiValue<?> kpiValue; - public Kpi(String kpiId, String timestamp, String kpiValue) { + public Kpi(String kpiId, String timestamp, KpiValue<?> kpiValue) { this.kpiId = kpiId; this.timestamp = timestamp; this.kpiValue = kpiValue; @@ -36,14 +36,14 @@ public class Kpi { return timestamp; } - public String getKpiValue() { + public KpiValue getKpiValue() { return kpiValue; } @Override public String toString() { return String.format( - "%s:{kpiId:\"%s\", timeStamp:\"%s\", kpiValue:\"%s\"}", + "%s:{kpiId:\"%s\", timeStamp:\"%s\", %s}", getClass().getSimpleName(), kpiId, timestamp, kpiValue); } } diff --git a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/KpiDescriptor.java b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/KpiDescriptor.java index 85e09ce2e6f7ac297657e59c7868fbbd750675b8..107c1033549facafc843e182090c0d8cd95e51e5 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/KpiDescriptor.java +++ b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/KpiDescriptor.java @@ -18,6 +18,7 @@ package eu.teraflow.policy.monitoring.model; import eu.teraflow.policy.context.model.EndPointId; import eu.teraflow.policy.context.model.ServiceId; +import eu.teraflow.policy.context.model.SliceId; import eu.teraflow.policy.kpi_sample_types.model.KpiSampleType; public class KpiDescriptor { @@ -27,18 +28,21 @@ public class KpiDescriptor { private final String deviceId; private final EndPointId endPointId; private final ServiceId serviceId; + private final SliceId sliceId; public KpiDescriptor( String kpiDescription, KpiSampleType kpiSampleType, String deviceId, EndPointId endPointId, - ServiceId serviceId) { + ServiceId serviceId, + SliceId sliceId) { this.kpiDescription = kpiDescription; this.kpiSampleType = kpiSampleType; this.deviceId = deviceId; this.endPointId = endPointId; this.serviceId = serviceId; + this.sliceId = sliceId; } public String getKpiDescription() { @@ -61,15 +65,20 @@ public class KpiDescriptor { return serviceId; } + public SliceId getSliceId() { + return sliceId; + } + @Override public String toString() { return String.format( - "%s:{kpiDescription:\"%s\", kpiSampleType:\"%s\", deviceId:\"%s\", %s, %s}", + "%s:{kpiDescription:\"%s\", kpiSampleType:\"%s\", deviceId:\"%s\", %s, %s, %s}", getClass().getSimpleName(), kpiDescription, kpiSampleType.toString(), deviceId, endPointId, - serviceId); + serviceId, + sliceId); } } diff --git a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/KpiValueRange.java b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/KpiValueRange.java new file mode 100644 index 0000000000000000000000000000000000000000..baa7c32c4e59afc47f3c91c8c65691457b4c6df4 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/KpiValueRange.java @@ -0,0 +1,41 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.monitoring.model; + +public class KpiValueRange { + + private final KpiValue<?> kpiMinValue; + private final KpiValue<?> kpiMaxValue; + + public KpiValueRange(KpiValue<?> kpiMinValue, KpiValue<?> kpiMaxValue) { + this.kpiMinValue = kpiMinValue; + this.kpiMaxValue = kpiMaxValue; + } + + public KpiValue getKpiMinValue() { + return kpiMinValue; + } + + public KpiValue getKpiMaxValue() { + return kpiMaxValue; + } + + @Override + public String toString() { + return String.format("%s:{%s, %s}", getClass().getSimpleName(), kpiMinValue, kpiMaxValue); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/SubsDescriptor.java b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/SubsDescriptor.java new file mode 100644 index 0000000000000000000000000000000000000000..ced38b3f9f76239ee83687f14587da168dc7c320 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/monitoring/model/SubsDescriptor.java @@ -0,0 +1,70 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy.monitoring.model; + +public class SubsDescriptor { + private final String kpiId; + private final float samplingDurationS; + private final float samplingIntervalS; + private final String startDate; + private final String endDate; + + public SubsDescriptor( + String kpiId, + float samplingDurationS, + float samplingIntervalS, + String startDate, + String endDate) { + this.kpiId = kpiId; + this.samplingDurationS = samplingDurationS; + this.samplingIntervalS = samplingIntervalS; + this.startDate = startDate; + this.endDate = endDate; + } + + public String getKpiId() { + return kpiId; + } + + public float getSamplingDurationS() { + return samplingDurationS; + } + + public float getSamplingIntervalS() { + return samplingIntervalS; + } + + public String getStartDate() { + return startDate; + } + + public String getEndDate() { + return endDate; + } + + @Override + public String toString() { + return String.format( + "%s:{kpiId:\"%s\", samplingDurationS:\"%f\", samplingIntervalS:\"%f\", startDate:\"%s\", endDate:\"%s\"}", + getClass().getSimpleName(), + kpiId, + samplingDurationS, + samplingIntervalS, + startDate, + endDate); + } +} diff --git a/src/policy/src/test/java/eu/teraflow/policy/ConfigRuleTypeTest.java b/src/policy/src/test/java/eu/teraflow/policy/ConfigRuleTypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..faaa49c3488cfa7e81f696637a8a7a4393d8f824 --- /dev/null +++ b/src/policy/src/test/java/eu/teraflow/policy/ConfigRuleTypeTest.java @@ -0,0 +1,90 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy; + +import static org.assertj.core.api.Assertions.assertThat; + +import eu.teraflow.policy.acl.AclAction; +import eu.teraflow.policy.acl.AclEntry; +import eu.teraflow.policy.acl.AclForwardActionEnum; +import eu.teraflow.policy.acl.AclLogActionEnum; +import eu.teraflow.policy.acl.AclMatch; +import eu.teraflow.policy.acl.AclRuleSet; +import eu.teraflow.policy.acl.AclRuleTypeEnum; +import eu.teraflow.policy.context.model.ConfigRuleAcl; +import eu.teraflow.policy.context.model.ConfigRuleCustom; +import eu.teraflow.policy.context.model.ConfigRuleTypeAcl; +import eu.teraflow.policy.context.model.ConfigRuleTypeCustom; +import eu.teraflow.policy.context.model.EndPointId; +import eu.teraflow.policy.context.model.TopologyId; +import io.quarkus.test.junit.QuarkusTest; +import java.util.List; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class ConfigRuleTypeTest { + + private AclMatch createAclMatch() { + + return new AclMatch(1, 2, "192.168.3.52", "192.168.4.192", 3224, 3845, 5, 10); + } + + private AclAction createAclAction() { + + return new AclAction(AclForwardActionEnum.ACCEPT, AclLogActionEnum.SYSLOG); + } + + private AclEntry createAclEntry(AclMatch aclMatch, AclAction aclAction) { + + return new AclEntry(1, "aclEntryDescription", aclMatch, aclAction); + } + + @Test + void shouldExtractConfigRuleCustomFromConfigRuleTypeCustom() { + final var resourceKey = "resourceKey"; + final var resourceValue = "resourceValue"; + + final var expectedConfigRuleCustom = new ConfigRuleCustom(resourceKey, resourceValue); + final var configRuleTypeCustom = new ConfigRuleTypeCustom(expectedConfigRuleCustom); + + assertThat(configRuleTypeCustom.getConfigRuleType()).isEqualTo(expectedConfigRuleCustom); + } + + @Test + void shouldExtractConfigRuleAclFromConfigRuleTypeAcl() { + final var contextIdUuid = "contextId"; + final var topologyIdUuid = "topologyUuid"; + final var deviceIdUuid = "deviceIdUuid"; + final var endpointIdUuid = "endpointIdUuid"; + + final var topologyId = new TopologyId(contextIdUuid, topologyIdUuid); + final var endPointId = new EndPointId(topologyId, deviceIdUuid, endpointIdUuid); + + final var aclMatch = createAclMatch(); + final var aclAction = createAclAction(); + final var aclEntry = createAclEntry(aclMatch, aclAction); + + final var aclRuleSet = + new AclRuleSet( + "aclRuleName", AclRuleTypeEnum.IPV4, "AclRuleDescription", "userId", List.of(aclEntry)); + + final var expectedConfigRuleAcl = new ConfigRuleAcl(endPointId, aclRuleSet); + final var configRuleTypeAcl = new ConfigRuleTypeAcl(expectedConfigRuleAcl); + + assertThat(configRuleTypeAcl.getConfigRuleType()).isEqualTo(expectedConfigRuleAcl); + } +} diff --git a/src/policy/src/test/java/eu/teraflow/policy/ConstraintTypeTest.java b/src/policy/src/test/java/eu/teraflow/policy/ConstraintTypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..71d44bd3182200f456a9f9d0cb5f02ad0b222d3f --- /dev/null +++ b/src/policy/src/test/java/eu/teraflow/policy/ConstraintTypeTest.java @@ -0,0 +1,134 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy; + +import static org.assertj.core.api.Assertions.assertThat; + +import eu.teraflow.policy.context.model.ConstraintCustom; +import eu.teraflow.policy.context.model.ConstraintEndPointLocation; +import eu.teraflow.policy.context.model.ConstraintSchedule; +import eu.teraflow.policy.context.model.ConstraintSlaAvailability; +import eu.teraflow.policy.context.model.ConstraintSlaCapacity; +import eu.teraflow.policy.context.model.ConstraintSlaIsolationLevel; +import eu.teraflow.policy.context.model.ConstraintSlaLatency; +import eu.teraflow.policy.context.model.ConstraintTypeCustom; +import eu.teraflow.policy.context.model.ConstraintTypeEndPointLocation; +import eu.teraflow.policy.context.model.ConstraintTypeSchedule; +import eu.teraflow.policy.context.model.ConstraintTypeSlaAvailability; +import eu.teraflow.policy.context.model.ConstraintTypeSlaCapacity; +import eu.teraflow.policy.context.model.ConstraintTypeSlaIsolationLevel; +import eu.teraflow.policy.context.model.ConstraintTypeSlaLatency; +import eu.teraflow.policy.context.model.EndPointId; +import eu.teraflow.policy.context.model.IsolationLevelEnum; +import eu.teraflow.policy.context.model.Location; +import eu.teraflow.policy.context.model.LocationTypeRegion; +import eu.teraflow.policy.context.model.TopologyId; +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class ConstraintTypeTest { + + @Test + void shouldExtractConstraintCustomFromConstraintTypeCustom() { + final var constraintType = "constraintType"; + final var constraintValue = "constraintValue"; + + final var expectedConstraintCustom = new ConstraintCustom(constraintType, constraintValue); + final var constraintTypeCustom = new ConstraintTypeCustom(expectedConstraintCustom); + + assertThat(constraintTypeCustom.getConstraintType()).isEqualTo(expectedConstraintCustom); + } + + @Test + void shouldExtractConstraintEndPointLocationFromConstraintTypeEndPointLocation() { + final var expectedTopologyId = new TopologyId("contextId", "id"); + final var expectedDeviceId = "expectedDeviceId"; + final var expectedId = "expectedId"; + final var endPointId = new EndPointId(expectedTopologyId, expectedDeviceId, expectedId); + + final var locationType = new LocationTypeRegion("ATH"); + final var location = new Location(locationType); + + final var expectedConstraintEndPointLocation = + new ConstraintEndPointLocation(endPointId, location); + final var constraintTypeEndPointLocation = + new ConstraintTypeEndPointLocation(expectedConstraintEndPointLocation); + + assertThat(constraintTypeEndPointLocation.getConstraintType()) + .isEqualTo(expectedConstraintEndPointLocation); + } + + @Test + void shouldExtractConstraintScheduleFromConstraintTypeSchedule() { + final var startTimestamp = 4.7f; + final var durationDays = 97.4f; + + final var expectedConstraintSchedule = new ConstraintSchedule(startTimestamp, durationDays); + final var constraintTypeSchedule = new ConstraintTypeSchedule(expectedConstraintSchedule); + + assertThat(constraintTypeSchedule.getConstraintType()).isEqualTo(expectedConstraintSchedule); + } + + @Test + void shouldExtractConstraintSlaAvailabilityFromConstraintTypeSlaAvailability() { + final var numDisjointPaths = 88; + final var allActive = false; + + final var expectedConstraintSlaAvailability = + new ConstraintSlaAvailability(numDisjointPaths, allActive); + final var constraintTypeSlaAvailability = + new ConstraintTypeSlaAvailability(expectedConstraintSlaAvailability); + + assertThat(constraintTypeSlaAvailability.getConstraintType()) + .isEqualTo(expectedConstraintSlaAvailability); + } + + @Test + void shouldExtractConstraintSlaCapacityFromConstraintTypeSlaCapacity() { + final var capacityGbps = 0.2f; + + final var expectedConstraintSlaCapacity = new ConstraintSlaCapacity(capacityGbps); + final var constraintTypeSlaCapacity = + new ConstraintTypeSlaCapacity(expectedConstraintSlaCapacity); + + assertThat(constraintTypeSlaCapacity.getConstraintType()) + .isEqualTo(expectedConstraintSlaCapacity); + } + + @Test + void shouldExtractConstraintSlaIsolationLevelFromConstraintTypeSlaIsolationLevel() { + final var expectedConstraintSlaIsolationLevel = + new ConstraintSlaIsolationLevel(IsolationLevelEnum.PHYSICAL_ISOLATION); + final var constraintTypeSlaIsolationLevel = + new ConstraintTypeSlaIsolationLevel(expectedConstraintSlaIsolationLevel); + + assertThat(constraintTypeSlaIsolationLevel.getConstraintType()) + .isEqualTo(expectedConstraintSlaIsolationLevel); + } + + @Test + void shouldExtractConstraintSlaLatencyFromConstraintTypeSlaLatency() { + final var capacityGbps = 0.2f; + + final var expectedConstraintSlaLatency = new ConstraintSlaLatency(capacityGbps); + final var constraintTypeSlaLatency = new ConstraintTypeSlaLatency(expectedConstraintSlaLatency); + + assertThat(constraintTypeSlaLatency.getConstraintType()) + .isEqualTo(expectedConstraintSlaLatency); + } +} diff --git a/src/policy/src/test/java/eu/teraflow/policy/LocationTypeTest.java b/src/policy/src/test/java/eu/teraflow/policy/LocationTypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d89d62c63486cf571f2606786b805abdc066204c --- /dev/null +++ b/src/policy/src/test/java/eu/teraflow/policy/LocationTypeTest.java @@ -0,0 +1,49 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy; + +import static org.assertj.core.api.Assertions.assertThat; + +import eu.teraflow.policy.context.model.GpsPosition; +import eu.teraflow.policy.context.model.LocationTypeGpsPosition; +import eu.teraflow.policy.context.model.LocationTypeRegion; +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class LocationTypeTest { + + @Test + void shouldExtractRegionFromLocationTypeRegion() { + final var expectedRegion = "ATH"; + + final var locationTypeRegion = new LocationTypeRegion(expectedRegion); + + assertThat(locationTypeRegion.getLocationType()).isEqualTo(expectedRegion); + } + + @Test + void shouldExtractLocationGpsPositionFromLocationTypeGpsPosition() { + final var latitude = 3.99f; + final var longitude = 77.32f; + + final var expectedLocationGpsPosition = new GpsPosition(latitude, longitude); + final var locationTypeGpsPosition = new LocationTypeGpsPosition(expectedLocationGpsPosition); + + assertThat(locationTypeGpsPosition.getLocationType()).isEqualTo(expectedLocationGpsPosition); + } +} diff --git a/src/policy/target/generated-sources/grpc/policy/Policy.java b/src/policy/target/generated-sources/grpc/policy/Policy.java index d332560fa0ceaabe472c8f78db306e7e8d9246eb..541f97f47bd2e69711a795dc454841054e865a3a 100644 --- a/src/policy/target/generated-sources/grpc/policy/Policy.java +++ b/src/policy/target/generated-sources/grpc/policy/Policy.java @@ -1457,17 +1457,29 @@ public final class Policy { policy.Policy.PolicyRuleIdOrBuilder getPolicyRuleIdOrBuilder(); /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> * @return Whether the policyRuleState field is set. */ boolean hasPolicyRuleState(); /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> * @return The policyRuleState. */ policy.Policy.PolicyRuleState getPolicyRuleState(); /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder(); @@ -1652,7 +1664,7 @@ public final class Policy { } case 18: { policy.Policy.PolicyRuleState.Builder subBuilder = null; - if (((bitField0_ & 0x00000001) != 0)) { + if (policyRuleState_ != null) { subBuilder = policyRuleState_.toBuilder(); } policyRuleState_ = input.readMessage(policy.Policy.PolicyRuleState.parser(), extensionRegistry); @@ -1660,7 +1672,7 @@ public final class Policy { subBuilder.mergeFrom(policyRuleState_); policyRuleState_ = subBuilder.buildPartial(); } - bitField0_ |= 0x00000001; + break; } case 24: { @@ -1669,9 +1681,9 @@ public final class Policy { break; } case 34: { - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { conditionList_ = new java.util.ArrayList<policy.PolicyCondition.PolicyRuleCondition>(); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } conditionList_.add( input.readMessage(policy.PolicyCondition.PolicyRuleCondition.parser(), extensionRegistry)); @@ -1684,9 +1696,9 @@ public final class Policy { break; } case 50: { - if (!((mutable_bitField0_ & 0x00000004) != 0)) { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { actionList_ = new java.util.ArrayList<policy.PolicyAction.PolicyRuleAction>(); - mutable_bitField0_ |= 0x00000004; + mutable_bitField0_ |= 0x00000002; } actionList_.add( input.readMessage(policy.PolicyAction.PolicyRuleAction.parser(), extensionRegistry)); @@ -1707,10 +1719,10 @@ public final class Policy { throw new com.google.protobuf.InvalidProtocolBufferException( e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000002) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { conditionList_ = java.util.Collections.unmodifiableList(conditionList_); } - if (((mutable_bitField0_ & 0x00000004) != 0)) { + if (((mutable_bitField0_ & 0x00000002) != 0)) { actionList_ = java.util.Collections.unmodifiableList(actionList_); } this.unknownFields = unknownFields.build(); @@ -1730,7 +1742,6 @@ public final class Policy { policy.Policy.PolicyRuleBasic.class, policy.Policy.PolicyRuleBasic.Builder.class); } - private int bitField0_; public static final int POLICYRULEID_FIELD_NUMBER = 1; private policy.Policy.PolicyRuleId policyRuleId_; /** @@ -1760,15 +1771,23 @@ public final class Policy { public static final int POLICYRULESTATE_FIELD_NUMBER = 2; private policy.Policy.PolicyRuleState policyRuleState_; /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> * @return Whether the policyRuleState field is set. */ @java.lang.Override public boolean hasPolicyRuleState() { - return ((bitField0_ & 0x00000001) != 0); + return policyRuleState_ != null; } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> * @return The policyRuleState. */ @java.lang.Override @@ -1776,11 +1795,15 @@ public final class Policy { return policyRuleState_ == null ? policy.Policy.PolicyRuleState.getDefaultInstance() : policyRuleState_; } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ @java.lang.Override public policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder() { - return policyRuleState_ == null ? policy.Policy.PolicyRuleState.getDefaultInstance() : policyRuleState_; + return getPolicyRuleState(); } public static final int PRIORITY_FIELD_NUMBER = 3; @@ -1958,7 +1981,7 @@ public final class Policy { if (policyRuleId_ != null) { output.writeMessage(1, getPolicyRuleId()); } - if (((bitField0_ & 0x00000001) != 0)) { + if (policyRuleState_ != null) { output.writeMessage(2, getPolicyRuleState()); } if (priority_ != 0) { @@ -1986,7 +2009,7 @@ public final class Policy { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getPolicyRuleId()); } - if (((bitField0_ & 0x00000001) != 0)) { + if (policyRuleState_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, getPolicyRuleState()); } @@ -2201,7 +2224,6 @@ public final class Policy { private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3 .alwaysUseFieldBuilders) { - getPolicyRuleStateFieldBuilder(); getConditionListFieldBuilder(); getActionListFieldBuilder(); } @@ -2218,14 +2240,14 @@ public final class Policy { if (policyRuleStateBuilder_ == null) { policyRuleState_ = null; } else { - policyRuleStateBuilder_.clear(); + policyRuleState_ = null; + policyRuleStateBuilder_ = null; } - bitField0_ = (bitField0_ & ~0x00000001); priority_ = 0; if (conditionListBuilder_ == null) { conditionList_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { conditionListBuilder_.clear(); } @@ -2233,7 +2255,7 @@ public final class Policy { if (actionListBuilder_ == null) { actionList_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } else { actionListBuilder_.clear(); } @@ -2264,25 +2286,21 @@ public final class Policy { public policy.Policy.PolicyRuleBasic buildPartial() { policy.Policy.PolicyRuleBasic result = new policy.Policy.PolicyRuleBasic(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (policyRuleIdBuilder_ == null) { result.policyRuleId_ = policyRuleId_; } else { result.policyRuleId_ = policyRuleIdBuilder_.build(); } - if (((from_bitField0_ & 0x00000001) != 0)) { - if (policyRuleStateBuilder_ == null) { - result.policyRuleState_ = policyRuleState_; - } else { - result.policyRuleState_ = policyRuleStateBuilder_.build(); - } - to_bitField0_ |= 0x00000001; + if (policyRuleStateBuilder_ == null) { + result.policyRuleState_ = policyRuleState_; + } else { + result.policyRuleState_ = policyRuleStateBuilder_.build(); } result.priority_ = priority_; if (conditionListBuilder_ == null) { - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { conditionList_ = java.util.Collections.unmodifiableList(conditionList_); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } result.conditionList_ = conditionList_; } else { @@ -2290,15 +2308,14 @@ public final class Policy { } result.booleanOperator_ = booleanOperator_; if (actionListBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000002) != 0)) { actionList_ = java.util.Collections.unmodifiableList(actionList_); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } result.actionList_ = actionList_; } else { result.actionList_ = actionListBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -2360,7 +2377,7 @@ public final class Policy { if (!other.conditionList_.isEmpty()) { if (conditionList_.isEmpty()) { conditionList_ = other.conditionList_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureConditionListIsMutable(); conditionList_.addAll(other.conditionList_); @@ -2373,7 +2390,7 @@ public final class Policy { conditionListBuilder_.dispose(); conditionListBuilder_ = null; conditionList_ = other.conditionList_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); conditionListBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getConditionListFieldBuilder() : null; @@ -2389,7 +2406,7 @@ public final class Policy { if (!other.actionList_.isEmpty()) { if (actionList_.isEmpty()) { actionList_ = other.actionList_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } else { ensureActionListIsMutable(); actionList_.addAll(other.actionList_); @@ -2402,7 +2419,7 @@ public final class Policy { actionListBuilder_.dispose(); actionListBuilder_ = null; actionList_ = other.actionList_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); actionListBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getActionListFieldBuilder() : null; @@ -2564,14 +2581,22 @@ public final class Policy { private com.google.protobuf.SingleFieldBuilderV3< policy.Policy.PolicyRuleState, policy.Policy.PolicyRuleState.Builder, policy.Policy.PolicyRuleStateOrBuilder> policyRuleStateBuilder_; /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> * @return Whether the policyRuleState field is set. */ public boolean hasPolicyRuleState() { - return ((bitField0_ & 0x00000001) != 0); + return policyRuleStateBuilder_ != null || policyRuleState_ != null; } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> * @return The policyRuleState. */ public policy.Policy.PolicyRuleState getPolicyRuleState() { @@ -2582,7 +2607,11 @@ public final class Policy { } } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ public Builder setPolicyRuleState(policy.Policy.PolicyRuleState value) { if (policyRuleStateBuilder_ == null) { @@ -2594,11 +2623,15 @@ public final class Policy { } else { policyRuleStateBuilder_.setMessage(value); } - bitField0_ |= 0x00000001; + return this; } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ public Builder setPolicyRuleState( policy.Policy.PolicyRuleState.Builder builderForValue) { @@ -2608,17 +2641,19 @@ public final class Policy { } else { policyRuleStateBuilder_.setMessage(builderForValue.build()); } - bitField0_ |= 0x00000001; + return this; } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ public Builder mergePolicyRuleState(policy.Policy.PolicyRuleState value) { if (policyRuleStateBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0) && - policyRuleState_ != null && - policyRuleState_ != policy.Policy.PolicyRuleState.getDefaultInstance()) { + if (policyRuleState_ != null) { policyRuleState_ = policy.Policy.PolicyRuleState.newBuilder(policyRuleState_).mergeFrom(value).buildPartial(); } else { @@ -2628,32 +2663,45 @@ public final class Policy { } else { policyRuleStateBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000001; + return this; } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ public Builder clearPolicyRuleState() { if (policyRuleStateBuilder_ == null) { policyRuleState_ = null; onChanged(); } else { - policyRuleStateBuilder_.clear(); + policyRuleState_ = null; + policyRuleStateBuilder_ = null; } - bitField0_ = (bitField0_ & ~0x00000001); + return this; } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ public policy.Policy.PolicyRuleState.Builder getPolicyRuleStateBuilder() { - bitField0_ |= 0x00000001; + onChanged(); return getPolicyRuleStateFieldBuilder().getBuilder(); } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ public policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder() { if (policyRuleStateBuilder_ != null) { @@ -2664,7 +2712,11 @@ public final class Policy { } } /** - * <code>optional .policy.PolicyRuleState policyRuleState = 2;</code> + * <pre> + *policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + * </pre> + * + * <code>.policy.PolicyRuleState policyRuleState = 2;</code> */ private com.google.protobuf.SingleFieldBuilderV3< policy.Policy.PolicyRuleState, policy.Policy.PolicyRuleState.Builder, policy.Policy.PolicyRuleStateOrBuilder> @@ -2714,9 +2766,9 @@ public final class Policy { private java.util.List<policy.PolicyCondition.PolicyRuleCondition> conditionList_ = java.util.Collections.emptyList(); private void ensureConditionListIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { conditionList_ = new java.util.ArrayList<policy.PolicyCondition.PolicyRuleCondition>(conditionList_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } @@ -2910,7 +2962,7 @@ public final class Policy { public Builder clearConditionList() { if (conditionListBuilder_ == null) { conditionList_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); } else { conditionListBuilder_.clear(); @@ -3015,7 +3067,7 @@ public final class Policy { conditionListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< policy.PolicyCondition.PolicyRuleCondition, policy.PolicyCondition.PolicyRuleCondition.Builder, policy.PolicyCondition.PolicyRuleConditionOrBuilder>( conditionList_, - ((bitField0_ & 0x00000002) != 0), + ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); conditionList_ = null; @@ -3100,9 +3152,9 @@ public final class Policy { private java.util.List<policy.PolicyAction.PolicyRuleAction> actionList_ = java.util.Collections.emptyList(); private void ensureActionListIsMutable() { - if (!((bitField0_ & 0x00000004) != 0)) { + if (!((bitField0_ & 0x00000002) != 0)) { actionList_ = new java.util.ArrayList<policy.PolicyAction.PolicyRuleAction>(actionList_); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000002; } } @@ -3296,7 +3348,7 @@ public final class Policy { public Builder clearActionList() { if (actionListBuilder_ == null) { actionList_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); onChanged(); } else { actionListBuilder_.clear(); @@ -3401,7 +3453,7 @@ public final class Policy { actionListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< policy.PolicyAction.PolicyRuleAction, policy.PolicyAction.PolicyRuleAction.Builder, policy.PolicyAction.PolicyRuleActionOrBuilder>( actionList_, - ((bitField0_ & 0x00000004) != 0), + ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); actionList_ = null; @@ -9338,50 +9390,49 @@ public final class Policy { "olicy-condition.proto\032\023policy-action.pro" + "to\"+\n\014PolicyRuleId\022\033\n\004uuid\030\001 \001(\0132\r.conte" + "xt.Uuid\"=\n\017PolicyRuleState\022*\n\017policyRule" + - "State\030\001 \001(\0162\021.policy.RuleState\"\256\002\n\017Polic" + + "State\030\001 \001(\0162\021.policy.RuleState\"\225\002\n\017Polic" + "yRuleBasic\022*\n\014policyRuleId\030\001 \001(\0132\024.polic" + - "y.PolicyRuleId\0225\n\017policyRuleState\030\002 \001(\0132" + - "\027.policy.PolicyRuleStateH\000\210\001\001\022\020\n\010priorit" + - "y\030\003 \001(\r\0222\n\rconditionList\030\004 \003(\0132\033.policy." + - "PolicyRuleCondition\0220\n\017booleanOperator\030\005" + - " \001(\0162\027.policy.BooleanOperator\022,\n\nactionL" + - "ist\030\006 \003(\0132\030.policy.PolicyRuleActionB\022\n\020_" + - "policyRuleState\"\223\001\n\021PolicyRuleService\0220\n" + - "\017policyRuleBasic\030\001 \001(\0132\027.policy.PolicyRu" + - "leBasic\022%\n\tserviceId\030\002 \001(\0132\022.context.Ser" + - "viceId\022%\n\ndeviceList\030\003 \003(\0132\021.context.Dev" + - "iceId\"k\n\020PolicyRuleDevice\0220\n\017policyRuleB" + - "asic\030\001 \001(\0132\027.policy.PolicyRuleBasic\022%\n\nd" + - "eviceList\030\002 \003(\0132\021.context.DeviceId\"B\n\020Po" + - "licyRuleIdList\022.\n\020policyRuleIdList\030\001 \003(\013" + - "2\024.policy.PolicyRuleId\"Q\n\025PolicyRuleServ" + - "iceList\0228\n\025policyRuleServiceList\030\001 \003(\0132\031" + - ".policy.PolicyRuleService\"N\n\024PolicyRuleD" + - "eviceList\0226\n\024policyRuleDeviceList\030\001 \003(\0132" + - "\030.policy.PolicyRuleDevice\";\n\016PolicyRuleL" + - "ist\022)\n\013policyRules\030\001 \003(\0132\024.policy.Policy" + - "RuleId*\365\001\n\tRuleState\022\024\n\020POLICY_UNDEFINED" + - "\020\000\022\021\n\rPOLICY_FAILED\020\001\022\023\n\017POLICY_INSERTED" + - "\020\002\022\024\n\020POLICY_VALIDATED\020\003\022\026\n\022POLICY_PROVI" + - "SIONED\020\004\022\021\n\rPOLICY_ACTIVE\020\005\022\023\n\017POLICY_EN" + - "FORCED\020\006\022\026\n\022POLICY_INEFFECTIVE\020\007\022\024\n\020POLI" + - "CY_EFFECTIVE\020\010\022\022\n\016POLICY_UPDATED\020\t\022\022\n\016PO" + - "LICY_REMOVED\020\n2\323\004\n\rPolicyService\022H\n\020Poli" + - "cyAddService\022\031.policy.PolicyRuleService\032" + - "\027.policy.PolicyRuleState\"\000\022F\n\017PolicyAddD" + - "evice\022\030.policy.PolicyRuleDevice\032\027.policy" + - ".PolicyRuleState\"\000\022K\n\023PolicyUpdateServic" + - "e\022\031.policy.PolicyRuleService\032\027.policy.Po" + - "licyRuleState\"\000\022I\n\022PolicyUpdateDevice\022\030." + - "policy.PolicyRuleDevice\032\027.policy.PolicyR" + - "uleState\"\000\022?\n\014PolicyDelete\022\024.policy.Poli" + - "cyRuleId\032\027.policy.PolicyRuleState\"\000\022E\n\020G" + - "etPolicyService\022\024.policy.PolicyRuleId\032\031." + - "policy.PolicyRuleService\"\000\022C\n\017GetPolicyD" + - "evice\022\024.policy.PolicyRuleId\032\030.policy.Pol" + - "icyRuleDevice\"\000\022K\n\024GetPolicyByServiceId\022" + - "\022.context.ServiceId\032\035.policy.PolicyRuleS" + - "erviceList\"\000b\006proto3" + "y.PolicyRuleId\0220\n\017policyRuleState\030\002 \001(\0132" + + "\027.policy.PolicyRuleState\022\020\n\010priority\030\003 \001" + + "(\r\0222\n\rconditionList\030\004 \003(\0132\033.policy.Polic" + + "yRuleCondition\0220\n\017booleanOperator\030\005 \001(\0162" + + "\027.policy.BooleanOperator\022,\n\nactionList\030\006" + + " \003(\0132\030.policy.PolicyRuleAction\"\223\001\n\021Polic" + + "yRuleService\0220\n\017policyRuleBasic\030\001 \001(\0132\027." + + "policy.PolicyRuleBasic\022%\n\tserviceId\030\002 \001(" + + "\0132\022.context.ServiceId\022%\n\ndeviceList\030\003 \003(" + + "\0132\021.context.DeviceId\"k\n\020PolicyRuleDevice" + + "\0220\n\017policyRuleBasic\030\001 \001(\0132\027.policy.Polic" + + "yRuleBasic\022%\n\ndeviceList\030\002 \003(\0132\021.context" + + ".DeviceId\"B\n\020PolicyRuleIdList\022.\n\020policyR" + + "uleIdList\030\001 \003(\0132\024.policy.PolicyRuleId\"Q\n" + + "\025PolicyRuleServiceList\0228\n\025policyRuleServ" + + "iceList\030\001 \003(\0132\031.policy.PolicyRuleService" + + "\"N\n\024PolicyRuleDeviceList\0226\n\024policyRuleDe" + + "viceList\030\001 \003(\0132\030.policy.PolicyRuleDevice" + + "\";\n\016PolicyRuleList\022)\n\013policyRules\030\001 \003(\0132" + + "\024.policy.PolicyRuleId*\365\001\n\tRuleState\022\024\n\020P" + + "OLICY_UNDEFINED\020\000\022\021\n\rPOLICY_FAILED\020\001\022\023\n\017" + + "POLICY_INSERTED\020\002\022\024\n\020POLICY_VALIDATED\020\003\022" + + "\026\n\022POLICY_PROVISIONED\020\004\022\021\n\rPOLICY_ACTIVE" + + "\020\005\022\023\n\017POLICY_ENFORCED\020\006\022\026\n\022POLICY_INEFFE" + + "CTIVE\020\007\022\024\n\020POLICY_EFFECTIVE\020\010\022\022\n\016POLICY_" + + "UPDATED\020\t\022\022\n\016POLICY_REMOVED\020\n2\323\004\n\rPolicy" + + "Service\022H\n\020PolicyAddService\022\031.policy.Pol" + + "icyRuleService\032\027.policy.PolicyRuleState\"" + + "\000\022F\n\017PolicyAddDevice\022\030.policy.PolicyRule" + + "Device\032\027.policy.PolicyRuleState\"\000\022K\n\023Pol" + + "icyUpdateService\022\031.policy.PolicyRuleServ" + + "ice\032\027.policy.PolicyRuleState\"\000\022I\n\022Policy" + + "UpdateDevice\022\030.policy.PolicyRuleDevice\032\027" + + ".policy.PolicyRuleState\"\000\022?\n\014PolicyDelet" + + "e\022\024.policy.PolicyRuleId\032\027.policy.PolicyR" + + "uleState\"\000\022E\n\020GetPolicyService\022\024.policy." + + "PolicyRuleId\032\031.policy.PolicyRuleService\"" + + "\000\022C\n\017GetPolicyDevice\022\024.policy.PolicyRule" + + "Id\032\030.policy.PolicyRuleDevice\"\000\022K\n\024GetPol" + + "icyByServiceId\022\022.context.ServiceId\032\035.pol" + + "icy.PolicyRuleServiceList\"\000b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -9407,7 +9458,7 @@ public final class Policy { internal_static_policy_PolicyRuleBasic_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_policy_PolicyRuleBasic_descriptor, - new java.lang.String[] { "PolicyRuleId", "PolicyRuleState", "Priority", "ConditionList", "BooleanOperator", "ActionList", "PolicyRuleState", }); + new java.lang.String[] { "PolicyRuleId", "PolicyRuleState", "Priority", "ConditionList", "BooleanOperator", "ActionList", }); internal_static_policy_PolicyRuleService_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_policy_PolicyRuleService_fieldAccessorTable = new diff --git a/src/policy/target/kubernetes/kubernetes.yml b/src/policy/target/kubernetes/kubernetes.yml index 97929a86330aa71f708199fa3333764e0fd31e38..248fb6143f0203cf436f2cc666da9038f97d8d54 100644 --- a/src/policy/target/kubernetes/kubernetes.yml +++ b/src/policy/target/kubernetes/kubernetes.yml @@ -3,8 +3,8 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: cfe69c57feb1d488c2dda620021e3c62d67fc3d3 - app.quarkus.io/build-timestamp: 2022-07-14 - 07:52:22 +0000 + app.quarkus.io/commit-id: 4244298f2625d05dce3c62d8431b03f799506e78 + app.quarkus.io/build-timestamp: 2022-07-21 - 11:54:42 +0000 labels: app.kubernetes.io/name: policyservice app: policyservice @@ -25,8 +25,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: cfe69c57feb1d488c2dda620021e3c62d67fc3d3 - app.quarkus.io/build-timestamp: 2022-07-14 - 07:52:22 +0000 + app.quarkus.io/commit-id: 4244298f2625d05dce3c62d8431b03f799506e78 + app.quarkus.io/build-timestamp: 2022-07-21 - 11:54:42 +0000 labels: app: policyservice app.kubernetes.io/name: policyservice @@ -39,8 +39,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: cfe69c57feb1d488c2dda620021e3c62d67fc3d3 - app.quarkus.io/build-timestamp: 2022-07-14 - 07:52:22 +0000 + app.quarkus.io/commit-id: 4244298f2625d05dce3c62d8431b03f799506e78 + app.quarkus.io/build-timestamp: 2022-07-21 - 11:54:42 +0000 labels: app: policyservice app.kubernetes.io/name: policyservice @@ -53,10 +53,10 @@ spec: fieldPath: metadata.namespace - name: MONITORING_SERVICE_HOST value: monitoringservice - - name: SERVICE_SERVICE_HOST - value: serviceservice - name: CONTEXT_SERVICE_HOST value: contextservice + - name: SERVICE_SERVICE_HOST + value: serviceservice image: registry.gitlab.com/teraflow-h2020/controller/policy:0.1.0 imagePullPolicy: Always livenessProbe: