From 0dca9b39e590d6be089917eccf4f34c3b15ab29e Mon Sep 17 00:00:00 2001 From: ruffsl Date: Tue, 6 Aug 2019 21:59:20 -0700 Subject: [PATCH] Add raw permission type Update schema and transforms as well as generating script Signed-off-by: ruffsl --- sros2/scripts/dds_sql_to_sros2_policy.py | 7 ++-- sros2/sros2/policy/schemas/policy.xsd | 11 +++++++ sros2/sros2/policy/templates/dds/demangle.xsl | 32 +++++++++--------- .../policy/templates/dds/permissions.xsl | 33 +++++++++++++++++++ 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/sros2/scripts/dds_sql_to_sros2_policy.py b/sros2/scripts/dds_sql_to_sros2_policy.py index 324b62ab..6c602cde 100755 --- a/sros2/scripts/dds_sql_to_sros2_policy.py +++ b/sros2/scripts/dds_sql_to_sros2_policy.py @@ -89,10 +89,10 @@ def df_to_dds_policy(df): __df = df.loc[namespace, name, :] for mode in __df.index.get_level_values('mode').unique(): if not pd.isna(mode): - topics = etree.SubElement(profile, 'dds_topics') + topics = etree.SubElement(profile, 'raws') topics.set(mode, "ALLOW") for dds_topic in df['dds_topic'].loc[namespace, name, mode]: - topic = etree.SubElement(topics, 'dds_topic') + topic = etree.SubElement(topics, 'raw') topic.text = dds_topic return dds_policy @@ -107,9 +107,8 @@ def dds_policy_to_sros2_policy(dds_policy): etree.parse( get_transport_template('dds', 'demangle.xsl'))) - # TODO: update schema for dds_topics? # Validate policy schema - # policy_xsd.assertValid(dds_policy) + policy_xsd.assertValid(dds_policy) # Transform policy sros2_policy = demangle_xsl(dds_policy) diff --git a/sros2/sros2/policy/schemas/policy.xsd b/sros2/sros2/policy/schemas/policy.xsd index 8086516e..fa11b28e 100644 --- a/sros2/sros2/policy/schemas/policy.xsd +++ b/sros2/sros2/policy/schemas/policy.xsd @@ -24,6 +24,7 @@ + @@ -34,6 +35,16 @@ + + + + + + + + + + diff --git a/sros2/sros2/policy/templates/dds/demangle.xsl b/sros2/sros2/policy/templates/dds/demangle.xsl index db800975..3cbdb1b7 100644 --- a/sros2/sros2/policy/templates/dds/demangle.xsl +++ b/sros2/sros2/policy/templates/dds/demangle.xsl @@ -227,13 +227,13 @@ - + - + @@ -241,14 +241,14 @@ - + - - - - + + + + + substring($_raw, + string-length($_raw) - string-length(@suffix) +1)" /> - + @@ -282,11 +282,11 @@ + substring($_raw, + string-length($_raw) - string-length(@suffix) +1)" /> - + @@ -301,7 +301,7 @@ - + diff --git a/sros2/sros2/policy/templates/dds/permissions.xsl b/sros2/sros2/policy/templates/dds/permissions.xsl index 5e855992..a5b86d2f 100644 --- a/sros2/sros2/policy/templates/dds/permissions.xsl +++ b/sros2/sros2/policy/templates/dds/permissions.xsl @@ -73,6 +73,9 @@ + + + @@ -90,6 +93,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +