コード例 #1
0
ファイル: zone_manager.py プロジェクト: mrlesmithjr/designate
def main():
    utils.read_config('designate', sys.argv)
    logging.setup(CONF, 'designate')
    gmr.TextGuruMeditation.setup_autorun(version)

    # NOTE(timsim): This is to ensure people don't start the wrong
    #               services when the worker model is enabled.

    if cfg.CONF['service:worker'].enabled:
        LOG.error('You have designate-worker enabled, starting '
                  'designate-zone-manager is incompatible with '
                  'designate-worker. You need to start '
                  'designate-producer instead.')
        sys.exit(1)

    debtcollector.deprecate('designate-zone-manager Is deprecated in '
                            'favor of the designate-producer',
                            version='newton',
                            removal_version='rocky')

    LOG.warning('Starting designate-producer under the zone-manager name')

    server = producer_service.Service(
        threads=CONF['service:zone_manager'].threads)
    service.serve(server, workers=CONF['service:zone_manager'].workers)
    service.wait()
コード例 #2
0
ファイル: pool_manager.py プロジェクト: openstack/designate
def main():
    utils.read_config('designate', sys.argv)

    logging.setup(CONF, 'designate')
    gmr.TextGuruMeditation.setup_autorun(version)

    # NOTE(timsim): This is to ensure people don't start the wrong
    #               services when the worker model is enabled.
    if cfg.CONF['service:worker'].enabled:
        LOG.error('You have designate-worker enabled, starting '
                  'designate-pool-manager is incompatible with '
                  'designate-worker. You need to start '
                  'designate-worker instead.')
        sys.exit(1)

    debtcollector.deprecate('designate-pool-manager is deprecated in favor of '
                            'designate-worker', version='newton',
                            removal_version='rocky')

    server = pool_manager_service.Service(
        threads=CONF['service:pool_manager'].threads
    )

    hookpoints.log_hook_setup()

    service.serve(server, workers=CONF['service:pool_manager'].workers)
    server.heartbeat_emitter.start()
    service.wait()
コード例 #3
0
ファイル: _deprecate.py プロジェクト: 2020human/neutron
    def __getattr__(self, name):
        value = self._mg__my_globals.get(name)
        if not name.startswith("__") and not inspect.ismodule(value):
            old_module = self._mg__old_ref
            specified_move = self._mg__moves.get((old_module, name))
            if specified_move:
                new_module, new_name = specified_move
            else:
                new_module, new_name = self._mg__default_new_mod, name
            if new_module and new_name in vars(new_module):

                old_location = '%s.%s' % (old_module.__name__, name)
                new_location = '%s.%s' % (new_module.__name__, new_name)
                changed = 'renamed' if old_module == new_module else 'moved'
                debtcollector.deprecate(
                    old_location,
                    message='%s to %s' % (changed, new_location),
                    stacklevel=4)

                return vars(new_module)[new_name]

        try:
            return self._mg__my_globals[name]
        except KeyError:
            raise AttributeError(
                _("'module' object has no attribute '%s'") % name)
コード例 #4
0
ファイル: utils.py プロジェクト: noironetworks/neutron
def wait_until_true(predicate, timeout=60, sleep=1, exception=None):
    """
    Wait until callable predicate is evaluated as True

    :param predicate: Callable deciding whether waiting should continue.
    Best practice is to instantiate predicate with functools.partial()
    :param timeout: Timeout in seconds how long should function wait.
    :param sleep: Polling interval for results in seconds.
    :param exception: Exception instance to raise on timeout. If None is passed
                      (default) then WaitTimeout exception is raised.
    """
    try:
        with eventlet.timeout.Timeout(timeout):
            while not predicate():
                eventlet.sleep(sleep)
    except eventlet.TimeoutError:
        if exception is None:
            debtcollector.deprecate(
                "Raising eventlet.TimeoutError by default has been deprecated",
                message="wait_until_true() now raises WaitTimeout error by " "default.",
                version="Ocata",
                removal_version="Pike",
            )
            exception = WaitTimeout("Timed out after %d seconds" % timeout)
        # NOTE(jlibosva): In case None is passed exception is instantiated on
        #                the line above.
        # pylint: disable=raising-bad-type
        raise exception
コード例 #5
0
ファイル: vlanmanager.py プロジェクト: sebrandon1/neutron
def deprecate_local_vlan_map_in_object(object_name, stacklevel_extra=0):
    debtcollector.deprecate(
        "local_vlan_map argument for %s was deprecated." % object_name,
        version="Newton",
        removal_version="Ocata",
        stacklevel=4 + stacklevel_extra,
    )
コード例 #6
0
ファイル: __init__.py プロジェクト: mahak/glance
    def __init__(self, mapper):
        mapper = mapper or wsgi.APIMapper()
        if CONF.enable_v1_registry:
            v1.init(mapper)
        if CONF.enable_v2_registry:
            debtcollector.deprecate("Glance Registry service has been "
                                    "deprecated for removal.")
            v2.init(mapper)

        super(API, self).__init__(mapper)
コード例 #7
0
ファイル: context.py プロジェクト: openstack/oslo.context
def _moved_msg(new_name, old_name):
    if old_name:
        deprecated_msg = "Property '%(old_name)s' has moved to '%(new_name)s'"
        deprecated_msg = deprecated_msg % {'old_name': old_name,
                                           'new_name': new_name}

        debtcollector.deprecate(deprecated_msg,
                                version='2.6',
                                removal_version='3.0',
                                stacklevel=5)
コード例 #8
0
    def _init_conf(self):
        '''Initialize this middleware from an oslo.config instance.'''

        # Set up a location for our latent configuration options
        self._latent_configuration = {
            'allow_headers': [],
            'expose_headers': [],
            'methods': []
        }

        # First, check the configuration and register global options.
        self.oslo_conf.register_opts(CORS_OPTS, 'cors')

        allowed_origin = self._conf_get('allowed_origin', 'cors')
        allow_credentials = self._conf_get('allow_credentials', 'cors')
        expose_headers = self._conf_get('expose_headers', 'cors')
        max_age = self._conf_get('max_age', 'cors')
        allow_methods = self._conf_get('allow_methods', 'cors')
        allow_headers = self._conf_get('allow_headers', 'cors')

        # Clone our original CORS_OPTS, and set the defaults to whatever is
        # set in the global conf instance. This is done explicitly (instead
        # of **kwargs), since we don't accidentally want to catch
        # allowed_origin.
        subgroup_opts = copy.deepcopy(CORS_OPTS)
        cfg.set_defaults(subgroup_opts,
                         allow_credentials=allow_credentials,
                         expose_headers=expose_headers,
                         max_age=max_age,
                         allow_methods=allow_methods,
                         allow_headers=allow_headers)

        # If the default configuration contains an allowed_origin, don't
        # forget to register that.
        self.add_origin(allowed_origin=allowed_origin,
                        allow_credentials=allow_credentials,
                        expose_headers=expose_headers,
                        max_age=max_age,
                        allow_methods=allow_methods,
                        allow_headers=allow_headers)

        # Iterate through all the loaded config sections, looking for ones
        # prefixed with 'cors.'
        for section in self.oslo_conf.list_all_sections():
            if section.startswith('cors.'):
                debtcollector.deprecate('Multiple configuration blocks are '
                                        'deprecated and will be removed in '
                                        'future versions. Please consolidate '
                                        'your configuration in the [cors] '
                                        'configuration block.')
                # Register with the preconstructed defaults
                self.oslo_conf.register_opts(subgroup_opts, section)
                self.add_origin(**self.oslo_conf[section])
コード例 #9
0
ファイル: server.py プロジェクト: kgiusti/oslo.messaging
    def __init__(self, transport, dispatcher, executor='blocking'):
        """Construct a message handling server.

        The dispatcher parameter is a DispatcherBase instance which is used
        for routing request to endpoint for processing.

        The executor parameter controls how incoming messages will be received
        and dispatched. By default, the most simple executor is used - the
        blocking executor. It handles only one message at once. It's
        recommended to use threading or eventlet.

        :param transport: the messaging transport
        :type transport: Transport
        :param dispatcher: has a dispatch() method which is invoked for each
                           incoming request
        :type dispatcher: DispatcherBase
        :param executor: name of message executor - available values are
                         'eventlet' and 'threading'
        :type executor: str
        """
        self.conf = transport.conf
        self.conf.register_opts(_pool_opts)

        self.transport = transport
        self.dispatcher = dispatcher
        self.executor_type = executor
        if self.executor_type == 'blocking':
            debtcollector.deprecate(
                'blocking executor is deprecated. Executor default will be '
                'removed. Use explicitly threading or eventlet instead',
                version="pike", removal_version="rocky",
                category=FutureWarning)
        elif self.executor_type == "eventlet":
            eventletutils.warn_eventlet_not_patched(
                expected_patched_modules=['thread'],
                what="the 'oslo.messaging eventlet executor'")

        self.listener = None

        try:
            mgr = driver.DriverManager('oslo.messaging.executors',
                                       self.executor_type)
        except RuntimeError as ex:
            raise ExecutorLoadFailure(self.executor_type, ex)

        self._executor_cls = mgr.driver

        self._work_executor = None

        self._started = False

        super(MessageHandlingServer, self).__init__()
コード例 #10
0
ファイル: collector.py プロジェクト: cloudbase/ceilometer
    def __init__(self, worker_id, conf):
        super(CollectorService, self).__init__(worker_id)
        self.conf = conf
        # ensure dispatcher is configured before starting other services
        dispatcher_managers = dispatcher.load_dispatcher_manager(conf)
        (self.meter_manager, self.event_manager) = dispatcher_managers
        self.sample_listener = None
        self.event_listener = None
        self.udp_thread = None

        import debtcollector
        debtcollector.deprecate("Ceilometer collector service is deprecated."
                                "Use publishers to push data instead",
                                version="9.0", removal_version="10.0")
コード例 #11
0
ファイル: murano_package.py プロジェクト: AleptNamrata/murano
    def find_class(self, name, search_requirements=True):
        payload = self._native_load_queue.pop(name, None)
        if payload is not None:
            return self._register_native_class(payload, name)

        payload = self._load_queue.pop(name, None)
        if payload is not None:
            result = self._register_mpl_classes(payload, name)
            if result:
                return result

        result = self._classes.get(name)
        if result:
            return result
        if search_requirements:
            pkgs_for_search = []
            for package_name, version_spec in six.iteritems(
                    self._requirements):
                if package_name == self.name:
                    continue
                referenced_package = self._package_loader.load_package(
                    package_name, version_spec)
                try:
                    return referenced_package.find_class(name, False)
                except exceptions.NoClassFound:
                    if name.startswith('io.murano.extensions'):
                        try:
                            short_name = name.replace(
                                'io.murano.extensions.', '', 1)
                            result = referenced_package.find_class(
                                short_name, False)
                            warnings.simplefilter("once")
                            msg = ("Plugin %(name)s was not found, but a "
                                   "%(shorter_name)s was found instead and "
                                   "will be used. This could be caused by "
                                   "recent change in plugin naming scheme. If "
                                   "you are developing applications targeting "
                                   "this plugin consider changing its name" %
                                   {'name': name, 'shorter_name': short_name})
                            debtcollector.deprecate(msg)
                            return result
                        except exceptions.NoClassFound:
                            pass
                    pkgs_for_search.append(referenced_package)
                    continue
            raise exceptions.NoClassFound(
                name, packages=pkgs_for_search + [self])

        raise exceptions.NoClassFound(name, packages=[self])
コード例 #12
0
ファイル: __init__.py プロジェクト: ZTE-SuZhengwei/ceilometer
def get_connection(url, namespace):
    """Return an open connection to the database."""
    connection_scheme = urlparse.urlparse(url).scheme
    # SqlAlchemy connections specify may specify a 'dialect' or
    # 'dialect+driver'. Handle the case where driver is specified.
    engine_name = connection_scheme.split('+')[0]
    if engine_name == 'db2':
        import warnings
        warnings.simplefilter("always")
        import debtcollector
        debtcollector.deprecate("The DB2nosql driver is no longer supported",
                                version="Liberty", removal_version="N*-cycle")
    # NOTE: translation not applied bug #1446983
    LOG.debug('looking for %(name)r driver in %(namespace)r',
              {'name': engine_name, 'namespace': namespace})
    mgr = driver.DriverManager(namespace, engine_name)
    return mgr.driver(url)
コード例 #13
0
ファイル: _deprecate.py プロジェクト: annp/neutron
    def __getattr__(self, name):
        a = self.my_globals.get(name)
        if not name.startswith("__") and not inspect.ismodule(a):
            other_mod = self.additional.get(name) or self.other_mod
            if name in vars(other_mod):

                # These should be enabled after most have been cleaned up
                # in neutron proper, which may not happen during the busy M-3.

                debtcollector.deprecate(
                    name,
                    message='moved to %s' % other_mod.__name__,
                    stacklevel=4)

                return vars(other_mod)[name]

        try:
            return self.my_globals[name]
        except KeyError:
            raise AttributeError(
                _("'module' object has no attribute '%s'") % name)
コード例 #14
0
ファイル: _deprecate.py プロジェクト: kimcharli/neutron
    def __getattr__(self, name):
        a = self.my_globals.get(name)
        if (not name.startswith("__") and not inspect.ismodule(a) and
            name in vars(self.other_mod)):

            # These should be enabled after most have been cleaned up
            # in neutron proper, which may not happen during the busy M-3.

            if os.getenv('NEUTRON_SHOW_DEPRECATION_WARNINGS'):
                debtcollector.deprecate(
                    name,
                    message='moved to neutron_lib',
                    version='mitaka',
                    removal_version='newton',
                    stacklevel=4)

            return vars(self.other_mod)[name]

        try:
            return self.my_globals[name]
        except KeyError:
            raise AttributeError()
コード例 #15
0
 def test_generation(self):
     with warnings.catch_warnings(record=True) as capture:
         warnings.simplefilter("always")
         debtcollector.deprecate("Its broken")
         debtcollector.deprecate("Its really broken")
     self.assertEqual(2, len(capture))
コード例 #16
0
ファイル: ha.py プロジェクト: brandonlogan/neutron
import eventlet
from oslo_log import log as logging
import webob

from neutron._i18n import _LI
from neutron.agent.linux import utils as agent_utils
from neutron.common import utils as common_utils
from neutron.conf.agent.l3 import ha as ha_conf
from neutron.notifiers import batch_notifier

LOG = logging.getLogger(__name__)

KEEPALIVED_STATE_CHANGE_SERVER_BACKLOG = 4096

debtcollector.deprecate(
    'Moved l3 agent ha opts to %s' % ha_conf.__name__,
    version="newton", removal_version="ocata")
OPTS = ha_conf.OPTS


class KeepalivedStateChangeHandler(object):
    def __init__(self, agent):
        self.agent = agent

    @webob.dec.wsgify(RequestClass=webob.Request)
    def __call__(self, req):
        router_id = req.headers['X-Neutron-Router-Id']
        state = req.headers['X-Neutron-State']
        self.enqueue(router_id, state)

    def enqueue(self, router_id, state):
コード例 #17
0
 def test_generation(self):
     with warnings.catch_warnings(record=True) as capture:
         warnings.simplefilter("always")
         debtcollector.deprecate("Its broken")
         debtcollector.deprecate("Its really broken")
     self.assertEqual(2, len(capture))
コード例 #18
0
from neutron.conf.services import provider_configuration as prov_config
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
from oslo_log import log as logging
import stevedore

from neutron._i18n import _, _LW
from neutron.api.v2 import attributes as attr

LOG = logging.getLogger(__name__)

SERVICE_PROVIDERS = 'neutron.service_providers'

debtcollector.deprecate(
    'Moved serviceprovider_opts to %s' % prov_config.__name__,
    version="newton", removal_version="ocata")
serviceprovider_opts = prov_config.serviceprovider_opts

prov_config.register_service_provider_opts()


class NeutronModule(object):
    """A Neutron extension module."""

    def __init__(self, service_module):
        self.module_name = service_module
        self.repo = {
            'mod': self._import_or_none(),
            'ini': None
        }
コード例 #19
0
ファイル: vlanmanager.py プロジェクト: muraliran/neutron
def deprecate_local_vlan_map_in_object(object_name):
    debtcollector.deprecate(
        "local_vlan_map argument for %s was deprecated." % object_name,
        version="Newton", removal_version="Ocata")
コード例 #20
0
def deprecate_local_vlan_map_in_object(object_name):
    debtcollector.deprecate("local_vlan_map argument for %s was deprecated." %
                            object_name,
                            version="Newton",
                            removal_version="Ocata")
コード例 #21
0
ファイル: ha.py プロジェクト: zainubwahid/neutron
import eventlet
from oslo_log import log as logging
import webob

from neutron._i18n import _LI
from neutron.agent.linux import utils as agent_utils
from neutron.common import utils as common_utils
from neutron.conf.agent.l3 import ha as ha_conf
from neutron.notifiers import batch_notifier

LOG = logging.getLogger(__name__)

KEEPALIVED_STATE_CHANGE_SERVER_BACKLOG = 4096

debtcollector.deprecate('Moved l3 agent ha opts to %s' % ha_conf.__name__,
                        version="newton",
                        removal_version="ocata")
OPTS = ha_conf.OPTS


class KeepalivedStateChangeHandler(object):
    def __init__(self, agent):
        self.agent = agent

    @webob.dec.wsgify(RequestClass=webob.Request)
    def __call__(self, req):
        router_id = req.headers['X-Neutron-Router-Id']
        state = req.headers['X-Neutron-State']
        self.enqueue(router_id, state)

    def enqueue(self, router_id, state):
コード例 #22
0
    def __init__(self, *args, **kwargs):
        """Instance initialization."""
        deprecate(
            "Warning!",
            message="This DebianBox class is deprecated",
            category=UserWarning,
        )
        self.args = args
        self.kwargs = kwargs
        name = kwargs.pop("name", None)
        ipaddr = kwargs.pop("ipaddr", None)
        color = kwargs.pop("color", "black")
        username = kwargs.pop("username", "root")
        password = kwargs.pop("password", "bigfoot1")
        port = kwargs.pop("port", "22")
        output = kwargs.pop("output", sys.stdout)
        reboot = kwargs.pop("reboot", False)
        location = kwargs.pop("location", None)
        self.dev_array = kwargs.pop("dev_array", None)
        pre_cmd_host = kwargs.pop("pre_cmd_host", None)
        cmd = kwargs.pop("cmd", None)
        post_cmd_host = kwargs.pop("post_cmd_host", None)
        post_cmd = kwargs.pop("post_cmd", None)
        cleanup_cmd = kwargs.pop("cleanup_cmd", None)
        lan_network = ipaddress.IPv4Interface(
            six.text_type(kwargs.pop("lan_network", "192.168.1.0/24"))).network
        lan_gateway = ipaddress.IPv4Interface(
            six.text_type(kwargs.pop("lan_gateway", "192.168.1.1/24"))).ip

        self.http_proxy = kwargs.pop("http_proxy", ipaddr + ":8080")

        if pre_cmd_host is not None:
            sys.stdout.write("\tRunning pre_cmd_host.... ")
            sys.stdout.flush()
            phc = bft_pexpect_helper.spawn(command="bash",
                                           args=["-c", pre_cmd_host],
                                           env=self.dev.env)
            phc.expect(pexpect.EOF, timeout=120)
            print("\tpre_cmd_host done")

        self.legacy_add = False
        # introducing a hack till json schema does not get updated
        if not self.dev_array:
            self.legacy_add = True
            arr_names = {"lan": "lan_clients", "wan": "wan_clients"}
            for k, v in arr_names.items():
                if k in name:
                    self.dev_array = v

        if ipaddr is not None:
            bft_pexpect_helper.spawn.__init__(
                self,
                command="ssh",
                args=[
                    "%s@%s" % (username, ipaddr),
                    "-p",
                    port,
                    "-o",
                    "StrictHostKeyChecking=no",
                    "-o",
                    "UserKnownHostsFile=/dev/null",
                    "-o",
                    "ServerAliveInterval=60",
                    "-o",
                    "ServerAliveCountMax=5",
                ],
            )

            self.ipaddr = ipaddr

        if cleanup_cmd is not None:
            self.cleanup_cmd = cleanup_cmd
            atexit.register(self.run_cleanup_cmd)

        if cmd is not None:
            sys.stdout.write("\tRunning cmd.... ")
            sys.stdout.flush()
            bft_pexpect_helper.spawn.__init__(self,
                                              command="bash",
                                              args=["-c", cmd],
                                              env=self.dev.env)
            self.ipaddr = None
            print("\tcmd done")

        self.name = name
        self.color = color
        self.output = output
        self.username = username
        if username != "root":
            self.prompt.append("%s\\@.*:.*$" % username)
        self.password = password
        self.port = port
        self.location = location
        self.lan_network = lan_network
        self.lan_gateway = lan_gateway
        self.tftp_device = self
        self.dante = False

        self.check_connection(username, name, password)

        # attempts to fix the cli columns size
        self.set_cli_size(200)

        # we need to pick a non-conflicting private network here
        # also we want it to be consistent and not random for a particular
        # board
        if self.gw is None:
            if (lan_gateway - lan_network.num_addresses).is_private:
                self.gw = lan_gateway - lan_network.num_addresses
            else:
                self.gw = lan_gateway + lan_network.num_addresses

        self.gw_ng = ipaddress.IPv4Interface(
            six.text_type(str(self.gw) + "/" + str(lan_network.prefixlen)))
        self.nw = self.gw_ng.network
        self.gw_prefixlen = self.nw.prefixlen

        # override above values if set in wan options
        if "options" in kwargs:
            options = [x.strip() for x in kwargs["options"].split(",")]
            for opt in options:
                if opt.startswith("wan-static-ip:"):
                    value = six.text_type(opt.replace("wan-static-ip:", ""))
                    if "/" not in value:
                        value = value + (u"/24")
                    self.gw_ng = ipaddress.IPv4Interface(value)
                    self.nw = self.gw_ng.network
                    self.gw_prefixlen = self.nw._prefixlen
                    self.gw = self.gw_ng.ip
                    self.static_ip = True
                if opt.startswith("wan-static-ipv6:"):
                    ipv6_address = six.text_type(
                        opt.replace("wan-static-ipv6:", ""))
                    if "/" not in opt:
                        ipv6_address += "/%s" % six.text_type(
                            str(self.ipv6_prefix))
                    self.ipv6_interface = ipaddress.IPv6Interface(ipv6_address)
                    self.ipv6_prefix = self.ipv6_interface._prefixlen
                    self.gwv6 = self.ipv6_interface.ip
                if opt.startswith("wan-static-route:"):
                    self.static_route = opt.replace("wan-static-route:",
                                                    "").replace("-", " via ")
                # TODO: remove wan-static-route at some point above
                if opt.startswith("static-route:"):
                    self.static_route = opt.replace("static-route:",
                                                    "").replace("-", " via ")
                if opt == "wan-dhcp-client":
                    self.wan_dhcp = True
                if opt == "wan-no-eth0":
                    self.wan_no_eth0 = True
                if opt == "wan-no-dhcp-server":
                    self.wan_dhcp_server = False
                if opt == "wan-dhcp-client-v6":
                    self.wan_dhcpv6 = True
                if opt.startswith("mgmt-dns:"):
                    value = six.text_type(opt.replace("mgmt-dns:", ""))
                    self.mgmt_dns = ipaddress.IPv4Interface(value).ip
                else:
                    self.mgmt_dns = "8.8.8.8"
                if opt == "dante":
                    self.dante = True

        if ipaddr is None:
            self.sendline("hostname")
            self.expect("hostname")
            self.expect(self.prompt)
            ipaddr = self.ipaddr = self.before.strip()

        self.print_connected_console_msg(ipaddr, port, color, name)

        if post_cmd_host is not None:
            sys.stdout.write("\tRunning post_cmd_host.... ")
            sys.stdout.flush()
            phc = bft_pexpect_helper.spawn(command="bash",
                                           args=["-c", post_cmd_host],
                                           env=self.dev.env)
            i = phc.expect([pexpect.EOF, pexpect.TIMEOUT, "password"])
            if i > 0:
                print("\tpost_cmd_host did not complete, it likely failed\n")
            else:
                print("\tpost_cmd_host done")

        if post_cmd is not None:
            sys.stdout.write("\tRunning post_cmd.... ")
            sys.stdout.flush()
            env_prefix = ""
            for k, v in self.dev.env.items():
                env_prefix += "export %s=%s; " % (k, v)

            self.sendline(env_prefix + post_cmd)
            self.expect(self.prompt)
            print("\tpost_cmd done")

        if reboot:
            self.reset()

        self.logfile_read = output