def test_mapped_neutron_error_localized(self, mock_translation): gettextutils.install('blaa', lazy=True) msg_translation = 'Translated error' mock_translation.return_value = msg_translation msg = _('Unmapped error') class TestException(q_exc.NeutronException): message = msg controller = mock.MagicMock() controller.test.side_effect = TestException() faults = {TestException: exc.HTTPGatewayTimeout} resource = webtest.TestApp( wsgi_resource.Resource(controller, faults=faults)) environ = { 'wsgiorg.routing_args': (None, { 'action': 'test', 'format': 'json' }) } res = resource.get('', extra_environ=environ, expect_errors=True) self.assertEqual(res.status_int, exc.HTTPGatewayTimeout.code) self.assertIn(msg_translation, str(wsgi.JSONDeserializer().deserialize(res.body)))
def test_unmapped_neutron_error_localized(self, mock_translation): gettextutils.install("blaa", lazy=True) msg_translation = "Translated error" mock_translation.return_value = msg_translation msg = _("Unmapped error") class TestException(q_exc.NeutronException): message = msg controller = mock.MagicMock() controller.test.side_effect = TestException() resource = webtest.TestApp(wsgi_resource.Resource(controller)) environ = {"wsgiorg.routing_args": (None, {"action": "test", "format": "json"})} res = resource.get("", extra_environ=environ, expect_errors=True) self.assertEqual(res.status_int, exc.HTTPInternalServerError.code) self.assertIn(msg_translation, str(wsgi.JSONDeserializer().deserialize(res.body)))
def test_mapped_neutron_error_localized(self, mock_translation): gettextutils.install('blaa', lazy=True) msg_translation = 'Translated error' mock_translation.return_value = msg_translation msg = _('Unmapped error') class TestException(n_exc.NeutronException): message = msg controller = mock.MagicMock() controller.test.side_effect = TestException() faults = {TestException: exc.HTTPGatewayTimeout} resource = webtest.TestApp(wsgi_resource.Resource(controller, faults=faults)) environ = {'wsgiorg.routing_args': (None, {'action': 'test', 'format': 'json'})} res = resource.get('', extra_environ=environ, expect_errors=True) self.assertEqual(res.status_int, exc.HTTPGatewayTimeout.code) self.assertIn(msg_translation, str(wsgi.JSONDeserializer().deserialize(res.body)))
#!/usr/bin/python import sys from oslo.config import cfg import neutron.openstack.common.gettextutils as gtutil gtutil.install("") import neutron.agent.linux.interface as vif_driver from neutronclient.neutron import client as qclient import neutronclient.common.exceptions as qcexp from neutron.agent.common import config # Arg 1: controller host # Arg 2: name of admin user # Arg 3: admin user password # Arg 4: tenant name # Arg 5: uuid of VM # Arg 6: MAC address of tap interface # Arg 7: name of tap interface host = sys.argv[1] user = sys.argv[2] pw = sys.argv[3] tenant = sys.argv[4] vm_uuid = sys.argv[5] mac_addr = sys.argv[6] interface = sys.argv[7] KEYSTONE_URL = "http://" + host + ":5000/v2.0"
#!/usr/bin/python import sys from oslo.config import cfg import neutron.openstack.common.gettextutils as gtutil gtutil.install('') import neutron.agent.linux.interface as vif_driver from neutronclient.neutron import client as qclient import neutronclient.common.exceptions as qcexp from neutron.agent.common import config # Arg 1: controller host # Arg 2: name of admin user # Arg 3: admin user password # Arg 4: tenant name # Arg 5: uuid of VM # Arg 6: MAC address of tap interface # Arg 7: name of tap interface host = sys.argv[1] user = sys.argv[2] pw = sys.argv[3] tenant = sys.argv[4] vm_uuid = sys.argv[5] mac_addr = sys.argv[6] interface = sys.argv[7] KEYSTONE_URL='http://' + host + ':5000/v2.0' qc = qclient.Client('2.0', auth_url=KEYSTONE_URL, username=user,
cfg.StrOpt('error_log', default='/var/log/neutron/http_error.log', help='The Error log file to write to.'), cfg.StrOpt('worker_class', default='eventlet', help='The type of workers to use.'), cfg.IntOpt('limit_request_line', default=0, help='The maximum size of HTTP request line in bytes.'), cfg.StrOpt('loglevel', default='debug', help='The granularity of Error log outputs.'), ] cfg.CONF.register_opts(options, 'gunicorn') gettextutils.install('neutron', lazy=True) LOG = logging.getLogger(__name__) class Neutron(base.Application): def init(self, *args, **kwargs): pass def load_config(self): self.cfg = gconfig.Config(self.usage, prog=self.prog) settings = { 'bind': '%s:%s' % (cfg.CONF.bind_host, cfg.CONF.bind_port), 'workers': cfg.CONF.api_workers,
#!/usr/bin/python import sys from oslo.config import cfg import neutron.openstack.common.gettextutils as gtutil gtutil.install('') import neutron.agent.linux.interface as vif_driver from neutronclient.neutron import client as qclient import neutronclient.common.exceptions as qcexp from neutron.agent.common import config # Arg 1: controller host # Arg 2: name of admin user # Arg 3: admin user password # Arg 4: tenant name # Arg 5: name of interface # Arg 6: MAC address of tap interface # Arg 7: uuid of VM # Arg 8: name of bridge # Arg 9: name of port # Arg 10: id of port # Arg 11: name of net # Arg 12: id of net host = sys.argv[1] user = sys.argv[2] pw = sys.argv[3] tenant = sys.argv[4] interface = sys.argv[5] mac_addr = sys.argv[6]
# License for the specific language governing permissions and limitations # under the License. # If ../neutron/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... import eventlet import sys from oslo.config import cfg from neutron.common import config from neutron import service from neutron.openstack.common import gettextutils gettextutils.install('neutron', lazy=True) def main(): eventlet.monkey_patch() # the configuration will be read into the cfg.CONF global data structure config.parse(sys.argv[1:]) if not cfg.CONF.config_file: sys.exit(_("ERROR: Unable to find configuration file via the default" " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and" " the '--config-file' option!")) try: neutron_service = service.serve_wsgi(service.NeutronApiService) neutron_service.wait() except RuntimeError as e:
# If ../neutron/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... import eventlet import sys from oslo.config import cfg from neutron.common import config from neutron import service from neutron.openstack.common import gettextutils from neutron.openstack.common import log as logging gettextutils.install("neutron", lazy=True) LOG = logging.getLogger(__name__) def main(): eventlet.monkey_patch() # the configuration will be read into the cfg.CONF global data structure config.parse(sys.argv[1:]) if not cfg.CONF.config_file: sys.exit( _( "ERROR: Unable to find configuration file via the default" " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and" " the '--config-file' option!"
# under the License. # If ../neutron/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... import eventlet import sys from oslo.config import cfg from neutron.common import config from neutron import service from neutron.openstack.common import gettextutils gettextutils.install("neutron", lazy=False) def main(): eventlet.monkey_patch() # the configuration will be read into the cfg.CONF global data structure config.parse(sys.argv[1:]) if not cfg.CONF.config_file: sys.exit( _( "ERROR: Unable to find configuration file via the default" " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and" " the '--config-file' option!" ) )
# License for the specific language governing permissions and limitations # under the License. # If ../neutron/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... import eventlet import sys from oslo.config import cfg from neutron.common import config from neutron import service from neutron.openstack.common import gettextutils gettextutils.install('neutron', lazy=False) def main(): eventlet.monkey_patch() # the configuration will be read into the cfg.CONF global data structure config.parse(sys.argv[1:]) if not cfg.CONF.config_file: sys.exit( _("ERROR: Unable to find configuration file via the default" " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and" " the '--config-file' option!")) try: neutron_service = service.serve_wsgi(service.NeutronApiService) neutron_service.wait()