def setUp(self):
<EOL>CONF.clear()<EOL>super(TestCiscoNexusBase, self).setUp()<EOL>CONF.import_opt('<STR_LIT>', '<STR_LIT>')<EOL>CONF.set_default('<STR_LIT>', <NUM_LIT:0>)<EOL>CONF.import_opt('<STR_LIT>', '<STR_LIT>')<EOL>CONF.set_default('<STR_LIT>', <NUM_LIT:0>)<EOL>self.mock_driver = mock.Mock()<EOL>mock.patch.object(<EOL>nexus_restapi_network_driver.CiscoNexusRestapiDriver,<EOL>'<STR_LIT>',<EOL>return_value=self.mock_driver).start()<EOL>self.mock_nxapi_client = mock.Mock()<EOL>mock.patch.object(<EOL>nexus_restapi_network_driver.CiscoNexusRestapiDriver,<EOL>'<STR_LIT>',<EOL>return_value=self.mock_nxapi_client).start()<EOL>self._verify_results = self._verify_restapi_results<EOL>original_get_switch_ips = (<EOL>mech_cisco_nexus.CiscoNexusMechanismDriver.get_switch_ips)<EOL>original_get_switch_host_mappings = (<EOL>nexus_db_v2.get_switch_host_mappings)<EOL>original_get_host_mappings = (<EOL>nexus_db_v2.get_host_mappings)<EOL>def new_get_switch_ips(self):<EOL><INDENT>switch_ips = original_get_switch_ips(self)<EOL>switch_ips.sort()<EOL>return switch_ips<EOL><DEDENT>def new_get_switch_host_mappings(switch_ip):<EOL><INDENT>map = original_get_switch_host_mappings(switch_ip)<EOL>map = sorted(map, key=attrgetter('<STR_LIT>'))<EOL>return map<EOL><DEDENT>def new_get_host_mappings(host_id):<EOL><INDENT>map = original_get_host_mappings(host_id)<EOL>map = sorted(map, key=attrgetter('<STR_LIT>', '<STR_LIT>'))<EOL>return map<EOL><DEDENT>mock.patch.object(nexus_db_v2,<EOL>'<STR_LIT>',<EOL>new=new_get_switch_host_mappings).start()<EOL>mock.patch.object(nexus_db_v2,<EOL>'<STR_LIT>',<EOL>new=new_get_host_mappings).start()<EOL>mock.patch.object(mech_cisco_nexus.CiscoNexusMechanismDriver,<EOL>'<STR_LIT>',<EOL>new=new_get_switch_ips).start()<EOL>test_config_parts = {}<EOL>for name, config in self.test_configs.items():<EOL><INDENT>host_name = config.host_name<EOL>nexus_port = config.nexus_port<EOL>if not config.nexus_ip_addr:<EOL><INDENT>if not config.profile:<EOL><INDENT>continue<EOL><DEDENT>all_link_info = config.profile['<STR_LIT>']<EOL>for link_info in all_link_info:<EOL><INDENT>ip_addr = link_info['<STR_LIT>']['<STR_LIT>']<EOL>self._config_switch_cred(test_config_parts, ip_addr)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ip_addr = config.nexus_ip_addr<EOL>self._config_switch_cred(test_config_parts, ip_addr)<EOL><DEDENT>if (host_name is not HOST_NAME_UNUSED and<EOL>HOST_NAME_Baremetal not in host_name):<EOL><INDENT>if host_name in test_config_parts[ip_addr]:<EOL><INDENT>test_config_parts[ip_addr][host_name].add(nexus_port)<EOL><DEDENT>else:<EOL><INDENT>test_config_parts[ip_addr][host_name] = set([nexus_port])<EOL><DEDENT><DEDENT><DEDENT>test_config_file = "<STR_LIT>"<EOL>for ip, subparts in test_config_parts.items():<EOL><INDENT>switch_config = subparts['<STR_LIT>']<EOL>host_config = None<EOL>for name, subpart in subparts.items():<EOL><INDENT>if name == "<STR_LIT>":<EOL><INDENT>continue<EOL><DEDENT>if not host_config:<EOL><INDENT>host_config = ("<STR_LIT>" %<EOL>(name, '<STR_LIT:U+002C>'.join(subpart)))<EOL><DEDENT>else:<EOL><INDENT>host_config += "<STR_LIT>" % (name, '<STR_LIT:U+002C>'.join(subpart))<EOL><DEDENT><DEDENT>test_config_file += switch_config<EOL>if host_config:<EOL><INDENT>test_config_file += "<STR_LIT>" % host_config<EOL><DEDENT><DEDENT>nc_base.load_config_file(test_config_file)<EOL>self.mock_continue_binding = mock.patch.object(<EOL>FakePortContext,<EOL>'<STR_LIT>').start()<EOL>self.mock_get_dynamic_segment = mock.patch.object(<EOL>bc.segments_db, '<STR_LIT>',<EOL>return_value={'<STR_LIT>': '<STR_LIT>'}).start()<EOL>mock.patch.object(<EOL>trunk.NexusMDTrunkHandler, '<STR_LIT>',<EOL>return_value=False).start()<EOL>self.restapi_mock_init()<EOL>self._cisco_mech_driver = mech_cisco_nexus.CiscoNexusMechanismDriver()<EOL>self._cisco_mech_driver.initialize()<EOL>self._cfg_monitor = self._cisco_mech_driver.monitor<EOL>self._cisco_mech_driver.driver.nexus_switches = (<EOL>CONF.ml2_cisco.nexus_switches)<EOL>self.addCleanup(self._clear_port_dbs)<EOL>
Sets up mock client, switch, and credentials dictionaries.