config-tools: refine append_node and add get_node

Refine the "append_node" which can add new node with an attribute and
return the appended node.

The method "get_node" finds the xpath value and return it if there is an
unique node exists, otherwise it returns None.
It is used to get an xpath element node or can determine the xpath existence.

The "get_text" is replaced with "get_node". The only get_text in
hv_ram.py is modified accordingly.

Tracked-On: #5980
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Yang,Yu-chu
2021-04-08 16:27:00 -07:00
committed by wenlingz
parent 81a867bc57
commit 3ed36ff02a
2 changed files with 11 additions and 7 deletions

View File

@@ -24,7 +24,7 @@ def fn(board_etree, scenario_etree, allocation_etree):
post_launched_vm_num += 1
hv_ram_size = common.HV_BASE_RAM_SIZE + common.POST_LAUNCHED_VM_RAM_SIZE * post_launched_vm_num
ivshmem_enabled = common.get_text("//IVSHMEM_ENABLED", scenario_etree)
ivshmem_enabled = common.get_node("//IVSHMEM_ENABLED/text()", scenario_etree)
total_shm_size = 0
if ivshmem_enabled == 'y':
raw_shmem_regions = scenario_etree.xpath("//IVSHMEM_REGION/text()")