def __init__(self, element, doc):
        """ element: DOMElement
        """
        # super
        DataObject.__init__(self, element, doc)

        #Check for mount options
        #__mopt = element.getElementsByTagName(MountOptions.TAGNAME)
        #if len(__mopt):
        #    self.mountOptions=MountOptions(__mopt[0], doc)
        #else:
        #    __node=doc.createElement(MountOptions.TAGNAME)
        #    element.appendChild(__node)
        #    self.mountOptions=MountOptions(__node, doc)
        # FIXME Do we need all of them ?
        self.formattable=0
        self.checked = 0
        self.name = ""
        self.linuxnativefs = 0
        self.maxSizeMB = 8 * 1024 * 1024
        self.maxLabelChars = 16
        self.partedFileSystemType = None
        self.cmd_fsck=None
        self.cmd_mkfs=None
        self.copyable=True
        self.nomountpoint=False
        self.cmd_mount=CMD_MOUNT
        self.cmd_umount=CMD_UMOUNT
 def testBooleanAttribute(self):
     from comoonics.ComDataObject import DataObject
     print "Testing boolean"
     path="//device[@id='rootfs']"
     element=comoonics.XmlTools.evaluateXPath(path, self.doc)[0]
     obj=DataObject(element)
     print "%s.options: %s" %(path, obj.getAttribute("options"))
     result=obj.getAttributeBoolean("options")
     print "%s.optionsAsBoolean: '%s'" %(path, result)
     self.assertTrue(result, "AttributeBoolean(%s) should return True but returned %s" %("options", result))
    def __init__(self, *args):
        if len(args) != 2:
            raise RuntimeError("2 Arguments required")
        if not isinstance(args[1], Node):
            raise RuntimeError("1. Argument must be a xml.dom.Document")
        doc = args[1]
        if isinstance(args[0], Node):
            element = args[0]
        else:
            element = self.__create_element_from_parted(args[0], doc)

        DataObject.__init__(self, element, doc)
 def testQueryProperties(self):
     from comoonics.ComDataObject import DataObject
     _tmp1 = "name"
     _tmp2 = "gfs-node1"
     _tmp3 = "name"
     _tmp4 = "eth1"
     result=[ "MASTER=yes", "SLAVE=no", "DELAY=0" ]
     result.sort()
     _query='/cluster/clusternodes/clusternode[@'+_tmp1+'="'+_tmp2+'"]/com_info/eth[@'+_tmp3+'="'+_tmp4+'"]'
     propertieselement=self.clusterInfo.queryXml(_query)[0]
     properties=DataObject(propertieselement).getProperties().list().split("\n")
     properties.sort()
     self.assertEquals(properties, result, "%s==%s != %s" %(_query, properties, result))
    def __init__(self, testMethod="runTest"):
        import os.path
        import inspect
        super(test_DataObject, self).__init__(testMethod)


        #parse the document
        self.doc = comoonics.XmlTools.parseXMLFile(os.path.join(os.path.dirname(inspect.getfile(self.__class__)), "example_config.xml"))

        from comoonics.ComDataObject import DataObject
        self.obj=DataObject(self.doc.documentElement, self.doc)
 def __init__(self, *params):
     if len(params) == 2:
         DataObject.__init__(self, params[0], params[1])
     else:
         raise IndexError('Index out of range for LinuxVolumeManager constructor (%u)' % len(params))
     self.ondisk=False
 def __getattr__(self, value):
     if not self.isstatic(value):
         return self.query(value)
     else:
         return DataObject.__getattribute__(self, value)
 def __init__(self, element, doc=None):
     DataObject.__init__(self, element, doc)
 def __init__(self, element, doc):
     """
     Creates a new requirement instance
     """
     DataObject.__init__(self, element, doc)
     self.order=Requirement.PRE
 def __init__(self, element, doc):
     DataObject.__init__(self, element, doc)
     Requirements.__init__(self, element, doc)
class test_DataObject(unittest.TestCase):    

    def __init__(self, testMethod="runTest"):
        import os.path
        import inspect
        super(test_DataObject, self).__init__(testMethod)


        #parse the document
        self.doc = comoonics.XmlTools.parseXMLFile(os.path.join(os.path.dirname(inspect.getfile(self.__class__)), "example_config.xml"))

        from comoonics.ComDataObject import DataObject
        self.obj=DataObject(self.doc.documentElement, self.doc)

#    def testToString(self):
#        _str=""
#        result=self.obj.__str__()
#        self.assertEquals(str, result, "str(obj):%s != %s" %(_str, result))

    def testHasAttributeXYZ(self):
        attribute="xyz"
        print "Testing hasAttribute(%s)" %attribute
        if self.obj.hasAttribute(attribute):
            self.assert_("Found Attribute \"%s\"!! Should not happen!!!" %attribute)
        else:
            print "No Attribute \"%s\" available. (OK)" % attribute

    def testHasAttributeID(self):
        attribute="id"
        print "Testing hasAttribute(%s)" %attribute
        if self.obj.hasAttribute(attribute):
            print "Found Attribute \"%s\"!! (OK)" %attribute
        else:
            self.assert_("No Attribute \"%s\"!! Should not happen!!!" %attribute)

    def testGetAttributeXYZWDefault(self):
        attribute="xyz"
        default=""
        print "Testing getAttribute(%s, %s)" %(attribute, default)
        result=self.obj.getAttribute(attribute, default)
        self.assertEquals(result, default, "Attribute %s is not default %s but %s" %(attribute, result, default))

    def testGetAttributeIDDefault(self):
        attribute="id"
        default="bootfs"
        print "Testing getAttribute(%s, %s)" %(attribute, default)
        result=self.obj.getAttribute(attribute, default)
        self.assertEquals(result, default, "Attribute %s is not default %s but %s" %(attribute, result, default))

    def testGetAttributeXYZ(self):
        attribute="xyz"
        print "Testing getAttribute(%s)" %(attribute)
        try:
            result=self.obj.getAttribute(attribute)
            self.assert_("Found value for Attribute \"%s\": %s !!!Should not happen !!!" %(attribute, result))
        except:
            print "Exception %s caught (OK)" %sys.exc_value

    def testBooleanAttribute(self):
        from comoonics.ComDataObject import DataObject
        print "Testing boolean"
        path="//device[@id='rootfs']"
        element=comoonics.XmlTools.evaluateXPath(path, self.doc)[0]
        obj=DataObject(element)
        print "%s.options: %s" %(path, obj.getAttribute("options"))
        result=obj.getAttributeBoolean("options")
        print "%s.optionsAsBoolean: '%s'" %(path, result)
        self.assertTrue(result, "AttributeBoolean(%s) should return True but returned %s" %("options", result))
 def __init__(self, element, doc):
     DataObject.__init__(self, element, doc)
     Requirements.__init__(self, element, doc)
     self.modifications=list()
Beispiel #13
0
 def __getattr__(self, value):
     if not self.isstatic(value):
         return self.query(value)
     else:
         return DataObject.__getattribute__(self, value)
Beispiel #14
0
 def __init__(self, element, doc):
     DataObject.__init__(self, element, doc)
     Requirements.__init__(self, element, doc)
 def __init__(self, element, doc=None):
     DataObject.__init__(self, element, doc)
 def __init__(self, element, doc, *args, **kwds):
     DataObject.__init__(self, element, doc)
     Requirements.__init__(self, element, doc)