def register_switch_ports(switch_info, n_ports, start_port=0, name=None): for i in xrange(n_ports): port = i + start_port if name == None: locname = switch_info.name + str(port) else: locname = name check(register_location(locname, switch_info.name, port)) return switch_info
def unwrap_reg_loc(switch_info, name, switch, port, port_name): check_dir_pass(register_location(name, switch, port, port_name))
if should_pass == True: log.err('Register should have passed') num_register = num_register - 1 if num_register == 0 and addedAll: print 'Registration test complete' def unwrap_reg_loc(switch_info, name, switch, port, port_name): check_dir_pass(register_location(name, switch, port, port_name)) d = check_dir_pass(register_switch('switch1', 0x505400000004)) d.addCallback(unwrap_reg_loc, 'loc1', 'switch1', 1, 'eth0') check_dir_pass(register_location('loc2', 0x505400000003, 0, 'eth0')) check_dir_pass(register_location('loc3', 0x505400000003, 1, 'eth1')) check_dir_pass(register_host('host1', dladdr=0x505400000001, is_gateway=True)) check_dir_pass(register_host('host2', dladdr=0x505400000002)) check_dir_pass(register_user('user1')) check_dir_pass(register_user('user2')) check_dir_fail(register_switch('switch1', 0x505400000004)) # dup entry check_dir_fail(register_switch('switch2', 0x505400000004)) # dup entry check_dir_fail(register_location('loc5', 0x505400000003, 0, 'eth0')) # dup entry check_dir_fail(register_location('loc6', 0x505400000003, 1, 'eth1')) # dup entry
def register_failed(res, should_pass): global num_register if should_pass == True: log.err('Register should have passed') num_register = num_register - 1 if num_register == 0 and addedAll: print 'Registration test complete' def unwrap_reg_loc(switch_info, name, switch, port, port_name): check_dir_pass(register_location(name, switch, port, port_name)) d = check_dir_pass(register_switch('switch1', 0x505400000004)) d.addCallback(unwrap_reg_loc, 'loc1', 'switch1', 1, 'eth0') check_dir_pass(register_location('loc2', 0x505400000003, 0, 'eth0')) check_dir_pass(register_location('loc3', 0x505400000003, 1, 'eth1')) check_dir_pass(register_host('host1', dladdr=0x505400000001, is_gateway=True)) check_dir_pass(register_host('host2', dladdr=0x505400000002)) check_dir_pass(register_user('user1')) check_dir_pass(register_user('user2')) check_dir_fail(register_switch('switch1', 0x505400000004)) # dup entry check_dir_fail(register_switch('switch2', 0x505400000004)) # dup entry check_dir_fail(register_location('loc5', 0x505400000003, 0, 'eth0')) # dup entry check_dir_fail(register_location('loc6', 0x505400000003, 1, 'eth1')) # dup entry check_dir_fail(register_location('loc1', 0x505400000004, 1, 'eth1')) # dup entry check_dir_fail(register_location('loc1', 0x505400000004, 2, 'eth2')) # diff addr
def register_success(res): global num_register num_register = num_register - 1 if num_register == 0 and addedAll: print 'Registration complete' def register_failed(res): print 'Registration failed' check(register_switch('switch1', 0x505400000003)) check(register_switch('switch2', 0x505400000006)) check(register_location('loc1', 0x505400000003, 0, 'eth0')) check(register_location('loc2', 0x505400000006, 0, 'eth0')) check(register_host('host1', dladdr=0x505400000001)) check(register_host('host2', dladdr=0x505400000002)) check(register_user('user1')) check(register_user('user2')) check(register_switch_group('s1group', 'my switch group', ['switch1'], [])) check(register_switch_group('s2group', 'my 2nd switch group', ['switch2'], [])) check(register_location_group('l1group', 'my loc group', ['loc1'], [])) check(register_location_group('l2group', 'my 2nd loc group', ['loc2'], [])) check(register_location_group('l3group', 'roup', [], [])) check(register_host_group('h1group', 'my host group', ['host1'], [])) check(register_host_group('h2group', 'my 2nd host group', ['host2'], [])) check(register_user_group('u1group', 'my user group', ['user1'], [])) check(register_user_group('u2group', 'my 2nd user group', ['user2'], []))
d.addCallback(register_success) d.addErrback(register_failed) def register_success(res): global num_register num_register = num_register - 1 if num_register == 0 and addedAll: print 'Registration complete' def register_failed(res): print 'Registration failed' check(register_switch('switch1', 0x505400000003)) check(register_switch('switch2', 0x505400000006)) check(register_location('loc1', 0x505400000003, 0, 'eth0')) check(register_location('loc2', 0x505400000006, 0, 'eth0')) check(register_host('host1', dladdr=0x505400000001)) check(register_host('host2', dladdr=0x505400000002)) check(register_user('user1')) check(register_user('user2')) check(register_switch_group('s1group', 'my switch group', ['switch1'], [])) check(register_switch_group('s2group', 'my 2nd switch group', ['switch2'], [])) check(register_location_group('l1group', 'my loc group', ['loc1'], [])) check(register_location_group('l2group', 'my 2nd loc group', ['loc2'], [])) check(register_location_group('l3group', 'roup', [], [])) check(register_host_group('h1group', 'my host group', ['host1'], [])) check(register_host_group('h2group', 'my 2nd host group', ['host2'], [])) check(register_user_group('u1group', 'my user group', ['user1'], [])) check(register_user_group('u2group', 'my 2nd user group', ['user2'], []))