Esempio n. 1
0
    def to_managed_object(self):
        """
        Method creates and returns an object of ManagedObject class using the class_id and information from the
        Generic managed object.
        """
        from Imc import class_factory

        cln = ImcUtils.word_u(self._class_id)
        mo = class_factory(cln)
        if mo and isinstance(mo, ManagedObject) == True:
            meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(self._class_id)
            mo.set_handle(self._handle)
            for prop in self.properties:
                if ImcUtils.word_u(prop) in CoreUtils.get_property_list(meta_class_id):
                    mo.set_attr(ImcUtils.word_u(prop), self.properties[prop])
                else:
                    ImcUtils.write_imc_warning("Property %s Not Exist in MO %s" %(ImcUtils.word_u(prop), meta_class_id))

            if len(self._child):
                for child in self._child:
                    moch = child.to_managed_object()
                    mo.child.append(moch)
            return mo
        else:
            return None
Esempio n. 2
0
    def to_managed_object(self):
        """
        Method creates and returns an object of ManagedObject class using the class_id and information from the
        Generic managed object.
        """
        from Imc import class_factory

        cln = ImcUtils.word_u(self._class_id)
        mo = class_factory(cln)
        if mo and isinstance(mo, ManagedObject) == True:
            meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(
                self._class_id)
            mo.set_handle(self._handle)
            for prop in self.properties:
                if ImcUtils.word_u(prop) in CoreUtils.get_property_list(
                        meta_class_id):
                    mo.set_attr(ImcUtils.word_u(prop), self.properties[prop])
                else:
                    ImcUtils.write_imc_warning(
                        "Property %s Not Exist in MO %s" %
                        (ImcUtils.word_u(prop), meta_class_id))

            if len(self._child):
                for child in self._child:
                    moch = child.to_managed_object()
                    mo.child.append(moch)
            return mo
        else:
            return None
Esempio n. 3
0
    def load_from_xml(self, element, handle):
        """ Method creates the object from the XML representation of the an external method object. """
        from Imc import class_factory
        self.set_handle(handle)
        if element.attrib:
            for attr_name, attr_value in element.attrib.iteritems():
                attr = ImcUtils.word_u(attr_name)
                if attr in CoreUtils.get_property_list(self._class_id):
                    at_meta = CoreUtils.get_method_property_meta(self._class_id, attr)
                    if at_meta.io == "Input" or at_meta.is_complex_type:
                        continue
                    self.set_attr(attr, str(attr_value))
                elif attr_name in _EXTERNAL_METHOD_ATTRS:
                    self.set_attr(_EXTERNAL_METHOD_ATTRS[attr_name], str(attr_value))

        child_elements = element.getchildren()
        if child_elements:
            for child_element in child_elements:
                if not ET.iselement(child_element) :
                    continue
        
                cln = ImcUtils.word_u(child_element.tag)
                if cln in CoreUtils.get_property_list(self._class_id):
                    prop_meta = CoreUtils.get_method_property_meta(self._class_id, cln)
                    if prop_meta.io == "Output" and prop_meta.is_complex_type:
                        child = class_factory(prop_meta.field_type)
                        if child != None:
                            self.set_attr(cln, child)
                            child.load_from_xml(child_element, handle)
Esempio n. 4
0
    def load_from_xml(self, element, handle):
        """ Method creates the object from the XML representation of the an external method object. """
        from Imc import class_factory
        self.set_handle(handle)
        if element.attrib:
            for attr_name, attr_value in element.attrib.iteritems():
                attr = ImcUtils.word_u(attr_name)
                if attr in CoreUtils.get_property_list(self._class_id):
                    at_meta = CoreUtils.get_method_property_meta(
                        self._class_id, attr)
                    if at_meta.io == "Input" or at_meta.is_complex_type:
                        continue
                    self.set_attr(attr, str(attr_value))
                elif attr_name in _EXTERNAL_METHOD_ATTRS:
                    self.set_attr(_EXTERNAL_METHOD_ATTRS[attr_name],
                                  str(attr_value))

        child_elements = element.getchildren()
        if child_elements:
            for child_element in child_elements:
                if not ET.iselement(child_element):
                    continue

                cln = ImcUtils.word_u(child_element.tag)
                if cln in CoreUtils.get_property_list(self._class_id):
                    prop_meta = CoreUtils.get_method_property_meta(
                        self._class_id, cln)
                    if prop_meta.io == "Output" and prop_meta.is_complex_type:
                        child = class_factory(prop_meta.field_type)
                        if child != None:
                            self.set_attr(cln, child)
                            child.load_from_xml(child_element, handle)