def test_config_atest(app_desc, config, run_test, verbose=True): proc = None ret = None vty = None try: cmd = app_desc[1].split(' ') + ["-c", config] if verbose: print("Verifying %s, test %s" % (' '.join(cmd), run_test.__name__)) proc = osmoutil.popen_devnull(cmd) end = app_desc[2] port = app_desc[0] vty = obscvty.VTYInteract(end, "127.0.0.1", port) ret = run_test(vty) except IOError as se: print("Failed to verify %s" % ' '.join(cmd), file=sys.stderr) print("Current directory: %s" % os.getcwd(), file=sys.stderr) print("Error was %s" % se, file=sys.stderr) print("Config was\n%s" % open(config).read(), file=sys.stderr) raise se finally: if proc: osmoutil.end_proc(proc) if vty: vty._close_socket() return ret
def dump_doc(name, port, filename): vty = obscvty.VTYInteract(name, "127.0.0.1", port) xml = vty.command("show online-help") # Now write everything until the end to the file out = open(filename, 'w') out.write(xml) out.close()
def test_config_atest(app_desc, config, run_test, verbose=True): proc = None ret = None try: cmd = [app_desc[1], "-c", config] if verbose: print "Verifying %s, test %s" % (' '.join(cmd), run_test.__name__) proc = osmoutil.popen_devnull(cmd) time.sleep(1) end = app_desc[2] port = app_desc[0] vty = obscvty.VTYInteract(end, "127.0.0.1", port) ret = run_test(vty) except IOError as se: print >> sys.stderr, "Failed to verify %s" % ' '.join(cmd) print >> sys.stderr, "Current directory: %s" % os.getcwd() print >> sys.stderr, "Error was %s" % se raise se finally: if proc: osmoutil.end_proc(proc) return ret
def expire_subscriber_by_msisdn(self, msisdn): try: vty = obscvty.VTYInteract(self._vty_appstring, self._ip_address, self._vty_port) cmd = "subscriber extension {} expire".format(msisdn) vty.enabled_command(cmd, close=True) except IOError: # TODO(matt9j) Log that communication failed with the MSC. pass
def setUp(self): osmo_vty_cmd = self.vty_command()[:] config_index = osmo_vty_cmd.index('-c') if config_index: cfi = config_index + 1 osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi]) try: self.proc = osmoutil.popen_devnull(osmo_vty_cmd) except OSError: print("Current directory: %s" % os.getcwd(), file=sys.stderr) print("Consider setting -b", file=sys.stderr) appstring = self.vty_app()[2] appport = self.vty_app()[0] self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)
def setUp(self): osmo_vty_cmd = osmoappdesc.vty_command[:] config_index = osmo_vty_cmd.index('-c') if config_index: cfi = config_index + 1 osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi]) try: print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd()) self.proc = osmoutil.popen_devnull(osmo_vty_cmd) except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() print >> sys.stderr, "Consider setting -b" time.sleep(1) appstring = osmoappdesc.vty_app[2] appport = osmoappdesc.vty_app[0] self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)
def _get_vty_connection(self): if self._cached_vty is None: self._cached_vty = obscvty.VTYInteract(self._appstring, self._ip, self._vty_port) return self._cached_vty