本文整理汇总了Python中servicemigration.require函数的典型用法代码示例。如果您正苦于以下问题:Python require函数的具体用法?Python require怎么用?Python require使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了require函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate
def migrate(self, pack):
if pack.prevZenPackVersion is None:
# Do nothing if this is a fresh install of self.version.
return
if not CONTROL_CENTER:
return
sm.require("1.0.0")
try:
ctx = sm.ServiceContext()
except Exception as e:
LOG.warn("failed to replace %s service: %s", SERVICE_NAME, e)
return
service = get_service_id(ctx)
if not service:
return
client = ControlPlaneClient(**getConnectionSettings())
# Stop and remove the old service.
remove_service(client, service)
# Install the new service.
pack.installServices()
示例2: test_sdk_versioning_bugfix_big
def test_sdk_versioning_bugfix_big(self):
major = int(sm.version.API_VERSION.split('.')[0])
minor = int(sm.version.API_VERSION.split('.')[1])
bugfx = int(sm.version.API_VERSION.split('.')[2]) + 1
try:
sm.require("%d.%d.%d" % (major, minor, bugfx))
except ValueError:
pass
else:
raise ValueError("SDK Versioning logic failed.")
示例3: migrate
def migrate(self, pack):
# Apply only on ZP upgrade.
if pack.prevZenPackVersion is None:
return
try:
import servicemigration as sm
except ImportError:
# No servicemigrations, which means we are on Zenoss 4.2.x or 5.0.x
# No need to install service on Zenoss 5.0.x as service install
# performed on each upgrade.
return
sm.require("1.0.0")
try:
ctx = sm.ServiceContext()
except:
log.warn("Couldn't generate service context, skipping.")
return
log.info("Looking for zenmapper services to migrate")
services = filter(lambda s: s.name == "zenmapper", ctx.services)
# Add the Redis endpoint import if it does not exist
if not services:
log.info("Found no 'zenmapper' services to migrate")
# short circuit
return
for service in services:
try:
if not service.ramCommitment:
service.ramCommitment = '5G'
except AttributeError:
log.warning("Your Zenoss version doesn't support such "
"migrations. Please set RAM commitment for "
"zenmapper service manualy to 5G using "
"Control Center UI.")
return
ctx.commit()
示例4: Copyright
# Copyright (C) Zenoss, Inc. 2015, 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 itertools
import logging
log = logging.getLogger("zen.migrate")
import Migrate
import servicemigration as sm
from servicemigration.endpoint import Endpoint
sm.require("1.0.0")
class AddEndpointsToZenjobs(Migrate.Step):
"Add zep + zproxy endpoints to zenjobs services"
version = Migrate.Version(5,0,70)
def cutover(self, dmd):
try:
ctx = sm.ServiceContext()
except sm.ServiceMigrationError:
log.info("Couldn't generate service context, skipping.")
return
endpoint_map = {
示例5: Copyright
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2016, 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 logging
log = logging.getLogger("zen.migrate")
import Migrate
import servicemigration as sm
sm.require("1.1.5")
from serviceRunLevels import serviceRunLevels
class AddServiceRunLevels(Migrate.Step):
"""
Add the emergency shutdown and startup levels to service definitions.
See ZEN-23931, ZEN-27299.
"""
version = Migrate.Version(109, 0, 0)
def cutover(self, dmd):
try:
ctx = sm.ServiceContext()
except sm.ServiceMigrationError:
示例6: addMissedRunsThreshold
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################
import logging
log = logging.getLogger("zen.migrate")
import Migrate
import servicemigration as sm
import servicemigration.thresholdconfig
import servicemigration.threshold
import servicemigration.eventtags
sm.require("1.1.6")
class addMissedRunsThreshold(Migrate.Step):
"""Adds a threshold for missedRuns for collector services"""
version = Migrate.Version(200, 0, 0)
def cutover(self, dmd):
try:
ctx = sm.ServiceContext()
except sm.ServiceMigrationError:
log.info("Couldn't generate context, skipping.")
return
# Get all collector services
changed = False
示例7: create_upstream_pattern
__doc__ = """AddAPIZopesSvcDef
Adds the service zenapi that provides Zope instances dedicated to serving non-UI JSON API requests.
"""
import logging
log = logging.getLogger("zen.migrate")
import os
import re
import copy
import Migrate
import servicemigration as sm
import subprocess
import shutil
sm.require("1.1.9")
def create_upstream_pattern(upstream_name, server_decl):
return re.compile("\\n\s+upstream %s {\\n\s+least_conn;\\n\s+%s;\\n\s+keepalive 64;\\n\s+}(?:(?:\\r)?\\n)" % (upstream_name, server_decl))
incl_mimetypes_pat = re.compile(r'include mime\.types;(?:(?:\\r)?\\n)?')
zope_upstream_pat = create_upstream_pattern('zopes', 'include zope-upstreams\.conf')
zopereports_upstream_pat = create_upstream_pattern('zopereports', 'include zopereports-upstreams\.conf')
debugzope_upstream_pat = create_upstream_pattern('debugzopes', 'server 127\.0\.0\.1:9310')
apizopes_upstream_pat = create_upstream_pattern('apizopes', 'include apizopes-upstreams\.conf')
map_whichzopes_pat = re.compile(r'\\n\s+map \$host \$whichzopes {\\n\s+default zopes;\\n\s+~\*zenapi apizopes;\\n\s+}\\n(?:(?:\\r)?\\n)')
apizopes_upstreams_decl = '\n\n upstream apizopes {\n least_conn;\n include apizopes-upstreams.conf;\n keepalive 64;\n }\n'
apizopes_map_clause = '\n ~*zenapi apizopes;'
apizopes_map_whichzopes_block_decl = '\n map $host $whichzopes {\n default zopes;\n ~*zenapi apizopes;\n }\n'
示例8: Copyright
#
# Copyright (C) Zenoss, Inc. 2017, 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 logging
import Migrate
import os
import servicemigration as sm
from Products.ZenUtils.Utils import zenPath
log = logging.getLogger("zen.migrate")
sm.require("1.1.10")
class AddZookeeperLogFilters(Migrate.Step):
"""
Add LogFilters for Zookeeper logs issue addressed by ZEN-28089
"""
version = Migrate.Version(200, 0, 0)
def cutover(self, dmd):
try:
ctx = sm.ServiceContext()
except sm.ServiceMigrationError:
log.info("Couldn't generate service context, skipping.")
return
service = ctx.getTopService()
示例9: AddZingConfigToZep
import os
import logging
log = logging.getLogger("zen.migrate")
import Migrate
import servicemigration as sm
from servicemigration.metrics import Metric
from servicemigration.graphrange import GraphRange
from servicemigration.graphconfig import GraphConfig
from servicemigration.metricconfig import MetricConfig
from servicemigration.graphdatapoint import GraphDatapoint
sm.require("1.1.12")
class AddZingConfigToZep(Migrate.Step):
"Add reasonable defaults to zeneventserver to enable sending events to Zenoss cloud"
version = Migrate.Version(300, 0, 6)
CLOUD_CONFIG_BLOCK = """
## Configuration to forward events to Zenoss Cloud
#
zep.zing.enabled=false
zep.zing.project={{getContext . "cse.project"}}
zep.zing.tenant={{getContext . "cse.tenant"}}
zep.zing.source={{getContext . "cse.source"}}
示例10: Copyright
#
# Copyright (C) Zenoss, Inc. 2017, 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 logging
log = logging.getLogger("zen.migrate")
import Migrate
import servicemigration as sm
sm.require("1.1.11")
class DeleteRateOptionsForServices(Migrate.Step):
"""
Update/Add rateOptions for counters.
Remove reset values.
"""
version = Migrate.Version(300, 0, 1)
def cutover(self, dmd):
try:
ctx = sm.ServiceContext()
except sm.ServiceMigrationError:
示例11: Copyright
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2016, 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 logging
import Migrate
import servicemigration as sm
sm.require("1.1.7")
class AddAuditLogFlag(Migrate.Step):
""" Add boolean flag to indicate which logs are audit logs."""
version = Migrate.Version(114, 0, 0)
def cutover(self, dmd):
log = logging.getLogger("zen.migrate")
try:
ctx = sm.ServiceContext()
except sm.ServiceMigrationError:
log.info("Couldn't generate service context, skipping.")
return
changed = False
for service in ctx.services:
示例12: ServiceTest
import unittest
import os
import servicemigration as sm
sm.require(sm.version.API_VERSION)
INFILENAME = os.path.join(os.path.dirname(__file__), "v1.0.0.json")
OUTFILENAME = os.path.join(os.path.dirname(__file__), "out.json")
class ServiceTest(unittest.TestCase):
def test_imageId_change(self):
"""
Tests changing an imageID
"""
imageID = "localhost:5000/fake:latest"
ctx = sm.ServiceContext(INFILENAME)
svc = filter(lambda x: x.description == "Zope server", ctx.services)[0]
svc.imageID = imageID
ctx.commit(OUTFILENAME)
ctx = sm.ServiceContext(OUTFILENAME)
svc = filter(lambda x: x.description == "Zope server", ctx.services)[0]
self.assertEqual(svc.imageID, imageID)
def test_description_remove(self):
"""
Tests completely removing a description.
"""
ctx = sm.ServiceContext(INFILENAME)
svc = filter(lambda x: x.description == "Zope server", ctx.services)[0]
示例13: test_sdk_versioning_bugfix_small
def test_sdk_versioning_bugfix_small(self):
major = int(sm.version.API_VERSION.split('.')[0])
minor = int(sm.version.API_VERSION.split('.')[1])
bugfx = int(sm.version.API_VERSION.split('.')[2]) - 1
sm.require("%d.%d.%d" % (major, minor, bugfx))