Permalink
Browse files

Include private IPs in managed guest lookup.

  • Loading branch information...
1 parent 83b78a8 commit 2e41a7a50447c643b9feea09762d74a6762c479e @cluther cluther committed Feb 22, 2012
Showing with 34 additions and 11 deletions.
  1. +16 −9 ZenPacks/zenoss/OpenStack/Server.py
  2. +17 −1 ZenPacks/zenoss/OpenStack/__init__.py
  3. +1 −1 setup.py
@@ -1,7 +1,7 @@
###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
-# Copyright (C) 2011, Zenoss Inc.
+# Copyright (C) 2011, 2012, Zenoss Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 or (at your
@@ -99,15 +99,22 @@ def getIconPath(self):
return '/++resource++openstack/img/openstack.png'
def getGuestDevice(self):
+ server_ips = []
+
if len(self.publicIps) > 0:
- for public_ip in self.publicIps:
- device = self.dmd.Devices.findDeviceByIdOrIp(public_ip)
- if device:
- return device
-
- ip = self.dmd.Networks.findIp(public_ip)
- if ip:
- return ip.device()
+ server_ips.extend(self.publicIps)
+
+ if len(self.privateIps) > 0:
+ server_ips.extend(self.privateIps)
+
+ for server_ip in server_ips:
+ device = self.dmd.Devices.findDeviceByIdOrIp(server_ip)
+ if device:
+ return device
+
+ ip = self.dmd.Networks.findIp(server_ip)
+ if ip:
+ return ip.device()
return None
@@ -1,7 +1,7 @@
###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
-# Copyright (C) 2011, Zenoss Inc.
+# Copyright (C) 2011, 2012, Zenoss Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 or (at your
@@ -61,10 +61,26 @@ def removePluginSymlink(self):
@monkeypatch('Products.ZenModel.Device.Device')
def getOpenStackServer(self):
+ device_ips = set()
+ if self.manageIp:
+ device_ips.add(self.manageIp)
+
+ for iface in self.os.interfaces():
+ for ip in iface.getIpAddresses():
+ device_ips.add(ip.split('/')[0])
+
catalog = ICatalogTool(self.dmd)
for record in catalog.search('ZenPacks.zenoss.OpenStack.Server.Server'):
server = record.getObject()
+ server_ips = set()
+
if server.publicIps:
+ server_ips.update(server.publicIps)
+
+ if server.privateIps:
+ server_ips.update(server.privateIps)
+
+ if server_ips.intersection(device_ips):
return server
# This would be much cleaner with the new "original" method support in
View
@@ -16,7 +16,7 @@
# or saved. Do not modify them directly here.
# NB: PACKAGES is deprecated
NAME = "ZenPacks.zenoss.OpenStack"
-VERSION = "1.1.1"
+VERSION = "1.1.2"
AUTHOR = "Zenoss"
LICENSE = ""
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.zenoss']

0 comments on commit 2e41a7a

Please sign in to comment.