コード例 #1
0
ファイル: contextlib_test.py プロジェクト: xiaojiongming/vdsm
    def test_suppress(self):
        with self.assertNotRaises():
            with suppress(Exception):
                raise Exception()

        with self.assertNotRaises():
            with suppress(OSError, AttributeError):
                raise AttributeError()

        with self.assertRaises(AttributeError):
            with suppress(OSError):
                raise AttributeError()

        with self.assertRaises(RuntimeError):
            with suppress(OSError, AttributeError):
                raise RuntimeError()
コード例 #2
0
ファイル: contextlib_test.py プロジェクト: EdDev/vdsm
    def test_suppress(self):
        with self.assertNotRaises():
            with suppress(Exception):
                raise Exception()

        with self.assertNotRaises():
            with suppress(OSError, AttributeError):
                raise AttributeError()

        with self.assertRaises(AttributeError):
            with suppress(OSError):
                raise AttributeError()

        with self.assertRaises(RuntimeError):
            with suppress(OSError, AttributeError):
                raise RuntimeError()
コード例 #3
0
ファイル: sourceroute.py プロジェクト: EdDev/vdsm
def remove(device):
    sroute = DynamicSourceRoute(device, None, None, None)
    routes, rules = sroute.current_srconfig()
    logging.debug('Removing source route for device %s', device)
    try:
        for route in routes:
            with suppress(IPRouteDeleteError):
                # The kernel or dhclient has won the race and removed
                # the route already.
                IPRoute.delete(route)

        for rule in rules:
            IPRule.delete(rule)

    except (IPRouteError, IPRuleError) as e:
        logging.error('Failed source route removal: %s', e.args)
コード例 #4
0
def remove(device):
    sroute = DynamicSourceRoute(device, None, None, None)
    routes, rules = sroute.current_srconfig()
    logging.debug('Removing source route for device %s', device)
    try:
        for route in routes:
            with suppress(IPRouteDeleteError):
                # The kernel or dhclient has won the race and removed
                # the route already.
                IPRoute.delete(route)

        for rule in rules:
            IPRule.delete(rule)

    except (IPRouteError, IPRuleError) as e:
        logging.error('Failed source route removal: %s', e.args)