• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_random_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron.common.utils.get_random_string函数的典型用法代码示例。如果您正苦于以下问题:Python get_random_string函数的具体用法?Python get_random_string怎么用?Python get_random_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_random_string函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, labels=None, down_revision=None):
     if not labels:
         labels = set()
     self.branch_labels = labels
     self.down_revision = down_revision
     self.revision = utils.get_random_string(10)
     self.module = mock.MagicMock()
开发者ID:yizhongyin,项目名称:OpenstackLiberty,代码行数:7,代码来源:test_migration.py


示例2: patch_supported

def patch_supported():
    seed = utils.get_random_string(6)
    name = "patchtest-" + seed
    peer_name = "peertest0-" + seed
    patch_name = "peertest1-" + seed
    with ovs_lib.OVSBridge(name) as br:
        port = br.add_patch_port(patch_name, peer_name)
        return port != ovs_lib.INVALID_OFPORT
开发者ID:asgard-lab,项目名称:neutron,代码行数:8,代码来源:checks.py


示例3: ovs_conntrack_supported

def ovs_conntrack_supported():
    random_str = utils.get_random_string(6)
    br_name = "ovs-test-" + random_str

    with ovs_lib.OVSBridge(br_name) as br:
        try:
            br.set_protocols(
                "OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14")
        except RuntimeError as e:
            LOG.debug("Exception while checking ovs conntrack support: %s", e)
            return False
    return ofctl_arg_supported(cmd='add-flow', ct_state='+trk', actions='drop')
开发者ID:Blahhhhh,项目名称:neutron,代码行数:12,代码来源:checks.py


示例4: get_related_rand_names

def get_related_rand_names(prefixes, max_length=None):
    """Returns a list of the prefixes with the same random characters appended

    :param prefixes: A list of prefix strings
    :param max_length: The maximum length of each returned string
    :returns: A list with each prefix appended with the same random characters
    """

    if max_length:
        length = max_length - max(len(p) for p in prefixes)
        if length <= 0:
            raise ValueError("'max_length' must be longer than all prefixes")
    else:
        length = 8
    rndchrs = utils.get_random_string(length)
    return [p + rndchrs for p in prefixes]
开发者ID:Jackwwg,项目名称:neutron,代码行数:16,代码来源:base.py


示例5: keepalived_ipv6_supported

def keepalived_ipv6_supported():
    """Check if keepalived supports IPv6 functionality.

    Validation is done as follows.
    1. Create a namespace.
    2. Create OVS bridge with two ports (ha_port and gw_port)
    3. Move the ovs ports to the namespace.
    4. Spawn keepalived process inside the namespace with IPv6 configuration.
    5. Verify if IPv6 address is assigned to gw_port.
    6. Verify if IPv6 default route is configured by keepalived.
    """

    random_str = utils.get_random_string(6)
    br_name = "ka-test-" + random_str
    ha_port = ha_router.HA_DEV_PREFIX + random_str
    gw_port = namespaces.INTERNAL_DEV_PREFIX + random_str
    gw_vip = 'fdf8:f53b:82e4::10/64'
    expected_default_gw = 'fe80:f816::1'

    with ovs_lib.OVSBridge(br_name) as br:
        with KeepalivedIPv6Test(ha_port, gw_port, gw_vip,
                                expected_default_gw) as ka:
            br.add_port(ha_port, ('type', 'internal'))
            br.add_port(gw_port, ('type', 'internal'))

            ha_dev = ip_lib.IPDevice(ha_port)
            gw_dev = ip_lib.IPDevice(gw_port)

            ha_dev.link.set_netns(ka.nsname)
            gw_dev.link.set_netns(ka.nsname)

            ha_dev.link.set_up()
            gw_dev.link.set_up()

            ka.configure()

            ka.start_keepalived_process()

            ka.verify_ipv6_address_assignment(gw_dev)

            default_gw = gw_dev.route.get_gateway(ip_version=6)
            if default_gw:
                default_gw = default_gw['gateway']

    return expected_default_gw == default_gw
开发者ID:asgard-lab,项目名称:neutron,代码行数:45,代码来源:checks.py


示例6: get_rand_name

def get_rand_name(max_length=None, prefix='test'):
    """Return a random string.

    The string will start with 'prefix' and will be exactly 'max_length'.
    If 'max_length' is None, then exactly 8 random characters, each
    hexadecimal, will be added. In case len(prefix) <= len(max_length),
    ValueError will be raised to indicate the problem.
    """

    if max_length:
        length = max_length - len(prefix)
        if length <= 0:
            raise ValueError("'max_length' must be bigger than 'len(prefix)'.")

    else:
        length = 8

    return prefix + utils.get_random_string(length)
开发者ID:dlevy-ibm,项目名称:neutron,代码行数:18,代码来源:base.py


示例7: ofctl_arg_supported

def ofctl_arg_supported(cmd, **kwargs):
    """Verify if ovs-ofctl binary supports cmd with **kwargs.

    :param cmd: ovs-ofctl command to use for test.
    :param **kwargs: arguments to test with the command.
    :returns: a boolean if the supplied arguments are supported.
    """
    br_name = "br-test-%s" % utils.get_random_string(6)
    with ovs_lib.OVSBridge(br_name) as test_br:
        full_args = ["ovs-ofctl", cmd, test_br.br_name, ovs_lib._build_flow_expr_str(kwargs, cmd.split("-")[0])]
        try:
            agent_utils.execute(full_args, run_as_root=True)
        except RuntimeError as e:
            LOG.debug("Exception while checking supported feature via " "command %s. Exception: %s", full_args, e)
            return False
        except Exception:
            LOG.exception(_LE("Unexpected exception while checking supported" " feature via command: %s"), full_args)
            return False
        else:
            return True
开发者ID:EnterSrl,项目名称:neutron,代码行数:20,代码来源:checks.py


示例8: ofctl_arg_supported

def ofctl_arg_supported(root_helper, cmd, args):
    '''Verify if ovs-ofctl binary supports command with specific args.

    :param root_helper: utility to use when running shell cmds.
    :param cmd: ovs-vsctl command to use for test.
    :param args: arguments to test with command.
    :returns: a boolean if the args supported.
    '''
    supported = True
    br_name = 'br-test-%s' % common_utils.get_random_string(6)
    test_br = OVSBridge(br_name, root_helper)
    test_br.reset_bridge()

    full_args = ["ovs-ofctl", cmd, test_br.br_name] + args
    try:
        utils.execute(full_args, root_helper=root_helper)
    except Exception:
        supported = False

    test_br.destroy()
    return supported
开发者ID:bradau,项目名称:neutron,代码行数:21,代码来源:ovs_lib.py


示例9: iproute2_vxlan_supported

def iproute2_vxlan_supported():
    ip = ip_lib.IPWrapper()
    name = "vxlantest-" + utils.get_random_string(4)
    port = ip.add_vxlan(name, 3000)
    ip.del_veth(name)
    return name == port.name
开发者ID:asgard-lab,项目名称:neutron,代码行数:6,代码来源:checks.py


示例10: ovs_geneve_supported

def ovs_geneve_supported(from_ip='192.0.2.3', to_ip='192.0.2.4'):
    name = "genevetest-" + utils.get_random_string(6)
    with ovs_lib.OVSBridge(name) as br:
        port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_GENEVE)
        return port != ovs_lib.INVALID_OFPORT
开发者ID:asgard-lab,项目名称:neutron,代码行数:5,代码来源:checks.py


示例11: ovs_vxlan_supported

def ovs_vxlan_supported(from_ip='192.0.2.1', to_ip='192.0.2.2'):
    name = "vxlantest-" + utils.get_random_string(6)
    with ovs_lib.OVSBridge(name) as br:
        port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
        return port != ovs_lib.INVALID_OFPORT
开发者ID:asgard-lab,项目名称:neutron,代码行数:5,代码来源:checks.py


示例12: test_get_random_string

 def test_get_random_string(self):
     length = 127
     random_string = utils.get_random_string(length)
     self.assertEqual(length, len(random_string))
     regex = re.compile('^[0-9a-fA-F]+$')
     self.assertIsNotNone(regex.match(random_string))
开发者ID:judytong,项目名称:neutron,代码行数:6,代码来源:test_utils.py


示例13: generate_tap_device_name

def generate_tap_device_name():
    return n_consts.TAP_DEVICE_PREFIX + common_utils.get_random_string(
        n_consts.DEVICE_NAME_MAX_LEN - len(n_consts.TAP_DEVICE_PREFIX))
开发者ID:coreycb,项目名称:neutron,代码行数:3,代码来源:test_ovsdb_handler.py


示例14: setUp

 def setUp(self):
     super(TestResourceAllocator, self).setUp()
     self.ra = resource_allocator.ResourceAllocator(
         utils.get_random_string(6), lambda: 42)
     self.addCleanup(safe_remove_file, self.ra._state_file_path)
开发者ID:HoratiusTang,项目名称:neutron,代码行数:5,代码来源:test_resource_allocator.py



注:本文中的neutron.common.utils.get_random_string函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.ip_to_cidr函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_random_mac函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap