def setUp(self): # mock nvp api client self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH) mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True) # Avoid runs of the synchronizer looping call # These unit tests will excplicitly invoke synchronization patch_sync = mock.patch.object(sync, '_start_loopingcall') self.mock_nvpapi = mock_nvpapi.start() patch_sync.start() self.mock_nvpapi.return_value.login.return_value = "the_cookie" # Emulate tests against NVP 3.x self.mock_nvpapi.return_value.get_nvp_version.return_value = ( NvpApiClient.NVPVersion("3.1")) def _fake_request(*args, **kwargs): return self.fc.fake_request(*args, **kwargs) self.mock_nvpapi.return_value.request.side_effect = _fake_request self.fake_cluster = nsx_cluster.NSXCluster( name='fake-cluster', nsx_controllers=['1.1.1.1:999'], default_tz_uuid=_uuid(), nsx_user='******', nsx_password='******') self.fake_cluster.api_client = NvpApiClient.NVPApiHelper( ('1.1.1.1', '999', True), self.fake_cluster.nsx_user, self.fake_cluster.nsx_password, self.fake_cluster.req_timeout, self.fake_cluster.http_timeout, self.fake_cluster.retries, self.fake_cluster.redirects) # Instantiate Neutron plugin # and setup needed config variables args = [ '--config-file', get_fake_conf('neutron.conf.test'), '--config-file', get_fake_conf('nsx.ini.test') ] config.parse(args=args) cfg.CONF.set_override('allow_overlapping_ips', True) self._plugin = NeutronPlugin.NvpPluginV2() # Mock neutron manager plugin load functions to speed up tests mock_nm_get_plugin = mock.patch('neutron.manager.NeutronManager.' 'get_plugin') mock_nm_get_service_plugins = mock.patch( 'neutron.manager.NeutronManager.get_service_plugins') self.mock_nm_get_plugin = mock_nm_get_plugin.start() self.mock_nm_get_plugin.return_value = self._plugin mock_nm_get_service_plugins.start() super(NvpSyncTestCase, self).setUp() self.addCleanup(self.fc.reset_all) self.addCleanup(patch_sync.stop) self.addCleanup(mock_nvpapi.stop) self.addCleanup(mock_nm_get_plugin.stop) self.addCleanup(mock_nm_get_service_plugins.stop)
def main(): if len(sys.argv) != 2: help(sys.argv[0]) args = ['--config-file'] args.append(sys.argv[1]) config.parse(args) print("----------------------- Database Options -----------------------") print("\tconnection: %s" % cfg.CONF.database.connection) print("\tretry_interval: %d" % cfg.CONF.database.retry_interval) print("\tmax_retries: %d" % cfg.CONF.database.max_retries) print("----------------------- NVP Options -----------------------") print("\tNVP Generation Timeout %d" % cfg.CONF.NVP.nvp_gen_timeout) print("\tNumber of concurrent connections to each controller %d" % cfg.CONF.NVP.concurrent_connections) print("\tmax_lp_per_bridged_ls: %s" % cfg.CONF.NVP.max_lp_per_bridged_ls) print("\tmax_lp_per_overlay_ls: %s" % cfg.CONF.NVP.max_lp_per_overlay_ls) print("----------------------- Cluster Options -----------------------") print("\trequested_timeout: %s" % cfg.CONF.req_timeout) print("\tretries: %s" % cfg.CONF.retries) print("\tredirects: %s" % cfg.CONF.redirects) print("\thttp_timeout: %s" % cfg.CONF.http_timeout) cluster = NeutronPlugin.create_nvp_cluster( cfg.CONF, cfg.CONF.NVP.concurrent_connections, cfg.CONF.NVP.nvp_gen_timeout) num_controllers = len(cluster.nvp_controllers) print("Number of controllers found: %s" % num_controllers) if num_controllers == 0: print("You must specify at least one controller!") sys.exit(1) for controller in cluster.nvp_controllers: print("\tController endpoint: %s" % controller) nvplib.check_cluster_connectivity(cluster) gateway_services = get_gateway_services(cluster) default_gateways = { "L2GatewayServiceConfig": cfg.CONF.default_l2_gw_service_uuid, "L3GatewayServiceConfig": cfg.CONF.default_l3_gw_service_uuid } errors = 0 for svc_type in default_gateways.keys(): for uuid in gateway_services[svc_type]: print("\t\tGateway(%s) uuid: %s" % (svc_type, uuid)) if (default_gateways[svc_type] and default_gateways[svc_type] not in gateway_services): print("\t\t\tError: specified default %s gateway (%s) is " "missing from NVP Gateway Services!" % (svc_type, default_gateways[svc_type])) errors += 1 transport_zones = get_transport_zones(cluster) print("\tTransport zones: %s" % transport_zones) if cfg.CONF.default_tz_uuid not in transport_zones: print("\t\tError: specified default transport zone " "(%s) is missing from NVP transport zones!" % cfg.CONF.default_tz_uuid) errors += 1 if errors: print("\nThere are %d errors with your configuration. " " Please, revise!" % errors) sys.exit(1) else: print("Done.")
def main(argv): if len(argv) != 2: help(argv[0]) args = ['--config-file'] args.append(argv[1]) config.parse(args) print "------------------------ Database Options ------------------------" print "\tconnection: %s" % cfg.CONF.database.connection print "\tretry_interval: %d" % cfg.CONF.database.retry_interval print "\tmax_retries: %d" % cfg.CONF.database.max_retries print "------------------------ NVP Options ------------------------" print "\tNVP Generation Timeout %d" % cfg.CONF.NVP.nvp_gen_timeout print ("\tNumber of concurrent connections to each controller %d" % cfg.CONF.NVP.concurrent_connections) print "\tmax_lp_per_bridged_ls: %s" % cfg.CONF.NVP.max_lp_per_bridged_ls print "\tmax_lp_per_overlay_ls: %s" % cfg.CONF.NVP.max_lp_per_overlay_ls print ("\tenable_metadata_access_network: %s" % cfg.CONF.NVP.enable_metadata_access_network) print "------------------------ Cluster Options ------------------------" print "\trequested_timeout: %s" % cfg.CONF.req_timeout print "\tretries: %s" % cfg.CONF.retries print "\tredirects: %s" % cfg.CONF.redirects print "\thttp_timeout: %s" % cfg.CONF.http_timeout cluster = NeutronPlugin.create_nvp_cluster( cfg.CONF, cfg.CONF.NVP.concurrent_connections, cfg.CONF.NVP.nvp_gen_timeout) num_controllers = len(cluster.nvp_controllers) print "Number of controllers found: %s" % num_controllers if num_controllers == 0: print "You must specify at least one controller!" sys.exit(1) for controller in cluster.nvp_controllers: print "\tController endpoint: %s" % controller nvplib.check_cluster_connectivity(cluster) gateway_services = get_gateway_services(cluster) default_gateways = { "L2GatewayServiceConfig": cfg.CONF.default_l2_gw_service_uuid, "L3GatewayServiceConfig": cfg.CONF.default_l3_gw_service_uuid} errors = 0 for svc_type in default_gateways.keys(): for uuid in gateway_services[svc_type]: print "\t\tGateway(%s) uuid: %s" % (svc_type, uuid) if (default_gateways[svc_type] and default_gateways[svc_type] not in gateway_services): print ("\t\t\tError: specified default %s gateway (%s) is " "missing from NVP Gateway Services!" % (svc_type, default_gateways[svc_type])) errors += 1 transport_zones = get_transport_zones(cluster) print "\tTransport zones: %s" % transport_zones if cfg.CONF.default_tz_uuid not in transport_zones: print ("\t\tError: specified default transport zone " "(%s) is missing from NVP transport zones!" % cfg.CONF.default_tz_uuid) errors += 1 if errors: print ("\nThere are %d errors with your configuration. " " Please, revise!" % errors) sys.exit(1) else: print "Done."
def main(): if len(sys.argv) != 2: help(sys.argv[0]) args = ['--config-file'] args.append(sys.argv[1]) config.parse(args) print("----------------------- Database Options -----------------------") print("\tconnection: %s" % cfg.CONF.database.connection) print("\tretry_interval: %d" % cfg.CONF.database.retry_interval) print("\tmax_retries: %d" % cfg.CONF.database.max_retries) print("----------------------- NSX Options -----------------------") print("\tNSX Generation Timeout %d" % cfg.CONF.NSX.nsx_gen_timeout) print("\tNumber of concurrent connections to each controller %d" % cfg.CONF.NSX.concurrent_connections) print("\tmax_lp_per_bridged_ls: %s" % cfg.CONF.NSX.max_lp_per_bridged_ls) print("\tmax_lp_per_overlay_ls: %s" % cfg.CONF.NSX.max_lp_per_overlay_ls) print("----------------------- Cluster Options -----------------------") print("\trequested_timeout: %s" % cfg.CONF.req_timeout) print("\tretries: %s" % cfg.CONF.retries) print("\tredirects: %s" % cfg.CONF.redirects) print("\thttp_timeout: %s" % cfg.CONF.http_timeout) cluster = NeutronPlugin.create_nvp_cluster( cfg.CONF, cfg.CONF.NSX.concurrent_connections, cfg.CONF.NSX.nsx_gen_timeout) nsx_controllers = get_nsx_controllers(cluster) num_controllers = len(nsx_controllers) print("Number of controllers found: %s" % num_controllers) if num_controllers == 0: print("You must specify at least one controller!") sys.exit(1) get_control_cluster_nodes(cluster) for controller in nsx_controllers: print("\tController endpoint: %s" % controller) gateway_services = get_gateway_services(cluster) default_gateways = { "L2GatewayServiceConfig": cfg.CONF.default_l2_gw_service_uuid, "L3GatewayServiceConfig": cfg.CONF.default_l3_gw_service_uuid} errors = 0 for svc_type in default_gateways.keys(): for uuid in gateway_services[svc_type]: print("\t\tGateway(%s) uuid: %s" % (svc_type, uuid)) if (default_gateways[svc_type] and default_gateways[svc_type] not in gateway_services[svc_type]): print("\t\t\tError: specified default %s gateway (%s) is " "missing from NSX Gateway Services!" % ( svc_type, default_gateways[svc_type])) errors += 1 transport_zones = get_transport_zones(cluster) print("\tTransport zones: %s" % transport_zones) if cfg.CONF.default_tz_uuid not in transport_zones: print("\t\tError: specified default transport zone " "(%s) is missing from NSX transport zones!" % cfg.CONF.default_tz_uuid) errors += 1 transport_nodes = get_transport_nodes(cluster) print("\tTransport nodes: %s" % transport_nodes) node_errors = [] for node in transport_nodes: if not is_transport_node_connected(cluster, node): node_errors.append(node) # Use different exit codes, so that we can distinguish # between config and runtime errors if len(node_errors): print("\nThere are one or mode transport nodes that are " "not connected: %s. Please, revise!" % node_errors) sys.exit(10) elif errors: print("\nThere are %d errors with your configuration. " "Please, revise!" % errors) sys.exit(12) else: print("Done.")