コード例 #1
0
class ListTypeTests(TypeTestHelper, unittest.TestCase):
    type = types.List()

    def test_empty_value(self):
        self.assertConvertedValue('', [])

    def test_single_value(self):
        self.assertConvertedValue(' foo bar ', ['foo bar'])

    def test_tuple_of_values(self):
        self.assertConvertedValue(('foo', 'bar'), ['foo', 'bar'])

    def test_list_of_values(self):
        self.assertConvertedValue(' foo bar, baz ', ['foo bar', 'baz'])

    def test_list_of_values_containing_commas(self):
        self.type_instance = types.List(types.String(quotes=True))
        self.assertConvertedValue('foo,"bar, baz",bam',
                                  ['foo', 'bar, baz', 'bam'])

    def test_list_of_lists(self):
        self.type_instance = types.List(types.List(types.String(),
                                                   bounds=True))
        self.assertConvertedValue('[foo],[bar, baz],[bam]',
                                  [['foo'], ['bar', 'baz'], ['bam']])

    def test_list_of_custom_type(self):
        self.type_instance = types.List(types.Integer())
        self.assertConvertedValue('1,2,3,5', [1, 2, 3, 5])

    def test_bounds_parsing(self):
        self.type_instance = types.List(types.Integer(), bounds=True)
        self.assertConvertedValue('[1,2,3]', [1, 2, 3])

    def test_bounds_required(self):
        self.type_instance = types.List(types.Integer(), bounds=True)
        self.assertInvalid('1,2,3')
        self.assertInvalid('[1,2,3')
        self.assertInvalid('1,2,3]')

    def test_repr(self):
        t = types.List(types.Integer())
        self.assertEqual('List of Integer', repr(t))

    def test_equal(self):
        self.assertTrue(types.List() == types.List())

    def test_equal_with_equal_custom_item_types(self):
        it1 = types.Integer()
        it2 = types.Integer()
        self.assertTrue(types.List(it1) == types.List(it2))

    def test_not_equal_with_non_equal_custom_item_types(self):
        it1 = types.Integer()
        it2 = types.String()
        self.assertFalse(it1 == it2)
        self.assertFalse(types.List(it1) == types.List(it2))

    def test_not_equal_to_other_class(self):
        self.assertFalse(types.List() == types.Integer())
コード例 #2
0
    def _get_pdu_opts(cls):
        return [
            cfg.Opt(
                name="pdu_servers",
                type=types.Dict(
                    value_type=types.String(),
                ),
                help="A mapping between PDU names and their endpoint "
                     "(IP/FQDN)",
                sample_default=(
                    "[my_data_puller]\n"
                    "#pdu_servers=PDU_1:127.0.0.1,PDU_2:192.168.1.1")
            ),
            cfg.MultiOpt(
                name="mapping",
                item_type=types.Dict(
                    value_type=types.List(
                        bounds=True,
                        item_type=types.Dict(
                            value_type=types.Integer()
                        ),
                    ),
                ),
                help="Each entry specified here should be an entry mapping a "
                     "PDU name to a list of servers. Each server is a pair "
                     "between its endpoint and its related outlet ID.",
                sample_default=(
                    "[my_data_puller]\n"
                    "#mapping = PDU_1:[serv1.hostname:1,serv2.hostname:2]\n"
                    "#mapping = PDU_2:[serv3.hostname:1,serv4.hostname:2]"
                ),

            ),
        ]
コード例 #3
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_bounds_required(self):
     self.type_instance = types.List(types.Integer(), bounds=True)
     self.assertInvalid('1,2,3')
     self.assertInvalid('[1,2,3')
     self.assertInvalid('1,2,3]')
コード例 #4
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_bounds_parsing(self):
     self.type_instance = types.List(types.Integer(), bounds=True)
     self.assertConvertedValue('[1,2,3]', [1, 2, 3])
コード例 #5
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_tuple_of_custom_type(self):
     self.type_instance = types.List(types.Integer())
     self.assertConvertedValue(('1', '2', '3', '5'), [1, 2, 3, 5])
コード例 #6
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_list_of_custom_type_containing_trailing_comma(self):
     self.type_instance = types.List(types.Integer())
     self.assertConvertedValue('1,2,3,5,', [1, 2, 3, 5])
コード例 #7
0
ファイル: hp_xp_opts.py プロジェクト: simplivity/cinder
    cfg.ListOpt('hpxp_target_ports',
                default=None,
                required=True,
                help='Target port names for host group or iSCSI target'),
    cfg.ListOpt('hpxp_compute_target_ports',
                default=None,
                help=('Target port names of compute node '
                      'for host group or iSCSI target')),
    cfg.BoolOpt('hpxp_group_request',
                default=False,
                help='Request for creating host group or iSCSI target'),
]

HORCM_VOLUME_OPTS = [
    cfg.Opt('hpxp_horcm_numbers',
            type=types.List(item_type=types.Integer(min=0, max=2047)),
            default=[200, 201],
            help='Instance numbers for HORCM'),
    cfg.StrOpt('hpxp_horcm_user',
               default=None,
               required=True,
               help='Username of storage system for HORCM'),
    cfg.BoolOpt('hpxp_horcm_add_conf',
                default=True,
                help='Add to HORCM configuration'),
    cfg.StrOpt('hpxp_horcm_resource_name',
               default='meta_resource',
               help='Resource group name of storage system for HORCM'),
    cfg.BoolOpt(
        'hpxp_horcm_name_only_discovery',
        default=False,
コード例 #8
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_not_equal_to_other_class(self):
     self.assertFalse(types.List() == types.Integer())
コード例 #9
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_equal_with_equal_custom_item_types(self):
     it1 = types.Integer()
     it2 = types.Integer()
     self.assertTrue(types.List(it1) == types.List(it2))
コード例 #10
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_list_not_list(self):
     t = types.List()
     self.assertEqual(['foo'],
                      t.format_defaults('',
                                        sample_default=Exception('foo')))
コード例 #11
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_list_no_type(self):
     t = types.List()
     test_list = ['foo', Exception(' bar ')]
     self.assertEqual(['foo," bar "'],
                      t.format_defaults('', sample_default=test_list))
コード例 #12
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_list_string(self):
     t = types.List(item_type=types.String())
     test_list = ['foo', Exception(' bar ')]
     self.assertEqual(['foo," bar "'],
                      t.format_defaults('', sample_default=test_list))
コード例 #13
0
ファイル: engine_driver.py プロジェクト: takanattie/masakari
can be overridden to make the metadata key different per failure type.
    """),
]

taskflow_options = [
    cfg.StrOpt('connection',
               help="""
The SQLAlchemy connection string to use to connect to the taskflow database.
"""),
]

taskflow_driver_recovery_flows = [
    cfg.Opt('host_auto_failure_recovery_tasks',
            type=types.Dict(bounds=False,
                            value_type=types.List(
                                bounds=True,
                                item_type=types.String(quotes=True))),
            default={
                'pre': ['disable_compute_service_task'],
                'main': ['prepare_HA_enabled_instances_task'],
                'post': ['evacuate_instances_task']
            },
            help=("""
This option allows operator to customize tasks to be executed for host failure
auto recovery workflow.

Provide list of strings reflecting to the task classes that should be included
to the host failure recovery workflow. The full classname path of all task
classes should be defined in the 'masakari.task_flow.tasks' of setup.cfg and
these classes may be implemented by OpenStack Masaskari project team, deployer
or third party.
コード例 #14
0
     'physnet',
     help=_('This is required if Nexus VXLAN overlay feature is '
            'configured.  It should be the physical network name defined '
            'in "network_vlan_ranges" (defined beneath the "ml2_type_vlan" '
            'section) that this switch is controlling.  The configured '
            '"physnet" is the physical network domain that is connected '
            'to this switch. The vlan ranges defined in '
            '"network_vlan_ranges" for a physical '
            'network are allocated dynamically and are unique per physical '
            'network. These dynamic vlans may be reused across physical '
            'networks.  This configuration applies to non-baremetal '
            'only.')),
 cfg.Opt('host_ports_mapping',
         default={},
         sample_default='<None>',
         type=types.Dict(value_type=types.List(bounds=True)),
         help=_(
             'A list of key:value pairs describing which host is '
             'connected to which physical port or portchannel on the '
             'Nexus switch. The format should look like:\n'
             'host_port_mapping='
             '<your-hostname>:[<intf_type><port>,<intf_type><port>],\n'
             '                  <your-second-host>:[<intf_type><port>]\n'
             'For example:\n'
             'host_port_mapping='
             'host-1:[ethernet1/1, ethernet1/2],\n'
             '                  host-2:[ethernet1/3],\n'
             '                  host-3:[port-channel20]\n'
             'Lines can be broken with indentation to ensure config files '
             'remain readable. '
             'All compute nodes must be configured while '
コード例 #15
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_repr(self):
     t = types.List(types.Integer())
     self.assertEqual('List of Integer', repr(t))
コード例 #16
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_equal(self):
     self.assertTrue(types.List() == types.List())
コード例 #17
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_list_of_values_containing_commas(self):
     self.type_instance = types.List(types.String(quotes=True))
     self.assertConvertedValue('foo,"bar, baz",bam',
                               ['foo', 'bar, baz', 'bam'])
コード例 #18
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_not_equal_with_non_equal_custom_item_types(self):
     it1 = types.Integer()
     it2 = types.String()
     self.assertFalse(it1 == it2)
     self.assertFalse(types.List(it1) == types.List(it2))
コード例 #19
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_list_of_lists(self):
     self.type_instance = types.List(types.List(types.String(),
                                                bounds=True))
     self.assertConvertedValue('[foo],[bar, baz],[bam]',
                               [['foo'], ['bar', 'baz'], ['bam']])
コード例 #20
0

def CapNameOrInt(value):
    value = str(value).strip()
    try:
        return capabilities.CAPS_BYNAME[value]
    except KeyError:
        return int(value)


OPTS = [
    cfg.StrOpt('user', help=_('User that the privsep daemon should run as.')),
    cfg.StrOpt('group',
               help=_('Group that the privsep daemon should run as.')),
    cfg.Opt('capabilities',
            type=types.List(CapNameOrInt),
            default=[],
            help=_('List of Linux capabilities retained by the privsep '
                   'daemon.')),
    cfg.StrOpt('helper_command',
               help=_('Command to invoke to start the privsep daemon if '
                      'not using the "fork" method. '
                      'If not specified, a default is generated using '
                      '"sudo privsep-helper" and arguments designed to '
                      'recreate the current configuration. '
                      'This command must accept suitable --privsep_context '
                      'and --privsep_sock_path arguments.')),
]

_ENTRYPOINT_ATTR = 'privsep_entrypoint'
_HELPER_COMMAND_PREFIX = ['sudo']
コード例 #21
0
ファイル: test_types.py プロジェクト: nickpfeil/Cellar
 def test_list_of_custom_type(self):
     self.type_instance = types.List(types.Integer())
     self.assertConvertedValue('1,2,3,5', [1, 2, 3, 5])