Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cluther committed Aug 21, 2013
2 parents 8af08ff + b4c253c commit 2ee6753
Show file tree
Hide file tree
Showing 11 changed files with 866 additions and 17 deletions.
32 changes: 31 additions & 1 deletion ZenPacks/zenoss/CloudStack/Host.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
# Copyright (C) 2011, Zenoss Inc.
# Copyright (C) 2011, 2013, 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
Expand All @@ -14,6 +14,7 @@
from Products.ZenRelations.RelSchema import ToMany, ToManyCont, ToOne

from ZenPacks.zenoss.CloudStack import BaseComponent
from ZenPacks.zenoss.CloudStack.utils import require_zenpack


class Host(BaseComponent):
Expand Down Expand Up @@ -67,6 +68,27 @@ class Host(BaseComponent):
),
)

_catalogs = {
'HostCatalog': {
'deviceclass': '/CloudStack',
'indexes': {
'ipv4_addresses': {'type': 'keyword'},
},
},
}

@property
def ipv4_addresses(self):
return (self.ip_address,)

@classmethod
def findByIP(cls, dmd, ipv4_addresses):
'''
Return the first Host matching one of ipv4_addresses.
'''
return next(cls.search(
dmd, 'HostCatalog', ipv4_addresses=ipv4_addresses), None)

def device(self):
return self.cluster().device()

Expand All @@ -78,3 +100,11 @@ def getManagedDevice(self):
ip = self.getDmdRoot("Networks").findIp(self.ip_address)
if ip:
return ip.device()

@require_zenpack('ZenPacks.zenoss.XenServer')
def xenserver_host(self):
from ZenPacks.zenoss.XenServer.PIF import PIF

pif = PIF.findByIP(self.dmd, self.ipv4_addresses)
if pif:
return pif.host()
53 changes: 52 additions & 1 deletion ZenPacks/zenoss/CloudStack/RouterVM.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
# Copyright (C) 2012, Zenoss Inc.
# Copyright (C) 2012-2013, 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
Expand All @@ -14,6 +14,7 @@
from Products.ZenRelations.RelSchema import ToMany, ToManyCont, ToOne

from ZenPacks.zenoss.CloudStack import BaseComponent, TouchTestMixin
from ZenPacks.zenoss.CloudStack.utils import require_zenpack


class RouterVM(BaseComponent, TouchTestMixin):
Expand Down Expand Up @@ -71,6 +72,48 @@ class RouterVM(BaseComponent, TouchTestMixin):
),
)

_catalogs = {
'RouterVMCatalog': {
'deviceclass': '/CloudStack',
'indexes': {
'ipv4_addresses': {'type': 'keyword'},
'mac_addresses': {'type': 'keyword'},
},
},
}

@property
def ipv4_addresses(self):
return filter(
lambda x: x, (
self.guest_ip,
self.linklocal_ip,
self.public_ip))

@property
def mac_addresses(self):
return filter(
lambda x: x, (
self.guest_macaddress,
self.linklocal_macaddress,
self.public_macaddress))

@classmethod
def findByIP(cls, dmd, ipv4_addresses):
'''
Return the first RouterVM matching one of ipv4_addresses.
'''
return next(cls.search(
dmd, 'RouterVMCatalog', ipv4_addresses=ipv4_addresses), None)

@classmethod
def findByMAC(cls, dmd, mac_addresses):
'''
Return the first RouterVM matching one of mac_addresses.
'''
return next(cls.search(
dmd, 'RouterVMCatalog', mac_addresses=mac_addresses), None)

def device(self):
return self.pod().device()

Expand All @@ -91,3 +134,11 @@ def getRRDTemplates(self):
templates.extend(self.extra_templates())

return templates

@require_zenpack('ZenPacks.zenoss.XenServer')
def xenserver_vm(self):
from ZenPacks.zenoss.XenServer.VIF import VIF

vif = VIF.findByMAC(self.dmd, mac_addresses=self.mac_addresses)
if vif:
return vif.vm()
53 changes: 52 additions & 1 deletion ZenPacks/zenoss/CloudStack/SystemVM.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
# Copyright (C) 2012, Zenoss Inc.
# Copyright (C) 2012-2013, 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
Expand All @@ -14,6 +14,7 @@
from Products.ZenRelations.RelSchema import ToMany, ToManyCont, ToOne

from ZenPacks.zenoss.CloudStack import BaseComponent, TouchTestMixin
from ZenPacks.zenoss.CloudStack.utils import require_zenpack


class SystemVM(BaseComponent, TouchTestMixin):
Expand Down Expand Up @@ -61,6 +62,48 @@ class SystemVM(BaseComponent, TouchTestMixin):
),
)

_catalogs = {
'SystemVMCatalog': {
'deviceclass': '/CloudStack',
'indexes': {
'ipv4_addresses': {'type': 'keyword'},
'mac_addresses': {'type': 'keyword'},
},
},
}

@property
def ipv4_addresses(self):
return filter(
lambda x: x, (
self.linklocal_ip,
self.private_ip,
self.public_ip))

@property
def mac_addresses(self):
return filter(
lambda x: x, (
self.linklocal_macaddress,
self.private_macaddress,
self.public_macaddress))

@classmethod
def findByIP(cls, dmd, ipv4_addresses):
'''
Return the first SystemVM matching one of ipv4_addresses.
'''
return next(cls.search(
dmd, 'SystemVMCatalog', ipv4_addresses=ipv4_addresses), None)

@classmethod
def findByMAC(cls, dmd, mac_addresses):
'''
Return the first SystemVM matching one of mac_addresses.
'''
return next(cls.search(
dmd, 'SystemVMCatalog', mac_addresses=mac_addresses), None)

def device(self):
return self.pod().device()

Expand All @@ -86,3 +129,11 @@ def getRRDTemplates(self):
templates.append(console_proxy)

return templates

@require_zenpack('ZenPacks.zenoss.XenServer')
def xenserver_vm(self):
from ZenPacks.zenoss.XenServer.VIF import VIF

vif = VIF.findByMAC(self.dmd, mac_addresses=self.mac_addresses)
if vif:
return vif.vm()
45 changes: 44 additions & 1 deletion ZenPacks/zenoss/CloudStack/VirtualMachine.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
# Copyright (C) 2012, Zenoss Inc.
# Copyright (C) 2012-2013, 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
Expand All @@ -14,6 +14,7 @@
from Products.ZenRelations.RelSchema import ToMany, ToManyCont, ToOne

from ZenPacks.zenoss.CloudStack import BaseComponent
from ZenPacks.zenoss.CloudStack.utils import require_zenpack


class VirtualMachine(BaseComponent):
Expand Down Expand Up @@ -67,6 +68,40 @@ class VirtualMachine(BaseComponent):
),
)

_catalogs = {
'VirtualMachineCatalog': {
'deviceclass': '/CloudStack',
'indexes': {
'ipv4_addresses': {'type': 'keyword'},
'mac_addresses': {'type': 'keyword'},
},
},
}

@property
def ipv4_addresses(self):
return (self.ip_address,)

@property
def mac_addresses(self):
return (self.mac_address,)

@classmethod
def findByIP(cls, dmd, ipv4_addresses):
'''
Return the first VirtualMachine matching one of ipv4_addresses.
'''
return next(cls.search(
dmd, 'VirtualMachineCatalog', ipv4_addresses=ipv4_addresses), None)

@classmethod
def findByMAC(cls, dmd, mac_addresses):
'''
Return the first VirtualMachine matching one of mac_addresses.
'''
return next(cls.search(
dmd, 'VirtualMachineCatalog', mac_addresses=mac_addresses), None)

def device(self):
zone = self.zone()
if not zone:
Expand Down Expand Up @@ -95,3 +130,11 @@ def getManagedDevice(self):
ip = self.getDmdRoot("Networks").findIp(self.ip_address)
if ip:
return ip.device()

@require_zenpack('ZenPacks.zenoss.XenServer')
def xenserver_vm(self):
from ZenPacks.zenoss.XenServer.VIF import VIF

vif = VIF.findByMAC(self.dmd, mac_addresses=self.mac_addresses)
if vif:
return vif.vm()
Loading

0 comments on commit 2ee6753

Please sign in to comment.