示例#1
0
 def tomof(self):
     mof = 'Qualifier %s : %s' % (self.name, self.type)
     if self.is_array:
         mof += '['
         if self.array_size is not None:
             mof += str(self.array_size)
         mof += ']'
     if self.value is not None:
         if isinstance(self.value, list):
             mof += '{'
             mof+= ', '.join([atomic_to_cim_xml(tocimobj(self.type, x)) \
                     for x in self.value])
             mof += '}'
         else:
             mof += ' = %s' % atomic_to_cim_xml(
                 tocimobj(self.type, self.value))
     mof += ',\n    '
     mof += 'Scope('
     mof += ', '.join([x.lower()
                       for x, y in self.scopes.items() if y]) + ')'
     if not self.overridable and not self.tosubclass \
             and not self.toinstance and not self.translatable:
         mof += ';'
         return mof
     mof += ',\n    Flavor('
     mof += self.overridable and 'EnableOverride' or 'DisableOverride'
     mof += ', '
     mof += self.tosubclass and 'ToSubclass' or 'Restricted'
     if self.toinstance:
         mof += ', ToInstance'
     if self.translatable:
         mof += ', Translatable'
     mof += ');'
     return mof
示例#2
0
 def tomof(self):
     mof = 'Qualifier %s : %s' % (self.name, self.type)
     if self.is_array:
         mof+= '['
         if self.array_size is not None:
             mof+= str(self.array_size)
         mof+= ']'
     if self.value is not None:
         if isinstance(self.value, list):
             mof+= '{'
             mof+= ', '.join([atomic_to_cim_xml(tocimobj(self.type, x)) \
                     for x in self.value])
             mof+= '}'
         else:
             mof+= ' = %s' % atomic_to_cim_xml(tocimobj(self.type,self.value))
     mof+= ',\n    '
     mof+= 'Scope('
     mof+= ', '.join([x.lower() for x, y in self.scopes.items() if y]) + ')'
     if not self.overridable and not self.tosubclass \
             and not self.toinstance and not self.translatable:
         mof+= ';'
         return mof
     mof+= ',\n    Flavor('
     mof+= self.overridable and 'EnableOverride' or 'DisableOverride'
     mof+= ', '
     mof+= self.tosubclass and 'ToSubclass' or 'Restricted'
     if self.toinstance:
         mof+= ', ToInstance'
     if self.translatable:
         mof+= ', Translatable'
     mof+= ');'
     return mof
示例#3
0
    def tocimxml(self):

        if self.is_array:

            value = self.value
            if value is not None:
                if value:
                    if self.embedded_object is not None:
                        value = [v.tocimxml().toxml() for v in value]
                value = VALUE_ARRAY(
                    [VALUE(atomic_to_cim_xml(v)) for v in value])

            return PROPERTY_ARRAY(
                self.name,
                self.type,
                value,
                self.array_size,
                self.class_origin,
                self.propagated,
                qualifiers=[q.tocimxml() for q in self.qualifiers.values()],
                embedded_object=self.embedded_object)

        elif self.type == 'reference':

            value_reference = None
            if self.value is not None:
                value_reference = VALUE_REFERENCE(self.value.tocimxml())

            return PROPERTY_REFERENCE(
                self.name,
                value_reference,
                reference_class=self.reference_class,
                class_origin=self.class_origin,
                propagated=self.propagated,
                qualifiers=[q.tocimxml() for q in self.qualifiers.values()])

        else:
            value = self.value
            if value is not None:
                if self.embedded_object is not None:
                    value = value.tocimxml().toxml()
                else:
                    value = atomic_to_cim_xml(value)
                value = VALUE(value)

            return PROPERTY(
                self.name,
                self.type,
                value,
                class_origin=self.class_origin,
                propagated=self.propagated,
                qualifiers=[q.tocimxml() for q in self.qualifiers.values()],
                embedded_object=self.embedded_object)
示例#4
0
    def tocimxml(self):

        if self.is_array:

            value = self.value
            if value is not None:
                if value:
                    if self.embedded_object is not None:
                        value = [v.tocimxml().toxml() for v in value]
                value = VALUE_ARRAY([VALUE(atomic_to_cim_xml(v)) for v in value])

            return PROPERTY_ARRAY(
                self.name,
                self.type,
                value,
                self.array_size,
                self.class_origin,
                self.propagated,
                qualifiers = [q.tocimxml() for q in self.qualifiers.values()],
                embedded_object = self.embedded_object)

        elif self.type == 'reference':

            value_reference = None
            if self.value is not None:
                value_reference = VALUE_REFERENCE(self.value.tocimxml())

            return PROPERTY_REFERENCE(
                self.name,
                value_reference,
                reference_class = self.reference_class,
                class_origin = self.class_origin,
                propagated = self.propagated,
                qualifiers = [q.tocimxml() for q in self.qualifiers.values()])

        else:
            value = self.value
            if value is not None:
                if self.embedded_object is not None:
                    value = value.tocimxml().toxml()
                else:
                    value = atomic_to_cim_xml(value)
                value = VALUE(value)

            return PROPERTY(
                self.name,
                self.type,
                value,
                class_origin = self.class_origin,
                propagated = self.propagated,
                qualifiers = [q.tocimxml() for q in self.qualifiers.values()],
                embedded_object = self.embedded_object)
示例#5
0
 def paramvalue(obj):
     """Return a cim_xml node to be used as the value for a
     parameter."""
     if isinstance(obj, (datetime, timedelta)):
         obj = cim_types.CIMDateTime(obj)
     if isinstance(obj, (cim_types.CIMType, bool, StringTypes)):
         return cim_xml.VALUE(cim_types.atomic_to_cim_xml(obj))
     if isinstance(obj, (CIMClassName, CIMInstanceName)):
         return cim_xml.VALUE_REFERENCE(obj.tocimxml())
     if isinstance(obj, (CIMClass, CIMInstance)):
         return cim_xml.VALUE(obj.tocimxml().toxml())
     if isinstance(obj, list):
         if obj and isinstance(obj[0], (CIMClassName, CIMInstanceName)):
             return cim_xml.VALUE_REFARRAY([paramvalue(x) for x in obj])
         return cim_xml.VALUE_ARRAY([paramvalue(x) for x in obj])
     raise TypeError('Unsupported parameter type "%s"' % type(obj))