示例#1
0
    def afterSetUp(self):
        super(TestLegacyCatalogAdapters, self).afterSetUp()
        self.global_catalog = LegacyCatalogAdapter(self.dmd, "global_catalog")
        self.device_catalog = LegacyCatalogAdapter(self.dmd.Devices,
                                                   "deviceSearch")
        self.layer2_catalog = LegacyCatalogAdapter(self.dmd, "layer2_catalog")
        self.layer3_catalog = LegacyCatalogAdapter(self.dmd, "layer3_catalog")
        self.ip_catalog = LegacyCatalogAdapter(self.dmd.Networks, "ipSearch")

        self.n_devices = 5
        self.devices = {}
        for dev_id in xrange(self.n_devices):
            dev = MockDevice()
            dev.device_class = self.dmd.Devices.createOrganizer(
                DEVICE_CLASS.format(dev_id))
            dev.location = self.dmd.Locations.createOrganizer(
                LOCATION.format(dev_id))
            dev.device = dev.device_class.createInstance(DEVICE.format(dev_id))
            dev.device.setLocation("/".join(
                dev.location.getPrimaryPath())[10:])
            iface_name = 'eth{}'.format(dev_id)
            manage_addIpInterface(dev.device.os.interfaces, iface_name, True)
            iface = dev.device.os.interfaces._getOb(iface_name)
            iface._setPropValue('macaddress', MAC.format(dev_id))
            iface.addIpAddress(IP.format(dev_id, dev_id))
            dev.ip = iface.ipaddresses()[0]
            dev.device.setManageIp(dev.ip.id)
            dev.interface = iface
            self.devices[dev_id] = dev
    def afterSetUp(self):
        super(TestLegacyCatalogAdapters, self).afterSetUp()
        self.global_catalog = LegacyCatalogAdapter(self.dmd, "global_catalog")
        self.device_catalog = LegacyCatalogAdapter(self.dmd.Devices, "deviceSearch")
        self.layer2_catalog = LegacyCatalogAdapter(self.dmd, "layer2_catalog")
        self.layer3_catalog = LegacyCatalogAdapter(self.dmd, "layer3_catalog")
        self.ip_catalog     = LegacyCatalogAdapter(self.dmd.Networks, "ipSearch")

        self.n_devices = 5
        self.devices = {}
        for dev_id in xrange(self.n_devices):
            dev = MockDevice()
            dev.device_class = self.dmd.Devices.createOrganizer(DEVICE_CLASS.format(dev_id))
            dev.location = self.dmd.Locations.createOrganizer(LOCATION.format(dev_id))
            dev.device = dev.device_class.createInstance(DEVICE.format(dev_id))
            dev.device.setLocation("/".join(dev.location.getPrimaryPath())[10:])
            iface_name = 'eth{}'.format(dev_id)
            manage_addIpInterface(dev.device.os.interfaces, iface_name, True)
            iface = dev.device.os.interfaces._getOb(iface_name)
            iface._setPropValue('macaddress', MAC.format(dev_id))
            iface.addIpAddress(IP.format(dev_id, dev_id))
            dev.ip = iface.ipaddresses()[0]
            dev.device.setManageIp(dev.ip.id)
            dev.interface = iface
            self.devices[dev_id] = dev
示例#3
0
    def test_getManagedDevice(self):
        self._loadZenossData()

        host_device1 = self.dmd.Devices.createInstance('host_device1')
        host_device1.setManageIp('10.208.37.11')
        host_device1.setPerformanceMonitor('localhost')

        host_device2 = self.dmd.Devices.createInstance('host_device2')
        host_device2.setManageIp('12.34.56.78')
        host_device2.setPerformanceMonitor('localhost')

        from Products.ZenModel.IpInterface import manage_addIpInterface
        manage_addIpInterface(host_device2.os.interfaces, 'eth0', False)
        eth0 = host_device2.os.interfaces._getOb('eth0')
        eth0.setIpAddresses(['10.208.37.12/24'])

        zone = self.d.zones._getOb('zone1')
        pod = zone.pods._getOb('pod1')
        cluster = pod.clusters._getOb('cluster1')

        # Test finding host device by manageIp.
        info1 = IInfo(cluster.hosts._getOb('host1'))
        self.assertEquals(info1.managed_device.id, 'host_device1')

        # Test finding host by interface IP.
        info2 = IInfo(cluster.hosts._getOb('host5'))
        self.assertEquals(info2.managed_device.id, 'host_device2')
示例#4
0
 def _linkDevices(self, devs):
     subnet = self._getSubnet()
     for i in devs:
         dev = devs[i]
         iid = self.globalInt.next()
         manage_addIpInterface(dev.os.interfaces, 'eth%d' % iid, True)
         iface = dev.os.interfaces._getOb('eth%d' % iid)
         iface.addIpAddress(subnet.next())
示例#5
0
 def afterSetUp(self):
     super(TestLayer2Linking, self).afterSetUp()
     self.dev = self.dmd.Devices.createInstance("testdev")
     manage_addIpInterface(self.dev.os.interfaces, 'eth0', True)
     self.iface = self.dev.os.interfaces._getOb('eth0')
     self.mac = '00:11:22:33:44:55'
     self.iface._setPropValue('macaddress', self.mac)
     self.catalog = IModelCatalogTool(self.dmd).layer2
示例#6
0
 def _linkDevices(self, devs):
     subnet = self._getSubnet()
     for i in devs:
         dev = devs[i]
         iid = self.globalInt.next()
         manage_addIpInterface(dev.os.interfaces, 'eth%d'%iid, True)
         iface = dev.os.interfaces._getOb('eth%d'%iid)
         iface.addIpAddress(subnet.next())
示例#7
0
 def afterSetUp(self):
     super(TestLayer2Linking, self).afterSetUp()
     self.dev = self.dmd.Devices.createInstance("testdev")
     manage_addIpInterface(self.dev.os.interfaces, 'eth0', True)
     self.iface = self.dev.os.interfaces._getOb('eth0')
     self.mac = '00:11:22:33:44:55'
     self.iface._setPropValue('macaddress', self.mac)
     self.catalog = IModelCatalogTool(self.dmd).layer2
示例#8
0
    def afterSetUp(self):
        super(TestComponentIndexing, self).afterSetUp()
        self.devcat = self.dmd.Devices.deviceSearch
        self.layer2cat = self.dmd.ZenLinkManager._getCatalog(layer=2)
        self.layer3cat = self.dmd.ZenLinkManager._getCatalog(layer=3)

        self.devclass = self.dmd.Devices.createOrganizer(DEVCLASS)
        self.devclass2 = self.dmd.Devices.createOrganizer(DEVCLASS)

        # Control
        dummydev =  self.dmd.Devices.createInstance('dummydev')

        self.dev = self.devclass.createInstance('testdev')

        manage_addIpInterface(self.dev.os.interfaces, 'eth0', True)
        self.iface = self.dev.os.interfaces._getOb('eth0')
        self.iface._setPropValue('macaddress', MAC)
        self.iface.addIpAddress(IPADDR)
        self.ipaddress = self.iface.ipaddresses()[0]
        self.net = self.dmd.Networks.getNet(NET)
        
        manage_addWinService(self.dev.os.winservices,'wuauserv','test service')
        self.winService = self.dev.os.winservices._getOb('wuauserv')
    def afterSetUp(self):
        super(TestComponentIndexing, self).afterSetUp()
        self.model_catalog = IModelCatalogTool(self.dmd.Devices)
        self.layer2cat = self.model_catalog.layer2
        self.layer3cat = self.model_catalog.layer3

        self.devclass = self.dmd.Devices.createOrganizer(DEVCLASS)
        self.devclass2 = self.dmd.Devices.createOrganizer(DEVCLASS)

        # Control
        dummydev =  self.dmd.Devices.createInstance('dummydev')

        self.dev = self.devclass.createInstance('testdev')

        manage_addIpInterface(self.dev.os.interfaces, 'eth0', True)
        self.iface = self.dev.os.interfaces._getOb('eth0')
        self.iface._setPropValue('macaddress', MAC)
        self.iface.addIpAddress(IPADDR)
        self.ipaddress = self.iface.ipaddresses()[0]
        self.net = self.dmd.Networks.getNet(NET)
        
        manage_addWinService(self.dev.os.winservices,'wuauserv','test service')
        self.winService = self.dev.os.winservices._getOb('wuauserv')
示例#10
0
    def testzDrawMapLinksProperty(self):
        devs = self._makeDevices(6)

        devs[0].setLocation('/A')
        devs[1].setLocation('/A')
        devs[2].setLocation('/B')
        devs[3].setLocation('/C')
        devs[4].setLocation('/D')
        devs[5].setLocation('/A')

        manage_addIpInterface(devs[0].os.interfaces, 'eth0', True)
        iface0 = devs[0].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[1].os.interfaces, 'eth0', True)
        iface1 = devs[1].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[2].os.interfaces, 'eth0', True)
        iface2 = devs[2].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[3].os.interfaces, 'eth0', True)
        iface3 = devs[3].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[4].os.interfaces, 'eth0', True)
        iface4 = devs[4].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[5].os.interfaces, 'eth0', True)
        iface5 = devs[5].os.interfaces._getOb('eth0')

        iface0.addIpAddress('192.168.254.9/30')
        iface2.addIpAddress('192.168.254.10/30')

        iface1.addIpAddress('192.168.254.5/30')
        iface3.addIpAddress('192.168.254.6/30')

        iface4.addIpAddress('192.168.254.1/30')
        iface5.addIpAddress('192.168.254.2/30')

        nononet = self.dmd.Networks.getNet('192.168.254.8')
        nononet.zDrawMapLinks = False

        links = self.dmd.ZenLinkManager.getChildLinks(self.dmd.Locations)
        links = json.loads(links)
        self.assertEqual(len(links), 2)
示例#11
0
    def testSlash30Nets(self, getFacade):
        devs = self._makeDevices(6)

        devs[0].setLocation('/A')
        devs[1].setLocation('/A')
        devs[2].setLocation('/B')
        devs[3].setLocation('/C')
        devs[4].setLocation('/D')
        devs[5].setLocation('/A')

        manage_addIpInterface(devs[0].os.interfaces, 'eth0', True)
        iface0 = devs[0].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[1].os.interfaces, 'eth0', True)
        iface1 = devs[1].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[2].os.interfaces, 'eth0', True)
        iface2 = devs[2].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[3].os.interfaces, 'eth0', True)
        iface3 = devs[3].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[4].os.interfaces, 'eth0', True)
        iface4 = devs[4].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[5].os.interfaces, 'eth0', True)
        iface5 = devs[5].os.interfaces._getOb('eth0')

        iface0.addIpAddress('192.168.254.9/30')
        iface2.addIpAddress('192.168.254.10/30')

        iface1.addIpAddress('192.168.254.5/30')
        iface3.addIpAddress('192.168.254.6/30')

        iface4.addIpAddress('192.168.254.1/30')
        iface5.addIpAddress('192.168.254.2/30')

        links = self.dmd.ZenLinkManager.getChildLinks(self.dmd.Locations)
        links = json.loads(links)
        self.assertEqual(len(links), 3)
示例#12
0
 def testints(self):
     for i in range(self.nints):
         intname = "tint%03d" % i
         manage_addIpInterface(self.dc, intname)
示例#13
0
 def create(self):
     device = self.getdev()
     for i in range(self.nints):
         intname = "hme%03d" % i
         manage_addIpInterface(device.interfaces, intname)
示例#14
0
    def testzDrawMapLinksProperty(self):
        devs = self._makeDevices(6)

        devs[0].setLocation('/A')
        devs[1].setLocation('/A')
        devs[2].setLocation('/B')
        devs[3].setLocation('/C')
        devs[4].setLocation('/D')
        devs[5].setLocation('/A')

        manage_addIpInterface(devs[0].os.interfaces, 'eth0', True)
        iface0 = devs[0].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[1].os.interfaces, 'eth0', True)
        iface1 = devs[1].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[2].os.interfaces, 'eth0', True)
        iface2 = devs[2].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[3].os.interfaces, 'eth0', True)
        iface3 = devs[3].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[4].os.interfaces, 'eth0', True)
        iface4 = devs[4].os.interfaces._getOb('eth0')
        manage_addIpInterface(devs[5].os.interfaces, 'eth0', True)
        iface5 = devs[5].os.interfaces._getOb('eth0')

        iface0.addIpAddress('192.168.254.9/30')
        iface2.addIpAddress('192.168.254.10/30')

        iface1.addIpAddress('192.168.254.5/30')
        iface3.addIpAddress('192.168.254.6/30')

        iface4.addIpAddress('192.168.254.1/30')
        iface5.addIpAddress('192.168.254.2/30')

        nononet = self.dmd.Networks.getNet('192.168.254.8')
        nononet.zDrawMapLinks = False

        links = self.dmd.ZenLinkManager.getChildLinks(self.dmd.Locations)
        links = json.loads(links)
        self.assertEqual(len(links), 2)
 def testints(self):
     for i in range(self.nints):
         intname = "tint%03d" % i
         manage_addIpInterface(self.dc, intname)
 def create(self):
     device = self.getdev()
     for i in range(self.nints):
         intname = "hme%03d" % i
         manage_addIpInterface(device.interfaces, intname)