Esempio n. 1
0
 def _add_default_stmts(self, prop):
     """Add default statements."""
     prop_path = self._get_element_path(prop)
     default_path = prop_path.replace('->', '.')
     for seg in _DEFAULT_LEAFREFS:
         if all((default_path.endswith(seg), is_reference_prop(prop))):
             self._add_default_reference_stmts(prop)
Esempio n. 2
0
 def _add_default_reference_stmts(self, prop):
     """Add default reference statements."""
     refprop, refclass = self._get_reference_prop(prop)
     path = self._get_element_path(prop)
     refpath = self._get_element_path(refprop)
     self.stmts.add_adjustment(path, refpath)
     if is_reference_prop(refprop):
         self._add_default_reference_stmts(refprop)
Esempio n. 3
0
 def _add_prop_stmts(self, prop):
     """Add property statements."""
     if is_config_prop(prop):
         if is_reference_prop(prop):
             self._add_reference_stmts(prop)
             self._add_requisite_prop_stmts(prop)
         elif is_terminal_prop(prop):
             self._add_terminal_prop_stmts(prop)
Esempio n. 4
0
 def _add_default_reference_stmts(self, prop):
     """Add default reference statements."""
     refprop, refclass = self._get_reference_prop(prop)
     path = self._get_element_path(prop)
     refpath = self._get_element_path(refprop)
     self.stmts.add_adjustment(path, refpath)
     if is_reference_prop(refprop):
         self._add_default_reference_stmts(refprop)
Esempio n. 5
0
 def _print_test_case_compare(self, clazz):
     self._print_logging('Comparing leaf/leaf-lists...')
     for prop in clazz.properties():
         if is_reference_prop(prop) or is_terminal_prop(prop):
             # unable to compare empty
             # read object will not be assigned to Empty() automatically
             if not is_empty_prop(prop):
                 self._print_compare_stmt(prop)
Esempio n. 6
0
 def _add_default_stmts(self, prop):
     """Add default statements."""
     prop_path = self._get_element_path(prop)
     default_path = prop_path.replace('->', '.')
     for seg in _DEFAULT_LEAFREFS:
         if all((default_path.endswith(seg),
                 is_reference_prop(prop))):
             self._add_default_reference_stmts(prop)
Esempio n. 7
0
 def _add_prop_stmts(self, prop):
     """Add property statements."""
     if is_config_prop(prop):
         if is_reference_prop(prop):
             self._add_reference_stmts(prop)
             self._add_requisite_prop_stmts(prop)
         elif is_terminal_prop(prop):
             self._add_terminal_prop_stmts(prop)
Esempio n. 8
0
 def _print_test_case_compare(self, clazz):
     self._print_logging('Comparing leaf/leaf-lists...')
     for prop in clazz.properties():
         if is_reference_prop(prop) or is_terminal_prop(prop):
             # unable to compare empty
             # read object will not be assigned to Empty() automatically
             if not is_empty_prop(prop):
                 self._print_compare_stmt(prop)
Esempio n. 9
0
 def _add_reference_stmt(self, prop, refprop):
     """Add reference statements."""
     path = self._get_element_path(prop)
     refpath = self._get_element_path(refprop)
     value = self._get_value(refprop)
     if is_leaflist_prop(prop):
         self.stmts.add_leaflist_append(path, refpath)
     else:
         self.stmts.add_reference(path, refpath)
     if is_reference_prop(refprop):
         prop = refprop
         refprop, _ = self._get_reference_prop(prop)
         self._add_reference_stmt(prop, refprop)
     else:
         self._add_requisite_stmts(refprop.owner)
         self.stmts.add_assignment(refpath, value)
Esempio n. 10
0
 def _add_reference_stmt(self, prop, refprop):
     """Add reference statements."""
     path = self._get_element_path(prop)
     refpath = self._get_element_path(refprop)
     value = self._get_value(refprop)
     if is_leaflist_prop(prop):
         self.stmts.add_leaflist_append(path, refpath)
     else:
         self.stmts.add_reference(path, refpath)
     if is_reference_prop(refprop):
         prop = refprop
         refprop, _ = self._get_reference_prop(prop)
         self._add_reference_stmt(prop, refprop)
     else:
         self._add_requisite_stmts(refprop.owner)
         self.stmts.add_assignment(refpath, value)
Esempio n. 11
0
    def _add_leafref_path_key_stmts(self, prop):
        """Add leafref statements if the reference path has predicate needs
        to be set.
        """
        orig_refstmt, _ = prop.stmt.i_leafref_ptr
        orig_refprop = orig_refstmt.i_property
        path_type_spec = prop.stmt.i_leafref
        if path_type_spec is None:
            return
        plist = path_type_spec.i_path_list
        _, pspec_list, _, _ = path_type_spec.path_spec
        if len(pspec_list) > len(plist):
            idx = 0
            for _, pstmt in plist:
                idx += 1
                pspec, pspec_list = pspec_list[0], pspec_list[1:]
                if pstmt.keyword == 'list':
                    if len(pspec) == 4 and pspec[0] == 'predicate':
                        pspec, pspec_list = pspec_list[0], pspec_list[1:]
                        _, identifier, up, dn = pspec
                        if up == 0:
                            # absolute path
                            continue

                        path_prop = self._get_path_predicate_prop(prop, up, dn)
                        # need to adjust value assigned according to predicate
                        if is_reference_prop(path_prop):
                            path = self._get_element_path(orig_refprop,
                                                          length=idx)
                            if isinstance(identifier, tuple):
                                _, identifier = identifier
                            path = self.path_sep.join([path, identifier])
                            value = self._get_element_path(path_prop)
                            self.stmts.add_adjustment(path, value)
                        elif is_terminal_prop(path_prop):
                            self._add_terminal_prop_stmts(path_prop)
Esempio n. 12
0
    def _add_leafref_path_key_stmts(self, prop):
        """Add leafref statements if the reference path has predicate needs
        to be set.
        """
        orig_refstmt, _ = prop.stmt.i_leafref_ptr
        orig_refprop = orig_refstmt.i_property
        path_type_spec = prop.stmt.i_leafref
        if path_type_spec is None:
            return
        plist = path_type_spec.i_path_list
        _, pspec_list, _, _ = path_type_spec.path_spec
        if len(pspec_list) > len(plist):
            idx = 0
            for _, pstmt in plist:
                idx += 1
                pspec, pspec_list = pspec_list[0], pspec_list[1:]
                if pstmt.keyword == 'list':
                    if len(pspec) == 4 and pspec[0] == 'predicate':
                        pspec, pspec_list = pspec_list[0], pspec_list[1:]
                        _, identifier, up, dn = pspec
                        if up == 0:
                            # absolute path
                            continue

                        path_prop = self._get_path_predicate_prop(prop, up, dn)
                        # need to adjust value assigned according to predicate
                        if is_reference_prop(path_prop):
                            path = self._get_element_path(orig_refprop,
                                                          length=idx)
                            if isinstance(identifier, tuple):
                                _, identifier = identifier
                            path = self.path_sep.join([path, identifier])
                            value = self._get_element_path(path_prop)
                            self.stmts.add_adjustment(path, value)
                        elif is_terminal_prop(path_prop):
                            self._add_terminal_prop_stmts(path_prop)