misc: move the RDT interface to common library

The current RDT class and interface was define by the clos.py which is
mix get and merge RDT policy, create clos nodes.

Now we need call these interface to check the CLOS IDs number after
merged RDT policy, so this patch abstract the RDT interface to common
and add an assert to check the CLOS IDs number.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@intel.com>
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Chenli Wei
2022-06-10 16:42:34 +08:00
committed by acrnsi-robot
parent 27525d0ae6
commit 72c406c2b7
5 changed files with 217 additions and 184 deletions

View File

@@ -9,6 +9,7 @@
from decimal import Decimal
from copy import copy
import operator
import rdt
import elementpath
BaseParser = elementpath.XPath2Parser
@@ -20,6 +21,8 @@ class CustomParser(BaseParser):
'has',
'duplicate-values',
'number-of-clos-id-needed',
}
method = CustomParser.method
@@ -84,6 +87,14 @@ def select_duplicate_values_function(self, context=None):
yield from duplicate_values()
@method(function('number-of-clos-id-needed', nargs=1))
def evaluate_number_of_clos_id_needed(self, context=None):
op = self.get_argument(context, index=0)
try:
return len(rdt.get_policy_list(op.elem)) if op else 0
except AttributeError as err:
raise self.error('XPTY0004', err)
###
# Collection of counter examples