def launch_api_server_rdbms(test_id, listen_ip, listen_port, http_server_port, admin_port, conf_sections): db_file = "./test_db_%s.db" % test_id args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--admin_port %s " % (admin_port) args_str = args_str + "--db_engine rdbms " args_str = args_str + "--rdbms_connection sqlite:///%s " % db_file args_str = args_str + "--log_local " args_str = args_str + "--log_file api_server_%s.log " % (test_id) vnc_cgitb.enable(format='text') try: os.remove(db_file) shutil.copyfile('./base_db.db', db_file) except: pass with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile( ) as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " % (conf.name) args_str = args_str + "--logging_conf %s " % (logconf.name) server = vnc_cfg_api_server.VncApiServer(args_str) gevent.getcurrent().api_server = server vnc_cfg_api_server.main(args_str, server)
def generate_kube_args(self): args_str = "" kube_config = [ ('DEFAULTS', 'log_file', 'contrail-kube-manager.log'), ('VNC', 'vnc_endpoint_ip', self._api_server_ip), ('VNC', 'vnc_endpoint_port', self._api_server_port), ('VNC', 'cassandra_server_list', "0.0.0.0:9160"), ('KUBERNETES', 'service_subnets', "10.96.0.0/12"), ('KUBERNETES', 'pod_subnets', "10.32.0.0/12"), ] vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile( ) as conf, tempfile.NamedTemporaryFile() as logconf: cfg_parser = test_common.generate_conf_file_contents(kube_config) cfg_parser.write(conf) conf.flush() cfg_parser = test_common.generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = ["-c", conf.name] args = kube_args.parse_args(args_str) return args
def launch_api_server(test_id, listen_ip, listen_port, http_server_port, admin_port, ifmap_port, conf_sections, ifmap_server_ip=None): args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--admin_port %s " % (admin_port) if ifmap_server_ip is not None: args_str = args_str + "--ifmap_server_ip %s " % ifmap_server_ip args_str = args_str + "--ifmap_server_port %s " % ifmap_port else: args_str = args_str + "--ifmap_listen_ip %s " % listen_ip args_str = args_str + "--ifmap_listen_port %s " % ifmap_port args_str = args_str + "--cassandra_server_list 0.0.0.0:9160 " args_str = args_str + "--log_local " args_str = args_str + "--log_file api_server_%s.log " %(test_id) vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " %(conf.name) args_str = args_str + "--logging_conf %s " %(logconf.name) server = vnc_cfg_api_server.VncApiServer(args_str) gevent.getcurrent().api_server = server vnc_cfg_api_server.main(args_str, server)
def launch_api_server(test_id, listen_ip, listen_port, http_server_port, admin_port, conf_sections): kombu_mock = mock.Mock() kombu_patch = mock.patch('vnc_cfg_api_server.api_server.KombuAmqpClient') kombu_init_mock = kombu_patch.start() kombu_init_mock.side_effect = kombu_mock args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--admin_port %s " % (admin_port) args_str = args_str + "--cassandra_server_list 0.0.0.0:9160 " args_str = args_str + "--log_local " args_str = args_str + "--log_file api_server_%s.log " % (test_id) args_str = args_str + "--cluster_id %s " % (test_id) vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile(mode='w+') as conf, \ tempfile.NamedTemporaryFile(mode='w+') as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " % (conf.name) args_str = args_str + "--logging_conf %s " % (logconf.name) server = api_server.VncApiServer(args_str) gevent.getcurrent().api_server = server api_server.main(args_str, server)
def launch_api_server(test_id, listen_ip, listen_port, http_server_port, admin_port, conf_sections): args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--admin_port %s " % (admin_port) args_str = args_str + "--cassandra_server_list 0.0.0.0:9160 " args_str = args_str + "--log_local " args_str = args_str + "--log_file api_server_%s.log " % (test_id) args_str = args_str + "--cluster_id %s " % (test_id) vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, \ tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " % (conf.name) args_str = args_str + "--logging_conf %s " % (logconf.name) server = vnc_cfg_api_server.VncApiServer(args_str) gevent.getcurrent().api_server = server vnc_cfg_api_server.main(args_str, server)
def main(args_str=None, mesos_api_skip=False, event_queue=None): vnc_cgitb.enable(format='text') args = mesos_args.parse_args(args_str) mesos_nw_mgr = MesosNetworkManager(args, mesos_api_connected=mesos_api_skip, queue=event_queue) mesos_nw_mgr.start_tasks()
def launch_disc_server(test_id, listen_ip, listen_port, http_server_port, conf_sections): args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--cassandra_server_list 0.0.0.0:9160 " args_str = args_str + "--ttl_min 30 " args_str = args_str + "--ttl_max 60 " args_str = args_str + "--log_local " args_str = args_str + "--log_file discovery_server_%s.log " % test_id vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile( ) as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " % (conf.name) disc_server.main(args_str)
def launch_api_server_rdbms(test_id, listen_ip, listen_port, http_server_port, admin_port, conf_sections): db_file = "./test_db_%s.db" % test_id args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--admin_port %s " % (admin_port) args_str = args_str + "--db_engine rdbms " args_str = args_str + "--rdbms_connection sqlite:///%s " % db_file args_str = args_str + "--log_local " args_str = args_str + "--log_file api_server_%s.log " %(test_id) vnc_cgitb.enable(format='text') try: os.remove(db_file) shutil.copyfile('./base_db.db', db_file) except: pass with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " %(conf.name) args_str = args_str + "--logging_conf %s " %(logconf.name) server = vnc_cfg_api_server.VncApiServer(args_str) gevent.getcurrent().api_server = server vnc_cfg_api_server.main(args_str, server)
def launch_kube_manager(test_id, conf_sections, kube_api_skip, event_queue, vnc_kubernetes_config_dict=None): args_str = "" vnc_cgitb.enable(format='text') wait_for_kube_manager_down() with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile( ) as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = ["-c", conf.name] kube_manager.main( args_str, kube_api_skip=kube_api_skip, event_queue=event_queue, vnc_kubernetes_config_dict=vnc_kubernetes_config_dict)
def main(args_str=None, mesos_api_skip=False, event_queue=None): vnc_cgitb.enable(format='text') args = mesos_args.parse_args(args_str) mesos_nw_mgr = MesosNetworkManager(args, mesos_api_connected=mesos_api_skip, queue=event_queue) MesosNetworkManager._mesos_network_manager = mesos_nw_mgr mesos_nw_mgr.start_tasks()
def _add_detailed_traceback(self, exc_info): vnc_cgitb.enable(format='text') from cStringIO import StringIO tmp_file = StringIO() cgitb_hook(format="text", file=tmp_file, info=exc_info) tb_str = tmp_file.getvalue() tmp_file.close() self.addDetail('detailed-traceback', content.text_content(tb_str))
def _add_detailed_traceback(self, exc_info): vnc_cgitb.enable(format='text') from cStringIO import StringIO tmp_file = StringIO() vnc_cgitb.Hook(format="text", file=tmp_file).handle(exc_info) tb_str = tmp_file.getvalue() tmp_file.close() self.addDetail('detailed-traceback', content.text_content(tb_str))
def launch_mesos_manager(test_id, conf_sections, mesos_api_skip, event_queue): args_str = "" vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str= ["-c", conf.name] mesos_manager.main(args_str, mesos_api_skip=mesos_api_skip, event_queue=event_queue)
def launch_mesos_manager(test_id, conf_sections, mesos_api_skip, event_queue): args_str = "" vnc_cgitb.enable(format='text') wait_for_mesos_manager_down() with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str= ["-c", conf.name] mesos_manager.main(args_str, mesos_api_skip=mesos_api_skip, event_queue=event_queue)
def launch_api_server(test_id, listen_ip, listen_port, http_server_port, admin_port, ifmap_port, conf_sections, ifmap_server_ip=None): args_str = "" ifmap_cert_dir = None args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--admin_port %s " % (admin_port) if ifmap_server_ip is not None: args_str = args_str + "--ifmap_server_ip %s " % ifmap_server_ip args_str = args_str + "--ifmap_server_port %s " % ifmap_port else: args_str = args_str + "--ifmap_listen_ip %s " % listen_ip args_str = args_str + "--ifmap_listen_port %s " % ifmap_port ifmap_cert_dir = tempfile.mkdtemp() args_str = args_str + "--ifmap_key_path %s/key " % ifmap_cert_dir args_str = args_str + "--ifmap_cert_path %s/cert " % ifmap_cert_dir args_str = args_str + "--cassandra_server_list 0.0.0.0:9160 " args_str = args_str + "--log_local " args_str = args_str + "--log_file api_server_%s.log " % (test_id) vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, \ tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " % (conf.name) args_str = args_str + "--logging_conf %s " % (logconf.name) server = vnc_cfg_api_server.VncApiServer(args_str) gevent.getcurrent().api_server = server vnc_cfg_api_server.main(args_str, server) if ifmap_cert_dir is not None: shutil.rmtree(ifmap_cert_dir)
def generate_kube_args(self): kube_config = [ ('DEFAULTS', 'log_file', 'contrail-kube-manager.log'), ('VNC', 'vnc_endpoint_ip', self._api_server_ip), ('VNC', 'vnc_endpoint_port', self._api_server_port), ('VNC', 'cassandra_server_list', "0.0.0.0:9160"), ('KUBERNETES', 'service_subnets', "10.96.0.0/12"), ('KUBERNETES', 'pod_subnets', "10.32.0.0/12"), ] vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile() as logconf: cfg_parser = test_common.generate_conf_file_contents(kube_config) cfg_parser.write(conf) conf.flush() cfg_parser = test_common.generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args = kube_args.parse_args(["-c", conf.name]) return args
def launch_disc_server(test_id, listen_ip, listen_port, http_server_port, conf_sections): args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--cassandra_server_list 0.0.0.0:9160 " args_str = args_str + "--ttl_min 30 " args_str = args_str + "--ttl_max 60 " args_str = args_str + "--log_local " args_str = args_str + "--log_file discovery_server_%s.log " % test_id vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " %(conf.name) disc_server.main(args_str)
def launch_api_server(test_id, listen_ip, listen_port, http_server_port, admin_port, conf_sections): kombu_mock = mock.Mock() kombu_patch = mock.patch( 'vnc_cfg_api_server.vnc_cfg_api_server.KombuAmqpClient') kombu_init_mock = kombu_patch.start() kombu_init_mock.side_effect = kombu_mock args_str = "" args_str = args_str + "--listen_ip_addr %s " % (listen_ip) args_str = args_str + "--listen_port %s " % (listen_port) args_str = args_str + "--http_server_port %s " % (http_server_port) args_str = args_str + "--admin_port %s " % (admin_port) args_str = args_str + "--cassandra_server_list 0.0.0.0:9160 " args_str = args_str + "--log_local " args_str = args_str + "--log_file api_server_%s.log " %(test_id) args_str = args_str + "--cluster_id %s " %(test_id) vnc_cgitb.enable(format='text') with tempfile.NamedTemporaryFile() as conf, \ tempfile.NamedTemporaryFile() as logconf: cfg_parser = generate_conf_file_contents(conf_sections) cfg_parser.write(conf) conf.flush() cfg_parser = generate_logconf_file_contents() cfg_parser.write(logconf) logconf.flush() args_str = args_str + "--conf_file %s " %(conf.name) args_str = args_str + "--logging_conf %s " %(logconf.name) server = vnc_cfg_api_server.VncApiServer(args_str) gevent.getcurrent().api_server = server vnc_cfg_api_server.main(args_str, server)
# # Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. # import gevent import sys import uuid import logging from testtools.matchers import MismatchError from testtools import ExpectedException from vnc_api.vnc_api import * from cfgm_common import vnc_cgitb vnc_cgitb.enable(format='text') sys.path.append('../common/tests') import test_utils import test_case logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) class TestQuota(test_case.ApiServerTestCase): def __init__(self, *args, **kwargs): super(TestQuota, self).__init__(*args, **kwargs) self._port_quota = 3 self._fip_quota = 3 @classmethod
def main(): vnc_cgitb.enable(format='text') args = parse_args() kube_nw_mgr = KubeNetworkManager(args) kube_nw_mgr.start_tasks()
def main(): vnc_cgitb.enable(format='text') args = mesos_args.parse_args() mesos_nw_mgr = MesosNetworkManager(args) mesos_nw_mgr.start_tasks()
def server_main(): vnc_cgitb.enable(format='text') main()
import copy import inspect import pycassa import kombu import requests import netaddr from vnc_api.vnc_api import * import vnc_api.gen.vnc_api_test_gen from vnc_api.gen.resource_test import * from netaddr import IPNetwork, IPAddress import cfgm_common from cfgm_common import vnc_cgitb from cfgm_common import get_lr_internal_vn_name vnc_cgitb.enable(format='text') sys.path.append('../common/tests') from test_utils import * import test_common import test_case logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) class TestPhysicalInterface(test_case.ApiServerTestCase): @classmethod def setUpClass(cls, *args, **kwargs): cls.console_handler = logging.StreamHandler() cls.console_handler.setLevel(logging.DEBUG)
def server_main(): vnc_cgitb.enable(format="text") main()