本文整理汇总了Python中neutron.tests.tools.fail函数的典型用法代码示例。如果您正苦于以下问题:Python fail函数的具体用法?Python fail怎么用?Python fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fail函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_peer_name
def get_peer_name(name):
if name.startswith(VETH0_PREFIX):
return name.replace(VETH0_PREFIX, VETH1_PREFIX)
elif name.startswith(VETH1_PREFIX):
return name.replace(VETH1_PREFIX, VETH0_PREFIX)
else:
tools.fail("%s is not a valid VethFixture veth endpoint" % name)
示例2: assert_no_ping
def assert_no_ping(self, dst_ip):
try:
self._ping_destination(dst_ip)
tools.fail("destination ip %(dst_ip)s is replying to ping"
"from namespace %(ns)s, but it shouldn't" %
{'ns': self.namespace.namespace, 'dst_ip': dst_ip})
except RuntimeError:
pass
示例3: get
def get(cls, bridge, namespace=None):
"""Deduce PortFixture class from bridge type and instantiate it."""
if isinstance(bridge, ovs_lib.OVSBridge):
return OVSPortFixture(bridge, namespace)
if isinstance(bridge, bridge_lib.BridgeDevice):
return LinuxBridgePortFixture(bridge, namespace)
if isinstance(bridge, VethBridge):
return VethPortFixture(bridge, namespace)
tools.fail("Unexpected bridge type: %s" % type(bridge))
示例4: assert_no_arping
def assert_no_arping(src_namespace, dst_ip, source=None, timeout=1, count=1):
try:
assert_arping(src_namespace, dst_ip, source, timeout, count)
except RuntimeError:
pass
else:
tools.fail("destination ip %(destination)s is replying to arp from "
"namespace %(ns)s, but it shouldn't" %
{'ns': src_namespace, 'destination': dst_ip})
示例5: wrapper
def wrapper(*args, **kwargs):
try:
return wrapped(*args, **kwargs)
except (testtools.TestCase.skipException, unittest.case.SkipTest) as e:
if base.bool_from_env('OS_FAIL_ON_MISSING_DEPS'):
tools.fail(
'%s cannot be skipped because OS_FAIL_ON_MISSING_DEPS '
'is enabled, skip reason: %s' % (wrapped.__name__, e))
raise
示例6: assert_no_ping
def assert_no_ping(src_namespace, dst_ip, timeout=1, count=1):
try:
assert_ping(src_namespace, dst_ip, timeout, count)
except RuntimeError:
pass
else:
tools.fail(
"destination ip %(destination)s is replying to ping from "
"namespace %(ns)s, but it shouldn't" % {"ns": src_namespace, "destination": dst_ip}
)
示例7: get
def get(cls, bridge, namespace=None, mac=None, port_id=None,
hybrid_plug=False):
"""Deduce PortFixture class from bridge type and instantiate it."""
if isinstance(bridge, ovs_lib.OVSBridge):
return OVSPortFixture(bridge, namespace, mac, port_id, hybrid_plug)
if isinstance(bridge, bridge_lib.BridgeDevice):
return LinuxBridgePortFixture(bridge, namespace, mac, port_id)
if isinstance(bridge, VethBridge):
return VethPortFixture(bridge, namespace)
tools.fail('Unexpected bridge type: %s' % type(bridge))
示例8: _setUp
def _setUp(self):
# NOTE(cbrandily): Ensure we will not delete a directory existing
# before test run during cleanup.
if os.path.exists(self.directory):
tools.fail('%s already exists' % self.directory)
create_cmd = ['mkdir', '-p', self.directory]
delete_cmd = ['rm', '-r', self.directory]
utils.execute(create_cmd, run_as_root=True)
self.addCleanup(utils.execute, delete_cmd, run_as_root=True)
示例9: test_arp_spoof_blocks_request
def test_arp_spoof_blocks_request(self):
# this will prevent the source from sending an ARP
# request with its own address
self._setup_arp_spoof_for_port(self.src_p.name, ["192.168.0.3"])
self.src_p.addr.add("%s/24" % self.src_addr)
self.dst_p.addr.add("%s/24" % self.dst_addr)
ns_ip_wrapper = ip_lib.IPWrapper(self.src_namespace)
try:
ns_ip_wrapper.netns.execute(["arping", "-I", self.src_p.name, "-c1", self.dst_addr])
tools.fail("arping should have failed. The arp request should " "have been blocked.")
except RuntimeError:
pass
示例10: increment_ip_cidr
def increment_ip_cidr(ip_cidr, offset=1):
"""Increment ip_cidr offset times.
example: increment_ip_cidr("1.2.3.4/24", 2) ==> "1.2.3.6/24"
"""
net0 = netaddr.IPNetwork(ip_cidr)
net = netaddr.IPNetwork(ip_cidr)
net.value += offset
if not net0.network < net.ip < net0.broadcast:
tools.fail(
'Incorrect ip_cidr,offset tuple (%s,%s): "incremented" ip_cidr is ' "outside ip_cidr" % (ip_cidr, offset)
)
return str(net)
示例11: set_namespace_gateway
def set_namespace_gateway(port_dev, gateway_ip):
"""Set gateway for the namespace associated to the port."""
if not port_dev.namespace:
tools.fail("tests should not change test machine gateway")
port_dev.route.add_gateway(gateway_ip)
示例12: allocate_port
def allocate_port(self):
try:
return self.unallocated_ports.pop()
except KeyError:
tools.fail("All FakeBridge ports (%s) are already allocated." % len(self.ports))