def setup_server(self, network_info, metadata=None): """Set up and configures share server with given network parameters.""" server_name = network_info['server_id'] segmentation_id = network_info['segmentation_id'] network = self.validate_network(network_info) mtu = network['mtu'] tenant = self.client.get_tenant(network_info['server_id'], segmentation_id) sp_ports_map = unity_utils.find_ports_by_mtu( self.client.get_file_ports(), self.port_ids_conf, mtu) sp = self._choose_sp(sp_ports_map) nas_server = self.client.create_nas_server(server_name, sp, self.nas_server_pool, tenant=tenant) sp = nas_server.home_sp port_id = self._choose_port(sp_ports_map, sp) try: self._create_network_interface(nas_server, network, port_id) self._handle_security_services(nas_server, network_info['security_services']) return {'share_server_name': server_name} except Exception: with excutils.save_and_reraise_exception(): LOG.exception('Could not setup server.') server_details = {'share_server_name': server_name} self.teardown_server(server_details, network_info['security_services'])
def setup_server(self, network_info, metadata=None): """Set up and configures share server with given network parameters.""" server_name = network_info['server_id'] segmentation_id = network_info['segmentation_id'] network = self.validate_network(network_info) mtu = network['mtu'] tenant = self.client.get_tenant(network_info['server_id'], segmentation_id) sp_ports_map = unity_utils.find_ports_by_mtu( self.client.get_file_ports(), self.port_ids_conf, mtu) sp = self._choose_sp(sp_ports_map) nas_server = self.client.create_nas_server(server_name, sp, self.nas_server_pool, tenant=tenant) sp = nas_server.home_sp port_id = self._choose_port(sp_ports_map, sp) try: self._create_network_interface(nas_server, network, port_id) self._handle_security_services( nas_server, network_info['security_services']) return {'share_server_name': server_name} except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE('Could not setup server.')) server_details = {'share_server_name': server_name} self.teardown_server( server_details, network_info['security_services'])
def test_find_ports_by_mtu(self): all_ports = [SPA_ETH0, SPB_ETH0, SPA_ETH1, SPB_ETH1, SPA_LA1, SPB_LA1] port_ids_conf = '*' port_map = utils.find_ports_by_mtu(all_ports, port_ids_conf, 1500) self.assertEqual({'spa': {'spa_eth0', 'spa_la_1'}, 'spb': {'spb_eth0', 'spb_la_1'}}, port_map)
def test_find_ports_by_mtu(self): all_ports = [SPA_ETH0, SPB_ETH0, SPA_ETH1, SPB_ETH1, SPA_LA1, SPB_LA1] port_ids_conf = '*' port_map = utils.find_ports_by_mtu(all_ports, port_ids_conf, 1500) self.assertEqual( { 'spa': {'spa_eth0', 'spa_la_1'}, 'spb': {'spb_eth0', 'spb_la_1'} }, port_map)