def __init__(self, *args, **kwargs): """Instance initialization. This method is to initialize the variables required from board-farm perspective to execute the tests and fetch results from CD-router. These variables include ipaddress, wan_iface, lan_iface etc., :param ``*args``: set of arguments to be passed if any. :type ``*args``: tuple :param ``**kwargs``: extra args to be used if any. :type ``**kwargs``: dict """ bf_args = bfargs() # legacy implementation # will have to go bf_args.ipaddr = kwargs.pop("ipaddr", "") bf_args.wan_iface = kwargs.pop("wan_iface", "") bf_args.lan_iface = kwargs.pop("lan_iface", "") bf_args.wanispip = kwargs.pop("wanispip", "") bf_args.wanispip_v6 = kwargs.pop("wanispip_v6", "") bf_args.wanispgateway = kwargs.pop("wanispgateway", "") bf_args.wanispgateway_v6 = kwargs.pop("wanispgateway_v6", "") bf_args.ipv4hopcount = kwargs.pop("ipv4hopcount", "") self.bf_args = bf_args self.bf_args.jobs = {} self.bf_args.results = [] # Set this function during runtime, in order to proceed with unpausing a job self.unpause_methods = [] self.bf_args.cdrouter_server = "http://" + self.bf_args.ipaddr CDRouter.__init__(self, base=self.bf_args.cdrouter_server)
def parse(config): try: from boardfarm.devices import cdrouter url = 'http://' + cdrouter.ipaddr except: return [] c = CDRouter(url) new_tests = [] for mod in c.testsuites.list_modules(): name = "CDrouter" + mod.name.replace('.', '').replace('-', '_') list_of_tests = [six.text_type(x) for x in mod.tests] new_tests.append( type(six.text_type(name), (CDrouterStub, ), {'tests': list_of_tests})) return new_tests
def parse(config): if 'cdrouter_server' in config.board: cdrouter_server = config.board['cdrouter_server'] elif config.cdrouter_server is not None: cdrouter_server = config.cdrouter_server c = CDRouter(cdrouter_server) cdrouter_test_matrix = {} new_tests = [] for mod in c.testsuites.list_modules(): name = "CDrouter" + mod.name.replace('.', '').replace('-', '_') list_of_tests = [x.encode('ascii', 'ignore') for x in mod.tests] globals()[name] = type(name.encode('ascii', 'ignore'), (CDrouterStub, ), {'tests': list_of_tests}) new_tests.append(name) return new_tests
def parse(config): """CDRouter.""" try: from boardfarm.devices import cdrouter url = "http://" + cdrouter.bf_args.ipaddr except Exception: return [] c = CDRouter(url) new_tests = [] for mod in c.testsuites.list_modules(): name = "CDrouter" + mod.name.replace(".", "").replace("-", "_") list_of_tests = [six.text_type(x) for x in mod.tests] new_tests.append( type(six.text_type(name), (CDrouterStub, ), {"tests": list_of_tests})) return new_tests
def runTest(self): if 'cdrouter_server' in self.config.board: self.cdrouter_server = self.config.board['cdrouter_server'] elif self.config.cdrouter_server is not None: self.cdrouter_server = self.config.cdrouter_server if 'cdrouter_wan_iface' in self.config.board: self.cdrouter_wan_iface = self.config.board['cdrouter_wan_iface'] else: self.cdrouter_wan_iface = self.config.cdrouter_wan_iface if 'cdrouter_lan_iface' in self.config.board: self.cdrouter_lan_iface = self.config.board['cdrouter_lan_iface'] else: self.cdrouter_lan_iface = self.config.cdrouter_lan_iface if self.tests is None: self.skipTest("No tests defined!") if self.cdrouter_server is None: self.skipTest("No cdrouter server specified") lan.sendline('ifconfig %s down' % lan.iface_dut) lan.expect(prompt) if not board.has_cmts: wan.sendline('ifconfig %s down' % wan.iface_dut) wan.expect(prompt) c = CDRouter(self.cdrouter_server) try: board.sendcontrol('c') board.expect(prompt) board.sendline('reboot') board.expect('reboot: Restarting system') except: board.reset() board.wait_for_linux() board.wait_for_network() # Add extra board specific delay board.expect(pexpect.TIMEOUT, timeout=getattr(board, 'cdrouter_bootdelay', 0)) # If alt mac addr is specified in config, use that.. # CMTS = we route so no wan mac is used # if we route, we need to add routes wandutmac = None if board.has_cmts and wan.wan_cmts_provisioner: # TODO: there are more missing ones CDrouter expects wan.sendline('ip route add 200.0.0.0/8 via 192.168.3.2') wan.expect(prompt) elif not wan.static_ip: for device in self.config.board['devices']: if device['name'] == 'wan': if 'alt_macaddr' in device: wandutmac = device['alt_macaddr'] break # Otherwise grab this from the device interface if wandutmac is None: board.sendline('ifconfig %s' % board.wan_iface) board.expect('([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})') wandutmac = board.match.group() board.expect(prompt) print("Using %s for WAN mac address" % wandutmac) lan.vlan = wan.vlan = 0 for device in self.config.board['devices']: d = None if device['name'] == 'wan': d = wan elif device['name'] == 'lan': d = lan else: continue if d is not None: d.vlan = getattr(device, 'vlan', 0) if d.vlan == 0: d.sendline('cat /proc/net/vlan/config') d.expect_exact('cat /proc/net/vlan/config') if 0 == d.expect( [pexpect.TIMEOUT, '%s.*\|\s([0-9]+).*\|' % d.iface_dut], timeout=5): d.vlan = 0 else: d.vlan = d.match.group(1) d.expect(prompt) print("Using %s for WAN vlan" % wan.vlan) print("Using %s for LAN vlan" % lan.vlan) # TODO: move wan and lan interface to bft config? contents = """ testvar wanInterface """ + self.cdrouter_wan_iface if wandutmac is not None: contents = contents + """ testvar wanDutMac """ + wandutmac if wan.vlan != 0: contents = contents + """ testvar wanVlanId """ + wan.vlan contents = contents + """ testvar lanInterface """ + self.cdrouter_lan_iface if lan.vlan != 0: contents = contents + """ testvar lanVlanId """ + lan.vlan def add_cdrouter_config(config): cdr_conf = None # TODO: make a generic helper to search path and overlays if os.path.isfile(config): cdr_conf = open(config, 'r').readlines() elif 'BFT_OVERLAY' in os.environ: for p in os.environ['BFT_OVERLAY'].split(' '): p = os.path.realpath(p) try: cdr_conf = open(os.path.join(p, config), 'r').readlines() except: continue else: break return "\n" + "".join(cdr_conf) # Take config from overall config, but fallback to board config if self.config.cdrouter_config is not None: contents = contents + add_cdrouter_config( self.config.cdrouter_config) elif board.cdrouter_config is not None: contents = contents + add_cdrouter_config(board.cdrouter_config) if self.extra_config: contents = contents + "\n" + self.extra_config.replace(',', '\n') if board.has_cmts: for i in range(5): try: wan_ip = board.get_interface_ipaddr(board.erouter_iface) except: board.expect(pexpect.TIMEOUT, timeout=15) continue else: if i == 4: raise Exception("Failed to get erouter ip address") break # TODO: mask from config? wanNatIp vs. wanIspAssignGateway? contents=contents + """ testvar wanMode static testvar wanIspIp %s testvar wanIspGateway %s testvar wanIspMask 255.255.255.0 testvar wanIspAssignIp %s testvar wanNatIp %s testvar IPv4HopCount %s testvar lanDnsServer %s testvar wanDnsServer %s""" % (self.config.board['cdrouter_wanispip'], \ self.config.board['cdrouter_wanispgateway'], \ wan_ip, wan_ip, \ self.config.board['cdrouter_ipv4hopcount'], \ board.get_dns_server(), \ board.get_dns_server_upstream()) print("Using below for config:") print(contents) print("#######################") config_name = "bft-automated-job-%s" % str(time.time()).replace( '.', '') cfg = c.configs.create(Config(name=config_name, contents=contents)) p = c.packages.create( Package(name=config_name, testlist=self.tests, config_id=cfg.id)) self.start_time = time.time() j = c.jobs.launch(Job(package_id=p.id)) while j.result_id is None: if (time.time() - self.start_time) > 300: # delete job if it fails to start c.jobs.delete(j.id) raise Exception("Failed to start CDrouter job") board.expect(pexpect.TIMEOUT, timeout=1) j = c.jobs.get(j.id) print('Job Result-ID: {0}'.format(j.result_id)) self.job_id = j.result_id self.results = c.results unpaused = False end_of_start = False no_more_pausing = False while True: r = c.results.get(j.result_id) print(r.status) # we are ready to go from boardfarm reset above if r.status == "paused" and unpaused == False: c.results.unpause(j.result_id) unpaused = True board.expect(pexpect.TIMEOUT, timeout=1) c.results.pause(j.result_id, when="end-of-test") end_of_start = True continue if r.status == "paused" and end_of_start == True: end_of_start = False # TODO: do we need this anymore? we have board specific cdrouter_bootdelay board.expect(pexpect.TIMEOUT, timeout=60) c.results.unpause(j.result_id) board.expect(pexpect.TIMEOUT, timeout=1) no_more_pausing = True continue if no_more_pausing and r.status == "paused": print("Error: test is still paused") c.results.stop(j.result_id) break if r.status != "running" and r.status != "paused": break board.expect(pexpect.TIMEOUT, timeout=5) print(r.result) self.result_message = r.result.encode('ascii', 'ignore') # TODO: results URL? elapsed_time = time.time() - self.start_time print("Test took %s" % time.strftime("%H:%M:%S", time.gmtime(elapsed_time))) summary = c.results.summary_stats(j.result_id) self.result_message += " (Failed= %s, Passed = %s, Skipped = %s)" \ % (summary.result_breakdown.failed, \ summary.result_breakdown.passed, \ summary.result_breakdown.skipped) for test in summary.test_summaries: self.logged[test.name] = vars(test) if str(test.name) not in ["start", "final"]: from lib.common import TestResult try: grade_map = { "pass": "******", "fail": "FAIL", "skip": "SKIP" }[test.result] tr = TestResult(test.name, grade_map, test.description) if test.started is not None: tr.start_time = test.started tr.stop_time = test.started + test.duration else: tr.elapsed_time = test.duration self.subtests.append(tr) except: continue # TODO: handle skipped tests try: metric = c.results.get(result_id, test.name, "bandwidth") print(vars(metric)) # TODO: decide how to export data to kibana except: # Not all tests have this metric, no other way? pass assert (r.result == "The package completed successfully") self.recover()
def runTest(self): board = self.dev.board wan = self.dev.wan lan = self.dev.lan from boardfarm.devices import cdrouter self.cdrouter_server = "http://" + cdrouter.ipaddr self.cdrouter_wan_iface = cdrouter.wan_iface self.cdrouter_lan_iface = cdrouter.lan_iface if self.tests is None: self.skipTest("No tests defined!") if self.cdrouter_server is None: self.skipTest("No cdrouter server specified") lan.sendline('ifconfig %s down' % lan.iface_dut) lan.expect(prompt) if not board.has_cmts: wan.sendline('ifconfig %s down' % wan.iface_dut) wan.expect(prompt) c = CDRouter(self.cdrouter_server) wandutmac = None if board.has_cmts: provisioner = self.dev.provisioner # TODO: there are more missing ones CDrouter expects provisioner.sendline('ip route add 200.0.0.0/8 via 192.168.3.2') provisioner.expect(prompt) provisioner.sendline('ip route add 3.3.3.3 via 192.168.3.2') provisioner.expect(prompt) provisioner.sendline( 'ip route add 3001:cafe:1::/64 via 2001:dead:beef:1::2') provisioner.expect(prompt) provisioner.sendline( 'ip route add 3001:51a:cafe::1 via 2001:dead:beef:1::2') provisioner.expect(prompt) elif not wan.static_ip: for device in self.config.board['devices']: if device['name'] == 'wan': if 'alt_macaddr' in device: wandutmac = device['alt_macaddr'] break # Otherwise grab this from the device interface if wandutmac is None: board.sendline('ifconfig %s' % board.wan_iface) board.expect('([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})') wandutmac = board.match.group() board.expect(prompt) print("Using %s for WAN mac address" % wandutmac) lan.vlan = wan.vlan = 0 for device in self.config.board['devices']: d = None if device['name'] == 'wan': d = wan elif device['name'] == 'lan': d = lan else: continue if d is not None: d.vlan = getattr(device, 'vlan', 0) if d.vlan == 0: d.sendline('cat /proc/net/vlan/config') d.expect_exact('cat /proc/net/vlan/config') if 0 == d.expect( [pexpect.TIMEOUT, '%s.*\|\s([0-9]+).*\|' % d.iface_dut], timeout=5): d.vlan = 0 else: d.vlan = d.match.group(1) d.expect(prompt) # TODO - WIP wan.vlan = "136" print("Using %s for WAN vlan" % wan.vlan) print("Using %s for LAN vlan" % lan.vlan) # TODO: move wan and lan interface to bft config? contents = """ testvar wanInterface """ + self.cdrouter_wan_iface if wandutmac is not None: contents = contents + """ testvar wanDutMac """ + wandutmac if wan.vlan != 0: contents = contents + """ testvar wanVlanId """ + wan.vlan contents = contents + """ testvar lanInterface """ + self.cdrouter_lan_iface if lan.vlan != 0: contents = contents + """ testvar lanVlanId """ + lan.vlan if self.extra_config: contents = contents + "\n" + self.extra_config.replace(',', '\n') def add_cdrouter_config(config): p = os.path.realpath(config) cdr_conf = open(os.path.join(p, config), 'r').readlines() return "\n" + "".join(cdr_conf) if board.cdrouter_config is not None: contents = contents + add_cdrouter_config(board.cdrouter_config) if board.has_cmts: for i in range(5): exp = None try: wan_ip = board.get_interface_ipaddr(board.erouter_iface) # TODO: this breaks ipv6 only wan_ip6 = board.get_interface_ip6addr(board.erouter_iface) lan.start_lan_client() lan_ip6 = lan.get_interface_ip6addr(lan.iface_dut) ip6 = ipaddress.IPv6Network(six.text_type(lan_ip6)) fixed_prefix6 = str( ip6.supernet(new_prefix=64).network_address) break except Exception as e: exp = e board.expect(pexpect.TIMEOUT, timeout=15) continue else: if i == 4: raise exp # TODO: mask from config? wanNatIp vs. wanIspAssignGateway? contents=contents + """ testvar ipv6LanIp %s%%eui64%% testvar ipv6LanPrefixLen 64 testvar healthCheckEnable yes testvar supportsIPv6 yes testvar ipv6WanMode static testvar ipv6WanIspIp %s testvar ipv6WanIspGateway %s testvar ipv6WanIspAssignIp %s testvar ipv6WanIspPrefixLen 64 testvar ipv6LanMode autoconf testvar ipv6RemoteHost 3001:51a:cafe::1 testvar ipv6FreeNetworkStart 3001:cafe:1:: testvar ipv6FreeNetworkEnd 3001:cafe:ffff:: testvar ipv6FreeNetworkPrefixLen 64 testvar wanMode static testvar wanIspIp %s testvar wanIspGateway %s testvar wanIspMask 255.255.255.128 testvar wanIspAssignIp %s testvar wanNatIp %s testvar remoteHostIp 3.3.3.3 testvar FreeNetworkStart 200.0.0.0 testvar FreeNetworkMask 255.255.255.0 testvar FreeNetworkStop 201.0.0.0 testvar IPv4HopCount %s testvar lanDnsServer %s testvar wanDnsServer %s """ % (fixed_prefix6, cdrouter.wanispip_v6, \ cdrouter.wanispgateway_v6, \ wan_ip6, \ cdrouter.wanispip, \ cdrouter.wanispgateway, \ wan_ip, wan_ip, \ cdrouter.ipv4hopcount, \ board.get_dns_server(), \ board.get_dns_server_upstream()) print("Using below for config:") print(contents) print("#######################") config_name = "bft-automated-job-%s" % str(time.time()).replace( '.', '') cfg = c.configs.create(Config(name=config_name, contents=contents)) p = c.packages.create( Package(name=config_name, testlist=self.tests, config_id=cfg.id)) self.start_time = time.time() j = c.jobs.launch(Job(package_id=p.id)) while j.result_id is None: if (time.time() - self.start_time) > 300: # delete job if it fails to start c.jobs.delete(j.id) raise Exception("Failed to start CDrouter job") board.expect(pexpect.TIMEOUT, timeout=1) j = c.jobs.get(j.id) print('Job Result-ID: {0}'.format(j.result_id)) self.job_id = j.result_id self.results = c.results unpaused = False end_of_start = False no_more_pausing = False while True: r = c.results.get(j.result_id) print(r.status) # we are ready to go from boardfarm reset above if r.status == "paused" and unpaused == False: c.results.unpause(j.result_id) unpaused = True board.expect(pexpect.TIMEOUT, timeout=1) c.results.pause(j.result_id, when="end-of-test") end_of_start = True continue if r.status == "paused" and end_of_start == True: end_of_start = False # TODO: do we need this anymore? we have board specific cdrouter_bootdelay board.expect(pexpect.TIMEOUT, timeout=60) c.results.unpause(j.result_id) board.expect(pexpect.TIMEOUT, timeout=1) no_more_pausing = True continue if no_more_pausing and r.status == "paused": print("Error: test is still paused") c.results.stop(j.result_id) break if r.status != "running" and r.status != "paused": break board.expect(pexpect.TIMEOUT, timeout=5) print(r.result) self.result_message = r.result.encode('ascii', 'ignore') # TODO: results URL? elapsed_time = time.time() - self.start_time print("Test took %s" % time.strftime("%H:%M:%S", time.gmtime(elapsed_time))) summary = c.results.summary_stats(j.result_id) self.result_message = six.text_type(self.result_message) + \ " (Failed= %s, Passed = %s, Skipped = %s)" \ % (summary.result_breakdown.failed, \ summary.result_breakdown.passed, \ summary.result_breakdown.skipped) for test in summary.test_summaries: self.logged[test.name] = vars(test) if str(test.name) not in ["start", "final"]: try: grade_map = { "pass": "******", "fail": "FAIL", "skip": "SKIP" }[test.result] tr = TestResult(test.name, grade_map, test.description) if test.started is not None: tr.start_time = test.started tr.stop_time = test.started + test.duration else: tr.elapsed_time = test.duration self.subtests.append(tr) except: continue # TODO: handle skipped tests try: metric = c.results.get(j.result_id, test.name, "bandwidth") print(vars(metric)) # TODO: decide how to export data to kibana except: # Not all tests have this metric, no other way? pass assert (r.result == "The package completed successfully") self.recover()
def runTest(self): if 'cdrouter_server' in self.config.board: self.cdrouter_server = self.config.board['cdrouter_server'] elif self.config.cdrouter_server is not None: self.cdrouter_server = self.config.cdrouter_server if self.tests is None: self.skipTest("No tests defined!") if self.cdrouter_server is None: self.skipTest("No cdrouter server specified") for d in [wan, lan]: d.sendline('ifconfig eth1 down') d.expect(prompt) board.sendcontrol('c') board.expect(prompt) # TODO: make host configurable in bft config? c = CDRouter(self.cdrouter_server) # If alt mac addr is specified in config, use that.. # This is used when a CMTS for example is placed between # the device under test and the WAN wandutmac = None for device in self.config.board['devices']: if device['name'] == 'wan': if 'alt_macaddr' in device: wandutmac = device['alt_macaddr'] break # Otherwise grab this from the device interface if wandutmac is None: board.sendline('ifconfig %s' % board.wan_iface) board.expect('([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})') wandutmac = board.match.group() board.expect(prompt) print("Using %s for WAN mac address" % wandutmac) lan.vlan = wan.vlan = 0 for device in self.config.board['devices']: d = None if device['name'] == 'wan': d = wan elif device['name'] == 'lan': d = lan if d is not None: d.vlan = getattr(device, 'vlan', 0) if d.vlan == 0: d.sendline('cat /proc/net/vlan/config') d.expect('eth1.*\|\s([0-9]+).*\|') d.vlan = d.match.group(1) d.expect(prompt) print("Using %s for WAN vlan" % wan.vlan) print("Using %s for LAN vlan" % lan.vlan) # TODO: move wan and lan interface to bft config? contents = """ testvar wanInterface """ + self.config.cdrouter_wan_iface contents = contents + """ testvar wanDutMac """ + wandutmac if wan.vlan != 0: contents = contents + """ testvar wanVlanId """ + wan.vlan contents = contents + """ testvar lanInterface """ + self.config.cdrouter_lan_iface if lan.vlan != 0: contents = contents + """ testvar lanVlanId """ + lan.vlan if self.config.cdrouter_config is not None: contents = contents + "\n" + "".join( open(self.config.cdrouter_config, 'r').readlines()) if self.extra_config: contents = contents + "\n" + self.extra_config.replace(',', '\n') print("Using below for config:") print(contents) print("#######################") config_name = "bft-automated-job-%s" % str(time.time()).replace( '.', '') cfg = c.configs.create(Config(name=config_name, contents=contents)) p = c.packages.create( Package(name=config_name, testlist=self.tests, config_id=cfg.id)) try: board.sendline('reboot') board.expect('reboot: Restarting system') except: board.reset() self.start_time = time.time() j = c.jobs.launch(Job(package_id=p.id)) while j.result_id is None: if (time.time() - self.start_time) > 300: # delete job if it fails to start c.jobs.delete(j.id) raise Exception("Failed to start CDrouter job") board.expect(pexpect.TIMEOUT, timeout=1) j = c.jobs.get(j.id) print('Job Result-ID: {0}'.format(j.result_id)) self.job_id = j.result_id self.results = c.results unpaused = False end_of_start = False no_more_pausing = False while True: r = c.results.get(j.result_id) print(r.status) # we are ready to go from boardfarm reset above if r.status == "paused" and unpaused == False: c.results.unpause(j.result_id) unpaused = True board.expect(pexpect.TIMEOUT, timeout=1) c.results.pause(j.result_id, when="end-of-test") end_of_start = True continue if r.status == "paused" and end_of_start == True: end_of_start = False # TODO: make this board specific? board.expect(pexpect.TIMEOUT, timeout=60) c.results.unpause(j.result_id) board.expect(pexpect.TIMEOUT, timeout=1) no_more_pausing = True continue if no_more_pausing and r.status == "paused": print("Error: test is still paused") c.results.stop(j.result_id) break if r.status != "running" and r.status != "paused": break board.expect(pexpect.TIMEOUT, timeout=5) print(r.result) self.result_message = r.result.encode('ascii', 'ignore') # TODO: results URL? elapsed_time = time.time() - self.start_time print("Test took %s" % time.strftime("%H:%M:%S", time.gmtime(elapsed_time))) summary = c.results.summary_stats(j.result_id) self.result_message += " (Failed= %s, Passed = %s, Skipped = %s)" \ % (summary.result_breakdown.failed, \ summary.result_breakdown.passed, \ summary.result_breakdown.skipped) for test in summary.test_summaries: self.logged[test.name] = vars(test) if str(test.name) not in ["start", "final"]: from lib.common import TestResult try: grade_map = { "pass": "******", "fail": "FAIL", "skip": "SKIP" }[test.result] tr = TestResult(test.name, grade_map, test.description) if test.started is not None: tr.start_time = test.started tr.stop_time = test.started + test.duration else: tr.elapsed_time = test.duration self.subtests.append(tr) except: continue # TODO: handle skipped tests try: metric = c.results.get(result_id, test.name, "bandwidth") print vars(metric) # TODO: decide how to export data to kibana except: # Not all tests have this metric, no other way? pass assert (r.result == "The package completed successfully") self.recover()
from cdrouter.highlights import Highlight if len(sys.argv) < 4: print('usage: <base_url> <token> <result-id> [<color> <filter>]...') sys.exit(1) colors = ['yellow', 'blue', 'red', 'green'] base = sys.argv[1] token = sys.argv[2] result_id = int(sys.argv[3]) color_filter_pairs = [] if len(sys.argv) > 4: color_filter_pairs = sys.argv[4:] c = CDRouter(base, token=token) r = c.results.get(result_id) # unstar the result r.starred = False c.results.edit(r) # loop over all tests in the result for tr in c.tests.iter_list(result_id): # some tests don't have a logfile, skip them if len(tr.log) == 0: continue # delete any existing comments/highlights for ann in c.annotations.list(tr.id, tr.seq):
resource, name, rs[name].response.message)) except CDRouterError as cde: print('Error migrating {} {}: {}'.format(resource, r.id, cde)) if si is not None: dst.imports.delete(si.id) try: # don't allow API token to be set from environment variable since # behavior is potentially confusing with two CDRouter systems if 'CDROUTER_API_TOKEN' in os.environ: del os.environ['CDROUTER_API_TOKEN'] src = CDRouter(args.src_base, token=args.src_token, username=args.src_user, password=args.src_password, insecure=args.insecure) dst = CDRouter(args.dst_base, token=args.dst_token, username=args.dst_user, password=args.dst_password, insecure=args.insecure) resources = args.resources.split(',') # devices were added in CDRouter 10.1 src_devices = re.match('^10\.0\.', src.testsuites.info().release) is None dst_devices = re.match('^10\.0\.', dst.testsuites.info().release) is None filter = [] if args.after is not None:
fields = line.split() if len(fields) != 3: print('Wrong number of fields in {}, line {}'.format(args.cdrsystems, i)) sys.exit(1) cdrsystem = {'url': fields[0], 'username': fields[1], 'password': fields[2]} cdrsystems.append(cdrsystem) # Here we go... for cdrsystem in cdrsystems: print() print('{}'.format(cdrsystem['url'])) print('=========================') print() cdr = CDRouter(cdrsystem['url'], username=cdrsystem['username'], password=cdrsystem['password'], retries=1) # Do a sanity check that we can talk to this cdrsystem. try: cdr.system.time() except CDRouterError as ce: print('Cannot connect to {}, {}'.format(cdrsystem['url'], ce)) continue # Get the user_id for the user that will own the new package(s). try: user_id = cdr.users.get_by_name(args.package_owner).id except CDRouterError as ce: print('Cannot get info for user {}, {}'.format(args.package_owner, ce)) continue