Example #1
0
             default=False,
             help='Whether the http/https/email subscription need to be '
             'confirmed before notification.'),
 cfg.StrOpt('external_confirmation_url',
            help='The confirmation page url that will be used in email '
            'subscription confirmation before notification.'),
 cfg.DictOpt("subscription_confirmation_email_template",
             default={
                 'topic':
                 'Zaqar Notification - Subscription '
                 'Confirmation',
                 'body':
                 'You have chosen to subscribe to the '
                 'queue: {0}. This queue belongs to '
                 'project: {1}. '
                 'To confirm this subscription, '
                 'click or visit this link below: {2}',
                 'sender':
                 'Zaqar Notifications '
                 '<*****@*****.**>'
             },
             help="Defines the set of subscription confirmation email "
             "content, including topic, body and sender. There is "
             "a mapping is {0} -> queue name, {1} ->project id, "
             "{2}-> confirm url in body string. User can use any of "
             "the three value. But they can't use more than three."),
 cfg.DictOpt("unsubscribe_confirmation_email_template",
             default={
                 'topic':
                 'Zaqar Notification - '
                 'Unsubscribe Confirmation',
                 'body':
             default='False',
             help='If true, it will take nova node name from host_state object, '
                  'and use it without any further processing, as is.'
                  'Currently only True is supported'),
 cfg.StrOpt('source_driver_path',
            default='stc_nova_filters.drivers.prometheus_v1',
            help='This is the path from where source_driver_class is loaded, '
                 'it should be importable by nova'),
 cfg.StrOpt('metric_evaluation_interval',
            default="5m",
            help='This is the period for which avarage metric value will be calculated, '
                 'for more information please refer to prometheus documentation, '
            ),
 cfg.DictOpt('driver_opts',
             default={
                 "prometheus_endpoint": "http://mtr:9094",
                 "request_timeout": 0.05
             }),
 cfg.DictOpt('metrics_and_options_dict',
             default={
                 "mem_used_percent": "mem_used_percent_options_dict",
                 "cpu_usage_idle": "cpu_usage_idle_options_dict"
             },
             help="Key of this dict is a metric name to be queried from driver, "
                  "Value of key has to correspond to another config option defined in this config, "
                  "Target config option MUST be of a type Dict, and MUST have key following entries: "
                  "comparison_operator: possible values: 'grater_than', 'less_than', "
                  "threshold: should be float, metric value queried from the driver will be compared against this, "
                  "using 'comparison_operator key of this dict"
                  "if True is a result of the operation, filter will remove host from the list "
                  "(instance will not be scheduled on this host),"
Example #3
0
from toscaparser.utils import yamlparser
from translator.hot import tosca_translator
import yaml

from tacker.common import log
from tacker.extensions import common_services as cs
from tacker.extensions import vnfm
from tacker.tosca import utils as toscautils

from collections import OrderedDict

LOG = logging.getLogger(__name__)
CONF = cfg.CONF

OPTS = [
    cfg.DictOpt('flavor_extra_specs', default={},
                help=_("Flavor Extra Specs")),
]

CONF.register_opts(OPTS, group='openstack_vim')

HEAT_VERSION_INCOMPATIBILITY_MAP = {
    'OS::Neutron::Port': {
        'port_security_enabled': 'value_specs',
    },
}

HEAT_TEMPLATE_BASE = """
heat_template_version: 2013-05-23
"""

ALARMING_POLICY = 'tosca.policies.tacker.Alarming'
Example #4
0
def _register_api_opts():
    # XXX: note : template_path value only works if started from the top-level of the codebase.
    # Brittle!
    pecan_opts = [
        cfg.StrOpt('root',
                   default='st2api.controllers.root.RootController',
                   help='Pecan root controller'),
        cfg.StrOpt('template_path',
                   default='%(confdir)s/st2api/st2api/templates'),
        cfg.ListOpt('modules', default=['st2api']),
        cfg.BoolOpt('debug', default=True),
        cfg.BoolOpt('auth_enable', default=True),
        cfg.DictOpt('errors',
                    default={
                        404: '/error/404',
                        '__force_dict__': True
                    })
    ]

    _register_opts(pecan_opts, group='api_pecan')

    api_opts = [
        cfg.BoolOpt('debug', default=True),
        cfg.IntOpt(
            'max_page_size',
            default=100,
            help=
            'Maximum limit (page size) argument which can be specified by the user in a query '
            'string. If a larger value is provided, it will default to this value.'
        )
    ]

    _register_opts(api_opts, group='api')

    messaging_opts = [
        cfg.StrOpt('url',
                   default='amqp://*****:*****@127.0.0.1:5672//',
                   help='URL of the messaging server.'),
        cfg.ListOpt(
            'cluster_urls',
            default=[],
            help='URL of all the nodes in a messaging service cluster.'),
        cfg.IntOpt(
            'connection_retries',
            default=10,
            help='How many times should we retry connection before failing.'),
        cfg.IntOpt('connection_retry_wait',
                   default=10000,
                   help='How long should we wait between connection retries.'),
        cfg.BoolOpt(
            'ssl',
            default=False,
            help='Use SSL / TLS to connect to the messaging server. Same as '
            'appending "?ssl=true" at the end of the connection URL string.'),
        cfg.StrOpt(
            'ssl_keyfile',
            default=None,
            help=
            'Private keyfile used to identify the local connection against RabbitMQ.'
        ),
        cfg.StrOpt(
            'ssl_certfile',
            default=None,
            help=
            'Certificate file used to identify the local connection (client).'
        ),
        cfg.StrOpt(
            'ssl_cert_reqs',
            default=None,
            choices='none, optional, required',
            help=
            'Specifies whether a certificate is required from the other side of the '
            'connection, and whether it will be validated if provided.'),
        cfg.StrOpt(
            'ssl_ca_certs',
            default=None,
            help=
            'ca_certs file contains a set of concatenated CA certificates, which are '
            'used to validate certificates passed from RabbitMQ.'),
        cfg.StrOpt(
            'login_method',
            default=None,
            help='Login method to use (AMQPLAIN, PLAIN, EXTERNAL, etc.).')
    ]

    _register_opts(messaging_opts, group='messaging')

    ssh_runner_opts = [
        cfg.StrOpt('remote_dir',
                   default='/tmp',
                   help='Location of the script on the remote filesystem.'),
        cfg.BoolOpt(
            'allow_partial_failure',
            default=False,
            help=
            'How partial success of actions run on multiple nodes should be treated.'
        ),
        cfg.BoolOpt(
            'use_ssh_config',
            default=False,
            help='Use the .ssh/config file. Useful to override ports etc.')
    ]

    _register_opts(ssh_runner_opts, group='ssh_runner')
Example #5
0
volume_opts = [
    cfg.StrOpt('smbfs_shares_config',
               default=r'C:\OpenStack\smbfs_shares.txt',
               help='File with the list of available smbfs shares.'),
    cfg.StrOpt('smbfs_default_volume_format',
               default='vhd',
               choices=['vhd', 'vhdx'],
               help=('Default format that will be used when creating volumes '
                     'if no volume format is specified.')),
    cfg.StrOpt('smbfs_mount_point_base',
               default=r'C:\OpenStack\_mnt',
               help=('Base dir containing mount points for smbfs shares.')),
    cfg.DictOpt('smbfs_pool_mappings',
                default={},
                help=('Mappings between share locations and pool names. '
                      'If not specified, the share names will be used as '
                      'pool names. Example: '
                      '//addr/share:pool_name,//addr/share2:pool_name2')),
]

CONF = cfg.CONF
CONF.register_opts(volume_opts, group=configuration.SHARED_CONF_GROUP)


@interface.volumedriver
class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
                         remotefs_drv.RemoteFSPoolMixin,
                         remotefs_drv.RemoteFSManageableVolumesMixin,
                         remotefs_drv.RemoteFSSnapDriverDistributed):
    VERSION = VERSION
Example #6
0
            default=1,
            help='Maximum number of channels.'),
 cfg.IntOpt('pika_frame_max',
            default=131072,
            help='Maximum byte size for an AMQP frame.'),
 #rabbit config
 cfg.IntOpt('heartbeat_rate',
            default=2,
            help='How often times we check the heartbeat.'),
 cfg.BoolOpt('rabbit_use_ssl',
             default=False,
             deprecated_group='DEFAULT',
             help='Connect over SSL for RabbitMQ.'),
 #pika config
 cfg.DictOpt('pika_ssl_options',
             default = {},
             help = 'Connect over SSL for RabbitMQ.'),
 #rabbit config
 cfg.IntOpt('rabbit_max_retries',
            default=None,
            deprecated_for_removal=True,
            deprecated_group='DEFAULT',
            help='Maximum number of RabbitMQ connection retries. '
                 'Default is 0 (infinite retry count).'),
 cfg.IntOpt('rabbit_retry_interval',
            default=1,
            help='How frequently to retry connecting with RabbitMQ.'),
 #pika config
 cfg.IntOpt('pika_socket_timeout',
            default=10,
            help='Socket timeout to use for high latency networks.'),
Example #7
0
from cinder.volume.drivers.huawei import huawei_conf
from cinder.volume.drivers.huawei import huawei_flow
from cinder.volume.drivers.huawei import huawei_utils
from cinder.volume.drivers.huawei import hypermetro
from cinder.volume.drivers.huawei import replication
from cinder.volume.drivers.huawei import rest_client

LOG = logging.getLogger(__name__)

huawei_opts = [
    cfg.StrOpt('cinder_huawei_conf_file',
               default='/etc/cinder/cinder_huawei_conf.xml',
               help='The configuration file for Huawei driver.'),
    cfg.DictOpt('hypermetro_device',
                secret=True,
                help='To represent a hypermetro target device, which takes '
                     'standard dict config form: hypermetro_device = '
                     'key1:value1,key2:value2...'),
    cfg.BoolOpt('retain_storage_mapping',
                default=False,
                help='Whether to retain the storage mapping when the last '
                     'volume on the host is unmapped'),
]

CONF = cfg.CONF
CONF.register_opts(huawei_opts)


class HuaweiBaseDriver(object):
    VERSION = "2.3.RC3"
Example #8
0
                    help=_("Set a maximun amount of ports per pool. "
                           "0 to disable"),
                    default=0),
    oslo_cfg.IntOpt('ports_pool_min',
                    help=_("Set a target minimum size of the pool of ports"),
                    default=5),
    oslo_cfg.IntOpt('ports_pool_batch',
                    help=_("Number of ports to be created in a bulk request"),
                    default=10),
    oslo_cfg.IntOpt('ports_pool_update_frequency',
                    help=_("Minimun interval (in seconds) "
                           "between pool updates"),
                    default=20),
    oslo_cfg.DictOpt('pools_vif_drivers',
                     help=_("Dict with the pool driver and pod driver to be "
                            "used. If not set, it will take them from the "
                            "kubernetes driver options for pool and pod "
                            "drivers respectively"),
                     default={}),
]

oslo_cfg.CONF.register_opts(vif_pool_driver_opts, "vif_pool")

node_vif_driver_caching_opts = [
    oslo_cfg.BoolOpt('caching', default=True),
    oslo_cfg.IntOpt('cache_time', default=3600),
]

oslo_cfg.CONF.register_opts(node_vif_driver_caching_opts,
                            "node_driver_caching")

cache.configure(oslo_cfg.CONF)
Example #9
0
]

wsgi_opts = [
    cfg.StrOpt('secure_proxy_ssl_header',
               deprecated_for_removal=True,
               deprecated_reason=_('Use the http_proxy_to_wsgi middleware '
                                   'instead.'),
               help=_('The HTTP header used to determine the scheme for the '
                      'original request, even if it was removed by an SSL '
                      'terminating proxy. Typical value is '
                      '"HTTP_X_FORWARDED_PROTO".')),
]

store_opts = [
    cfg.DictOpt('enabled_backends',
                help=_('Key:Value pair of store identifier and store type. '
                       'In case of multiple backends should be separated '
                       'using comma.')),
]

cli_opts = [
    cfg.StrOpt('pipe-handle',
               help='This argument is used internally on Windows. Glance '
               'passes a pipe handle to child processes, which is then '
               'used for inter-process communication.'),
]

cache_opts = [
    cfg.FloatOpt('cache_prefetcher_interval',
                 default=300,
                 help=_("""
The interval in seconds to run periodic job cache_images.
    cfg.ListOpt('ignore_user_roles',
                default='admin',
                help=_("""
Specify name of user roles to be ignored for injecting metadata
properties in the image.

Possible values:
    * List containing user roles. For example: [admin,member]

""")),
    cfg.DictOpt('inject',
                default={},
                help=_("""
Dictionary contains metadata properties to be injected in image.

Possible values:
    * Dictionary containing key/value pairs. Key characters
    length should be <= 255. For example: k1:v1,k2:v2


""")),
]

CONF.register_opts(inject_metadata_opts, group='inject_metadata_properties')


class _InjectMetadataProperties(task.Task):
    def __init__(self, context, task_id, task_type, image_repo, image_id):
        self.context = context
        self.task_id = task_id
        self.task_type = task_type
Example #11
0
        "option can be used with the NeutronBindNetworkPlugin. The value for "
        "this option has to be a comma separated list of names that "
        "correspond to each binding profile. Each binding profile needs to be "
        "specified as an individual configuration section using the binding "
        "profile name as the section name."),
]

neutron_binding_profile_opts = [
    cfg.StrOpt('neutron_switch_id', help="Switch ID for binding profile."),
    cfg.StrOpt(
        'neutron_port_id',
        help="Port ID on the given switch.",
    ),
    cfg.DictOpt(
        'neutron_switch_info',
        help="Switch label. For example: 'switch_ip: 10.4.30.5'. Multiple "
        "key-value pairs separated by commas are accepted.",
    ),
]

CONF = cfg.CONF


class NeutronNetworkPlugin(network.NetworkBaseAPI):
    def __init__(self, *args, **kwargs):
        db_driver = kwargs.pop('db_driver', None)
        config_group_name = kwargs.get('config_group_name', 'DEFAULT')
        super(NeutronNetworkPlugin,
              self).__init__(config_group_name=config_group_name,
                             db_driver=db_driver)
        self._neutron_api = None
Example #12
0
    ),
    cfg.DictOpt(
        "dummy_driver_driver_methods_delays",
        help="It is dictionary-like config option, that consists of "
             "driver method names as keys and integer/float values that are "
             "time delay in seconds. Optional.",
        default={
            "ensure_share": "1.05",
            "create_share": "3.98",
            "get_pool": "0.5",
            "do_setup": "0.05",

            "_get_pools_info": "0.1",
            "_update_share_stats": "0.3",

            "create_replica": "3.99",
            "delete_replica": "2.98",
            "promote_replica": "0.75",
            "update_replica_state": "0.85",
            "create_replicated_snapshot": "4.15",
            "delete_replicated_snapshot": "3.16",
            "update_replicated_snapshot": "1.17",

            "migration_start": 1.01,
            "migration_continue": 1.02,  # it will be called 2 times
            "migration_complete": 1.03,
            "migration_cancel": 1.04,
            "migration_get_progress": 1.05,
            "migration_check_compatibility": 0.05,
        },
    ),
]
Example #13
0
DEFAULT_CPU_FLAGS_MAPPING = {
    'vmx': 'cpu_vt',
    'svm': 'cpu_vt',
    'aes': 'cpu_aes',
    'pse': 'cpu_hugepages',
    'pdpe1gb': 'cpu_hugepages_1g',
    'smx': 'cpu_txt',
}

CAPABILITIES_OPTS = [
    cfg.BoolOpt('boot_mode',
                default=False,
                help=_('Whether to store the boot mode (BIOS or UEFI).')),
    cfg.DictOpt('cpu_flags',
                default=DEFAULT_CPU_FLAGS_MAPPING,
                help=_('Mapping between a CPU flag and a capability to set '
                       'if this flag is present.')),
]


def list_opts():
    return [
        ('capabilities', CAPABILITIES_OPTS)
    ]

CONF = cfg.CONF
CONF.register_opts(CAPABILITIES_OPTS, group='capabilities')
LOG = utils.getProcessingLogger(__name__)


class CapabilitiesHook(base.ProcessingHook):
Example #14
0
                deprecated_reason='FusionStorage cinder driver refactored the '
                                  'code with Restful method and the old CLI '
                                  'mode has been abandon. So those '
                                  'configuration items are no longer used.'),
    cfg.IntOpt('clone_volume_timeout',
               default=680,
               help='Create clone volume timeout',
               deprecated_for_removal=True,
               deprecated_since='14.0.0',
               deprecated_reason='FusionStorage cinder driver refactored the '
                                 'code with Restful method and the old CLI '
                                 'mode has been abandon. So those '
                                 'configuration items are no longer used.'),
    cfg.DictOpt('manager_ips',
                default={},
                help='This option is to support the FSA to mount across the '
                     'different nodes. The parameters takes the standard dict '
                     'config form, manager_ips = host1:ip1, host2:ip2...'),
    cfg.DictOpt('storage',
                default={},
                secret=True,
                help='This field is configured with the information of array '
                     'and user info. The parameters takes the standard dict '
                     'config form, Storage = UserName:xxx, Password:xxx, '
                     'RestURL:xxx')
]

CONF = cfg.CONF
CONF.register_opts(volume_opts)

Example #15
0
               help=_("Base URI for the API for use in pagination links. "
                      "This will be autodetected from the request if not "
                      "overridden here.")),
    cfg.BoolOpt('allow_tls_terminated_listeners',
                default=True,
                help=_("Allow users to create TLS Terminated listeners?")),
    cfg.BoolOpt('allow_ping_health_monitors',
                default=True,
                help=_("Allow users to create PING type Health Monitors?")),
    cfg.DictOpt('enabled_provider_drivers',
                help=_('A comma separated list of dictionaries of the '
                       'enabled provider driver names and descriptions. '
                       'Must match the driver name in the '
                       'octavia.api.drivers entrypoint. Example: '
                       'amphora:The Octavia Amphora driver.,'
                       'octavia:Deprecated alias of the Octavia '
                       'Amphora driver.'),
                default={
                    'amphora': 'The Octavia Amphora driver.',
                    'octavia': 'Deprecated alias of the Octavia Amphora '
                    'driver.'
                }),
    cfg.StrOpt('default_provider_driver',
               default='amphora',
               help=_('Default provider driver.')),
    cfg.IntOpt('udp_connect_min_interval_health_monitor',
               default=3,
               help=_("The minimum health monitor delay interval for the "
                      "UDP-CONNECT Health Monitor type. A negative integer "
                      "value means 'no limit'.")),
]
        help=_("""
            Specifies allowed network types given as a Comma-separated list of
            types.

            Default: --allowed_network_types=local,vlan,vxlan,gre
            """)),

    cfg.DictOpt(
        'bridge_mappings',
        default={},
        help=_("""
            Comma-separated list of <physical_network>:<bridge> tuples mapping
            physical network names to the agent's node-specific Open vSwitch
            bridge names to be used for flat and VLAN networks. The length of
            bridge names should be no more than 11. Each bridge must exist, and
            should have a physical network interface configured as a port. All
            physical networks configured on the server should have mappings to
            appropriate bridges on each agent.

            Note: If you remove a bridge from this mapping, make sure to
            disconnect it from the integration bridge as it won't be managed by
            the agent anymore.

            Default: --bridge_mappings=
            """)),

    cfg.StrOpt(
        'datapath_type',
        choices=['system', 'netdev', 'dpdkvhostuser'],
        default=None,
        help=_("""
            It specifies the OVS data path to use.
Example #17
0
 #非uefi启动机器对应的pxe模板
 cfg.StrOpt('pxe_config_template',
            default=os.path.join(
                '$pybasedir', 'drivers/modules/pxe_config.template'),
            help=_('On ironic-conductor node, template file for PXE '
                   'configuration.')),
 #采用uefi启动的机器对应的pxe配置模板
 cfg.StrOpt('uefi_pxe_config_template',
            default=os.path.join(
                '$pybasedir',
                'drivers/modules/pxe_grub_config.template'),
            help=_('On ironic-conductor node, template file for PXE '
                   'configuration for UEFI boot loader.')),
 cfg.DictOpt('pxe_config_template_by_arch',
             default={},
             help=_('On ironic-conductor node, template file for PXE '
                    'configuration per node architecture. '
                    'For example: '
                    'aarch64:/opt/share/grubaa64_pxe_config.template')),
 cfg.StrOpt('tftp_server',
            default='$my_ip',
            help=_("IP address of ironic-conductor node's TFTP server.")),
 cfg.StrOpt('tftp_root',
            default='/tftpboot',
            help=_("ironic-conductor node's TFTP root path. The "
                   "ironic-conductor must have read/write access to this "
                   "path.")),
 cfg.StrOpt('tftp_master_path',
            default='/tftpboot/master_images',
            help=_('On ironic-conductor node, directory where master TFTP '
                   'images are stored on disk. '
                   'Setting to <None> disables image caching.')),
Example #18
0
    cfg.BoolOpt('datera_disable_profiler',
                default=False,
                help="Set to True to disable profiling in the Datera driver"),
    cfg.BoolOpt('datera_disable_extended_metadata',
                default=False,
                help="Set to True to disable sending additional metadata to "
                "the Datera backend"),
    cfg.BoolOpt('datera_disable_template_override',
                default=False,
                help="Set to True to disable automatic template override of "
                "the size attribute when creating from a template"),
    cfg.DictOpt('datera_volume_type_defaults',
                default={},
                help="Settings here will be used as volume-type defaults if "
                "the volume-type setting is not provided.  This can be "
                "used, for example, to set a very low total_iops_max "
                "value if none is specified in the volume-type to "
                "prevent accidental overusage.  Options are specified "
                "via the following format, WITHOUT ANY 'DF:' PREFIX: "
                "'datera_volume_type_defaults="
                "iops_per_gb:100,bandwidth_per_gb:200...etc'."),
]

CONF = cfg.CONF
CONF.import_opt('driver_use_ssl', 'cinder.volume.driver')
CONF.register_opts(d_opts)


@six.add_metaclass(utils.TraceWrapperWithABCMetaclass)
@interface.volumedriver
class DateraDriver(san.SanISCSIDriver, api21.DateraApi, api22.DateraApi):
    """The OpenStack Datera iSCSI volume driver.
Example #19
0
        'tosca-parameters-dir',
        default="$runtime_dir/tosca-parameters-dir",
        help="""
Path to the directory where the additional TOSCA parameters are stored.
"""),
    cfg.URIOpt(
        'tosca-repo',
        default="https://github.com/indigo-dc/tosca-templates/",
        schemes=["http", "https", "git"],
        help="""
URL of the DEEP tosca templates repository.
"""),
    cfg.DictOpt(
        "common-toscas",
        default={
            "default": "deep-oc-marathon-webdav.yml",
            "minimal": "deep-oc-marathon.yml",
        },
    ),
]

cache_opts = [
    cfg.StrOpt(
        "memcached-ip",
        help="""
IP of the memcached server to use.

If not set, we will not use memcached at all, therefore the DEEP dashboard
will not behave as expected when using several workers.
"""),
    cfg.PortOpt(
Example #20
0
}

# NOTE(roaet): shared ips are treated like any other IP and will consume
# from total_ips_on_port
shared_ip_on_network = {
    '00000000-0000-0000-0000-000000000000': 5,
    '11111111-1111-1111-1111-111111111111': 0,
    '*': -1
}

quark_ip_addr_opts = [
    cfg.BoolOpt('ipaddr_allow_fixed_ip',
                default=False,
                help=_('Controls if /ip_addresses can make fixed IPs or not')),
    cfg.DictOpt('total_ips_allowed_on_port',
                default=total_ips_on_port,
                help=_('Defines how many IPs may be on a port by network in '
                       'key:quantity format')),
    cfg.DictOpt('shared_ips_allowed_on_network',
                default=shared_ip_on_network,
                help=_('Defines how many shared IPs may be made on a network '
                       'in key:quantity format'))
]

CONF.register_opts(quark_ip_addr_opts, "QUARK")

# NOTE(thomasem): Since IP addresses are only at the subnet level, use
# the QuarkIpamANY strategy, due to other IPAM strategies only being
# relevant at the network level (port create).
ipam_driver = ipam.IPAM_REGISTRY.get_strategy(ipam.QuarkIpamANY.get_name())

Example #21
0
class GeneratorTestCase(base.BaseTestCase):

    opts = {
        'foo':
        cfg.StrOpt('foo', help='foo option'),
        'bar':
        cfg.StrOpt('bar', help='bar option'),
        'foo-bar':
        cfg.StrOpt('foo-bar', help='foobar'),
        'no_help':
        cfg.StrOpt('no_help'),
        'long_help':
        cfg.StrOpt('long_help',
                   help='Lorem ipsum dolor sit amet, consectetur '
                   'adipisicing elit, sed do eiusmod tempor '
                   'incididunt ut labore et dolore magna '
                   'aliqua. Ut enim ad minim veniam, quis '
                   'nostrud exercitation ullamco laboris '
                   'nisi ut aliquip ex ea commodo '
                   'consequat. Duis aute irure dolor in '
                   'reprehenderit in voluptate velit esse '
                   'cillum dolore eu fugiat nulla '
                   'pariatur. Excepteur sint occaecat '
                   'cupidatat non proident, sunt in culpa '
                   'qui officia deserunt mollit anim id est '
                   'laborum.'),
        'choices_opt':
        cfg.StrOpt('choices_opt',
                   default='a',
                   choices=(None, '', 'a', 'b', 'c'),
                   help='a string with choices'),
        'deprecated_opt':
        cfg.StrOpt('bar', deprecated_name='foobar', help='deprecated'),
        'deprecated_for_removal_opt':
        cfg.StrOpt('bar',
                   deprecated_for_removal=True,
                   help='deprecated for removal'),
        'deprecated_group':
        cfg.StrOpt('bar',
                   deprecated_group='group1',
                   deprecated_name='foobar',
                   help='deprecated'),
        # Unknown Opt default must be a string
        'unknown_type':
        cfg.Opt('unknown_opt', default='123', help='unknown'),
        'str_opt':
        cfg.StrOpt('str_opt', default='foo bar', help='a string'),
        'str_opt_sample_default':
        cfg.StrOpt('str_opt', default='fooishbar', help='a string'),
        'str_opt_with_space':
        cfg.StrOpt('str_opt',
                   default='  foo bar  ',
                   help='a string with spaces'),
        'bool_opt':
        cfg.BoolOpt('bool_opt', default=False, help='a boolean'),
        'int_opt':
        cfg.IntOpt('int_opt', default=10, help='an integer'),
        'float_opt':
        cfg.FloatOpt('float_opt', default=0.1, help='a float'),
        'list_opt':
        cfg.ListOpt('list_opt', default=['1', '2', '3'], help='a list'),
        'dict_opt':
        cfg.DictOpt('dict_opt', default={
            '1': 'yes',
            '2': 'no'
        }, help='a dict'),
        'multi_opt':
        cfg.MultiStrOpt('multi_opt',
                        default=['1', '2', '3'],
                        help='multiple strings'),
        'multi_opt_none':
        cfg.MultiStrOpt('multi_opt_none', help='multiple strings'),
        'multi_opt_empty':
        cfg.MultiStrOpt('multi_opt_empty', default=[],
                        help='multiple strings'),
        'multi_opt_sample_default':
        cfg.MultiStrOpt('multi_opt',
                        default=['1', '2', '3'],
                        sample_default=['5', '6'],
                        help='multiple strings'),
    }

    content_scenarios = [
        ('empty', dict(opts=[], expected='''[DEFAULT]
''')),
        ('single_namespace',
         dict(opts=[('test', [(None, [opts['foo']])])],
              expected='''[DEFAULT]

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('multiple_namespaces',
         dict(opts=[('test', [(None, [opts['foo']])]),
                    ('other', [(None, [opts['bar']])])],
              expected='''[DEFAULT]

#
# From other
#

# bar option (string value)
#bar = <None>

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('group',
         dict(opts=[('test', [('group1', [opts['foo']])])],
              expected='''[DEFAULT]


[group1]

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('empty_group',
         dict(opts=[('test', [('group1', [])])], expected='''[DEFAULT]
''')),
        ('multiple_groups',
         dict(opts=[('test', [('group1', [opts['foo']]),
                              ('group2', [opts['bar']])])],
              expected='''[DEFAULT]


[group1]

#
# From test
#

# foo option (string value)
#foo = <None>


[group2]

#
# From test
#

# bar option (string value)
#bar = <None>
''')),
        ('group_in_multiple_namespaces',
         dict(opts=[('test', [('group1', [opts['foo']])]),
                    ('other', [('group1', [opts['bar']])])],
              expected='''[DEFAULT]


[group1]

#
# From other
#

# bar option (string value)
#bar = <None>

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('hyphenated_name',
         dict(opts=[('test', [(None, [opts['foo-bar']])])],
              expected='''[DEFAULT]

#
# From test
#

# foobar (string value)
#foo_bar = <None>
''')),
        ('no_help',
         dict(opts=[('test', [(None, [opts['no_help']])])],
              log_warning=('"%s" is missing a help string', 'no_help'),
              expected='''[DEFAULT]

#
# From test
#

# (string value)
#no_help = <None>
''')),
        ('long_help',
         dict(opts=[('test', [(None, [opts['long_help']])])],
              expected='''[DEFAULT]

#
# From test
#

# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
# ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
# aliquip ex ea commodo consequat. Duis aute irure dolor in
# reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
# pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
# culpa qui officia deserunt mollit anim id est laborum. (string
# value)
#long_help = <None>
''')),
        ('long_help_wrap_at_40',
         dict(opts=[('test', [(None, [opts['long_help']])])],
              wrap_width=40,
              expected='''[DEFAULT]

#
# From test
#

# Lorem ipsum dolor sit amet,
# consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et
# dolore magna aliqua. Ut enim ad minim
# veniam, quis nostrud exercitation
# ullamco laboris nisi ut aliquip ex ea
# commodo consequat. Duis aute irure
# dolor in reprehenderit in voluptate
# velit esse cillum dolore eu fugiat
# nulla pariatur. Excepteur sint
# occaecat cupidatat non proident, sunt
# in culpa qui officia deserunt mollit
# anim id est laborum. (string value)
#long_help = <None>
''')),
        (
            'long_help_no_wrapping',
            dict(
                opts=[('test', [(None, [opts['long_help']])])],
                wrap_width=0,
                expected='''[DEFAULT]

#
# From test
#

'''

                # noqa
                '# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod '
                'tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, '
                'quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo '
                'consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse '
                'cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat '
                'non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. '
                '(string value)'
                '''
#long_help = <None>
''')),
        ('choices_opt',
         dict(opts=[('test', [(None, [opts['choices_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string with choices (string value)
# Allowed values: <None>, '', a, b, c
#choices_opt = a
''')),
        ('deprecated',
         dict(opts=[('test', [('foo', [opts['deprecated_opt']])])],
              expected='''[DEFAULT]


[foo]

#
# From test
#

# deprecated (string value)
# Deprecated group/name - [DEFAULT]/foobar
#bar = <None>
''')),
        ('deprecated_for_removal',
         dict(opts=[('test', [('foo', [opts['deprecated_for_removal_opt']])])],
              expected='''[DEFAULT]


[foo]

#
# From test
#

# deprecated for removal (string value)
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
#bar = <None>
''')),
        ('deprecated_group',
         dict(opts=[('test', [('foo', [opts['deprecated_group']])])],
              expected='''[DEFAULT]


[foo]

#
# From test
#

# deprecated (string value)
# Deprecated group/name - [group1]/foobar
#bar = <None>
''')),
        ('unknown_type',
         dict(opts=[('test', [(None, [opts['unknown_type']])])],
              log_warning=('Unknown option type: %s',
                           repr(opts['unknown_type'])),
              expected='''[DEFAULT]

#
# From test
#

# unknown (unknown type)
#unknown_opt = 123
''')),
        ('str_opt',
         dict(opts=[('test', [(None, [opts['str_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string (string value)
#str_opt = foo bar
''')),
        ('str_opt_with_space',
         dict(opts=[('test', [(None, [opts['str_opt_with_space']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string with spaces (string value)
#str_opt = "  foo bar  "
''')),
        ('bool_opt',
         dict(opts=[('test', [(None, [opts['bool_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a boolean (boolean value)
#bool_opt = false
''')),
        ('int_opt',
         dict(opts=[('test', [(None, [opts['int_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# an integer (integer value)
#int_opt = 10
''')),
        ('float_opt',
         dict(opts=[('test', [(None, [opts['float_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a float (floating point value)
#float_opt = 0.1
''')),
        ('list_opt',
         dict(opts=[('test', [(None, [opts['list_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a list (list value)
#list_opt = 1,2,3
''')),
        ('dict_opt',
         dict(opts=[('test', [(None, [opts['dict_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a dict (dict value)
#dict_opt = 1:yes,2:no
''')),
        ('multi_opt',
         dict(opts=[('test', [(None, [opts['multi_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt = 1
#multi_opt = 2
#multi_opt = 3
''')),
        ('multi_opt_none',
         dict(opts=[('test', [(None, [opts['multi_opt_none']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt_none =
''')),
        ('multi_opt_empty',
         dict(opts=[('test', [(None, [opts['multi_opt_empty']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt_empty =
''')),
        ('str_opt_sample_default',
         dict(opts=[('test', [(None, [opts['str_opt_sample_default']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string (string value)
#str_opt = fooishbar
''')),
        ('multi_opt_sample_default',
         dict(opts=[('test', [(None, [opts['multi_opt_sample_default']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt = 5
#multi_opt = 6
''')),
    ]

    output_file_scenarios = [
        ('stdout', dict(stdout=True, output_file=None)),
        ('output_file', dict(output_file='sample.conf', stdout=False)),
    ]

    @classmethod
    def generate_scenarios(cls):
        cls.scenarios = testscenarios.multiply_scenarios(
            cls.content_scenarios, cls.output_file_scenarios)

    def setUp(self):
        super(GeneratorTestCase, self).setUp()

        self.conf = cfg.ConfigOpts()
        self.config_fixture = config_fixture.Config(self.conf)
        self.config = self.config_fixture.config
        self.useFixture(self.config_fixture)

        self.tempdir = self.useFixture(fixtures.TempDir())

    def _capture_stream(self, stream_name):
        self.useFixture(
            fixtures.MonkeyPatch("sys.%s" % stream_name, moves.StringIO()))
        return getattr(sys, stream_name)

    def _capture_stdout(self):
        return self._capture_stream('stdout')

    @mock.patch('stevedore.named.NamedExtensionManager')
    @mock.patch.object(generator, 'LOG')
    def test_generate(self, mock_log, named_mgr):
        generator.register_cli_opts(self.conf)

        namespaces = [i[0] for i in self.opts]
        self.config(namespace=namespaces)

        wrap_width = getattr(self, 'wrap_width', None)
        if wrap_width is not None:
            self.config(wrap_width=wrap_width)

        if self.stdout:
            stdout = self._capture_stdout()
        else:
            output_file = self.tempdir.join(self.output_file)
            self.config(output_file=output_file)

        mock_eps = []
        for name, opts in self.opts:
            mock_ep = mock.Mock()
            mock_ep.configure_mock(name=name, obj=opts)
            mock_eps.append(mock_ep)
        named_mgr.return_value = mock_eps

        generator.generate(self.conf)

        if self.stdout:
            self.assertEqual(self.expected, stdout.getvalue())
        else:
            content = open(output_file).read()
            self.assertEqual(self.expected, content)

        named_mgr.assert_called_once_with(
            'oslo.config.opts',
            names=namespaces,
            on_load_failure_callback=generator.on_load_failure_callback,
            invoke_on_load=True)

        log_warning = getattr(self, 'log_warning', None)
        if log_warning is not None:
            mock_log.warning.assert_called_once_with(*log_warning)
        else:
            self.assertFalse(mock_log.warning.called)
Example #22
0
    * False

Related options:
    * https_ca_certificates_file

"""),
    cfg.DictOpt('http_proxy_information',
                default={},
                help="""
The http/https proxy information to be used to connect to the remote
server.

This configuration option specifies the http/https proxy information
that should be used to connect to the remote server. The proxy
information should be a key value pair of the scheme and proxy, for
example, http:10.0.0.1:3128. You can also specify proxies for multiple
schemes by separating the key value pairs with a comma, for example,
http:10.0.0.1:3128, https:10.0.0.1:1080.

Possible values:
    * A comma separated list of scheme:proxy pairs as described above

Related options:
    * None

""")
]


class StoreLocation(glance_store.location.StoreLocation):
    """Class describing an HTTP(S) URI."""
    def process_specs(self):
Example #23
0
from oslo_log import log
import six

from arsenal.common import util

LOG = log.getLogger(__name__)

opts = [
    cfg.StrOpt('module_class',
               default=('simple_proportional_strategy.'
                        'SimpleProportionalStrategy'),
               help='The strategy module to load.'),
    cfg.DictOpt('image_weights',
                default={},
                help='A dictionary where the keys are image names and the '
                     'values are their assigned weights to use when picking '
                     'images to cache to nodes. Image names should be strings '
                     'and weights should be non-negative integers. '
                     'Images with larger weights will be more likely to be '
                     'cached than those with lower weights.'),
    cfg.IntOpt('default_image_weight',
               default=1,
               help='The integral weight to use if a given image has '
                    'no corresponding entry in image_weights. Default is 1.')
]

strategy_group = cfg.OptGroup(name='strategy',
                              title='Strategy Options')

CONF = cfg.CONF
CONF.register_group(strategy_group)
CONF.register_opts(opts, strategy_group)
                    "showing the available bandwidth for the given device "
                    "in the given direction. The direction is meant from "
                    "VM perspective. Bandwidth is measured in kilobits per "
                    "second (kbps). The device must appear in "
                    "physical_device_mappings as the value. But not all "
                    "devices in physical_device_mappings must be listed "
                    "here. For a device not listed here we neither create "
                    "a resource provider in placement nor report "
                    "inventories against. An omitted direction means we do "
                    "not report an inventory for the corresponding "
                    "class.")),
 cfg.DictOpt('resource_provider_hypervisors',
             default={},
             help=_("Mapping of network devices to hypervisors: "
                    "<network_device>:<hypervisor>,... "
                    "hypervisor name is used to locate the parent of the "
                    "resource provider tree. Only needs to be set in the "
                    "rare case when the hypervisor name is different from "
                    "the DEFAULT.host config option value as known by the "
                    "nova-compute managing that hypervisor.")),
 cfg.DictOpt('resource_provider_inventory_defaults',
             default={
                 'allocation_ratio': 1.0,
                 'min_unit': 1,
                 'step_size': 1,
                 'reserved': 0
             },
             help=_("Key:value pairs to specify defaults used "
                    "while reporting resource provider inventories. "
                    "Possible keys with their types: "
                    "allocation_ratio:float, "
Example #25
0
                      "This will be autodetected from the request if not "
                      "overridden here.")),
    cfg.BoolOpt('api_v1_enabled', default=True, help=_("Expose the v1 API?")),
    cfg.BoolOpt('api_v2_enabled', default=True, help=_("Expose the v2 API?")),
    cfg.BoolOpt('allow_tls_terminated_listeners',
                default=True,
                help=_("Allow users to create TLS Terminated listeners?")),
    cfg.BoolOpt('allow_ping_health_monitors',
                default=True,
                help=_("Allow users to create PING type Health Monitors?")),
    cfg.DictOpt('enabled_provider_drivers',
                help=_('List of enabled provider drivers and description '
                       'dictionaries. Must match the driver name in the '
                       'octavia.api.drivers entrypoint. Example: '
                       '{\'amphora\': \'The Octavia Amphora driver.\', '
                       '\'octavia\': \'Deprecated alias of the Octavia '
                       'Amphora driver.\'}'),
                default={
                    'amphora': 'The Octavia Amphora driver.',
                    'octavia': 'Deprecated alias of the Octavia Amphora '
                    'driver.'
                }),
    cfg.StrOpt('default_provider_driver',
               default='amphora',
               help=_('Default provider driver.')),
    cfg.IntOpt('udp_connect_min_interval_health_monitor',
               default=3,
               help=_("The minimum health monitor delay interval for the "
                      "UDP-CONNECT Health Monitor type. A negative integer "
                      "value means 'no limit'.")),
]
Example #26
0
    oslo_cfg.IntOpt('ports_pool_min',
                    help=_("Set a target minimum size of the pool of ports"),
                    default=5),
    oslo_cfg.IntOpt('ports_pool_batch',
                    help=_("Number of ports to be created in a bulk request"),
                    default=10),
    oslo_cfg.IntOpt('ports_pool_update_frequency',
                    help=_("Minimum interval (in seconds) "
                           "between pool updates"),
                    default=20),
    oslo_cfg.DictOpt('pools_vif_drivers',
                     help=_("Dict with the pool driver and pod driver to be "
                            "used. If not set, it will take them from the "
                            "kubernetes driver options for pool and pod "
                            "drivers respectively"),
                     default={},
                     deprecated_for_removal=True,
                     deprecated_since="Stein",
                     deprecated_reason=_(
                         "Mapping from pool->vif does not allow different "
                         "vifs to use the same pool driver. "
                         "Use vif_pool_mapping instead.")),
    oslo_cfg.DictOpt('vif_pool_mapping',
                     help=_("Dict with the pod driver and the corresponding "
                            "pool driver to be used. If not set, it will take "
                            "them from the kubernetes driver options for pool "
                            "and pod drivers respectively"),
                     default={}),
]

oslo_cfg.CONF.register_opts(vif_pool_driver_opts, "vif_pool")
Example #27
0
               "API server."),
    cfg.StrOpt("blockbridge_auth_scheme",
               default='token',
               choices=['token', 'password'],
               help="Blockbridge API authentication scheme (token "
               "or password)"),
    cfg.StrOpt("blockbridge_auth_token",
               help="Blockbridge API token (for auth scheme 'token')",
               secret=True),
    cfg.StrOpt("blockbridge_auth_user",
               help="Blockbridge API user (for auth scheme 'password')"),
    cfg.StrOpt("blockbridge_auth_password",
               help="Blockbridge API password (for auth scheme 'password')",
               secret=True),
    cfg.DictOpt("blockbridge_pools",
                default={'OpenStack': '+openstack'},
                help="Defines the set of exposed pools and their associated "
                "backend query strings"),
    cfg.StrOpt("blockbridge_default_pool",
               help="Default pool name if unspecified."),
]

CONF = cfg.CONF
CONF.register_opts(blockbridge_opts)


class BlockbridgeAPIClient(object):
    _api_cfg = None

    def __init__(self, configuration=None):
        self.configuration = configuration
Example #28
0
    cfg.StrOpt('external_svc_net',
               help=_("Default external network ID for Kubernetes services")),
    cfg.StrOpt('external_svc_subnet',
               help=_("Optional external subnet ID for Kubernetes services"),
               default=None),
    cfg.IntOpt(
        'network_device_mtu',
        help='Default MTU setting for network interface.',
        default=1500,
    ),
    cfg.IntOpt('lbaas_activation_timeout',
               help=_("Time (in seconds) that kuryr controller waits for "
                      "neutron LBaaS to be activated"),
               default=300),
    cfg.DictOpt('subnet_mapping',
                help=_("A mapping of default subnets for certain driverType "
                       "in a form of <driverType>:<SUBNET-ID>"),
                default={}),
    cfg.ListOpt('resource_tags',
                help=_("List of tags that will be applied to all OpenStack "
                       "(Neutron and Octavia) resources created by Kuryr. "
                       "This can be used to identify and garbage-collect "
                       "them when Kubernetes cluster Kuryr was serving is no "
                       "longer needed."),
                default=[]),
]

octavia_defaults = [
    cfg.StrOpt('member_mode',
               help=_("Define the communication mode between load balanacer "
                      "and its members"),
               default='L3'),
Example #29
0
            choices=BASE_OS_DISTRO,
            help='The distro type of the base image.'),
 cfg.StrOpt('base-tag', default='latest',
            help='The base distro image tag'),
 cfg.StrOpt('base-image',
            help='The base image name. Default is the same with base.'),
 cfg.StrOpt('base-arch', default=hostarch,
            choices=BASE_ARCH,
            help='The base architecture. Default is same as host.'),
 cfg.BoolOpt('debug', short='d', default=False,
             help='Turn on debugging log level'),
 cfg.BoolOpt('skip-parents', default=False,
             help='Do not rebuild parents of matched images'),
 cfg.BoolOpt('skip-existing', default=False,
             help='Do not rebuild images present in the docker cache'),
 cfg.DictOpt('build-args',
             help='Set docker build time variables'),
 cfg.BoolOpt('keep', default=False,
             help='Keep failed intermediate containers'),
 cfg.BoolOpt('list-dependencies', short='l',
             help='Show image dependencies (filtering supported)'),
 cfg.BoolOpt('list-images',
             help='Show all available images (filtering supported)'),
 cfg.StrOpt('namespace', short='n', default='kolla',
            help='The Docker namespace name'),
 cfg.StrOpt('network_mode', default=None,
            help='The network mode for Docker build. Example: host'),
 cfg.BoolOpt('cache', default=True,
             help='Use the Docker cache when building'),
 cfg.MultiOpt('profile', types.String(), short='p',
              help=('Build a pre-defined set of images, see [profiles]'
                    ' section in config. The default profiles are:'
Example #30
0
class GeneratorTestCase(base.BaseTestCase):

    groups = {
        'group1':
        cfg.OptGroup(name='group1',
                     help='Lorem ipsum dolor sit amet, consectetur '
                     'adipisicing elit, sed do eiusmod tempor '
                     'incididunt ut labore et dolore magna '
                     'aliqua. Ut enim ad minim veniam, quis '
                     'nostrud exercitation ullamco laboris '
                     'nisi ut aliquip ex ea commodo '
                     'consequat. Duis aute irure dolor in.'),
        'group2':
        cfg.OptGroup(name='group2', title='Group 2'),
        'foo':
        cfg.OptGroup(name='foo', title='Foo Title', help='foo help'),
    }

    opts = {
        'foo':
        cfg.StrOpt('foo', help='foo option'),
        'bar':
        cfg.StrOpt('bar', help='bar option'),
        'foo-bar':
        cfg.StrOpt('foo-bar', help='foobar'),
        'no_help':
        cfg.StrOpt('no_help'),
        'long_help':
        cfg.StrOpt('long_help',
                   help='Lorem ipsum dolor sit amet, consectetur '
                   'adipisicing elit, sed do eiusmod tempor '
                   'incididunt ut labore et dolore magna '
                   'aliqua. Ut enim ad minim veniam, quis '
                   'nostrud exercitation ullamco laboris '
                   'nisi ut aliquip ex ea commodo '
                   'consequat. Duis aute irure dolor in '
                   'reprehenderit in voluptate velit esse '
                   'cillum dolore eu fugiat nulla '
                   'pariatur. Excepteur sint occaecat '
                   'cupidatat non proident, sunt in culpa '
                   'qui officia deserunt mollit anim id est '
                   'laborum.'),
        'long_help_pre':
        cfg.StrOpt('long_help_pre',
                   help='This is a very long help text which '
                   'is preformatted with line breaks. '
                   'It should break when it is too long '
                   'but also keep the specified line '
                   'breaks. This makes it possible to '
                   'create lists with items:\n'
                   '\n'
                   '* item 1\n'
                   '* item 2\n'
                   '\n'
                   'and should increase the '
                   'readability.'),
        'choices_opt':
        cfg.StrOpt('choices_opt',
                   default='a',
                   choices=(None, '', 'a', 'b', 'c'),
                   help='a string with choices'),
        'deprecated_opt':
        cfg.StrOpt('bar', deprecated_name='foobar', help='deprecated'),
        'deprecated_for_removal_opt':
        cfg.StrOpt('bar',
                   deprecated_for_removal=True,
                   help='deprecated for removal'),
        'deprecated_reason_opt':
        cfg.BoolOpt(
            'turn_off_stove',
            default=False,
            deprecated_for_removal=True,
            deprecated_reason='This was supposed to work but it really, '
            'really did not. Always buy house insurance.',
            help='Turn off stove'),
        'deprecated_group':
        cfg.StrOpt('bar',
                   deprecated_group='group1',
                   deprecated_name='foobar',
                   help='deprecated'),
        # Unknown Opt default must be a string
        'unknown_type':
        cfg.Opt('unknown_opt',
                default='123',
                help='unknown',
                type=types.String(type_name='unknown type')),
        'str_opt':
        cfg.StrOpt('str_opt', default='foo bar', help='a string'),
        'str_opt_sample_default':
        cfg.StrOpt('str_opt', default='fooishbar', help='a string'),
        'str_opt_with_space':
        cfg.StrOpt('str_opt',
                   default='  foo bar  ',
                   help='a string with spaces'),
        'bool_opt':
        cfg.BoolOpt('bool_opt', default=False, help='a boolean'),
        'int_opt':
        cfg.IntOpt('int_opt', default=10, min=1, max=20, help='an integer'),
        'float_opt':
        cfg.FloatOpt('float_opt', default=0.1, help='a float'),
        'list_opt':
        cfg.ListOpt('list_opt', default=['1', '2', '3'], help='a list'),
        'dict_opt':
        cfg.DictOpt('dict_opt', default={
            '1': 'yes',
            '2': 'no'
        }, help='a dict'),
        'ip_opt':
        cfg.IPOpt('ip_opt', default='127.0.0.1', help='an ip address'),
        'port_opt':
        cfg.PortOpt('port_opt', default=80, help='a port'),
        'multi_opt':
        cfg.MultiStrOpt('multi_opt',
                        default=['1', '2', '3'],
                        help='multiple strings'),
        'multi_opt_none':
        cfg.MultiStrOpt('multi_opt_none', help='multiple strings'),
        'multi_opt_empty':
        cfg.MultiStrOpt('multi_opt_empty', default=[],
                        help='multiple strings'),
        'multi_opt_sample_default':
        cfg.MultiStrOpt('multi_opt',
                        default=['1', '2', '3'],
                        sample_default=['5', '6'],
                        help='multiple strings'),
        'string_type_with_bad_default':
        cfg.Opt('string_type_with_bad_default',
                help='string with bad default',
                default=4096),
        'custom_type':
        cfg.Opt('custom_type', help='custom help', type=type('string')),
        'custom_type_name':
        cfg.Opt('custom_opt_type',
                type=types.Integer(type_name='port'
                                   ' number'),
                default=5511,
                help='this is a port'),
    }

    content_scenarios = [
        ('empty', dict(opts=[], expected='''[DEFAULT]
''')),
        ('single_namespace',
         dict(opts=[('test', [(None, [opts['foo']])])],
              expected='''[DEFAULT]

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('multiple_namespaces',
         dict(opts=[('test', [(None, [opts['foo']])]),
                    ('other', [(None, [opts['bar']])])],
              expected='''[DEFAULT]

#
# From other
#

# bar option (string value)
#bar = <None>

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('group',
         dict(opts=[('test', [(groups['group1'], [opts['foo']])])],
              expected='''[DEFAULT]


[group1]
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
# ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
# aliquip ex ea commodo consequat. Duis aute irure dolor in.

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('empty_group',
         dict(opts=[('test', [(groups['group1'], [])])],
              expected='''[DEFAULT]
''')),
        ('multiple_groups',
         dict(opts=[('test', [(groups['group1'], [opts['foo']]),
                              (groups['group2'], [opts['bar']])])],
              expected='''[DEFAULT]


[group1]
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
# ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
# aliquip ex ea commodo consequat. Duis aute irure dolor in.

#
# From test
#

# foo option (string value)
#foo = <None>


[group2]

#
# From test
#

# bar option (string value)
#bar = <None>
''')),
        ('group_in_multiple_namespaces',
         dict(opts=[('test', [(groups['group1'], [opts['foo']])]),
                    ('other', [(groups['group1'], [opts['bar']])])],
              expected='''[DEFAULT]


[group1]
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
# ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
# aliquip ex ea commodo consequat. Duis aute irure dolor in.

#
# From other
#

# bar option (string value)
#bar = <None>

#
# From test
#

# foo option (string value)
#foo = <None>
''')),
        ('hyphenated_name',
         dict(opts=[('test', [(None, [opts['foo-bar']])])],
              expected='''[DEFAULT]

#
# From test
#

# foobar (string value)
#foo_bar = <None>
''')),
        ('no_help',
         dict(opts=[('test', [(None, [opts['no_help']])])],
              log_warning=('"%s" is missing a help string', 'no_help'),
              expected='''[DEFAULT]

#
# From test
#

# (string value)
#no_help = <None>
''')),
        ('long_help',
         dict(opts=[('test', [(None, [opts['long_help']])])],
              expected='''[DEFAULT]

#
# From test
#

# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
# ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
# aliquip ex ea commodo consequat. Duis aute irure dolor in
# reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
# pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
# culpa qui officia deserunt mollit anim id est laborum. (string
# value)
#long_help = <None>
''')),
        ('long_help_wrap_at_40',
         dict(opts=[('test', [(None, [opts['long_help']])])],
              wrap_width=40,
              expected='''[DEFAULT]

#
# From test
#

# Lorem ipsum dolor sit amet,
# consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et
# dolore magna aliqua. Ut enim ad minim
# veniam, quis nostrud exercitation
# ullamco laboris nisi ut aliquip ex ea
# commodo consequat. Duis aute irure
# dolor in reprehenderit in voluptate
# velit esse cillum dolore eu fugiat
# nulla pariatur. Excepteur sint
# occaecat cupidatat non proident, sunt
# in culpa qui officia deserunt mollit
# anim id est laborum. (string value)
#long_help = <None>
''')),
        (
            'long_help_no_wrapping',
            dict(
                opts=[('test', [(None, [opts['long_help']])])],
                wrap_width=0,
                expected='''[DEFAULT]

#
# From test
#

'''

                # noqa
                '# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod '
                'tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, '
                'quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo '
                'consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse '
                'cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat '
                'non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. '
                '(string value)'
                '''
#long_help = <None>
''')),
        ('long_help_with_preformatting',
         dict(opts=[('test', [(None, [opts['long_help_pre']])])],
              wrap_width=70,
              expected='''[DEFAULT]

#
# From test
#

# This is a very long help text which is preformatted with line
# breaks. It should break when it is too long but also keep the
# specified line breaks. This makes it possible to create lists with
# items:
#
# * item 1
# * item 2
#
# and should increase the readability. (string value)
#long_help_pre = <None>
''')),
        ('choices_opt',
         dict(opts=[('test', [(None, [opts['choices_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string with choices (string value)
# Allowed values: <None>, '', a, b, c
#choices_opt = a
''')),
        ('deprecated',
         dict(opts=[('test', [(groups['foo'], [opts['deprecated_opt']])])],
              expected='''[DEFAULT]


[foo]
# foo help

#
# From test
#

# deprecated (string value)
# Deprecated group/name - [DEFAULT]/foobar
#bar = <None>
''')),
        ('deprecated_for_removal',
         dict(opts=[('test', [(groups['foo'],
                               [opts['deprecated_for_removal_opt']])])],
              expected='''[DEFAULT]


[foo]
# foo help

#
# From test
#

# deprecated for removal (string value)
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
#bar = <None>
''')),
        ('deprecated_reason',
         dict(opts=[('test', [(groups['foo'], [opts['deprecated_reason_opt']])
                              ])],
              expected='''[DEFAULT]


[foo]
# foo help

#
# From test
#

# Turn off stove (boolean value)
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
# Reason: This was supposed to work but it really, really did not.
# Always buy house insurance.
#turn_off_stove = false
''')),
        ('deprecated_group',
         dict(opts=[('test', [(groups['foo'], [opts['deprecated_group']])])],
              expected='''[DEFAULT]


[foo]
# foo help

#
# From test
#

# deprecated (string value)
# Deprecated group/name - [group1]/foobar
#bar = <None>
''')),
        ('unknown_type',
         dict(opts=[('test', [(None, [opts['unknown_type']])])],
              expected='''[DEFAULT]

#
# From test
#

# unknown (unknown type)
#unknown_opt = 123
''')),
        ('str_opt',
         dict(opts=[('test', [(None, [opts['str_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string (string value)
#str_opt = foo bar
''')),
        ('str_opt_with_space',
         dict(opts=[('test', [(None, [opts['str_opt_with_space']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string with spaces (string value)
#str_opt = "  foo bar  "
''')),
        ('bool_opt',
         dict(opts=[('test', [(None, [opts['bool_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a boolean (boolean value)
#bool_opt = false
''')),
        ('int_opt',
         dict(opts=[('test', [(None, [opts['int_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# an integer (integer value)
# Minimum value: 1
# Maximum value: 20
#int_opt = 10
''')),
        ('float_opt',
         dict(opts=[('test', [(None, [opts['float_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a float (floating point value)
#float_opt = 0.1
''')),
        ('list_opt',
         dict(opts=[('test', [(None, [opts['list_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a list (list value)
#list_opt = 1,2,3
''')),
        ('dict_opt',
         dict(opts=[('test', [(None, [opts['dict_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a dict (dict value)
#dict_opt = 1:yes,2:no
''')),
        ('ip_opt',
         dict(opts=[('test', [(None, [opts['ip_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# an ip address (IP address value)
#ip_opt = 127.0.0.1
''')),
        ('port_opt',
         dict(opts=[('test', [(None, [opts['port_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# a port (port value)
# Minimum value: 1
# Maximum value: 65535
#port_opt = 80
''')),
        ('multi_opt',
         dict(opts=[('test', [(None, [opts['multi_opt']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt = 1
#multi_opt = 2
#multi_opt = 3
''')),
        ('multi_opt_none',
         dict(opts=[('test', [(None, [opts['multi_opt_none']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt_none =
''')),
        ('multi_opt_empty',
         dict(opts=[('test', [(None, [opts['multi_opt_empty']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt_empty =
''')),
        ('str_opt_sample_default',
         dict(opts=[('test', [(None, [opts['str_opt_sample_default']])])],
              expected='''[DEFAULT]

#
# From test
#

# a string (string value)
#str_opt = fooishbar
''')),
        ('multi_opt_sample_default',
         dict(opts=[('test', [(None, [opts['multi_opt_sample_default']])])],
              expected='''[DEFAULT]

#
# From test
#

# multiple strings (multi valued)
#multi_opt = 5
#multi_opt = 6
''')),
        ('custom_type_name',
         dict(opts=[('test', [(None, [opts['custom_type_name']])])],
              expected='''[DEFAULT]

#
# From test
#

# this is a port (port number)
#custom_opt_type = 5511
''')),
        ('custom_type',
         dict(opts=[('test', [(None, [opts['custom_type']])])],
              expected='''[DEFAULT]

#
# From test
#

# custom help (unknown value)
#custom_type = <None>
''')),
        ('string_type_with_bad_default',
         dict(opts=[('test', [(None, [opts['string_type_with_bad_default']])])
                    ],
              expected='''[DEFAULT]

#
# From test
#

# string with bad default (string value)
#string_type_with_bad_default = 4096
''')),
    ]

    output_file_scenarios = [
        ('stdout', dict(stdout=True, output_file=None)),
        ('output_file', dict(output_file='sample.conf', stdout=False)),
    ]

    @classmethod
    def generate_scenarios(cls):
        cls.scenarios = testscenarios.multiply_scenarios(
            cls.content_scenarios, cls.output_file_scenarios)

    def setUp(self):
        super(GeneratorTestCase, self).setUp()

        self.conf = cfg.ConfigOpts()
        self.config_fixture = config_fixture.Config(self.conf)
        self.config = self.config_fixture.config
        self.useFixture(self.config_fixture)

        self.tempdir = self.useFixture(fixtures.TempDir())

    def _capture_stream(self, stream_name):
        self.useFixture(
            fixtures.MonkeyPatch("sys.%s" % stream_name, moves.StringIO()))
        return getattr(sys, stream_name)

    def _capture_stdout(self):
        return self._capture_stream('stdout')

    @mock.patch('stevedore.named.NamedExtensionManager')
    @mock.patch.object(generator, 'LOG')
    def test_generate(self, mock_log, named_mgr):
        generator.register_cli_opts(self.conf)

        namespaces = [i[0] for i in self.opts]
        self.config(namespace=namespaces)

        for group in self.groups.values():
            self.conf.register_group(group)

        wrap_width = getattr(self, 'wrap_width', None)
        if wrap_width is not None:
            self.config(wrap_width=wrap_width)

        if self.stdout:
            stdout = self._capture_stdout()
        else:
            output_file = self.tempdir.join(self.output_file)
            self.config(output_file=output_file)

        mock_eps = []
        for name, opts in self.opts:
            mock_ep = mock.Mock()
            mock_ep.configure_mock(name=name, obj=opts)
            mock_eps.append(mock_ep)
        named_mgr.return_value = mock_eps

        generator.generate(self.conf)

        if self.stdout:
            self.assertEqual(self.expected, stdout.getvalue())
        else:
            content = open(output_file).read()
            self.assertEqual(self.expected, content)

        named_mgr.assert_called_once_with(
            'oslo.config.opts',
            names=namespaces,
            on_load_failure_callback=generator.on_load_failure_callback,
            invoke_on_load=True)

        log_warning = getattr(self, 'log_warning', None)
        if log_warning is not None:
            mock_log.warning.assert_called_once_with(*log_warning)
        else:
            self.assertFalse(mock_log.warning.called)