Exemple #1
0
    def test_define(self):
        self.assert_('string' not in self.FLAGS)
        self.assert_('int' not in self.FLAGS)
        self.assert_('false' not in self.FLAGS)
        self.assert_('true' not in self.FLAGS)

        flags.DEFINE_string('string', 'default', 'desc',
                            flag_values=self.FLAGS)
        flags.DEFINE_integer('int', 1, 'desc', flag_values=self.FLAGS)
        flags.DEFINE_bool('false', False, 'desc', flag_values=self.FLAGS)
        flags.DEFINE_bool('true', True, 'desc', flag_values=self.FLAGS)

        self.assert_(self.FLAGS['string'])
        self.assert_(self.FLAGS['int'])
        self.assert_(self.FLAGS['false'])
        self.assert_(self.FLAGS['true'])
        self.assertEqual(self.FLAGS.string, 'default')
        self.assertEqual(self.FLAGS.int, 1)
        self.assertEqual(self.FLAGS.false, False)
        self.assertEqual(self.FLAGS.true, True)

        argv = ['flags_test',
                '--string', 'foo',
                '--int', '2',
                '--false',
                '--notrue']

        self.FLAGS(argv)
        self.assertEqual(self.FLAGS.string, 'foo')
        self.assertEqual(self.FLAGS.int, 2)
        self.assertEqual(self.FLAGS.false, True)
        self.assertEqual(self.FLAGS.true, False)
Exemple #2
0
    def test_flagfile(self):
        flags.DEFINE_string('string', 'default', 'desc',
                            flag_values=self.FLAGS)
        flags.DEFINE_integer('int', 1, 'desc', flag_values=self.FLAGS)
        flags.DEFINE_bool('false', False, 'desc', flag_values=self.FLAGS)
        flags.DEFINE_bool('true', True, 'desc', flag_values=self.FLAGS)
        flags.DEFINE_multistring('multi', ['blaa'], 'desc',
                                 flag_values=self.FLAGS)

        (fd, path) = tempfile.mkstemp(prefix='engine', suffix='.flags')

        try:
            os.write(fd, '--string=foo\n--int=2\n--false\n--notrue\n')
            os.write(fd, '--multi=foo\n--multi=bar\n')
            os.close(fd)

            self.FLAGS(['flags_test', '--flagfile=' + path])

            self.assertEqual(self.FLAGS.string, 'foo')
            self.assertEqual(self.FLAGS.int, 2)
            self.assertEqual(self.FLAGS.false, True)
            self.assertEqual(self.FLAGS.true, False)
            self.assertEqual(self.FLAGS.multi, ['foo', 'bar'])

            # Re-parse to test multistring isn't append multiple times
            self.FLAGS(['flags_test', '--flagfile=' + path])
            self.assertEqual(self.FLAGS.multi, ['foo', 'bar'])
        finally:
            os.remove(path)
Exemple #3
0
    'format string to use for log messages with context')
flags.DEFINE_string('logging_default_format_string',
                    '%(asctime)s %(levelname)s %(name)s [-] '
                    '%(message)s',
                    'format string to use for log messages without context')
flags.DEFINE_string(
    'logging_debug_format_suffix', 'from (pid=%(process)d) %(funcName)s'
    ' %(pathname)s:%(lineno)d',
    'data to append to log format when level is DEBUG')
flags.DEFINE_string('logging_exception_prefix', '(%(name)s): TRACE: ',
                    'prefix each line of exception output with this format')
flags.DEFINE_list('default_log_levels', [
    'amqplib=WARN', 'sqlalchemy=WARN', 'boto=WARN', 'suds=INFO',
    'eventlet.wsgi.server=WARN'
], 'list of logger=LEVEL pairs')
flags.DEFINE_bool('use_syslog', False, 'output to syslog')
flags.DEFINE_bool('publish_errors', False, 'publish error events')
flags.DEFINE_string('logfile', None, 'output to named file')
flags.DEFINE_bool('use_stderr', True, 'log to standard error')

# A list of things we want to replicate from logging.
# levels
CRITICAL = logging.CRITICAL
FATAL = logging.FATAL
ERROR = logging.ERROR
WARNING = logging.WARNING
WARN = logging.WARN
INFO = logging.INFO
DEBUG = logging.DEBUG
NOTSET = logging.NOTSET
Exemple #4
0
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2010 X7, LLC.
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
"""Module for VNC Proxying."""

from engine import flags

FLAGS = flags.FLAGS
flags.DEFINE_string('vncproxy_topic', 'vncproxy',
                    'the topic vnc proxy nodes listen on')
flags.DEFINE_string(
    'vncproxy_url', 'http://127.0.0.1:6080', 'location of vnc console proxy, \
                    in the form "http://127.0.0.1:6080"')
flags.DEFINE_string('vncserver_host', '0.0.0.0',
                    'the host interface on which vnc server should listen')
flags.DEFINE_bool('vnc_enabled', True, 'enable vnc related features')
flags.DEFINE_string('vnc_keymap', 'en-us', 'keymap for vnc')
Exemple #5
0
    'The interval used for polling of coalescing vhds.'
    '  Used only if connection_type=xenapi.')
flags.DEFINE_integer(
    'xenapi_vhd_coalesce_max_attempts', 5,
    'Max number of times to poll for VHD to coalesce.'
    '  Used only if connection_type=xenapi.')
flags.DEFINE_string(
    'xenapi_agent_path', 'usr/sbin/xe-update-networking',
    'Specifies the path in which the xenapi guest agent'
    '  should be located. If the agent is present,'
    '  network configuration is not injected into the image'
    '  Used only if connection_type=xenapi.'
    '  and flat_injected=True')
flags.DEFINE_string('xenapi_sr_base_path', '/var/run/sr-mount',
                    'Base path to the storage repository')
flags.DEFINE_bool('xenapi_log_instance_actions', False,
                  'Log all instance calls to XenAPI in the database.')
flags.DEFINE_string('target_host', None, 'iSCSI Target Host')
flags.DEFINE_string('target_port', '3260', 'iSCSI Target Port, 3260 Default')
flags.DEFINE_string('iqn_prefix', 'iqn.2010-10.org.x7', 'IQN Prefix')
# NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick, when we pull
# support for it, we should remove this
flags.DEFINE_bool(
    'xenapi_remap_vbd_dev', False, 'Used to enable the remapping of VBD dev '
    '(Works around an issue in Ubuntu Maverick)')
flags.DEFINE_string(
    'xenapi_remap_vbd_dev_prefix', 'sd', 'Specify prefix to remap VBD dev to '
    '(ex. /dev/xvdb -> /dev/sdb)')
flags.DEFINE_integer('xenapi_login_timeout', 10,
                     'Timeout in seconds for XenAPI login.')

Exemple #6
0
import mox
import nose.plugins.skip
import stubout

from engine import flags
import engine.image.fake
from engine import log
from engine import utils
from engine import service
from engine.testing.fake import rabbit
from engine.virt import fake

FLAGS = flags.FLAGS
flags.DEFINE_string('sqlite_clean_db', 'clean.sqlite',
                    'File name of clean sqlite db')
flags.DEFINE_bool('fake_tests', True, 'should we use everything for testing')

LOG = log.getLogger('engine.tests')


class skip_test(object):
    """Decorator that skips a test."""

    # TODO(tr3buchet): remember forever what comstud did here
    def __init__(self, msg):
        self.message = msg

    def __call__(self, func):
        @functools.wraps(func)
        def _skipper(*args, **kw):
            """Wrapped skipper function."""
Exemple #7
0
import uuid
import zipfile

from engine import context
from engine import crypto
from engine import db
from engine import exception
from engine import flags
from engine import log as logging
from engine import utils
from engine.auth import signer


FLAGS = flags.FLAGS
flags.DEFINE_bool('use_deprecated_auth',
                  False,
                  'This flag must be set to use old style auth')

flags.DEFINE_list('allowed_roles',
                  ['cloudadmin', 'itsec', 'sysadmin', 'netadmin', 'developer'],
                  'Allowed roles for project')
# NOTE(vish): a user with one of these roles will be a superuser and
#             have access to all api commands
flags.DEFINE_list('superuser_roles', ['cloudadmin'],
                  'Roles that ignore authorization checking completely')

# NOTE(vish): a user with one of these roles will have it for every
#             project, even if he or she is not a member of the project
flags.DEFINE_list('global_roles', ['cloudadmin', 'itsec'],
                  'Roles that apply to all projects')
Exemple #8
0
from engine.api.x7.v2 import flavors
from engine.api.x7.v2 import images
from engine.api.x7.v2 import image_metadata
from engine.api.x7.v2 import ips
from engine.api.x7.v2 import limits
from engine.api.x7.v2 import servers
from engine.api.x7.v2 import server_metadata
from engine.api.x7.v2 import versions
from engine.api.x7 import wsgi
from engine import flags
from engine import log as logging
from engine import wsgi as base_wsgi

LOG = logging.getLogger('engine.api.x7.v2')
FLAGS = flags.FLAGS
flags.DEFINE_bool('allow_admin_api', False,
                  'When True, this API service will accept admin operations.')
flags.DEFINE_bool(
    'allow_instance_snapshots', True,
    'When True, this API service will permit instance snapshot operations.')


class FaultWrapper(base_wsgi.Middleware):
    """Calls down the middleware stack, making exceptions into faults."""
    @webob.dec.wsgify(RequestClass=wsgi.Request)
    def __call__(self, req):
        try:
            return req.get_response(self.application)
        except Exception as ex:
            LOG.exception(_("Caught error: %s"), unicode(ex))
            exc = webob.exc.HTTPInternalServerError()
            return wsgi.Fault(exc)
Exemple #9
0
flags.DEFINE_string('routing_source_ip', '$my_ip',
                    'Public IP of network host')
flags.DEFINE_integer('dhcp_lease_time', 120,
                     'Lifetime of a DHCP lease in seconds')
flags.DEFINE_string('dns_server', None,
                    'if set, uses specific dns server for dnsmasq')
flags.DEFINE_string('dmz_cidr', '10.128.0.0/24',
                    'dmz range that should be accepted')
flags.DEFINE_string('dnsmasq_config_file', "",
                    'Override the default dnsmasq settings with this file')
flags.DEFINE_string('linuxnet_interface_driver',
                    'engine.network.linux_net.LinuxBridgeInterfaceDriver',
                    'Driver used to create ethernet devices.')
flags.DEFINE_string('linuxnet_ovs_integration_bridge',
                    'br-int', 'Name of Open vSwitch bridge used with linuxnet')
flags.DEFINE_bool('send_arp_for_ha', False,
                  'send gratuitous ARPs for HA setup')
flags.DEFINE_bool('use_single_default_gateway',
                   False, 'Use single default gateway. Only first nic of vm'
                          ' will get default gateway from dhcp server')
binary_name = os.path.basename(inspect.stack()[-1][1])


class IptablesRule(object):
    """An iptables rule.

    You shouldn't need to use this class directly, it's only used by
    IptablesManager.

    """

    def __init__(self, chain, rule, wrap=True, top=False):
Exemple #10
0
import functools

from engineclient import v1_1 as engineclient
from engineclient import exceptions as engineclient_exceptions

from engine import db
from engine import exception
from engine import flags
from engine import log as logging
from engine import rpc
from engine import utils

from eventlet import greenpool

FLAGS = flags.FLAGS
flags.DEFINE_bool('enable_zone_routing', False,
                  'When True, routing to child zones will occur.')

LOG = logging.getLogger('engine.scheduler.api')


def _call_scheduler(method, context, params=None):
    """Generic handler for RPC calls to the scheduler.

    :param params: Optional dictionary of arguments to be passed to the
                   scheduler worker

    :retval: Result returned by scheduler worker
    """
    if not params:
        params = {}
    queue = FLAGS.scheduler_topic