def get_bridge_name_for_port_name(self, port_name): try: return self.run_vsctl(['port-to-br', port_name], check_error=True) except RuntimeError as e: with utils.save_and_reraise_exception() as ctxt: if 'Exit code: 1\n' in str(e): ctxt.reraise = False
def get_bridges(): args = ["ovs-vsctl", "--timeout=%d" % cfg.CONF.ovs_vsctl_timeout, "list-br"] try: return utils.execute(args).strip().split("\n") except Exception as e: with utils.save_and_reraise_exception(): LOG.exception(_("Unable to retrieve bridges. Exception: %s"), e)
def bridge_exists(self, bridge_name): try: self.run_vsctl(['br-exists', bridge_name], check_error=True) except RuntimeError as e: with utils.save_and_reraise_exception() as ctxt: if 'Exit code: 2\n' in str(e): ctxt.reraise = False return False return True
def __init__(self, **kwargs): try: super(NeutronException, self).__init__(self.message % kwargs) self.msg = self.message % kwargs except Exception: with utils.save_and_reraise_exception() as ctxt: if not self.use_fatal_exceptions(): ctxt.reraise = False # at least get the core message out if something happened super(NeutronException, self).__init__(self.message)
def get_xapi_iface_id(self, xs_vif_uuid): args = ["xe", "vif-param-get", "param-name=other-config", "param-key=nicira-iface-id", "uuid=%s" % xs_vif_uuid] try: return utils.execute(args).strip() except Exception as e: with utils.save_and_reraise_exception(): LOG.error(_("Unable to execute %(cmd)s. " "Exception: %(exception)s"), {'cmd': args, 'exception': e})
def run_vsctl(self, args, check_error=False): full_args = ["ovs-vsctl", "--timeout=%d" % self.vsctl_timeout] + args try: return utils.execute(full_args) except Exception as e: with utils.save_and_reraise_exception() as ctxt: LOG.error(_("Unable to execute %(cmd)s. " "Exception: %(exception)s"), {'cmd': full_args, 'exception': e}) if not check_error: ctxt.reraise = False