From a3077cbb859a9237f9516ed0f073fe00839277c4 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Nov 2010 16:25:56 -0700 Subject: basics to get proxied ajaxterm working with virsh --- bin/nova-ajax-proxy | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 bin/nova-ajax-proxy (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy new file mode 100755 index 000000000..1a0c896ee --- /dev/null +++ b/bin/nova-ajax-proxy @@ -0,0 +1,31 @@ +#!/usr/bin/python +from twisted.internet import reactor +from twisted.web import http +from twisted.web.proxy import Proxy, ProxyRequest +import urlparse, exceptions + +class AjaxProxyRequest(ProxyRequest): + def process(self): + if 'referer' in self.received_headers: + auth_uri = self.received_headers['referer'] + else: + auth_uri = self.uri + + try: + auth_params = urlparse.parse_qs(urlparse.urlparse(auth_uri).query) + parsed_uri = urlparse.urlparse(self.uri) + + self.uri = "http://%s:%s%s?%s"% (auth_params['host'][0], auth_params['port'][0], parsed_uri.path, parsed_uri.query) + + ProxyRequest.process(self) + except (exceptions.KeyError): + pass + +class AjaxProxy(Proxy): + requestFactory = AjaxProxyRequest + +factory = http.HTTPFactory() +factory.protocol = AjaxProxy + +reactor.listenTCP(8000, factory) +reactor.run() -- cgit From c364724a0dc7a658058fcb167af66ee7eb5bcd2a Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Tue, 21 Dec 2010 01:41:28 -0500 Subject: Use paste.deploy for running the api server. --- bin/nova-api-paste | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100755 bin/nova-api-paste (limited to 'bin') diff --git a/bin/nova-api-paste b/bin/nova-api-paste new file mode 100755 index 000000000..dcb76522f --- /dev/null +++ b/bin/nova-api-paste @@ -0,0 +1,103 @@ +#!/usr/bin/env python +# pylint: disable-msg=C0103 +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Starter script for Nova API.""" + +import gettext +import logging +import os +import sys + +from paste import deploy + +from nova import flags +from nova import wsgi + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +gettext.install('nova', unicode=1) + +LOG = logging.getLogger('nova.api') +LOG.setLevel(logging.DEBUG) +LOG.addHandler(logging.StreamHandler()) + +FLAGS = flags.FLAGS + +API_ENDPOINTS = ['ec2', 'openstack'] + +def load_configuration(paste_config): + """Load the paste configuration from the config file and return it.""" + config = None + # Try each known name to get the global DEFAULTS, which will give ports + for name in API_ENDPOINTS: + try: + config = deploy.appconfig("config:%s" % paste_config, name=name) + except LookupError: + pass + if config: + verbose = config.get('verbose', None) + if verbose: + FLAGS.verbose = int(verbose) == 1 + if FLAGS.verbose: + logging.getLogger().setLevel(logging.DEBUG) + return config + LOG.debug("Paste config at %s has no secion for known apis", paste_config) + print "Paste config at %s has no secion for any known apis" % paste_config + os.exit(1) + +def launch_api(paste_config_file, section, server, port, host): + """Launch an api server from the specified port and IP.""" + LOG.debug("Launching api %s on %s:%s", section, host, port) + app = deploy.loadapp('config:%s' % paste_config_file, name=section) + server.start(app, int(port), host) + +def run_app(paste_config_file): + LOG.debug("Using paste.deploy config at: %s", configfile) + config = load_configuration(paste_config_file) + LOG.debug("Configuration: %r", config) + server = wsgi.Server() + ip = config.get('host', None) + for api in API_ENDPOINTS: + port = config.get("%s_port" % api, None) + if not port: + continue + host = config.get("%s_host" % api, None) or ip or '0.0.0.0' + launch_api(configfile, api, server, port, host) + LOG.debug("All api servers launched, now waiting") + server.wait() + +if __name__ == '__main__': + FLAGS(sys.argv) + configfiles = ['/etc/nova/nova-api.conf'] + if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + configfiles.insert(0, + os.path.join(possible_topdir, 'etc', 'nova-api.conf')) + for configfile in configfiles: + if os.path.exists(configfile): + run_app(configfile) + break + else: + LOG.debug("Skipping missing configuration: %s", configfile) -- cgit From 729468d0be1bf97c869b1169414154a76d9b96b2 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Tue, 21 Dec 2010 19:20:28 -0500 Subject: Burnin support by specifying a specific host via availability_zone for running instances and volumes on. --- bin/nova-manage | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 0c1b621ed..34bdd3df9 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -53,6 +53,7 @@ CLI interface for nova management. """ +import datetime import gettext import logging import os @@ -432,6 +433,52 @@ class NetworkCommands(object): int(network_size), int(vlan_start), int(vpn_start)) + +class ServiceCommands(object): + """Enable and disable running services""" + + def list(self, host=None, service=None): + """Show a list of all running services. Filter by host & service name. + args: [host] [service]""" + ctxt = context.get_admin_context() + now = datetime.datetime.utcnow() + services = db.service_get_all(ctxt) + if host: + services = [s for s in services if s['host'] == host] + if service: + services = [s for s in services if s['binary'] == service] + for svc in services: + delta = now - (svc['updated_at'] or svc['created_at']) + alive = (delta.seconds <= 15) + art = (alive and ":-)") or "XXX" + active = 'enabled' + if svc['disabled']: + active = 'disabled' + print "%-10s %-10s %-8s %s %s" % (svc['host'], svc['binary'], + active, art, + svc['updated_at']) + + def enable(self, host, service): + """Enable scheduling for a service + args: host service""" + ctxt = context.get_admin_context() + svc = db.service_get_by_args(ctxt, host, service) + if not svc: + print "Unable to find service" + return + db.service_update(ctxt, svc['id'], {'disabled': False}) + + def disable(self, host, service): + """Disable scheduling for a service + args: host service""" + ctxt = context.get_admin_context() + svc = db.service_get_by_args(ctxt, host, service) + if not svc: + print "Unable to find service" + return + db.service_update(ctxt, svc['id'], {'disabled': True}) + + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -439,7 +486,8 @@ CATEGORIES = [ ('shell', ShellCommands), ('vpn', VpnCommands), ('floating', FloatingIpCommands), - ('network', NetworkCommands)] + ('network', NetworkCommands), + ('service', ServiceCommands)] def lazy_match(name, key_value_tuples): -- cgit From f98bb2b2dee4a0ff67a6548646a852686092c53f Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 02:19:38 -0800 Subject: connecting ajax proxy to rabbit to allow token based security --- bin/nova-ajax-proxy | 71 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index 1a0c896ee..cad496b26 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -1,8 +1,30 @@ #!/usr/bin/python + +import datetime +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +from nova import utils +from nova import flags +from nova import rpc + +import exceptions +import logging +import urlparse + +FLAGS = flags.FLAGS from twisted.internet import reactor +from twisted.internet import task from twisted.web import http from twisted.web.proxy import Proxy, ProxyRequest -import urlparse, exceptions class AjaxProxyRequest(ProxyRequest): def process(self): @@ -20,12 +42,47 @@ class AjaxProxyRequest(ProxyRequest): ProxyRequest.process(self) except (exceptions.KeyError): pass - + class AjaxProxy(Proxy): + tokens = {} requestFactory = AjaxProxyRequest + + def start(self): + conn = rpc.Connection.instance(new=True) + self.consumer = rpc.TopicConsumer( + connection=conn, + topic=FLAGS.ajax_proxy_topic) + self.consumer.register_callback(self) + + task.LoopingCall(self.age).start(1.0) + task.LoopingCall(self.pollq).start(0.1) + + factory = http.HTTPFactory() + factory.protocol = AjaxProxy + + reactor.listenTCP(8000, factory) + reactor.run() + + def age(self): + pass + + def pollq(self): + self.consumer.fetch(auto_ack=True, enable_callbacks=True) -factory = http.HTTPFactory() -factory.protocol = AjaxProxy - -reactor.listenTCP(8000, factory) -reactor.run() + def __call__(self, data, message): + if data['method'] == 'authorize': + AjaxProxy.tokens['token'] = {'args': data['args'], 'born_at': datetime.datetime.now()} + + +if __name__ == '__main__': + utils.default_flagfile() + FLAGS(sys.argv) + + formatter = logging.Formatter('(%(name)s): %(levelname)s %(message)s') + handler = logging.StreamHandler() + handler.setFormatter(formatter) + logging.getLogger().addHandler(handler) + + ajaxproxy = AjaxProxy() + ajaxproxy.start() + -- cgit From 19f389b3dcc89f0115dc6fc1a6ca606338ad866a Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 12:36:37 -0800 Subject: working connection security --- bin/nova-ajax-proxy | 57 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 16 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index cad496b26..76a70d246 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -1,8 +1,8 @@ #!/usr/bin/python -import datetime import os import sys +import time # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... @@ -12,8 +12,9 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) -from nova import utils +from nova import exception from nova import flags +from nova import utils from nova import rpc import exceptions @@ -23,10 +24,13 @@ import urlparse FLAGS = flags.FLAGS from twisted.internet import reactor from twisted.internet import task -from twisted.web import http +from twisted.web import error, http from twisted.web.proxy import Proxy, ProxyRequest + +flags.DEFINE_integer('ajax_console_idle_timeout', 300, + 'Seconds before idle connection destroyed') -class AjaxProxyRequest(ProxyRequest): +class AjaxConsoleProxyRequest(ProxyRequest): def process(self): if 'referer' in self.received_headers: auth_uri = self.received_headers['referer'] @@ -36,42 +40,63 @@ class AjaxProxyRequest(ProxyRequest): try: auth_params = urlparse.parse_qs(urlparse.urlparse(auth_uri).query) parsed_uri = urlparse.urlparse(self.uri) + + auth_info = auth_params['token'][0] + auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]] + args = auth_info['args'] + auth_info['last_activity_at'] = time.time() + - self.uri = "http://%s:%s%s?%s"% (auth_params['host'][0], auth_params['port'][0], parsed_uri.path, parsed_uri.query) + self.uri = ("http://%s:%s%s?token=%s"% ( + str(args['host']), + str(args['port']), + parsed_uri.path, + str(args['token']))) ProxyRequest.process(self) except (exceptions.KeyError): - pass + raise exception.NotAuthorized("Unauthorized Request") -class AjaxProxy(Proxy): - tokens = {} - requestFactory = AjaxProxyRequest +class AjaxConsoleProxy(Proxy): + #tokens = {} + tokens = {'key': {'args':'','last_activity_at':time.time()}} + requestFactory = AjaxConsoleProxyRequest def start(self): conn = rpc.Connection.instance(new=True) self.consumer = rpc.TopicConsumer( connection=conn, - topic=FLAGS.ajax_proxy_topic) + topic=FLAGS.ajax_console_proxy_topic) self.consumer.register_callback(self) task.LoopingCall(self.age).start(1.0) task.LoopingCall(self.pollq).start(0.1) factory = http.HTTPFactory() - factory.protocol = AjaxProxy + factory.protocol = AjaxConsoleProxy - reactor.listenTCP(8000, factory) + port = urlparse.urlparse(FLAGS.ajax_console_proxy_url).port + reactor.listenTCP(port, factory) reactor.run() def age(self): - pass + now = time.time() + print now + to_delete = [] + for k, v in AjaxConsoleProxy.tokens.items(): + if now - v['last_activity_at'] > FLAGS.ajax_console_idle_timeout: + to_delete.append(k) + + for k in to_delete: + print "del" + del AjaxConsoleProxy.tokens[k] def pollq(self): self.consumer.fetch(auto_ack=True, enable_callbacks=True) def __call__(self, data, message): - if data['method'] == 'authorize': - AjaxProxy.tokens['token'] = {'args': data['args'], 'born_at': datetime.datetime.now()} + if data['method'] == 'authorize_ajax_console': + AjaxConsoleProxy.tokens[data['args']['token']] = {'args': data['args'], 'born_at': time.time()} if __name__ == '__main__': @@ -83,6 +108,6 @@ if __name__ == '__main__': handler.setFormatter(formatter) logging.getLogger().addHandler(handler) - ajaxproxy = AjaxProxy() + ajaxproxy = AjaxConsoleProxy() ajaxproxy.start() -- cgit From 4e9b4c9ce31a7a50d7e38d5e0bd71718d5bb8b95 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 18:52:43 -0800 Subject: minor notes, commit before rewriting proxy with eventlet --- bin/nova-ajax-proxy | 1 - 1 file changed, 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index 76a70d246..4948897cc 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -46,7 +46,6 @@ class AjaxConsoleProxyRequest(ProxyRequest): args = auth_info['args'] auth_info['last_activity_at'] = time.time() - self.uri = ("http://%s:%s%s?token=%s"% ( str(args['host']), str(args['port']), -- cgit From 4364a6e0570794fca841a7e5ecc8cecebf1bae9b Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 23:41:07 -0800 Subject: rewrite proxy to not use twisted --- bin/nova-ajax-proxy | 128 ++++++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 65 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index 4948897cc..52d7ee3de 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -12,101 +12,99 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) +import webob.dec +import webob.exc + from nova import exception from nova import flags from nova import utils from nova import rpc +from nova import wsgi import exceptions import logging import urlparse FLAGS = flags.FLAGS -from twisted.internet import reactor -from twisted.internet import task -from twisted.web import error, http -from twisted.web.proxy import Proxy, ProxyRequest flags.DEFINE_integer('ajax_console_idle_timeout', 300, 'Seconds before idle connection destroyed') -class AjaxConsoleProxyRequest(ProxyRequest): - def process(self): - if 'referer' in self.received_headers: - auth_uri = self.received_headers['referer'] - else: - auth_uri = self.uri +import eventlet +from eventlet import greenthread +from eventlet.green import urllib2 + +class AjaxConsoleProxy(object): + tokens = {} + def __call__(self, environ, start_response): try: - auth_params = urlparse.parse_qs(urlparse.urlparse(auth_uri).query) - parsed_uri = urlparse.urlparse(self.uri) + req_url = '%s://%s%s?%s' % (environ['wsgi.url_scheme'], environ['HTTP_HOST'], environ['PATH_INFO'], environ['QUERY_STRING']) + if 'HTTP_REFERER' in environ: + auth_url = environ['HTTP_REFERER'] + else: + auth_url = req_url + + auth_params = urlparse.parse_qs(urlparse.urlparse(auth_url).query) + parsed_url = urlparse.urlparse(req_url) - auth_info = auth_params['token'][0] - auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]] + auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]] args = auth_info['args'] auth_info['last_activity_at'] = time.time() - self.uri = ("http://%s:%s%s?token=%s"% ( - str(args['host']), - str(args['port']), - parsed_uri.path, - str(args['token']))) + remote_url = ("http://%s:%s%s?token=%s"% ( + str(args['host']), + str(args['port']), + parsed_url.path, + str(args['token']))) - ProxyRequest.process(self) + opener = urllib2.urlopen(remote_url, environ['wsgi.input'].read()) + body = opener.read() + info = opener.info() + + start_response("200 OK", info.dict.items()) + return body except (exceptions.KeyError): - raise exception.NotAuthorized("Unauthorized Request") + start_response("401 NOT AUTHORIZED",[]) + return "Not Authorized" + except Exception: + start_response("500 ERROR",[]) + return "Server Error" + -class AjaxConsoleProxy(Proxy): - #tokens = {} - tokens = {'key': {'args':'','last_activity_at':time.time()}} - requestFactory = AjaxConsoleProxyRequest + def register_listeners(self): + class Callback: + def __call__(self, data, message): + if data['method'] == 'authorize_ajax_console': + AjaxConsoleProxy.tokens[data['args']['token']] = \ + {'args': data['args'], 'last_activity_at': time.time()} - def start(self): conn = rpc.Connection.instance(new=True) - self.consumer = rpc.TopicConsumer( + consumer = rpc.TopicConsumer( connection=conn, topic=FLAGS.ajax_console_proxy_topic) - self.consumer.register_callback(self) - - task.LoopingCall(self.age).start(1.0) - task.LoopingCall(self.pollq).start(0.1) - - factory = http.HTTPFactory() - factory.protocol = AjaxConsoleProxy - - port = urlparse.urlparse(FLAGS.ajax_console_proxy_url).port - reactor.listenTCP(port, factory) - reactor.run() - - def age(self): - now = time.time() - print now - to_delete = [] - for k, v in AjaxConsoleProxy.tokens.items(): - if now - v['last_activity_at'] > FLAGS.ajax_console_idle_timeout: - to_delete.append(k) - - for k in to_delete: - print "del" - del AjaxConsoleProxy.tokens[k] - - def pollq(self): - self.consumer.fetch(auto_ack=True, enable_callbacks=True) - - def __call__(self, data, message): - if data['method'] == 'authorize_ajax_console': - AjaxConsoleProxy.tokens[data['args']['token']] = {'args': data['args'], 'born_at': time.time()} + consumer.register_callback(Callback()) + + def delete_expired_tokens(): + now = time.time() + to_delete = [] + for k, v in AjaxConsoleProxy.tokens.items(): + if now - v['last_activity_at'] > FLAGS.ajax_console_idle_timeout: + to_delete.append(k) + for k in to_delete: + del AjaxConsoleProxy.tokens[k] + + utils.LoopingCall(consumer.fetch, auto_ack=True, + enable_callbacks=True).start(0.1) + utils.LoopingCall(delete_expired_tokens).start(1) if __name__ == '__main__': utils.default_flagfile() FLAGS(sys.argv) + server = wsgi.Server() + acp = AjaxConsoleProxy() + acp.register_listeners() + server.start(acp, FLAGS.ajax_console_proxy_port, host='0.0.0.0') + server.wait() - formatter = logging.Formatter('(%(name)s): %(levelname)s %(message)s') - handler = logging.StreamHandler() - handler.setFormatter(formatter) - logging.getLogger().addHandler(handler) - - ajaxproxy = AjaxConsoleProxy() - ajaxproxy.start() - -- cgit From 237326dd6b5905a18fc7ba740457ceb52164ab59 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 23:46:21 -0800 Subject: some cleanup --- bin/nova-ajax-proxy | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index 52d7ee3de..df73b0adf 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -1,8 +1,15 @@ #!/usr/bin/python +from eventlet import greenthread +from eventlet.green import urllib2 + +import exceptions +import logging import os import sys import time +import urlparse + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... @@ -12,36 +19,28 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) -import webob.dec -import webob.exc - -from nova import exception from nova import flags from nova import utils from nova import rpc from nova import wsgi -import exceptions -import logging -import urlparse - FLAGS = flags.FLAGS flags.DEFINE_integer('ajax_console_idle_timeout', 300, 'Seconds before idle connection destroyed') -import eventlet -from eventlet import greenthread -from eventlet.green import urllib2 class AjaxConsoleProxy(object): tokens = {} - def __call__(self, environ, start_response): + def __call__(self, env, start_response): try: - req_url = '%s://%s%s?%s' % (environ['wsgi.url_scheme'], environ['HTTP_HOST'], environ['PATH_INFO'], environ['QUERY_STRING']) - if 'HTTP_REFERER' in environ: - auth_url = environ['HTTP_REFERER'] + req_url = '%s://%s%s?%s' % (env['wsgi.url_scheme'], + env['HTTP_HOST'], + env['PATH_INFO'], + env['QUERY_STRING']) + if 'HTTP_REFERER' in env: + auth_url = env['HTTP_REFERER'] else: auth_url = req_url @@ -50,7 +49,7 @@ class AjaxConsoleProxy(object): auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]] args = auth_info['args'] - auth_info['last_activity_at'] = time.time() + auth_info['last_activity'] = time.time() remote_url = ("http://%s:%s%s?token=%s"% ( str(args['host']), @@ -58,7 +57,7 @@ class AjaxConsoleProxy(object): parsed_url.path, str(args['token']))) - opener = urllib2.urlopen(remote_url, environ['wsgi.input'].read()) + opener = urllib2.urlopen(remote_url, env['wsgi.input'].read()) body = opener.read() info = opener.info() @@ -77,7 +76,7 @@ class AjaxConsoleProxy(object): def __call__(self, data, message): if data['method'] == 'authorize_ajax_console': AjaxConsoleProxy.tokens[data['args']['token']] = \ - {'args': data['args'], 'last_activity_at': time.time()} + {'args': data['args'], 'last_activity': time.time()} conn = rpc.Connection.instance(new=True) consumer = rpc.TopicConsumer( @@ -89,7 +88,7 @@ class AjaxConsoleProxy(object): now = time.time() to_delete = [] for k, v in AjaxConsoleProxy.tokens.items(): - if now - v['last_activity_at'] > FLAGS.ajax_console_idle_timeout: + if now - v['last_activity'] > FLAGS.ajax_console_idle_timeout: to_delete.append(k) for k in to_delete: -- cgit From e6a01c663bbcd5fc5244c48b97ef0bef4ce524ea Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 23:47:46 -0800 Subject: add in license --- bin/nova-ajax-proxy | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index df73b0adf..3adc1018c 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -1,4 +1,25 @@ -#!/usr/bin/python +#!/usr/bin/env python +# pylint: disable-msg=C0103 +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Ajax Console Proxy Server""" + from eventlet import greenthread from eventlet.green import urllib2 -- cgit From 86b9e564fec24423485b5087e41584abd0de1da0 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 23:49:10 -0800 Subject: more tweaks --- bin/nova-ajax-proxy | 3 --- 1 file changed, 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index 3adc1018c..bc828c5b1 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -20,7 +20,6 @@ """Ajax Console Proxy Server""" - from eventlet import greenthread from eventlet.green import urllib2 @@ -31,7 +30,6 @@ import sys import time import urlparse - # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -91,7 +89,6 @@ class AjaxConsoleProxy(object): start_response("500 ERROR",[]) return "Server Error" - def register_listeners(self): class Callback: def __call__(self, data, message): -- cgit From 50fe4b93ce2a015c31286d2b2de64a0128761086 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 23 Dec 2010 01:26:03 -0800 Subject: pep8 fixes --- bin/nova-ajax-proxy | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy index bc828c5b1..53b779711 100755 --- a/bin/nova-ajax-proxy +++ b/bin/nova-ajax-proxy @@ -21,7 +21,7 @@ """Ajax Console Proxy Server""" from eventlet import greenthread -from eventlet.green import urllib2 +from eventlet.green import urllib2 import exceptions import logging @@ -45,9 +45,9 @@ from nova import wsgi FLAGS = flags.FLAGS -flags.DEFINE_integer('ajax_console_idle_timeout', 300, +flags.DEFINE_integer('ajax_console_idle_timeout', 300, 'Seconds before idle connection destroyed') - + class AjaxConsoleProxy(object): tokens = {} @@ -67,10 +67,10 @@ class AjaxConsoleProxy(object): parsed_url = urlparse.urlparse(req_url) auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]] - args = auth_info['args'] - auth_info['last_activity'] = time.time() + args = auth_info['args'] + auth_info['last_activity'] = time.time() - remote_url = ("http://%s:%s%s?token=%s"% ( + remote_url = ("http://%s:%s%s?token=%s" % ( str(args['host']), str(args['port']), parsed_url.path, @@ -83,10 +83,10 @@ class AjaxConsoleProxy(object): start_response("200 OK", info.dict.items()) return body except (exceptions.KeyError): - start_response("401 NOT AUTHORIZED",[]) + start_response("401 NOT AUTHORIZED", []) return "Not Authorized" except Exception: - start_response("500 ERROR",[]) + start_response("500 ERROR", []) return "Server Error" def register_listeners(self): @@ -112,7 +112,7 @@ class AjaxConsoleProxy(object): for k in to_delete: del AjaxConsoleProxy.tokens[k] - utils.LoopingCall(consumer.fetch, auto_ack=True, + utils.LoopingCall(consumer.fetch, auto_ack=True, enable_callbacks=True).start(0.1) utils.LoopingCall(delete_expired_tokens).start(1) @@ -124,4 +124,3 @@ if __name__ == '__main__': acp.register_listeners() server.start(acp, FLAGS.ajax_console_proxy_port, host='0.0.0.0') server.wait() - -- cgit From e4c1fa91e0245dc6f673c5ac8880a99bd3d0dea1 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 23 Dec 2010 01:32:15 -0800 Subject: better bin name, and pep8 --- bin/nova-ajax-console-proxy | 126 ++++++++++++++++++++++++++++++++++++++++++++ bin/nova-ajax-proxy | 126 -------------------------------------------- 2 files changed, 126 insertions(+), 126 deletions(-) create mode 100755 bin/nova-ajax-console-proxy delete mode 100755 bin/nova-ajax-proxy (limited to 'bin') diff --git a/bin/nova-ajax-console-proxy b/bin/nova-ajax-console-proxy new file mode 100755 index 000000000..53b779711 --- /dev/null +++ b/bin/nova-ajax-console-proxy @@ -0,0 +1,126 @@ +#!/usr/bin/env python +# pylint: disable-msg=C0103 +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Ajax Console Proxy Server""" + +from eventlet import greenthread +from eventlet.green import urllib2 + +import exceptions +import logging +import os +import sys +import time +import urlparse + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +from nova import flags +from nova import utils +from nova import rpc +from nova import wsgi + +FLAGS = flags.FLAGS + +flags.DEFINE_integer('ajax_console_idle_timeout', 300, + 'Seconds before idle connection destroyed') + + +class AjaxConsoleProxy(object): + tokens = {} + + def __call__(self, env, start_response): + try: + req_url = '%s://%s%s?%s' % (env['wsgi.url_scheme'], + env['HTTP_HOST'], + env['PATH_INFO'], + env['QUERY_STRING']) + if 'HTTP_REFERER' in env: + auth_url = env['HTTP_REFERER'] + else: + auth_url = req_url + + auth_params = urlparse.parse_qs(urlparse.urlparse(auth_url).query) + parsed_url = urlparse.urlparse(req_url) + + auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]] + args = auth_info['args'] + auth_info['last_activity'] = time.time() + + remote_url = ("http://%s:%s%s?token=%s" % ( + str(args['host']), + str(args['port']), + parsed_url.path, + str(args['token']))) + + opener = urllib2.urlopen(remote_url, env['wsgi.input'].read()) + body = opener.read() + info = opener.info() + + start_response("200 OK", info.dict.items()) + return body + except (exceptions.KeyError): + start_response("401 NOT AUTHORIZED", []) + return "Not Authorized" + except Exception: + start_response("500 ERROR", []) + return "Server Error" + + def register_listeners(self): + class Callback: + def __call__(self, data, message): + if data['method'] == 'authorize_ajax_console': + AjaxConsoleProxy.tokens[data['args']['token']] = \ + {'args': data['args'], 'last_activity': time.time()} + + conn = rpc.Connection.instance(new=True) + consumer = rpc.TopicConsumer( + connection=conn, + topic=FLAGS.ajax_console_proxy_topic) + consumer.register_callback(Callback()) + + def delete_expired_tokens(): + now = time.time() + to_delete = [] + for k, v in AjaxConsoleProxy.tokens.items(): + if now - v['last_activity'] > FLAGS.ajax_console_idle_timeout: + to_delete.append(k) + + for k in to_delete: + del AjaxConsoleProxy.tokens[k] + + utils.LoopingCall(consumer.fetch, auto_ack=True, + enable_callbacks=True).start(0.1) + utils.LoopingCall(delete_expired_tokens).start(1) + +if __name__ == '__main__': + utils.default_flagfile() + FLAGS(sys.argv) + server = wsgi.Server() + acp = AjaxConsoleProxy() + acp.register_listeners() + server.start(acp, FLAGS.ajax_console_proxy_port, host='0.0.0.0') + server.wait() diff --git a/bin/nova-ajax-proxy b/bin/nova-ajax-proxy deleted file mode 100755 index 53b779711..000000000 --- a/bin/nova-ajax-proxy +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python -# pylint: disable-msg=C0103 -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Ajax Console Proxy Server""" - -from eventlet import greenthread -from eventlet.green import urllib2 - -import exceptions -import logging -import os -import sys -import time -import urlparse - -# If ../nova/__init__.py exists, add ../ to Python search path, so that -# it will override what happens to be installed in /usr/(local/)lib/python... -possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), - os.pardir, - os.pardir)) -if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): - sys.path.insert(0, possible_topdir) - -from nova import flags -from nova import utils -from nova import rpc -from nova import wsgi - -FLAGS = flags.FLAGS - -flags.DEFINE_integer('ajax_console_idle_timeout', 300, - 'Seconds before idle connection destroyed') - - -class AjaxConsoleProxy(object): - tokens = {} - - def __call__(self, env, start_response): - try: - req_url = '%s://%s%s?%s' % (env['wsgi.url_scheme'], - env['HTTP_HOST'], - env['PATH_INFO'], - env['QUERY_STRING']) - if 'HTTP_REFERER' in env: - auth_url = env['HTTP_REFERER'] - else: - auth_url = req_url - - auth_params = urlparse.parse_qs(urlparse.urlparse(auth_url).query) - parsed_url = urlparse.urlparse(req_url) - - auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]] - args = auth_info['args'] - auth_info['last_activity'] = time.time() - - remote_url = ("http://%s:%s%s?token=%s" % ( - str(args['host']), - str(args['port']), - parsed_url.path, - str(args['token']))) - - opener = urllib2.urlopen(remote_url, env['wsgi.input'].read()) - body = opener.read() - info = opener.info() - - start_response("200 OK", info.dict.items()) - return body - except (exceptions.KeyError): - start_response("401 NOT AUTHORIZED", []) - return "Not Authorized" - except Exception: - start_response("500 ERROR", []) - return "Server Error" - - def register_listeners(self): - class Callback: - def __call__(self, data, message): - if data['method'] == 'authorize_ajax_console': - AjaxConsoleProxy.tokens[data['args']['token']] = \ - {'args': data['args'], 'last_activity': time.time()} - - conn = rpc.Connection.instance(new=True) - consumer = rpc.TopicConsumer( - connection=conn, - topic=FLAGS.ajax_console_proxy_topic) - consumer.register_callback(Callback()) - - def delete_expired_tokens(): - now = time.time() - to_delete = [] - for k, v in AjaxConsoleProxy.tokens.items(): - if now - v['last_activity'] > FLAGS.ajax_console_idle_timeout: - to_delete.append(k) - - for k in to_delete: - del AjaxConsoleProxy.tokens[k] - - utils.LoopingCall(consumer.fetch, auto_ack=True, - enable_callbacks=True).start(0.1) - utils.LoopingCall(delete_expired_tokens).start(1) - -if __name__ == '__main__': - utils.default_flagfile() - FLAGS(sys.argv) - server = wsgi.Server() - acp = AjaxConsoleProxy() - acp.register_listeners() - server.start(acp, FLAGS.ajax_console_proxy_port, host='0.0.0.0') - server.wait() -- cgit From 66a074cc74a6c3cc09d7b36f3e5dcb5ad5e7b6d8 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Wed, 29 Dec 2010 17:08:42 -0500 Subject: Pep-8 cleanup. --- bin/nova-api-paste | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bin') diff --git a/bin/nova-api-paste b/bin/nova-api-paste index dcb76522f..3d26fdb4f 100755 --- a/bin/nova-api-paste +++ b/bin/nova-api-paste @@ -48,6 +48,7 @@ FLAGS = flags.FLAGS API_ENDPOINTS = ['ec2', 'openstack'] + def load_configuration(paste_config): """Load the paste configuration from the config file and return it.""" config = None @@ -68,12 +69,14 @@ def load_configuration(paste_config): print "Paste config at %s has no secion for any known apis" % paste_config os.exit(1) + def launch_api(paste_config_file, section, server, port, host): """Launch an api server from the specified port and IP.""" LOG.debug("Launching api %s on %s:%s", section, host, port) app = deploy.loadapp('config:%s' % paste_config_file, name=section) server.start(app, int(port), host) + def run_app(paste_config_file): LOG.debug("Using paste.deploy config at: %s", configfile) config = load_configuration(paste_config_file) @@ -89,6 +92,7 @@ def run_app(paste_config_file): LOG.debug("All api servers launched, now waiting") server.wait() + if __name__ == '__main__': FLAGS(sys.argv) configfiles = ['/etc/nova/nova-api.conf'] -- cgit From 903b053f7eb2bcac7ee0809d7a1cd1efe676909e Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Wed, 29 Dec 2010 17:15:50 -0500 Subject: i18n --- bin/nova-api-paste | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/nova-api-paste b/bin/nova-api-paste index 3d26fdb4f..9bcb98372 100755 --- a/bin/nova-api-paste +++ b/bin/nova-api-paste @@ -27,9 +27,6 @@ import sys from paste import deploy -from nova import flags -from nova import wsgi - # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -40,6 +37,9 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): gettext.install('nova', unicode=1) +from nova import flags +from nova import wsgi + LOG = logging.getLogger('nova.api') LOG.setLevel(logging.DEBUG) LOG.addHandler(logging.StreamHandler()) @@ -65,22 +65,24 @@ def load_configuration(paste_config): if FLAGS.verbose: logging.getLogger().setLevel(logging.DEBUG) return config - LOG.debug("Paste config at %s has no secion for known apis", paste_config) - print "Paste config at %s has no secion for any known apis" % paste_config + LOG.debug(_("Paste config at %s has no secion for known apis"), + paste_config) + print _("Paste config at %s has no secion for any known apis") % \ + paste_config os.exit(1) def launch_api(paste_config_file, section, server, port, host): """Launch an api server from the specified port and IP.""" - LOG.debug("Launching api %s on %s:%s", section, host, port) + LOG.debug(_("Launching %s api on %s:%s"), section, host, port) app = deploy.loadapp('config:%s' % paste_config_file, name=section) server.start(app, int(port), host) def run_app(paste_config_file): - LOG.debug("Using paste.deploy config at: %s", configfile) + LOG.debug(_("Using paste.deploy config at: %s"), configfile) config = load_configuration(paste_config_file) - LOG.debug("Configuration: %r", config) + LOG.debug(_("Configuration: %r"), config) server = wsgi.Server() ip = config.get('host', None) for api in API_ENDPOINTS: @@ -89,7 +91,7 @@ def run_app(paste_config_file): continue host = config.get("%s_host" % api, None) or ip or '0.0.0.0' launch_api(configfile, api, server, port, host) - LOG.debug("All api servers launched, now waiting") + LOG.debug(_("All api servers launched, now waiting")) server.wait() @@ -104,4 +106,4 @@ if __name__ == '__main__': run_app(configfile) break else: - LOG.debug("Skipping missing configuration: %s", configfile) + LOG.debug(_("Skipping missing configuration: %s"), configfile) -- cgit From 5b0450d5a145814baee9d5e05eab6fcc872dab9a Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Thu, 30 Dec 2010 01:19:38 -0500 Subject: Clean up how we determine IP to bind to. --- bin/nova-api-paste | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-api-paste b/bin/nova-api-paste index 9bcb98372..6ee833a18 100755 --- a/bin/nova-api-paste +++ b/bin/nova-api-paste @@ -84,12 +84,12 @@ def run_app(paste_config_file): config = load_configuration(paste_config_file) LOG.debug(_("Configuration: %r"), config) server = wsgi.Server() - ip = config.get('host', None) + ip = config.get('host', '0.0.0.0') for api in API_ENDPOINTS: port = config.get("%s_port" % api, None) if not port: continue - host = config.get("%s_host" % api, None) or ip or '0.0.0.0' + host = config.get("%s_host" % api, ip) launch_api(configfile, api, server, port, host) LOG.debug(_("All api servers launched, now waiting")) server.wait() -- cgit From c7305af78049f94dedcbb55480b91a3c6d843b9f Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Tue, 4 Jan 2011 00:23:35 -0500 Subject: Apply logging changes as a giant patch to work around the cloudpipe delete + add issue in the original patch. --- bin/nova-dhcpbridge | 20 +++--- bin/nova-instancemonitor | 7 ++- bin/nova-logspool | 156 +++++++++++++++++++++++++++++++++++++++++++++++ bin/nova-manage | 19 ++++-- bin/nova-spoolsentry | 97 +++++++++++++++++++++++++++++ 5 files changed, 285 insertions(+), 14 deletions(-) create mode 100644 bin/nova-logspool create mode 100644 bin/nova-spoolsentry (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 828aba3d1..cecc1c80c 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -22,7 +22,6 @@ Handle lease database updates from DHCP servers. """ import gettext -import logging import os import sys @@ -39,6 +38,7 @@ gettext.install('nova', unicode=1) from nova import context from nova import db from nova import flags +from nova import log as logging from nova import rpc from nova import utils from nova.network import linux_net @@ -50,10 +50,15 @@ flags.DECLARE('num_networks', 'nova.network.manager') flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager') +LOG = logging.getLogger('nova-dhcpbridge') +if FLAGS.verbose: + LOG.setLevel(logging.DEBUG) + + def add_lease(mac, ip_address, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: - logging.debug("leasing ip") + LOG.debug("leasing ip") network_manager = utils.import_object(FLAGS.network_manager) network_manager.lease_fixed_ip(context.get_admin_context(), mac, @@ -68,14 +73,14 @@ def add_lease(mac, ip_address, _hostname, _interface): def old_lease(mac, ip_address, hostname, interface): """Update just as add lease.""" - logging.debug("Adopted old lease or got a change of mac/hostname") + LOG.debug("Adopted old lease or got a change of mac/hostname") add_lease(mac, ip_address, hostname, interface) def del_lease(mac, ip_address, _hostname, _interface): """Called when a lease expires.""" if FLAGS.fake_rabbit: - logging.debug("releasing ip") + LOG.debug("releasing ip") network_manager = utils.import_object(FLAGS.network_manager) network_manager.release_fixed_ip(context.get_admin_context(), mac, @@ -100,6 +105,7 @@ def main(): flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile) utils.default_flagfile(flagfile) argv = FLAGS(sys.argv) + logging.basicConfig() interface = os.environ.get('DNSMASQ_INTERFACE', 'br0') if int(os.environ.get('TESTING', '0')): FLAGS.fake_rabbit = True @@ -117,9 +123,9 @@ def main(): mac = argv[2] ip = argv[3] hostname = argv[4] - logging.debug("Called %s for mac %s with ip %s and " - "hostname %s on interface %s", - action, mac, ip, hostname, interface) + LOG.debug("Called %s for mac %s with ip %s and " + "hostname %s on interface %s", + action, mac, ip, hostname, interface) globals()[action + '_lease'](mac, ip, hostname, interface) else: print init_leases(interface) diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor index 5dac3ffe6..17f573b9d 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -23,7 +23,6 @@ import gettext import os -import logging import sys from twisted.application import service @@ -37,19 +36,23 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): gettext.install('nova', unicode=1) +from nova import log as logging from nova import utils from nova import twistd from nova.compute import monitor +# TODO(todd): shouldn't this be done with flags? And what about verbose? logging.getLogger('boto').setLevel(logging.WARN) +LOG = logging.getLogger('nova-instancemonitor') + if __name__ == '__main__': utils.default_flagfile() twistd.serve(__file__) if __name__ == '__builtin__': - logging.warn('Starting instance monitor') + LOG.warn(_('Starting instance monitor')) # pylint: disable-msg=C0103 monitor = monitor.InstanceMonitor() diff --git a/bin/nova-logspool b/bin/nova-logspool new file mode 100644 index 000000000..d5aef4756 --- /dev/null +++ b/bin/nova-logspool @@ -0,0 +1,156 @@ +#!/usr/bin/env python + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Tools for working with logs generated by nova components +""" + + +import json +import os +import re +import sys + + +class Request(object): + + def __init__(self): + self.time = "" + self.host = "" + self.logger = "" + self.message = "" + self.trace = "" + self.env = "" + self.request_id = "" + + def add_error_line(self, error_line): + self.time = " ".join(error_line.split(" ")[:3]) + self.host = error_line.split(" ")[3] + self.logger = error_line.split("(")[1].split(" ")[0] + self.request_id = error_line.split("[")[1].split(" ")[0] + error_lines = error_line.split("#012") + self.message = self.clean_log_line(error_lines.pop(0)) + self.trace = "\n".join([self.clean_trace(l) for l in error_lines]) + + def add_environment_line(self, env_line): + self.env = self.clean_env_line(env_line) + + def clean_log_line(self, line): + """Remove log format for time, level, etc: split after context""" + return line.split('] ')[-1] + + def clean_env_line(self, line): + """Also has an 'Environment: ' string in the message""" + return re.sub(r'^Environment: ', '', self.clean_log_line(line)) + + def clean_trace(self, line): + """trace has a different format, so split on TRACE:""" + return line.split('TRACE: ')[-1] + + def to_dict(self): + return {'traceback': self.trace, 'message': self.message, + 'host': self.host, 'env': self.env, 'logger': self.logger, + 'request_id': self.request_id} + +class LogReader(object): + def __init__(self, filename): + self.filename = filename + self._errors = {} + + def process(self, spooldir): + with open(self.filename) as f: + line = f.readline() + while len(line) > 0: + parts = line.split(" ") + level = (len(parts) < 6) or parts[5] + if level == 'ERROR': + self.handle_logged_error(line) + elif level == '[-]' and self.last_error: + # twisted stack trace line + clean_line = " ".join(line.split(" ")[6:]) + self.last_error.trace = self.last_error.trace + clean_line + else: + self.last_error = None + line = f.readline() + self.update_spool(spooldir) + + def handle_logged_error(self, line): + request_id = re.search(r' \[([A-Z0-9\-/]+)', line) + if not request_id: + raise Exception("Unable to parse request id from %s" % line) + request_id = request_id.group(1) + data = self._errors.get(request_id, Request()) + if self.is_env_line(line): + data.add_environment_line(line) + elif self.is_error_line(line): + data.add_error_line(line) + else: + # possibly error from twsited + data.add_error_line(line) + self.last_error = data + self._errors[request_id] = data + + def is_env_line(self, line): + return re.search('Environment: ', line) + + def is_error_line(self, line): + return re.search('raised', line) + + def update_spool(self, directory): + processed_dir = "%s/processed" % directory + self._ensure_dir_exists(processed_dir) + for rid, value in self._errors.iteritems(): + if not self.has_been_processed(processed_dir, rid): + with open("%s/%s" % (directory, rid), "w") as spool: + spool.write(json.dumps(value.to_dict())) + self.flush_old_processed_spool(processed_dir) + + def _ensure_dir_exists(self, d): + mkdir = False + try: + os.stat(d) + except: + mkdir = True + if mkdir: + os.mkdir(d) + + def has_been_processed(self, processed_dir, rid): + rv = False + try: + os.stat("%s/%s" % (processed_dir, rid)) + rv = True + except: + pass + return rv + + def flush_old_processed_spool(self, processed_dir): + keys = self._errors.keys() + procs = os.listdir(processed_dir) + for p in procs: + if p not in keys: + # log has rotated and the old error won't be seen again + os.unlink("%s/%s" % (processed_dir, p)) + +if __name__ == '__main__': + filename = '/var/log/nova.log' + spooldir = '/var/spool/nova' + if len(sys.argv) > 1: + filename = sys.argv[1] + if len(sys.argv) > 2: + spooldir = sys.argv[2] + LogReader(filename).process(spooldir) diff --git a/bin/nova-manage b/bin/nova-manage index 3416c1a52..169ab5f62 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -55,8 +55,8 @@ import datetime import gettext -import logging import os +import re import sys import time @@ -77,6 +77,7 @@ from nova import crypto from nova import db from nova import exception from nova import flags +from nova import log as logging from nova import quota from nova import utils from nova.auth import manager @@ -499,6 +500,15 @@ class ServiceCommands(object): db.service_update(ctxt, svc['id'], {'disabled': True}) +class LogCommands(object): + def request(self, request_id, logfile='/var/log/nova.log'): + """Show all fields in the log for the given request. Assumes you + haven't changed the log format too much. + ARGS: request_id [logfile]""" + lines = utils.execute("cat %s | grep '\[%s '" % (logfile, request_id)) + print re.sub('#012', "\n", "\n".join(lines)) + + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -507,7 +517,8 @@ CATEGORIES = [ ('vpn', VpnCommands), ('floating', FloatingIpCommands), ('network', NetworkCommands), - ('service', ServiceCommands)] + ('service', ServiceCommands), + ('log', LogCommands)] def lazy_match(name, key_value_tuples): @@ -546,9 +557,7 @@ def main(): utils.default_flagfile() argv = FLAGS(sys.argv) - if FLAGS.verbose: - logging.getLogger().setLevel(logging.DEBUG) - + logging._set_log_levels() script_name = argv.pop(0) if len(argv) < 1: print script_name + " category action []" diff --git a/bin/nova-spoolsentry b/bin/nova-spoolsentry new file mode 100644 index 000000000..ab20268a9 --- /dev/null +++ b/bin/nova-spoolsentry @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import base64 +import json +import logging +import os +import shutil +import sys +import urllib +import urllib2 +try: + import cPickle as pickle +except: + import pickle + + +class SpoolSentry(object): + def __init__(self, spool_dir, sentry_url, key=None): + self.spool_dir = spool_dir + self.sentry_url = sentry_url + self.key = key + + def process(self): + for fname in os.listdir(self.spool_dir): + if fname == "processed": + continue + try: + sourcefile = "%s/%s" % (self.spool_dir, fname) + with open(sourcefile) as f: + fdata = f.read() + data_from_json = json.loads(fdata) + data = self.build_data(data_from_json) + self.send_data(data) + destfile = "%s/processed/%s" % (self.spool_dir, fname) + shutil.move(sourcefile, destfile) + except: + logging.exception("Unable to upload record %s", fname) + raise + + def build_data(self, filejson): + env = {'SERVER_NAME': 'unknown', 'SERVER_PORT': '0000', + 'SCRIPT_NAME': '/unknown/', 'PATH_INFO': 'unknown'} + if filejson['env']: + env = json.loads(filejson['env']) + url = "http://%s:%s%s%s" % (env['SERVER_NAME'], env['SERVER_PORT'], + env['SCRIPT_NAME'], env['PATH_INFO']) + rv = {'logger': filejson['logger'], 'level': logging.ERROR, + 'server_name': filejson['host'], 'url': url, + 'message': filejson['message'], + 'traceback': filejson['traceback']} + rv['data'] = {} + if filejson['env']: + rv['data']['META'] = env + if filejson['request_id']: + rv['data']['request_id'] = filejson['request_id'] + return rv + + def send_data(self, data): + data = { + 'data': base64.b64encode(pickle.dumps(data).encode('zlib')), + 'key': self.key + } + req = urllib2.Request(self.sentry_url) + res = urllib2.urlopen(req, urllib.urlencode(data)) + if res.getcode() != 200: + raise Exception("Bad HTTP code: %s" % res.getcode()) + txt = res.read() + +if __name__ == '__main__': + sentryurl = 'http://127.0.0.1/sentry/store/' + key = '' + spooldir = '/var/spool/nova' + if len(sys.argv) > 1: + sentryurl = sys.argv[1] + if len(sys.argv) > 2: + key = sys.argv[2] + if len(sys.argv) > 3: + spooldir = sys.argv[3] + SpoolSentry(spooldir, sentryurl, key).process() -- cgit From b9576a9f73195656f4a0a1327cd6bee3c4a6b6c9 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Tue, 4 Jan 2011 00:26:41 -0500 Subject: Final few log tweaks, i18n, levels, including contexts, etc. --- bin/nova-dhcpbridge | 15 ++++++--------- bin/nova-instancemonitor | 2 +- bin/nova-manage | 2 -- 3 files changed, 7 insertions(+), 12 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index cecc1c80c..1a994d956 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -49,16 +49,13 @@ flags.DECLARE('network_size', 'nova.network.manager') flags.DECLARE('num_networks', 'nova.network.manager') flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager') - -LOG = logging.getLogger('nova-dhcpbridge') -if FLAGS.verbose: - LOG.setLevel(logging.DEBUG) +LOG = logging.getLogger('nova.dhcpbridge') def add_lease(mac, ip_address, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: - LOG.debug("leasing ip") + LOG.debug(_("leasing ip")) network_manager = utils.import_object(FLAGS.network_manager) network_manager.lease_fixed_ip(context.get_admin_context(), mac, @@ -73,14 +70,14 @@ def add_lease(mac, ip_address, _hostname, _interface): def old_lease(mac, ip_address, hostname, interface): """Update just as add lease.""" - LOG.debug("Adopted old lease or got a change of mac/hostname") + LOG.debug(_("Adopted old lease or got a change of mac/hostname")) add_lease(mac, ip_address, hostname, interface) def del_lease(mac, ip_address, _hostname, _interface): """Called when a lease expires.""" if FLAGS.fake_rabbit: - LOG.debug("releasing ip") + LOG.debug(_("releasing ip")) network_manager = utils.import_object(FLAGS.network_manager) network_manager.release_fixed_ip(context.get_admin_context(), mac, @@ -123,8 +120,8 @@ def main(): mac = argv[2] ip = argv[3] hostname = argv[4] - LOG.debug("Called %s for mac %s with ip %s and " - "hostname %s on interface %s", + LOG.debug(_("Called %s for mac %s with ip %s and " + "hostname %s on interface %s"), action, mac, ip, hostname, interface) globals()[action + '_lease'](mac, ip, hostname, interface) else: diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor index 17f573b9d..7dca02014 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -44,7 +44,7 @@ from nova.compute import monitor # TODO(todd): shouldn't this be done with flags? And what about verbose? logging.getLogger('boto').setLevel(logging.WARN) -LOG = logging.getLogger('nova-instancemonitor') +LOG = logging.getLogger('nova.instancemonitor') if __name__ == '__main__': diff --git a/bin/nova-manage b/bin/nova-manage index 169ab5f62..40f540e5b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -77,7 +77,6 @@ from nova import crypto from nova import db from nova import exception from nova import flags -from nova import log as logging from nova import quota from nova import utils from nova.auth import manager @@ -557,7 +556,6 @@ def main(): utils.default_flagfile() argv = FLAGS(sys.argv) - logging._set_log_levels() script_name = argv.pop(0) if len(argv) < 1: print script_name + " category action []" -- cgit From b437a98738c7a564205d1b27e36b844cd54445d1 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Wed, 5 Jan 2011 14:16:14 -0600 Subject: add in xs-console worker and tests. --- bin/nova-combined | 5 +++-- bin/nova-console | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100755 bin/nova-console (limited to 'bin') diff --git a/bin/nova-combined b/bin/nova-combined index 53322f1a0..a1d2cdc66 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -56,11 +56,12 @@ if __name__ == '__main__': compute = service.Service.create(binary='nova-compute') network = service.Service.create(binary='nova-network') - volume = service.Service.create(binary='nova-volume') +# volume = service.Service.create(binary='nova-volume') scheduler = service.Service.create(binary='nova-scheduler') #objectstore = service.Service.create(binary='nova-objectstore') - service.serve(compute, network, volume, scheduler) +# service.serve(compute, network, volume, scheduler) + service.serve(compute, network, scheduler) server = wsgi.Server() server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host) diff --git a/bin/nova-console b/bin/nova-console new file mode 100755 index 000000000..802cc80b6 --- /dev/null +++ b/bin/nova-console @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright (c) 2010 Openstack, LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Starter script for Nova Console Proxy.""" + +import eventlet +eventlet.monkey_patch() + +import gettext +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +gettext.install('nova', unicode=1) + +from nova import service +from nova import utils + +if __name__ == '__main__': + utils.default_flagfile() + service.serve() + service.wait() -- cgit From b55940e8e3d977960ff60f4cb7cff4b6ea2e8fb8 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Wed, 5 Jan 2011 22:11:05 -0600 Subject: fix some glitches due to someone removing instanc.internal_id (not that I mind) remove accidental change to nova-combined script --- bin/nova-combined | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-combined b/bin/nova-combined index a1d2cdc66..53322f1a0 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -56,12 +56,11 @@ if __name__ == '__main__': compute = service.Service.create(binary='nova-compute') network = service.Service.create(binary='nova-network') -# volume = service.Service.create(binary='nova-volume') + volume = service.Service.create(binary='nova-volume') scheduler = service.Service.create(binary='nova-scheduler') #objectstore = service.Service.create(binary='nova-objectstore') -# service.serve(compute, network, volume, scheduler) - service.serve(compute, network, scheduler) + service.serve(compute, network, volume, scheduler) server = wsgi.Server() server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host) -- cgit From 8952629c576498c3b576a1f9085a8d1b850e8639 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Fri, 7 Jan 2011 14:09:38 -0500 Subject: pep8 fixes --- bin/nova-logspool | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-logspool b/bin/nova-logspool index d5aef4756..097459b12 100644 --- a/bin/nova-logspool +++ b/bin/nova-logspool @@ -28,7 +28,6 @@ import sys class Request(object): - def __init__(self): self.time = "" self.host = "" @@ -67,6 +66,7 @@ class Request(object): 'host': self.host, 'env': self.env, 'logger': self.logger, 'request_id': self.request_id} + class LogReader(object): def __init__(self, filename): self.filename = filename -- cgit From 20a326c1724fe74b196db5695a0ac2ecf040c0d8 Mon Sep 17 00:00:00 2001 From: Ryan Lane Date: Mon, 10 Jan 2011 15:02:29 +0000 Subject: Adding modify option for projects --- bin/nova-manage | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 40f540e5b..a81e407e9 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -333,6 +333,11 @@ class ProjectCommands(object): arguments: name project_manager [description]""" self.manager.create_project(name, project_manager, description) + def modify(self, name, project_manaber, description=None): + """Modifies a project + arguments: name project_manager [description]""" + self.manager.modify_project(name, project_manager, description) + def delete(self, name): """Deletes an existing project arguments: name""" -- cgit From 8d04f68f00d5cd37f13028a4ee5909530ea9c92c Mon Sep 17 00:00:00 2001 From: Ryan Lane Date: Mon, 10 Jan 2011 15:13:30 +0000 Subject: Typo fix --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index a81e407e9..3f5957190 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -333,7 +333,7 @@ class ProjectCommands(object): arguments: name project_manager [description]""" self.manager.create_project(name, project_manager, description) - def modify(self, name, project_manaber, description=None): + def modify(self, name, project_manager, description=None): """Modifies a project arguments: name project_manager [description]""" self.manager.modify_project(name, project_manager, description) -- cgit From 94f3782eb27fd63c64845f9ab59039d07ac7ba8c Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Mon, 10 Jan 2011 14:59:32 -0600 Subject: remove uneeded superclass --- bin/nova-combined | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-combined b/bin/nova-combined index 53322f1a0..4e49fd1fc 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -60,7 +60,8 @@ if __name__ == '__main__': scheduler = service.Service.create(binary='nova-scheduler') #objectstore = service.Service.create(binary='nova-objectstore') - service.serve(compute, network, volume, scheduler) + #service.serve(compute, network, volume, scheduler) + service.serve(compute, network, scheduler) server = wsgi.Server() server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host) -- cgit From d6a66d13718a41d5146d713ced192e795e72457e Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Mon, 10 Jan 2011 15:00:30 -0600 Subject: whups, fix accidental change to nova-combined --- bin/nova-combined | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-combined b/bin/nova-combined index 4e49fd1fc..53322f1a0 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -60,8 +60,7 @@ if __name__ == '__main__': scheduler = service.Service.create(binary='nova-scheduler') #objectstore = service.Service.create(binary='nova-objectstore') - #service.serve(compute, network, volume, scheduler) - service.serve(compute, network, scheduler) + service.serve(compute, network, volume, scheduler) server = wsgi.Server() server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host) -- cgit From 4edfa8ea26f8e820674e8bebbe34b6ed5885a69b Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 10 Jan 2011 13:44:45 -0800 Subject: consolidate boto_extensions.py and euca-get-ajax-console, fix bugs from previous trunk merge --- bin/nova-ajax-console-proxy | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-ajax-console-proxy b/bin/nova-ajax-console-proxy index 53b779711..2bc407658 100755 --- a/bin/nova-ajax-console-proxy +++ b/bin/nova-ajax-console-proxy @@ -24,6 +24,7 @@ from eventlet import greenthread from eventlet.green import urllib2 import exceptions +import gettext import logging import os import sys @@ -38,9 +39,12 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) +gettext.install('nova', unicode=1) + from nova import flags -from nova import utils +from nova import log as logging from nova import rpc +from nova import utils from nova import wsgi FLAGS = flags.FLAGS @@ -48,6 +52,10 @@ FLAGS = flags.FLAGS flags.DEFINE_integer('ajax_console_idle_timeout', 300, 'Seconds before idle connection destroyed') +LOG = logging.getLogger('nova.ajax_console_proxy') +LOG.setLevel(logging.DEBUG) +LOG.addHandler(logging.StreamHandler()) + class AjaxConsoleProxy(object): tokens = {} @@ -83,6 +91,9 @@ class AjaxConsoleProxy(object): start_response("200 OK", info.dict.items()) return body except (exceptions.KeyError): + if env['PATH_INFO'] != '/favicon.ico': + LOG.audit("Unauthorized request %s, %s" + % (req_url, str(env))) start_response("401 NOT AUTHORIZED", []) return "Not Authorized" except Exception: -- cgit From 5afd9848ad09414c00062ceebdad45bca0604888 Mon Sep 17 00:00:00 2001 From: Muneyuki Noguchi Date: Tue, 11 Jan 2011 18:01:23 +0900 Subject: Add support for EBS volumes to the live migration feature. Currently, only AoE is supported. --- bin/nova-manage | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 7c87d21ff..fa044859d 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -83,8 +83,6 @@ from nova import rpc from nova.cloudpipe import pipelib from nova.api.ec2 import cloud - - FLAGS = flags.FLAGS flags.DECLARE('fixed_range', 'nova.network.manager') flags.DECLARE('num_networks', 'nova.network.manager') @@ -462,6 +460,10 @@ class InstanceCommands(object): def live_migration(self, ec2_id, dest): """live_migration""" + if FLAGS.volume_driver != 'nova.volume.driver.AOEDriver': + raise exception.Error('Only AOEDriver is supported for now. ' + 'Sorry.') + logging.basicConfig() ctxt = context.get_admin_context() @@ -491,7 +493,6 @@ class InstanceCommands(object): class HostCommands(object): """Class for mangaging host(physical nodes).""" - def list(self): """describe host list.""" @@ -502,7 +503,6 @@ class HostCommands(object): for host_ref in host_refs: print host_ref['name'] - def show(self, host): """describe cpu/memory/hdd info for host.""" @@ -546,6 +546,7 @@ CATEGORIES = [ ('instance', InstanceCommands), ('host', HostCommands)] + def lazy_match(name, key_value_tuples): """Finds all objects that have a key that case insensitively contains [name] key_value_tuples is a list of tuples of the form (key, value) -- cgit From 3e9d08bded2f504a5dd03712c82e981f73ae16ed Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 12 Jan 2011 14:16:51 -0400 Subject: change novarc template from cc_port to osapi_port. Removed osapi_port from bin scripts. --- bin/nova-api | 1 - bin/nova-combined | 1 - 2 files changed, 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 1c671201e..c7cbb3ab4 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -41,7 +41,6 @@ from nova import wsgi FLAGS = flags.FLAGS -flags.DEFINE_integer('osapi_port', 8774, 'OpenStack API port') flags.DEFINE_string('osapi_host', '0.0.0.0', 'OpenStack API host') flags.DEFINE_integer('ec2api_port', 8773, 'EC2 API port') flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host') diff --git a/bin/nova-combined b/bin/nova-combined index 53322f1a0..f932fdfd5 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -44,7 +44,6 @@ from nova import wsgi FLAGS = flags.FLAGS -flags.DEFINE_integer('osapi_port', 8774, 'OpenStack API port') flags.DEFINE_string('osapi_host', '0.0.0.0', 'OpenStack API host') flags.DEFINE_integer('ec2api_port', 8773, 'EC2 API port') flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host') -- cgit From 982067aefcd656de7751623e272d9b6cf1447dc3 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Wed, 12 Jan 2011 15:12:08 -0500 Subject: Stop error messages for logs when running nova-manage. --- bin/nova-manage | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 3f5957190..3e290567c 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -77,12 +77,14 @@ from nova import crypto from nova import db from nova import exception from nova import flags +from nova import log as logging from nova import quota from nova import utils from nova.auth import manager from nova.cloudpipe import pipelib +logging.basicConfig() FLAGS = flags.FLAGS flags.DECLARE('fixed_range', 'nova.network.manager') flags.DECLARE('num_networks', 'nova.network.manager') -- cgit