Skip to content

Commit

Permalink
Merge branch 'release/1.0.0beta2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cluther committed Aug 23, 2013
2 parents 583da0b + c96370d commit 3720d9b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 87 deletions.
11 changes: 0 additions & 11 deletions ZenPacks/zenoss/XenServer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ class ZenPack(ZenPackBase):
('zXenServerEventsInterval', 60, 'int'),
]

def install(self, app):
ZenPackBase.install(self, app)

self.installBinFile('zenxenservermodeler')

def remove(self, app, leaveObjects=False):
if not leaveObjects:
self.removeBinFile('zenxenservermodeler')

ZenPackBase.remove(self, app, leaveObjects=leaveObjects)


# Patch last to avoid import recursion problems.
from ZenPacks.zenoss.XenServer import patches
Expand Down
40 changes: 8 additions & 32 deletions ZenPacks/zenoss/XenServer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
from Products.ZenUtils.Ext import DirectRouter, DirectResponse

from Products import Zuul
from Products.ZenModel.ZDeviceLoader import DeviceCreationJob
from Products.ZenUtils.Utils import binPath
from Products.Zuul.facades import ZuulFacade
from Products.Zuul.interfaces import IFacade

from ZenPacks.zenoss.XenServer.jobs import XenServerCreationJob


class IXenServerFacade(IFacade):
'''
Expand All @@ -47,46 +47,22 @@ def add_xenserver(self, name, address, username, password, collector='localhost'
'zXenServerPassword': password,
}

zendiscCmd = [
binPath('zenxenservermodeler'),
'run', '--now',
'-d', name,
'--monitor', collector,
]

kwargs = {
'deviceName': name,
'devicePath': '/XenServer',
'title': name,
'discoverProto': 'XenAPI',
'manageIp': '',
'discoverProto': 'none',
'performanceMonitor': collector,
'rackSlot': 0,
'productionState': 1000,
'comments': '',
'hwManufacturer': '',
'hwProductName': '',
'osManufacturer': '',
'osProductName': '',
'priority': 3,
'tag': '',
'serialNumber': '',
'locationPath': '',
'systemPaths': [],
'groupPaths': [],
'zProperties': zProps,
'zendiscCmd': zendiscCmd,
}

jobManager = self._dmd.JobManager

try:
job_status = self._dmd.JobManager.addJob(
DeviceCreationJob, kwargs=kwargs)
return jobManager.addJob(XenServerCreationJob, kwargs=kwargs)
except TypeError:
# 4.1.1 compatibility.
job_status = self._dmd.JobManager.addJob(
DeviceCreationJob, **kwargs)

return job_status
# Zenoss 4.1.1 compatibility.
return jobManager.addJob(XenServerCreationJob, **kwargs)


class XenServerRouter(DirectRouter):
Expand Down
43 changes: 0 additions & 43 deletions ZenPacks/zenoss/XenServer/bin/zenxenservermodeler

This file was deleted.

68 changes: 68 additions & 0 deletions ZenPacks/zenoss/XenServer/jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2013, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import time

import transaction
from ZODB.transact import transact

from Products.ZenModel.ZDeviceLoader import JobDeviceLoader
from Products.Jobber.jobs import SubprocessJob

# How long to wait after making model changes for zenhub to become
# aware of the changes.
ZENHUB_DELAY = 40


class XenServerCreationJob(SubprocessJob):
'''
Job for adding XenServer endpoints.
Used when a XenServer is added through the web interface or API.
'''

@classmethod
def getJobType(cls):
return "Add XenServer Endpoint"

@classmethod
def getJobDescription(cls, *args, **kwargs):
return "Add {deviceName} under {devicePath}".format(**kwargs)

def _run(self, deviceName, performanceMonitor='localhost', zProperties=None):
loader = JobDeviceLoader(self.dmd)

@transact
def createDevice():
device = loader.load_device(
deviceName=deviceName,
devicePath='/XenServer',
discoverProto='none',
performanceMonitor=performanceMonitor,
zProperties=zProperties)

device._temp_device = False
return device

try:
self.log.info("Created XenServer endpoint device %s", deviceName)
device = createDevice()
except Exception:
transaction.abort()
self.log.exception("Encountered error. Rolling back initial device add.")
raise
else:
self.log.info(
"Waiting %s seconds for ZenHub to learn about %s",
ZENHUB_DELAY, deviceName)

time.sleep(ZENHUB_DELAY)

self.log.info("Scheduling immediate modeling job for %s", deviceName)
return device.collectDevice(background=True)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# or saved. Do not modify them directly here.
# NB: PACKAGES is deprecated
NAME = "ZenPacks.zenoss.XenServer"
VERSION = "1.0.0beta1"
VERSION = "1.0.0beta2"
AUTHOR = "Zenoss"
LICENSE = "GPLv2"
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.zenoss']
Expand Down

0 comments on commit 3720d9b

Please sign in to comment.