def afterSetUp(self):
        super(TestObjects, self).afterSetUp()

        map(self.dmd.Devices.createOrganizer, (DEVICECLASS_DEPENDENCIES))
        map(self.dmd.Events.createOrganizer, (EVENTCLASS_DEPENDENCIES))
        map(self.dmd.Reports.createOrganizer, (REPORTCLASS_DEPENDENCIES))

        self.dmd.REQUEST = None

        from Products.ZenRelations.ImportRM import NoLoginImportRM
        im = NoLoginImportRM(self.app)

        for zenpack in ZENPACK_DEPENDENCIES:
            __import__(zenpack)
            zp_module = sys.modules[zenpack]

            objects_file = '%s/objects/objects.xml' % zp_module.__path__[0]

            if os.path.isfile(objects_file):
                log.info('Loading objects for %s.', zenpack)
                im.loadObjectFromXML(objects_file)

        # Required to prevent erroring out when trying to define viewlets in
        # ../browser/configure.zcml.
        import zope.viewlet
        zcml.load_config('meta.zcml', zope.viewlet)

        import ZenPacks.zenoss.CloudStack
        zcml.load_config('configure.zcml', ZenPacks.zenoss.CloudStack)
Beispiel #2
0
    def afterSetUp(self):
        super(TestObjects, self).afterSetUp()

        map(self.dmd.Devices.createOrganizer, (DEVICECLASS_DEPENDENCIES))
        map(self.dmd.Events.createOrganizer, (EVENTCLASS_DEPENDENCIES))
        map(self.dmd.Reports.createOrganizer, (REPORTCLASS_DEPENDENCIES))

        self.dmd.REQUEST = None

        from Products.ZenRelations.ImportRM import NoLoginImportRM
        im = NoLoginImportRM(self.app)

        for zenpack in ZENPACK_DEPENDENCIES:
            __import__(zenpack)
            zp_module = sys.modules[zenpack]

            objects_file = '%s/objects/objects.xml' % zp_module.__path__[0]

            if os.path.isfile(objects_file):
                log.info('Loading objects for %s.', zenpack)
                im.loadObjectFromXML(objects_file)

        # Required to prevent erroring out when trying to define viewlets in
        # ../browser/configure.zcml.
        import zope.viewlet
        zcml.load_config('meta.zcml', zope.viewlet)

        import ZenPacks.zenoss.CloudStack
        zcml.load_config('configure.zcml', ZenPacks.zenoss.CloudStack)
 def testImportSkip(self):
     """test skipping vmware relations that are not relevant to the
     standard device class"""
     self.failIf(hasattr(self.dmd.Devices, 'dev'))
     im = NoLoginImportRM(self.dmd.Devices)
     infile = StringIO.StringIO(objwithskip)
     im.loadObjectFromXML(infile)
     self.assert_(self.dmd.Devices.dev)
     self.failIf(hasattr(self.dmd.Devices.dev, 'guestDevices'))
Beispiel #4
0
            def devImport(xmlfile):
                """
                Load a new device from a file.

                @param xmlfile: file type object
                @type xmlfile: file type object
                """
                im = NoLoginImportRM(target.devices)
                im.loadObjectFromXML(xmlfile)
                im.processLinks()
 def testImportObject(self):
     "test importing rm without properties"
     self.failIf(hasattr(self.app, 'loc'))
     self.failIf(hasattr(self.app, 'dev'))
     im = NoLoginImportRM(self.app)
     infile = StringIO.StringIO(objnoprops)
     im.loadObjectFromXML(infile)
     self.assert_(self.app.loc)
     self.assertEqual('loc', self.app.loc.id)
     self.assertEqual('Products.ZenRelations.tests.TestSchema',
                      self.app.loc.__module__)
     self.assertEqual('Location', self.app.loc.__class__.__name__)
     self.failIf(hasattr(self.app, 'dev'))
 def testImportProperties(self):
     "test importing rm with properties"
     self.failIf(hasattr(self.app, 'loc'))
     self.failIf(hasattr(self.app, 'dev'))
     im = NoLoginImportRM(self.app)
     infile = StringIO.StringIO(objwithprops)
     im.loadObjectFromXML(infile)
     self.assert_(self.app.dev)
     self.assertEqual('dev', self.app.dev.id)
     self.assertEqual('Products.ZenRelations.tests.TestSchema',
                      self.app.dev.__module__)
     self.assertEqual('Device', self.app.dev.__class__.__name__)
     self.assertEqual(0, self.app.dev.pingStatus)
     self.failIf(hasattr(self.app, 'loc'))
 def testImportToOne(self):
     "test importing rm with to-one relationship"
     self.failIf(hasattr(self.app, 'dev'))
     loc = self.build(self.app, Location, "loc")
     self.assert_(hasattr(self.app, 'loc'))
     im = NoLoginImportRM(self.app)
     xml = "<objects>" + objwithtoone + "</objects>"
     im.loadObjectFromXML(StringIO.StringIO(xml))
     self.assert_(self.app.dev)
     self.assert_(self.app.loc)
     self.assert_(self.app.dev.location())
     self.assertEqual('loc', self.app.dev.location().id)
     self.assertEqual(1, len(self.app.loc.devices()))
     self.assert_('dev', self.app.loc.devices()[0].id)
 def _persistDataSource(self, datasource):
     """after switching the __class__ attribute, call this function to make the
     change permanent"""
     id = datasource.id
     from cStringIO import StringIO
     xml_file = StringIO()
     datasource.exportXml(xml_file)
     parent = datasource.getPrimaryParent()
     parent._delObject(datasource.id)
     from Products.ZenRelations.ImportRM import NoLoginImportRM
     xml_importer = NoLoginImportRM(parent)
     xml_file.seek(0)
     xml_importer.loadObjectFromXML(xml_file)
     xml_importer.processLinks()
     ds = parent._getOb(id)
     notify(IndexingEvent(ds))
Beispiel #9
0
    def afterSetUp(self):
        super(TestPack, self).afterSetUp()
        map(self.dmd.Devices.createOrganizer, (DEVICECLASS_DEPENDENCIES))

        self.dmd.REQUEST = None

        from Products.ZenRelations.ImportRM import NoLoginImportRM
        im = NoLoginImportRM(self.app)

        for zenpack in ZENPACK_DEPENDENCIES:
            __import__(zenpack)
            zp_module = sys.modules[zenpack]

            objects_file = '%s/objects/objects.xml' % zp_module.__path__[0]

            if os.path.isfile(objects_file):
                log.info('Loading objects for %s.', zenpack)
                im.loadObjectFromXML(objects_file)

        self.dc = self.dmd.Devices.Server.WebLogic
Beispiel #10
0
            def devImport(xmlfile):
                """
                Load a new device from a file.

                @param xmlfile: file type object
                @type xmlfile: file type object
                """
                im = NoLoginImportRM(target.devices)
                im.loadObjectFromXML(xmlfile)
                im.processLinks()
Beispiel #11
0
 def _persistDataSource(self, datasource):
     """after switching the __class__ attribute, call this function to make the
     change permanent"""
     id = datasource.id
     from cStringIO import StringIO
     xml_file = StringIO()
     datasource.exportXml(xml_file)
     parent = datasource.getPrimaryParent()
     parent._delObject(datasource.id)
     from Products.ZenRelations.ImportRM import NoLoginImportRM
     xml_importer = NoLoginImportRM(parent)
     xml_file.seek(0)
     xml_importer.loadObjectFromXML(xml_file)
     xml_importer.processLinks()
     ds = parent._getOb(id)
     notify(IndexingEvent(ds))