def run_ofctl(self, cmd, args, process_input=None): full_args = ["ovs-ofctl", cmd, self.br_name] + args try: return utils.execute(full_args, process_input=process_input) except Exception as e: LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"), {'cmd': full_args, 'exception': e})
def get_bridge_external_bridge_id(bridge): args = ["ovs-vsctl", "--timeout=2", "br-get-external-id", bridge, "bridge-id"] try: return utils.execute(args).strip() except Exception: LOG.exception(_("Bridge %s not found."), bridge) return None
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 get_bridge_for_iface(iface): args = ["ovs-vsctl", "--timeout=%d" % cfg.CONF.ovs_vsctl_timeout, "iface-to-br", iface] try: return utils.execute(args).strip() except Exception: LOG.exception(_("Interface %s not found."), iface) return None
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