From c9610db6c4d573568bd4b6dc390df99349b0a4ea Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Tue, 18 Jan 2011 08:48:50 -0500 Subject: ComputeAPI -> compute.API in bin/nova-direct-api. Fixes LP#704422 --- bin/nova-direct-api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nova-direct-api b/bin/nova-direct-api index e7dd14fb2..173b39bdb 100755 --- a/bin/nova-direct-api +++ b/bin/nova-direct-api @@ -49,7 +49,7 @@ if __name__ == '__main__': utils.default_flagfile() FLAGS(sys.argv) - direct.register_service('compute', compute_api.ComputeAPI()) + direct.register_service('compute', compute_api.API()) direct.register_service('reflect', direct.Reflection()) router = direct.Router() with_json = direct.JsonParamsMiddleware(router) -- cgit From 785c5df3d17bb158ef2c1a66ce59ee8e6d4236b1 Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Tue, 18 Jan 2011 10:24:20 -0500 Subject: Removes circular import issues from bin/stack and replaces utils.loads with json.loads. Fixes Bug#704424 --- bin/stack | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/stack b/bin/stack index 7a6ce5960..25caca06f 100755 --- a/bin/stack +++ b/bin/stack @@ -22,6 +22,7 @@ import eventlet eventlet.monkey_patch() +import json import os import pprint import sys @@ -38,7 +39,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) import gflags -from nova import utils FLAGS = gflags.FLAGS @@ -106,8 +106,12 @@ def do_request(controller, method, params=None): 'X-OpenStack-Project': FLAGS.project} req = urllib2.Request(url, data, headers) - resp = urllib2.urlopen(req) - return utils.loads(resp.read()) + try: + resp = urllib2.urlopen(req) + except urllib2.HTTPError, e: + print e.read() + sys.exit(1) + return json.loads(resp.read()) if __name__ == '__main__': -- cgit From 2f4e7b732d5cafd09a5a73cbc01583503b8ba105 Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Tue, 18 Jan 2011 10:25:40 -0500 Subject: Docstrings aren't guaranteed to exist, so split() can't automatically be called on a method without first checking for the method docstring's existence. Fixes Bug #704447 --- nova/api/direct.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nova/api/direct.py b/nova/api/direct.py index 81b3ae202..2dfbcae39 100644 --- a/nova/api/direct.py +++ b/nova/api/direct.py @@ -142,9 +142,15 @@ class Reflection(object): if argspec[2]: args_out.insert(0, ('**%s' % argspec[2],)) + if f.__doc__: + short_doc = f.__doc__.split('\n')[0] + doc = f.__doc__ + else: + short_doc = doc = _('not available') + methods['/%s/%s' % (route, k)] = { - 'short_doc': f.__doc__.split('\n')[0], - 'doc': f.__doc__, + 'short_doc': short_doc, + 'doc': doc, 'name': k, 'args': list(reversed(args_out))} -- cgit From 1862fe5ecd5265d963f8e9ec591f8eaa7b51fde3 Mon Sep 17 00:00:00 2001 From: Kost Date: Tue, 18 Jan 2011 14:41:32 -0500 Subject: added paste pastedeploy to nova.sh --- contrib/nova.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/nova.sh b/contrib/nova.sh index a0e8e642c..08dc89bae 100755 --- a/contrib/nova.sh +++ b/contrib/nova.sh @@ -87,6 +87,7 @@ if [ "$CMD" == "install" ]; then sudo apt-get install -y python-twisted python-sqlalchemy python-mox python-greenlet python-carrot sudo apt-get install -y python-daemon python-eventlet python-gflags python-ipy sudo apt-get install -y python-libvirt python-libxml2 python-routes python-cheetah + sudo apt-get install -y python-paste python-pastedeploy #For IPV6 sudo apt-get install -y python-netaddr sudo apt-get install -y radvd -- cgit From 25f9c308714a41c93450ae4c5b14e90615d75425 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 13:46:06 -0800 Subject: fixes related to #701749. Also, added nova-manage commands to recover from certain states: # Delete a volume that is in an error state nova-manage cleanup delete_volume vol-id # reattach a volume. this is typically required after a host reboot nova-manage cleanup reattach_volume vol-id --- bin/nova-manage | 44 +++++++++++++++++++++++++++++++++++++++++++- nova/volume/driver.py | 33 +++++++++++++++++++++++++++++++-- nova/volume/manager.py | 18 ++++++++++++------ 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 1ad3120b8..f8523f18b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -80,7 +80,9 @@ from nova import exception from nova import flags from nova import log as logging from nova import quota +from nova import rpc from nova import utils +from nova.api.ec2.cloud import ec2_id_to_id from nova.auth import manager from nova import rpc from nova.cloudpipe import pipelib @@ -597,6 +599,45 @@ class LogCommands(object): print re.sub('#012', "\n", "\n".join(lines)) +class CleanupCommands(object): + """Methods for dealing with a cloud in an odd state""" + + def delete_volume(self, volume_id): + """Delete a volume, bypassing the check that it + must be available. + args: volume_id_id""" + ctxt = context.get_admin_context() + volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + host = volume['host'] + if volume['status'] == 'in-use': + print "Volume is in-use." + print "Detach volume from instance and then try again." + return + + rpc.cast(ctxt, + db.queue_get_for(ctxt, FLAGS.volume_topic, host), + {"method": "delete_volume", + "args": {"volume_id": volume['id']}}) + + def reattach_volume(self, volume_id): + """Re-attach a volume that has previously been attached + to an instance. Typically called after a compute host + has been rebooted. + args: volume_id_id""" + ctxt = context.get_admin_context() + volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + if not volume['instance_id']: + print "volume is not attached to an instance" + return + instance = db.instance_get(ctxt, volume['instance_id']) + host = instance['host'] + rpc.cast(ctxt, + db.queue_get_for(ctxt, FLAGS.compute_topic, host), + {"method": "attach_volume", + "args": {"instance_id": instance['id'], + "volume_id": volume['id'], + "mountpoint": volume['mountpoint']}}) + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -608,7 +649,8 @@ CATEGORIES = [ ('instance', InstanceCommands), ('host', HostCommands), ('service', ServiceCommands), - ('log', LogCommands)] + ('log', LogCommands), + ('cleanup', CleanupCommands)] def lazy_match(name, key_value_tuples): diff --git a/nova/volume/driver.py b/nova/volume/driver.py index 7a2395dbd..de018b573 100644 --- a/nova/volume/driver.py +++ b/nova/volume/driver.py @@ -100,6 +100,14 @@ class VolumeDriver(object): def delete_volume(self, volume): """Deletes a logical volume.""" + try: + self._try_execute("sudo lvdisplay %s/%s" % + (FLAGS.volume_group, + volume['name'])) + except Exception as e: + # If the volume isn't present, then don't attempt to delete + return True + self._try_execute("sudo lvremove -f %s/%s" % (FLAGS.volume_group, volume['name'])) @@ -238,8 +246,14 @@ class ISCSIDriver(VolumeDriver): def ensure_export(self, context, volume): """Synchronously recreates an export for a logical volume.""" - iscsi_target = self.db.volume_get_iscsi_target_num(context, + try: + iscsi_target = self.db.volume_get_iscsi_target_num(context, volume['id']) + except exception.NotFound: + LOG.info(_("Skipping ensure_export. No iscsi_target " + + "provisioned for volume: %d"), volume['id']) + return + iscsi_name = "%s%s" % (FLAGS.iscsi_target_prefix, volume['name']) volume_path = "/dev/%s/%s" % (FLAGS.volume_group, volume['name']) self._sync_exec("sudo ietadm --op new " @@ -278,8 +292,23 @@ class ISCSIDriver(VolumeDriver): def remove_export(self, context, volume): """Removes an export for a logical volume.""" - iscsi_target = self.db.volume_get_iscsi_target_num(context, + try: + iscsi_target = self.db.volume_get_iscsi_target_num(context, volume['id']) + except exception.NotFound: + LOG.info(_("Skipping remove_export. No iscsi_target " + + "provisioned for volume: %d"), volume['id']) + return + + try: + # ietadm show will exit with an error + # this export has already been removed + self._execute("sudo ietadm --op show --tid=%s " % iscsi_target) + except Exception as e: + LOG.info(_("Skipping remove_export. No iscsi_target " + + "is presently exported for volume: %d"), volume['id']) + return + self._execute("sudo ietadm --op delete --tid=%s " "--lun=0" % iscsi_target) self._execute("sudo ietadm --op delete --tid=%s" % diff --git a/nova/volume/manager.py b/nova/volume/manager.py index 1735d79eb..b27d684c7 100644 --- a/nova/volume/manager.py +++ b/nova/volume/manager.py @@ -99,12 +99,18 @@ class VolumeManager(manager.Manager): # before passing it to the driver. volume_ref['host'] = self.host - LOG.debug(_("volume %s: creating lv of size %sG"), volume_ref['name'], - volume_ref['size']) - self.driver.create_volume(volume_ref) - - LOG.debug(_("volume %s: creating export"), volume_ref['name']) - self.driver.create_export(context, volume_ref) + try: + LOG.debug(_("volume %s: creating lv of size %sG"), + volume_ref['name'], + volume_ref['size']) + self.driver.create_volume(volume_ref) + + LOG.debug(_("volume %s: creating export"), volume_ref['name']) + self.driver.create_export(context, volume_ref) + except Exception as e: + self.db.volume_update(context, + volume_ref['id'], {'status': 'error'}) + raise e now = datetime.datetime.utcnow() self.db.volume_update(context, -- cgit From a0af78323131b05a76eb7959df38f6a18e2b39ed Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 14:17:54 -0800 Subject: s/cleanup/volume. volume commands will need their own ns in the long run --- bin/nova-manage | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index f8523f18b..3e4f28fe5 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -599,10 +599,10 @@ class LogCommands(object): print re.sub('#012', "\n", "\n".join(lines)) -class CleanupCommands(object): +class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" - def delete_volume(self, volume_id): + def delete(self, volume_id): """Delete a volume, bypassing the check that it must be available. args: volume_id_id""" @@ -619,7 +619,7 @@ class CleanupCommands(object): {"method": "delete_volume", "args": {"volume_id": volume['id']}}) - def reattach_volume(self, volume_id): + def reattach(self, volume_id): """Re-attach a volume that has previously been attached to an instance. Typically called after a compute host has been rebooted. @@ -650,7 +650,7 @@ CATEGORIES = [ ('host', HostCommands), ('service', ServiceCommands), ('log', LogCommands), - ('cleanup', CleanupCommands)] + ('volume', VolumeCommands)] def lazy_match(name, key_value_tuples): -- cgit From 13398a761da64bc51864a9e5e46155095ef6ed47 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 15:28:19 -0800 Subject: update status to 'error_deleting' on volumes where deletion fails --- nova/volume/manager.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nova/volume/manager.py b/nova/volume/manager.py index b27d684c7..2f1acef55 100644 --- a/nova/volume/manager.py +++ b/nova/volume/manager.py @@ -127,10 +127,17 @@ class VolumeManager(manager.Manager): raise exception.Error(_("Volume is still attached")) if volume_ref['host'] != self.host: raise exception.Error(_("Volume is not local to this node")) - LOG.debug(_("volume %s: removing export"), volume_ref['name']) - self.driver.remove_export(context, volume_ref) - LOG.debug(_("volume %s: deleting"), volume_ref['name']) - self.driver.delete_volume(volume_ref) + + try: + LOG.debug(_("volume %s: removing export"), volume_ref['name']) + self.driver.remove_export(context, volume_ref) + LOG.debug(_("volume %s: deleting"), volume_ref['name']) + self.driver.delete_volume(volume_ref) + except Exception as e: + self.db.volume_update(context, + volume_ref['id'], {'status': 'error_deleting'}) + raise e + self.db.volume_destroy(context, volume_id) LOG.debug(_("volume %s: deleted successfully"), volume_ref['name']) return True -- cgit From 76a4d683d973c7f8120ae6b409d9fd9c09a3ab98 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 16:12:52 -0800 Subject: per vish's feedback, allow admin to specify volume id in any of the acceptable manners (vol-, volume-, and int) Also, have manager only attempt to export volumes that are in-use or available --- bin/nova-manage | 14 ++++++++++++-- nova/volume/manager.py | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 3e4f28fe5..654a13820 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -98,6 +98,16 @@ flags.DECLARE('vpn_start', 'nova.network.manager') flags.DECLARE('fixed_range_v6', 'nova.network.manager') +def param2id(object_id): + """Helper function to convert various id types to internal id. + args: [object_id], e.g. 'vol-0000000a' or 'volume-0000000a' or '10' + """ + if '-' in object_id: + return ec2_id_to_id(object_id) + else: + return int(object_id) + + class VpnCommands(object): """Class for managing VPNs.""" @@ -607,7 +617,7 @@ class VolumeCommands(object): must be available. args: volume_id_id""" ctxt = context.get_admin_context() - volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + volume = db.volume_get(ctxt, param2id(volume_id)) host = volume['host'] if volume['status'] == 'in-use': print "Volume is in-use." @@ -625,7 +635,7 @@ class VolumeCommands(object): has been rebooted. args: volume_id_id""" ctxt = context.get_admin_context() - volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + volume = db.volume_get(ctxt, param2id(volume_id)) if not volume['instance_id']: print "volume is not attached to an instance" return diff --git a/nova/volume/manager.py b/nova/volume/manager.py index 2f1acef55..da949df9e 100644 --- a/nova/volume/manager.py +++ b/nova/volume/manager.py @@ -84,7 +84,10 @@ class VolumeManager(manager.Manager): volumes = self.db.volume_get_all_by_host(ctxt, self.host) LOG.debug(_("Re-exporting %s volumes"), len(volumes)) for volume in volumes: - self.driver.ensure_export(ctxt, volume) + if volume['status'] in ['available', 'in-use']: + self.driver.ensure_export(ctxt, volume) + else: + LOG.info(_("volume %s: skipping export"), volume_ref['name']) def create_volume(self, context, volume_id): """Creates and exports the volume.""" -- cgit From 50ec058cc70044a4cfbad97147940a6124aa10a8 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 19 Jan 2011 10:50:54 +0100 Subject: Refactor run_tests.sh to allow us to run an extra command after the tests. Run pep8 after unit tests in run_tests.sh. Fix setup.py to be PEP-8 compliant. --- run_tests.sh | 58 +++++++++++++++++++++++++++++----------------------------- setup.py | 17 +++++++++-------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index fe703fece..0574643c5 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -31,46 +31,46 @@ always_venv=0 never_venv=0 force=0 noseargs= - +wrapper="" for arg in "$@"; do process_option $arg done -NOSETESTS="python run_tests.py $noseargs" - -if [ $never_venv -eq 1 ]; then +function run_tests { # Just run the test suites in current environment - rm -f nova.sqlite - $NOSETESTS 2> run_tests.err.log - exit -fi + ${wrapper} rm -f nova.sqlite + ${wrapper} $NOSETESTS 2> run_tests.err.log +} -# Remove the virtual environment if --force used -if [ $force -eq 1 ]; then - echo "Cleaning virtualenv..." - rm -rf ${venv} -fi +NOSETESTS="python run_tests.py $noseargs" -if [ -e ${venv} ]; then - ${with_venv} rm -f nova.sqlite - ${with_venv} $NOSETESTS 2> run_tests.err.log -else - if [ $always_venv -eq 1 ]; then - # Automatically install the virtualenv - python tools/install_venv.py +if [ $never_venv -eq 0 ] +then + # Remove the virtual environment if --force used + if [ $force -eq 1 ]; then + echo "Cleaning virtualenv..." + rm -rf ${venv} + fi + if [ -e ${venv} ]; then + wrapper="${with_venv}" else - echo -e "No virtual environment found...create one? (Y/n) \c" - read use_ve - if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then - # Install the virtualenv and run the test suite in it + if [ $always_venv -eq 1 ]; then + # Automatically install the virtualenv python tools/install_venv.py + wrapper="${with_venv}" else - rm -f nova.sqlite - $NOSETESTS 2> run_tests.err.log - exit + echo -e "No virtual environment found...create one? (Y/n) \c" + read use_ve + if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then + # Install the virtualenv and run the test suite in it + python tools/install_venv.py + wrapper=${with_venv} + fi fi fi - ${with_venv} rm -f nova.sqlite - ${with_venv} $NOSETESTS 2> run_tests.err.log fi + +run_tests + +pep8 --repeat --show-pep8 --show-source bin/* nova setup.py diff --git a/setup.py b/setup.py index 3608ff805..65adbe992 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,7 @@ class local_BuildDoc(BuildDoc): self.finalize_options() BuildDoc.run(self) + class local_sdist(sdist): """Customized sdist hook - builds the ChangeLog file from VC first""" @@ -57,17 +58,17 @@ class local_sdist(sdist): changelog_file.write(str_dict_replace(changelog, mailmap)) sdist.run(self) -nova_cmdclass= { 'sdist': local_sdist, - 'build_sphinx' : local_BuildDoc } +nova_cmdclass = {'sdist': local_sdist, + 'build_sphinx': local_BuildDoc} try: - from babel.messages import frontend as babel - nova_cmdclass['compile_catalog'] = babel.compile_catalog - nova_cmdclass['extract_messages'] = babel.extract_messages - nova_cmdclass['init_catalog'] = babel.init_catalog - nova_cmdclass['update_catalog'] = babel.update_catalog + from babel.messages import frontend as babel + nova_cmdclass['compile_catalog'] = babel.compile_catalog + nova_cmdclass['extract_messages'] = babel.extract_messages + nova_cmdclass['init_catalog'] = babel.init_catalog + nova_cmdclass['update_catalog'] = babel.update_catalog except: - pass + pass setup(name='nova', version=version.canonical_version_string(), -- cgit From 8d828520602dd3fc66fa0ea22af797c1d99d3f1a Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 19 Jan 2011 17:03:09 +0100 Subject: Eagerly load instance's fixed_ip.network attribute. --- nova/db/sqlalchemy/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index b63b84bed..7b965f672 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -777,7 +777,7 @@ def instance_get_by_id(context, instance_id): result = session.query(models.Instance).\ options(joinedload_all('fixed_ip.floating_ips')).\ options(joinedload('security_groups')).\ - options(joinedload_all('fixed_ip.floating_ips')).\ + options(joinedload_all('fixed_ip.network')).\ filter_by(id=instance_id).\ filter_by(deleted=can_read_deleted(context)).\ first() @@ -785,6 +785,7 @@ def instance_get_by_id(context, instance_id): result = session.query(models.Instance).\ options(joinedload('security_groups')).\ options(joinedload_all('fixed_ip.floating_ips')).\ + options(joinedload_all('fixed_ip.network')).\ filter_by(project_id=context.project_id).\ filter_by(id=instance_id).\ filter_by(deleted=False).\ -- cgit From beff00fbe9b9e05e265f3c4ce5b6670426e22de2 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 19 Jan 2011 11:20:56 -0800 Subject: make sure params have no unicode keys --- nova/api/direct.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/api/direct.py b/nova/api/direct.py index 81b3ae202..509ab3ae0 100644 --- a/nova/api/direct.py +++ b/nova/api/direct.py @@ -196,6 +196,8 @@ class ServiceWrapper(wsgi.Controller): # TODO(termie): do some basic normalization on methods method = getattr(self.service_handle, action) + # NOTE(vish): make sure we have no unicode keys for py2.6. + params = dict([(str(k), v) for (k, v) in params.iteritems()]) result = method(context, **params) if type(result) is dict or type(result) is list: return self._serialize(result, req) -- cgit From 96a7787874a2c3f71bdfda1d4addf99408ca4e34 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 19 Jan 2011 23:15:20 +0100 Subject: Return non-zero if either unit tests or pep8 fails. --- run_tests.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 0574643c5..786fa70c6 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -71,6 +71,4 @@ then fi fi -run_tests - -pep8 --repeat --show-pep8 --show-source bin/* nova setup.py +run_tests && pep8 --repeat --show-pep8 --show-source bin/* nova setup.py || exit 1 -- cgit From 43a9cbf855d8128be0d1fb6fb4f3b8e855bac113 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 19 Jan 2011 23:32:08 +0100 Subject: Add Rob Kost to Authors. --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 82e07a6b5..608fec523 100644 --- a/Authors +++ b/Authors @@ -40,6 +40,7 @@ Nachi Ueno Rick Clark Rick Harris +Rob Kost Ryan Lane Ryan Lucio Salvatore Orlando -- cgit From f8db53d4b106940e123aaaadcef0b8e7082fbd6c Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Thu, 20 Jan 2011 00:46:20 +0100 Subject: Add etc/ directory to tarball. --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 07e4dd516..3908830d7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,7 @@ graft CA graft doc graft smoketests graft tools +graft etc include nova/api/openstack/notes.txt include nova/auth/novarc.template include nova/auth/slap.sh -- cgit From 2c75ad02c5a025e2262cd3cd6c9ab42cd34b585c Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Thu, 20 Jan 2011 01:23:57 +0100 Subject: Exclude vcsversion.py from pep8 check. It's not compliant, but out of our control. --- run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_tests.sh b/run_tests.sh index 786fa70c6..cf1affcea 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -71,4 +71,4 @@ then fi fi -run_tests && pep8 --repeat --show-pep8 --show-source bin/* nova setup.py || exit 1 +run_tests && pep8 --repeat --show-pep8 --show-source --exclude=vcsversion.py bin/* nova setup.py || exit 1 -- cgit From 4203bba809eec90dd8a176c2d4f8869ae748e8bc Mon Sep 17 00:00:00 2001 From: Ryan Lane Date: Thu, 20 Jan 2011 00:47:33 +0000 Subject: Changing service_get_all_by_host to not require admin context as it is used for describing instances, which any user in a project can do. --- nova/db/sqlalchemy/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 7b965f672..9825764bf 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -156,7 +156,7 @@ def service_get_all_by_topic(context, topic): all() -@require_admin_context +@require_context def service_get_all_by_host(context, host): session = get_session() return session.query(models.Service).\ -- cgit From 33803f02a3b4bd16d394363179a8b91b7f295318 Mon Sep 17 00:00:00 2001 From: Ryan Lane Date: Thu, 20 Jan 2011 01:17:51 +0000 Subject: Fetches the security group from ID, allowing the object to be used properly, later. --- nova/compute/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index a6b99c1cb..3c232152e 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -246,7 +246,10 @@ class API(base.Base): # ..then we distill the security groups to which they belong.. security_groups = set() for rule in security_group_rules: - security_groups.add(rule['parent_group_id']) + security_group = self.db.security_group_get( + context, + rule['parent_group_id']) + security_groups.add(security_group) # ..then we find the instances that are members of these groups.. instances = set() -- cgit From 36681f096574e5fdab26e6167a39e87df0f92fd4 Mon Sep 17 00:00:00 2001 From: Ryan Lane Date: Thu, 20 Jan 2011 01:34:54 +0000 Subject: Passing in an elevated context instead of making the call non-elevated. --- nova/api/ec2/cloud.py | 2 +- nova/db/sqlalchemy/api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index c94540793..a64c9fed8 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -133,7 +133,7 @@ class CloudController(object): return result def _get_availability_zone_by_host(self, context, host): - services = db.service_get_all_by_host(context, host) + services = db.service_get_all_by_host(context.elevated(), host) if len(services) > 0: return services[0]['availability_zone'] return 'unknown zone' diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 9825764bf..7b965f672 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -156,7 +156,7 @@ def service_get_all_by_topic(context, topic): all() -@require_context +@require_admin_context def service_get_all_by_host(context, host): session = get_session() return session.query(models.Service).\ -- cgit From a9c8ef031780636dd851095f0e76dabeb9eed487 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Thu, 20 Jan 2011 12:20:50 +0100 Subject: Add timestamp to default log format, invert name and level for better readability, log version once at startup --- nova/log.py | 10 +++++----- nova/service.py | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nova/log.py b/nova/log.py index 4997d3f28..d021561bb 100644 --- a/nova/log.py +++ b/nova/log.py @@ -40,15 +40,15 @@ from nova import version FLAGS = flags.FLAGS flags.DEFINE_string('logging_context_format_string', - '(%(name)s %(nova_version)s): %(levelname)s ' + '%(asctime)s %(levelname)s %(name)s ' '[%(request_id)s %(user)s ' '%(project)s] %(message)s', - 'format string to use for log messages') + 'format string to use for log messages with context') flags.DEFINE_string('logging_default_format_string', - '(%(name)s %(nova_version)s): %(levelname)s [N/A] ' + '%(asctime)s %(levelname)s %(name)s [-] ' '%(message)s', - 'format string to use for log messages') + 'format string to use for log messages without context') flags.DEFINE_string('logging_debug_format_suffix', 'from %(processName)s (pid=%(process)d) %(funcName)s' @@ -56,7 +56,7 @@ flags.DEFINE_string('logging_debug_format_suffix', 'data to append to log format when level is DEBUG') flags.DEFINE_string('logging_exception_prefix', - '(%(name)s): TRACE: ', + '%(asctime)s TRACE %(name)s: ', 'prefix each line of exception output with this format') flags.DEFINE_list('default_log_levels', diff --git a/nova/service.py b/nova/service.py index efc08fd63..91e00d3d1 100644 --- a/nova/service.py +++ b/nova/service.py @@ -38,6 +38,7 @@ from nova import log as logging from nova import flags from nova import rpc from nova import utils +from nova import version FLAGS = flags.FLAGS @@ -156,7 +157,8 @@ class Service(object): report_interval = FLAGS.report_interval if not periodic_interval: periodic_interval = FLAGS.periodic_interval - logging.audit(_("Starting %s node"), topic) + logging.audit(_("Starting %s node (version %s)"), topic, + version.version_string_with_vcs()) service_obj = cls(host, binary, topic, manager, report_interval, periodic_interval) -- cgit From 6ef429d425b82db6dc87fa40241d97bea897bd23 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Thu, 20 Jan 2011 12:26:19 +0100 Subject: Also print version at nova-api startup, for consistency --- bin/nova-api | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/nova-api b/bin/nova-api index 7b4fbeab1..44bbfaf86 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -36,6 +36,7 @@ gettext.install('nova', unicode=1) from nova import flags from nova import log as logging +from nova import version from nova import wsgi logging.basicConfig() @@ -79,6 +80,8 @@ def run_app(paste_config_file): if __name__ == '__main__': FLAGS(sys.argv) + LOG.audit(_("Starting nova-api node (version %s)"), + version.version_string_with_vcs()) conf = wsgi.paste_config_file('nova-api.conf') if conf: run_app(conf) -- cgit From b2ec5bf282f212f251479ec2bde520bc21531435 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Thu, 20 Jan 2011 15:05:55 +0100 Subject: Pass a PluginManager to nose.config.Config(). This lets us use plugins like coverage, xcoverage, etc. --- run_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_tests.py b/run_tests.py index 7b5e2192a..5c8436aee 100644 --- a/run_tests.py +++ b/run_tests.py @@ -60,7 +60,8 @@ class NovaTestRunner(core.TextTestRunner): if __name__ == '__main__': c = config.Config(stream=sys.stdout, env=os.environ, - verbosity=3) + verbosity=3, + plugins=core.DefaultPluginManager()) runner = NovaTestRunner(stream=c.stream, verbosity=c.verbosity, -- cgit From 2042c8722910c1f22ba04636163841812b3e24ba Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Thu, 20 Jan 2011 15:12:02 +0100 Subject: Keep exception tracing as it was --- nova/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/log.py b/nova/log.py index d021561bb..e1c9f46f4 100644 --- a/nova/log.py +++ b/nova/log.py @@ -56,7 +56,7 @@ flags.DEFINE_string('logging_debug_format_suffix', 'data to append to log format when level is DEBUG') flags.DEFINE_string('logging_exception_prefix', - '%(asctime)s TRACE %(name)s: ', + '(%(name)s): TRACE: ', 'prefix each line of exception output with this format') flags.DEFINE_list('default_log_levels', -- cgit From 13b4f32d1995a8c50bcf86786b6ee75d49bea701 Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Thu, 20 Jan 2011 12:52:02 -0500 Subject: i18n's strings that were missed or have been added since initial i18n strings branch. --- nova/api/ec2/cloud.py | 2 +- nova/auth/dbdriver.py | 4 +- nova/auth/ldapdriver.py | 43 ++++++++-------- nova/console/manager.py | 2 +- nova/console/xvp.py | 14 ++--- nova/network/manager.py | 2 +- nova/objectstore/handler.py | 6 ++- nova/objectstore/image.py | 13 +++-- nova/rpc.py | 2 +- nova/scheduler/simple.py | 4 +- nova/twistd.py | 4 +- nova/virt/libvirt_conn.py | 3 +- nova/wsgi.py | 2 +- .../xenapi/etc/xapi.d/plugins/pluginlib_nova.py | 60 +++++++++++++--------- 14 files changed, 91 insertions(+), 70 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index c94540793..f0aa8d813 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -59,7 +59,7 @@ def _gen_key(context, user_id, key_name): # creation before creating key_pair try: db.key_pair_get(context, user_id, key_name) - raise exception.Duplicate("The key_pair %s already exists" + raise exception.Duplicate(_("The key_pair %s already exists") % key_name) except exception.NotFound: pass diff --git a/nova/auth/dbdriver.py b/nova/auth/dbdriver.py index 0eb6fe588..d8dad8edd 100644 --- a/nova/auth/dbdriver.py +++ b/nova/auth/dbdriver.py @@ -119,8 +119,8 @@ class DbDriver(object): for member_uid in member_uids: member = db.user_get(context.get_admin_context(), member_uid) if not member: - raise exception.NotFound("Project can't be created " - "because user %s doesn't exist" + raise exception.NotFound(_("Project can't be created " + "because user %s doesn't exist") % member_uid) members.add(member) diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py index bc53e0ec6..a6915ce03 100644 --- a/nova/auth/ldapdriver.py +++ b/nova/auth/ldapdriver.py @@ -146,7 +146,7 @@ class LdapDriver(object): def create_user(self, name, access_key, secret_key, is_admin): """Create a user""" if self.__user_exists(name): - raise exception.Duplicate("LDAP user %s already exists" % name) + raise exception.Duplicate(_("LDAP user %s already exists") % name) if FLAGS.ldap_user_modify_only: if self.__ldap_user_exists(name): # Retrieve user by name @@ -310,7 +310,7 @@ class LdapDriver(object): def delete_user(self, uid): """Delete a user""" if not self.__user_exists(uid): - raise exception.NotFound("User %s doesn't exist" % uid) + raise exception.NotFound(_("User %s doesn't exist") % uid) self.__remove_from_all(uid) if FLAGS.ldap_user_modify_only: # Delete attributes @@ -432,15 +432,15 @@ class LdapDriver(object): description, member_uids=None): """Create a group""" if self.__group_exists(group_dn): - raise exception.Duplicate("Group can't be created because " - "group %s already exists" % name) + raise exception.Duplicate(_("Group can't be created because " + "group %s already exists") % name) members = [] if member_uids is not None: for member_uid in member_uids: if not self.__user_exists(member_uid): - raise exception.NotFound("Group can't be created " - "because user %s doesn't exist" % - member_uid) + raise exception.NotFound(_("Group can't be created " + "because user %s doesn't exist") + % member_uid) members.append(self.__uid_to_dn(member_uid)) dn = self.__uid_to_dn(uid) if not dn in members: @@ -455,8 +455,8 @@ class LdapDriver(object): def __is_in_group(self, uid, group_dn): """Check if user is in group""" if not self.__user_exists(uid): - raise exception.NotFound("User %s can't be searched in group " - "because the user doesn't exist" % uid) + raise exception.NotFound(_("User %s can't be searched in group " + "because the user doesn't exist") % uid) if not self.__group_exists(group_dn): return False res = self.__find_object(group_dn, @@ -467,10 +467,10 @@ class LdapDriver(object): def __add_to_group(self, uid, group_dn): """Add user to group""" if not self.__user_exists(uid): - raise exception.NotFound("User %s can't be added to the group " - "because the user doesn't exist" % uid) + raise exception.NotFound(_("User %s can't be added to the group " + "because the user doesn't exist") % uid) if not self.__group_exists(group_dn): - raise exception.NotFound("The group at dn %s doesn't exist" % + raise exception.NotFound(_("The group at dn %s doesn't exist") % group_dn) if self.__is_in_group(uid, group_dn): raise exception.Duplicate(_("User %s is already a member of " @@ -481,15 +481,15 @@ class LdapDriver(object): def __remove_from_group(self, uid, group_dn): """Remove user from group""" if not self.__group_exists(group_dn): - raise exception.NotFound("The group at dn %s doesn't exist" % - group_dn) + raise exception.NotFound(_("The group at dn %s doesn't exist") + % group_dn) if not self.__user_exists(uid): - raise exception.NotFound("User %s can't be removed from the " - "group because the user doesn't exist" % - uid) + raise exception.NotFound(_("User %s can't be removed from the " + "group because the user doesn't exist") + % uid) if not self.__is_in_group(uid, group_dn): - raise exception.NotFound("User %s is not a member of the group" % - uid) + raise exception.NotFound(_("User %s is not a member of the group") + % uid) # NOTE(vish): remove user from group and any sub_groups sub_dns = self.__find_group_dns_with_member(group_dn, uid) for sub_dn in sub_dns: @@ -509,8 +509,9 @@ class LdapDriver(object): def __remove_from_all(self, uid): """Remove user from all roles and projects""" if not self.__user_exists(uid): - raise exception.NotFound("User %s can't be removed from all " - "because the user doesn't exist" % uid) + raise exception.NotFound(_("User %s can't be removed from all " + "because the user doesn't exist") + % uid) role_dns = self.__find_group_dns_with_member( FLAGS.role_project_subtree, uid) for role_dn in role_dns: diff --git a/nova/console/manager.py b/nova/console/manager.py index c55ca8e8f..5697e7cb1 100644 --- a/nova/console/manager.py +++ b/nova/console/manager.py @@ -67,7 +67,7 @@ class ConsoleProxyManager(manager.Manager): pool['id'], instance_id) except exception.NotFound: - logging.debug("Adding console") + logging.debug(_("Adding console")) if not password: password = self.driver.generate_password() if not port: diff --git a/nova/console/xvp.py b/nova/console/xvp.py index 2a76223da..ee66dac46 100644 --- a/nova/console/xvp.py +++ b/nova/console/xvp.py @@ -96,7 +96,7 @@ class XVPConsoleProxy(object): return os.urandom(length * 2).encode('base64')[:length] def _rebuild_xvp_conf(self, context): - logging.debug("Rebuilding xvp conf") + logging.debug(_("Rebuilding xvp conf")) pools = [pool for pool in db.console_pool_get_all_by_host_type(context, self.host, self.console_type) @@ -113,12 +113,12 @@ class XVPConsoleProxy(object): self._xvp_restart() def _write_conf(self, config): - logging.debug('Re-wrote %s' % FLAGS.console_xvp_conf) + logging.debug(_('Re-wrote %s') % FLAGS.console_xvp_conf) with open(FLAGS.console_xvp_conf, 'w') as cfile: cfile.write(config) def _xvp_stop(self): - logging.debug("Stopping xvp") + logging.debug(_("Stopping xvp")) pid = self._xvp_pid() if not pid: return @@ -131,19 +131,19 @@ class XVPConsoleProxy(object): def _xvp_start(self): if self._xvp_check_running(): return - logging.debug("Starting xvp") + logging.debug(_("Starting xvp")) try: utils.execute('xvp -p %s -c %s -l %s' % (FLAGS.console_xvp_pid, FLAGS.console_xvp_conf, FLAGS.console_xvp_log)) except exception.ProcessExecutionError, err: - logging.error("Error starting xvp: %s" % err) + logging.error(_("Error starting xvp: %s") % err) def _xvp_restart(self): - logging.debug("Restarting xvp") + logging.debug(_("Restarting xvp")) if not self._xvp_check_running(): - logging.debug("xvp not running...") + logging.debug(_("xvp not running...")) self._xvp_start() else: pid = self._xvp_pid() diff --git a/nova/network/manager.py b/nova/network/manager.py index 61de8055a..5d7589090 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -211,7 +211,7 @@ class NetworkManager(manager.Manager): def release_fixed_ip(self, context, mac, address): """Called by dhcp-bridge when ip is released.""" - LOG.debug("Releasing IP %s", address, context=context) + LOG.debug(_("Releasing IP %s"), address, context=context) fixed_ip_ref = self.db.fixed_ip_get_by_address(context, address) instance_ref = fixed_ip_ref['instance'] if not instance_ref: diff --git a/nova/objectstore/handler.py b/nova/objectstore/handler.py index bc26fd3c5..43ed7ffe7 100644 --- a/nova/objectstore/handler.py +++ b/nova/objectstore/handler.py @@ -315,8 +315,10 @@ class ObjectResource(ErrorHandlingResource): context=request.context) if not self.bucket.is_authorized(request.context): - LOG.audit("Unauthorized attempt to delete object %s from " - "bucket %s", self.name, self.bucket.name, + LOG.audit(_("Unauthorized attempt to delete object " + "%(object)s from bucket %(bucket)s") % + {'object': self.name, + 'bucket': self.bucket.name}, context=request.context) raise exception.NotAuthorized() diff --git a/nova/objectstore/image.py b/nova/objectstore/image.py index abc28182e..41e0abd80 100644 --- a/nova/objectstore/image.py +++ b/nova/objectstore/image.py @@ -259,22 +259,25 @@ class Image(object): process_input=encrypted_key, check_exit_code=False) if err: - raise exception.Error("Failed to decrypt private key: %s" % err) + raise exception.Error(_("Failed to decrypt private key: %s") + % err) iv, err = utils.execute( 'openssl rsautl -decrypt -inkey %s' % cloud_private_key, process_input=encrypted_iv, check_exit_code=False) if err: - raise exception.Error("Failed to decrypt initialization " - "vector: %s" % err) + raise exception.Error(_("Failed to decrypt initialization " + "vector: %s") % err) _out, err = utils.execute( 'openssl enc -d -aes-128-cbc -in %s -K %s -iv %s -out %s' % (encrypted_filename, key, iv, decrypted_filename), check_exit_code=False) if err: - raise exception.Error("Failed to decrypt image file %s : %s" % - (encrypted_filename, err)) + raise exception.Error(_("Failed to decrypt image file " + "%(image_file)s: %(err)s") % + {'image_file': encrypted_filename, + 'err': err}) @staticmethod def untarzip_image(path, filename): diff --git a/nova/rpc.py b/nova/rpc.py index 49b11602b..bbfa71138 100644 --- a/nova/rpc.py +++ b/nova/rpc.py @@ -343,7 +343,7 @@ def call(context, topic, msg): def cast(context, topic, msg): """Sends a message on a topic without waiting for a response""" - LOG.debug("Making asynchronous cast...") + LOG.debug(_("Making asynchronous cast...")) _pack_context(msg, context) conn = Connection.instance() publisher = TopicPublisher(connection=conn, topic=topic) diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py index 47baf0d73..baf4966d4 100644 --- a/nova/scheduler/simple.py +++ b/nova/scheduler/simple.py @@ -48,7 +48,7 @@ class SimpleScheduler(chance.ChanceScheduler): service = db.service_get_by_args(context.elevated(), host, 'nova-compute') if not self.service_is_up(service): - raise driver.WillNotSchedule("Host %s is not alive" % host) + raise driver.WillNotSchedule(_("Host %s is not alive") % host) # TODO(vish): this probably belongs in the manager, if we # can generalize this somehow @@ -80,7 +80,7 @@ class SimpleScheduler(chance.ChanceScheduler): service = db.service_get_by_args(context.elevated(), host, 'nova-volume') if not self.service_is_up(service): - raise driver.WillNotSchedule("Host %s not available" % host) + raise driver.WillNotSchedule(_("Host %s not available") % host) # TODO(vish): this probably belongs in the manager, if we # can generalize this somehow diff --git a/nova/twistd.py b/nova/twistd.py index 556271999..6390a8144 100644 --- a/nova/twistd.py +++ b/nova/twistd.py @@ -156,7 +156,7 @@ def WrapTwistedOptions(wrapped): try: self.parseArgs(*argv) except TypeError: - raise usage.UsageError("Wrong number of arguments.") + raise usage.UsageError(_("Wrong number of arguments.")) self.postOptions() return args @@ -220,7 +220,7 @@ def stop(pidfile): time.sleep(0.1) except OSError, err: err = str(err) - if err.find("No such process") > 0: + if err.find(_("No such process")) > 0: if os.path.exists(pidfile): os.remove(pidfile) else: diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index e70abb4e5..7005ae814 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -732,7 +732,8 @@ class LibvirtConnection(object): 'cpu_time': cpu_time} def get_diagnostics(self, instance_name): - raise exception.APIError("diagnostics are not supported for libvirt") + raise exception.APIError(_("diagnostics are not supported " + "for libvirt")) def get_disks(self, instance_name): """ diff --git a/nova/wsgi.py b/nova/wsgi.py index 4f5307d80..a48bede9c 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -143,7 +143,7 @@ class Application(object): See the end of http://pythonpaste.org/webob/modules/dec.html for more info. """ - raise NotImplementedError("You must implement __call__") + raise NotImplementedError(_("You must implement __call__")) class Middleware(Application): diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py index 8e7a829d5..cc0a196af 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py @@ -60,7 +60,7 @@ def ignore_failure(func, *args, **kwargs): try: return func(*args, **kwargs) except XenAPI.Failure, e: - logging.error('Ignoring XenAPI.Failure %s', e) + logging.error(_('Ignoring XenAPI.Failure %s'), e) return None @@ -78,19 +78,25 @@ def validate_exists(args, key, default=None): """ if key in args: if len(args[key]) == 0: - raise ArgumentError('Argument %r value %r is too short.' % - (key, args[key])) + raise ArgumentError(_('Argument %(key)s value %(value)s is too ' + 'short.') % + {'key': key, + 'value': args[key]}) if not ARGUMENT_PATTERN.match(args[key]): - raise ArgumentError('Argument %r value %r contains invalid ' - 'characters.' % (key, args[key])) + raise ArgumentError(_('Argument %(key)s value %(value)s contains ' + 'invalid characters.') % + {'key': key, + 'value': args[key]}) if args[key][0] == '-': - raise ArgumentError('Argument %r value %r starts with a hyphen.' - % (key, args[key])) + raise ArgumentError(_('Argument %(key)s value %(value)s starts ' + 'with a hyphen.') % + {'key': key, + 'value': args[key]}) return args[key] elif default is not None: return default else: - raise ArgumentError('Argument %s is required.' % key) + raise ArgumentError(_('Argument %s is required.') % key) def validate_bool(args, key, default=None): @@ -105,8 +111,10 @@ def validate_bool(args, key, default=None): elif value.lower() == 'false': return False else: - raise ArgumentError("Argument %s may not take value %r. " - "Valid values are ['true', 'false']." % (key, value)) + raise ArgumentError(_("Argument %(key)s may not take value %(value)s. " + "Valid values are ['true', 'false'].") + % {'key': key, + 'value': value}) def exists(args, key): @@ -116,7 +124,7 @@ def exists(args, key): if key in args: return args[key] else: - raise ArgumentError('Argument %s is required.' % key) + raise ArgumentError(_('Argument %s is required.') % key) def optional(args, key): @@ -149,8 +157,13 @@ def create_vdi(session, sr_ref, name_label, virtual_size, read_only): 'other_config': {}, 'sm_config': {}, 'tags': []}) - logging.debug('Created VDI %s (%s, %s, %s) on %s.', vdi_ref, name_label, - virtual_size, read_only, sr_ref) + logging.debug(_('Created VDI %(vdi_ref)s (%(label)s, %(size)s, ' + '%(read_only)s) on %(sr_ref)s.') % + {'vdi_ref': vdi_ref, + 'label': name_label, + 'size': virtual_size, + 'read_only': read_only, + 'sr_ref': sr_ref}) return vdi_ref @@ -169,19 +182,19 @@ def with_vdi_in_dom0(session, vdi, read_only, f): vbd_rec['qos_algorithm_type'] = '' vbd_rec['qos_algorithm_params'] = {} vbd_rec['qos_supported_algorithms'] = [] - logging.debug('Creating VBD for VDI %s ... ', vdi) + logging.debug(_('Creating VBD for VDI %s ... '), vdi) vbd = session.xenapi.VBD.create(vbd_rec) - logging.debug('Creating VBD for VDI %s done.', vdi) + logging.debug(_('Creating VBD for VDI %s done.'), vdi) try: - logging.debug('Plugging VBD %s ... ', vbd) + logging.debug(_('Plugging VBD %s ... '), vbd) session.xenapi.VBD.plug(vbd) - logging.debug('Plugging VBD %s done.', vbd) + logging.debug(_('Plugging VBD %s done.'), vbd) return f(session.xenapi.VBD.get_device(vbd)) finally: - logging.debug('Destroying VBD for VDI %s ... ', vdi) + logging.debug(_('Destroying VBD for VDI %s ... '), vdi) vbd_unplug_with_retry(session, vbd) ignore_failure(session.xenapi.VBD.destroy, vbd) - logging.debug('Destroying VBD for VDI %s done.', vdi) + logging.debug(_('Destroying VBD for VDI %s done.'), vdi) def vbd_unplug_with_retry(session, vbd): @@ -192,19 +205,20 @@ def vbd_unplug_with_retry(session, vbd): while True: try: session.xenapi.VBD.unplug(vbd) - logging.debug('VBD.unplug successful first time.') + logging.debug(_('VBD.unplug successful first time.')) return except XenAPI.Failure, e: if (len(e.details) > 0 and e.details[0] == 'DEVICE_DETACH_REJECTED'): - logging.debug('VBD.unplug rejected: retrying...') + logging.debug(_('VBD.unplug rejected: retrying...')) time.sleep(1) elif (len(e.details) > 0 and e.details[0] == 'DEVICE_ALREADY_DETACHED'): - logging.debug('VBD.unplug successful eventually.') + logging.debug(_('VBD.unplug successful eventually.')) return else: - logging.error('Ignoring XenAPI.Failure in VBD.unplug: %s', e) + logging.error(_('Ignoring XenAPI.Failure in VBD.unplug: %s'), + e) return -- cgit From 7511b1b50b9a3f9d7dc7f3aaec6187577d97f194 Mon Sep 17 00:00:00 2001 From: Ryan Lane Date: Thu, 20 Jan 2011 19:33:37 +0000 Subject: Fixing another instance of getting a list of ids instead of a list of objects. --- nova/compute/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 3c232152e..6a3fe08b6 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -255,7 +255,7 @@ class API(base.Base): instances = set() for security_group in security_groups: for instance in security_group['instances']: - instances.add(instance['id']) + instances.add(instance) # ...then we find the hosts where they live... hosts = set() -- cgit From fc964378b521458be3c405783b2991b0c4f3f560 Mon Sep 17 00:00:00 2001 From: Anne Gentle Date: Thu, 20 Jan 2011 14:56:29 -0600 Subject: Doc changes for db sync --- doc/source/adminguide/distros/ubuntu.10.04.rst | 2 +- doc/source/adminguide/index.rst | 3 +- doc/source/adminguide/multi.node.install.rst | 149 +++++++++++++++---------- doc/source/adminguide/single.node.install.rst | 2 +- doc/source/index.rst | 4 +- 5 files changed, 98 insertions(+), 62 deletions(-) diff --git a/doc/source/adminguide/distros/ubuntu.10.04.rst b/doc/source/adminguide/distros/ubuntu.10.04.rst index 9d856458a..bd0693c46 100644 --- a/doc/source/adminguide/distros/ubuntu.10.04.rst +++ b/doc/source/adminguide/distros/ubuntu.10.04.rst @@ -31,7 +31,7 @@ If you're running on Ubuntu 10.04, you'll need to install Twisted and python-gfl :: - sudo add-get install python-software-properties + sudo apt-get install python-software-properties sudo add-apt-repository ppa:nova-core/trunk sudo apt-get update sudo apt-get install python-twisted python-gflags diff --git a/doc/source/adminguide/index.rst b/doc/source/adminguide/index.rst index e653c9e8b..3bd72cfdc 100644 --- a/doc/source/adminguide/index.rst +++ b/doc/source/adminguide/index.rst @@ -60,12 +60,13 @@ For background on the core objects referenced in this section, see :doc:`../obje Deployment ---------- -.. todo:: talk about deployment scenarios +For a starting multi-node architecture, you would start with two nodes - a cloud controller node and a compute node. The cloud controller node contains the nova- services plus the Nova database. The compute node installs all the nova-services but then refers to the database installation, which is hosted by the cloud controller node. Ensure that the nova.conf file is identical on each node. If you find performance issues not related to database reads or writes, but due to the messaging queue backing up, you could add additional messaging services (rabbitmq). .. toctree:: :maxdepth: 1 multi.node.install + dbsync Networking diff --git a/doc/source/adminguide/multi.node.install.rst b/doc/source/adminguide/multi.node.install.rst index 5918b0d38..df7078180 100644 --- a/doc/source/adminguide/multi.node.install.rst +++ b/doc/source/adminguide/multi.node.install.rst @@ -1,20 +1,3 @@ -.. - Copyright 2010-2011 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. Installing Nova on Multiple Servers =================================== @@ -26,13 +9,14 @@ through that process. You can install multiple nodes to increase performance and availability of the OpenStack Compute installation. -This setup is based on an Ubuntu Lucid 10.04 installation with the latest updates. Most of this works around issues that need to be resolved in the installation and configuration scripts as of October 18th 2010. It also needs to eventually be generalized, but the intent here is to get the multi-node configuration bootstrapped so folks can move forward. - - +This setup is based on an Ubuntu Lucid 10.04 installation with the latest updates. Most of this works around issues that need to be resolved either in packaging or bug-fixing. It also needs to eventually be generalized, but the intent here is to get the multi-node configuration bootstrapped so folks can move forward. + +For a starting architecture, these instructions describing installing a cloud controller node and a compute node. The cloud controller node contains the nova- services plus the database. The compute node installs all the nova-services but then refers to the database installation, which is hosted by the cloud controller node. + Requirements for a multi-node installation ------------------------------------------ -* You need a real database, compatible with SQLAlchemy (mysql, postgresql) There's not a specific reason to choose one over another, it basically depends what you know. MySQL is easier to do High Availability (HA) with, but people may already know Postgres. We should document both configurations, though. +* You need a real database, compatible with SQLAlchemy (mysql, postgresql) There's not a specific reason to choose one over another, it basically depends what you know. MySQL is easier to do High Availability (HA) with, but people may already know PostgreSQL. We should document both configurations, though. * For a recommended HA setup, consider a MySQL master/slave replication, with as many slaves as you like, and probably a heartbeat to kick one of the slaves into being a master if it dies. * For performance optimization, split reads and writes to the database. MySQL proxy is the easiest way to make this work if running MySQL. @@ -41,7 +25,45 @@ Assumptions * Networking is configured between/through the physical machines on a single subnet. * Installation and execution are both performed by ROOT user. - + +Scripted Installation +--------------------- +A script available to get your OpenStack cloud running quickly. You can copy the file to the server where you want to install OpenStack Compute services - typically you would install a compute node and a cloud controller node. + +You must run these scripts with root permissions. + +From a server you intend to use as a cloud controller node, use this command to get the cloud controller script. This script is a work-in-progress and the maintainer plans to keep it up, but it is offered "as-is." Feel free to collaborate on it in GitHub - https://github.com/dubsquared/OpenStack-NOVA-Installer-Script/. + +:: + + wget --no-check-certificate https://github.com/dubsquared/OpenStack-NOVA-Installer-Script/raw/master/Nova_CC_Installer_v0.1 + +Ensure you can execute the script by modifying the permissions on the script file. + +:: + + sudo chmod 755 Nova_CC_Installer_v0.1 + + +:: + + sudo ./Nova_CC_Installer_v0.1 + +Next, from a server you intend to use as a compute node (doesn't contain the database), install the nova services. Copy the nova.conf from the cloud controller node to the compute node. + +Restart related services:: + + libvirtd restart; service nova-network restart; service nova-compute restart; service nova-api restart; service nova-objectstore restart; service nova-scheduler restart + +You can go to the `Configuration section`_ for next steps. + +Manual Installation - Step-by-Step +---------------------------------- +The following sections show you how to install Nova manually with a cloud controller node and a separate compute node. The cloud controller node contains the database plus all nova- services, and the compute node runs nova- services only. + +Cloud Controller Installation +````````````````````````````` +On the cloud controller node, you install nova services and the related helper applications, and then configure with the nova.conf file. You will then copy the nova.conf file to the compute node, which you install as a second node in the `Compute Installation`_. Step 1 - Use apt-get to get the latest code ------------------------------------------- @@ -59,19 +81,18 @@ Step 1 - Use apt-get to get the latest code sudo apt-get update -3. Install nova-pkgs (dependencies should be automatically installed). +3. Install python required packages, nova-packages, and helper apps. :: - sudo apt-get install python-greenlet - sudo apt-get install nova-common nova-doc python-nova nova-api nova-network nova-objectstore nova-scheduler + sudo apt-get install python-greenlet python-mysqldb python-nova nova-common nova-doc nova-api nova-network nova-objectstore nova-scheduler nova-compute euca2ools unzip It is highly likely that there will be errors when the nova services come up since they are not yet configured. Don't worry, you're only at step 1! -Step 2 Setup configuration file (installed in /etc/nova) --------------------------------------------------------- +Step 2 Set up configuration file (installed in /etc/nova) +--------------------------------------------------------- -1. Nova development has consolidated all config files to nova.conf as of November 2010. There is a default set of options that are already configured in nova.conf: +1. Nova development has consolidated all config files to nova.conf as of November 2010. There is a default set of options that are already configured in nova.conf: :: @@ -81,7 +102,7 @@ Step 2 Setup configuration file (installed in /etc/nova) --logdir=/var/log/nova --state_path=/var/lib/nova -The following items ALSO need to be defined in /etc/nova/nova.conf. I’ve added some explanation of the variables, as comments CANNOT be in nova.conf. There seems to be an issue with nova-manage not processing the comments/whitespace correctly: +The following items ALSO need to be defined in /etc/nova/nova.conf. I’ve added some explanation of the variables, as comments CANNOT be in nova.conf. There seems to be an issue with nova-manage not processing the comments/whitespace correctly: --sql_connection ### Location of Nova SQL DB @@ -130,7 +151,7 @@ Detailed explanation of the following example is available above. The Nova config file should have its owner set to root:nova, and mode set to 0644, since they contain your MySQL server's root password. :: chown -R root:nova /etc/nova - chmod 644 /etc/nova/nova.conf + chmod 644 /etc/nova/nova.conf Step 3 - Setup the SQL DB (MySQL for this setup) ------------------------------------------------ @@ -153,10 +174,30 @@ Step 3 - Setup the SQL DB (MySQL for this setup) sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf service mysql restart + +4. MySQL DB configuration: + +Create NOVA database:: + + mysql -uroot -p$MYSQL_PASS -e 'CREATE DATABASE nova;' + +Update the DB to include user 'root'@'%' with super user privileges:: + + mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" + +Set mySQL root password:: + + mysql -uroot -p$MYSQL_PASS -e "SET PASSWORD FOR 'root'@'%' = PASSWORD('$MYSQL_PASS');" + +Compute Node Installation +````````````````````````` -3. Network Configuration +Repeat steps 1 and 2 from the Cloud Controller Installation section above, then configure the network for your Compute instances on the Compute node. Copy the nova.conf file from the Cloud Controller node to this node. -If you use FlatManager (as opposed to VlanManager that we set) as your network manager, there are some additional networking changes you’ll have to make to ensure connectivity between your nodes and VMs. If you chose VlanManager or FlatDHCP, you may skip this section, as it’s set up for you automatically. +Network Configuration +--------------------- + +If you use FlatManager as your network manager (as opposed to VlanManager that is shown in the nova.conf example above), there are some additional networking changes you’ll have to make to ensure connectivity between your nodes and VMs. If you chose VlanManager or FlatDHCP, you may skip this section, as it’s set up for you automatically. Nova defaults to a bridge device named 'br100'. This needs to be created and somehow integrated into YOUR network. To keep things as simple as possible, have all the VM guests on the same network as the VM hosts (the compute nodes). To do so, set the compute node's external IP address to be on the bridge and add eth0 to that bridge. To do this, edit your network interfaces config to look like the following:: @@ -179,31 +220,24 @@ Next, restart networking to apply the changes:: sudo /etc/init.d/networking restart -4. MySQL DB configuration: - -Create NOVA database:: - - mysql -uroot -p$MYSQL_PASS -e 'CREATE DATABASE nova;' - -Update the DB to include user 'root'@'%' with super user privileges:: +Configuration +````````````` - mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" - -Set mySQL root password:: +On the Compute node, you should continue with these configuration steps. - mysql -uroot -p$MYSQL_PASS -e "SET PASSWORD FOR 'root'@'%' = PASSWORD('$MYSQL_PASS');" - -Step 4 - Setup Nova environment -------------------------------- +Step 1 - Set up the Nova environment +------------------------------------ -These are the commands you run to set up a user and project:: +These are the commands you run to update the database if needed, and then set up a user and project:: + /usr/bin/python /usr/bin/nova-manage db sync /usr/bin/python /usr/bin/nova-manage user admin /usr/bin/python /usr/bin/nova-manage project create /usr/bin/python /usr/bin/nova-manage network create Here is an example of what this looks like with real data:: + /usr/bin/python /usr/bin/nova-manage db sync /usr/bin/python /usr/bin/nova-manage user admin dub /usr/bin/python /usr/bin/nova-manage project create dubproject dub /usr/bin/python /usr/bin/nova-manage network create 192.168.0.0/24 1 255 @@ -215,7 +249,7 @@ Note: The nova-manage service assumes that the first IP address is your network On running this command, entries are made in the 'networks' and 'fixed_ips' table. However, one of the networks listed in the 'networks' table needs to be marked as bridge in order for the code to know that a bridge exists. The Network is marked as bridged automatically based on the type of network manager selected. This is ONLY necessary if you chose FlatManager as your network type. More information can be found at the end of this document discussing setting up the bridge device. -Step 5 - Create Nova certifications +Step 2 - Create Nova certifications ----------------------------------- 1. Generate the certs as a zip file. These are the certs you will use to launch instances, bundle images, and all the other assorted api functions. @@ -229,18 +263,18 @@ Step 5 - Create Nova certifications :: - unzip /root/creds/novacreds.zip -d /root/creds/ + unzip /root/creds/novacreds.zip -d /root/creds/ cat /root/creds/novarc >> ~/.bashrc source ~/.bashrc -Step 6 - Restart all relevant services +Step 3 - Restart all relevant services -------------------------------------- Restart all six services in total, just to cover the entire spectrum:: libvirtd restart; service nova-network restart; service nova-compute restart; service nova-api restart; service nova-objectstore restart; service nova-scheduler restart -Step 7 - Closing steps, and cleaning up +Step 4 - Closing steps, and cleaning up --------------------------------------- One of the most commonly missed configuration areas is not allowing the proper access to VMs. Use the 'euca-authorize' command to enable access. Below, you will find the commands to allow 'ping' and 'ssh' to your VMs:: @@ -253,8 +287,8 @@ Another common issue is you cannot ping or SSH your instances after issusing the killall dnsmasq service nova-network restart -Step 8 – Testing the installation ---------------------------------- +Testing the Installation +```````````````````````` You can then use `euca2ools` to test some items:: @@ -267,13 +301,15 @@ If you have issues with the API key, you may need to re-source your creds file:: If you don’t get any immediate errors, you’re successfully making calls to your cloud! -Step 9 - Spinning up a VM for testing -------------------------------------- +Spinning up a VM for Testing +```````````````````````````` (This excerpt is from Thierry Carrez's blog, with reference to http://wiki.openstack.org/GettingImages.) The image that you will use here will be a ttylinux image, so this is a limited function server. You will be able to ping and SSH to this instance, but it is in no way a full production VM. +UPDATE: Due to `bug 661159 `_, we can’t use images without ramdisks yet, so we can’t use the classic Ubuntu cloud images from http://uec-images.ubuntu.com/releases/ yet. For the sake of this tutorial, we’ll use the `ttylinux images from Scott Moser instead `_. + Download the image, and publish to your bucket: :: @@ -324,5 +360,4 @@ You can determine the instance-id with `euca-describe-instances`, and the format For more information in creating you own custom (production ready) instance images, please visit http://wiki.openstack.org/GettingImages for more information! -Enjoy your new private cloud, and play responsibly! - +Enjoy your new private cloud, and play responsibly! \ No newline at end of file diff --git a/doc/source/adminguide/single.node.install.rst b/doc/source/adminguide/single.node.install.rst index 8572c5a4a..119e3855b 100644 --- a/doc/source/adminguide/single.node.install.rst +++ b/doc/source/adminguide/single.node.install.rst @@ -159,7 +159,7 @@ To make things easier, we've provided a small image on the Rackspace CDN. Use th Resolving cblah2.cdn.cloudfiles.rackspacecloud.com... 208.111.196.6, 208.111.196.7 Connecting to cblah2.cdn.cloudfiles.rackspacecloud.com|208.111.196.6|:80... connected. HTTP request sent, awaiting response... 200 OK - Length: 58520278 (56M) [appication/x-gzip] + Length: 58520278 (56M) [application/x-gzip] Saving to: `images.tgz' 100%[======================================>] 58,520,278 14.1M/s in 3.9s diff --git a/doc/source/index.rst b/doc/source/index.rst index 6eec09acb..d337fb69f 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -20,7 +20,7 @@ Welcome to Nova's documentation! Nova is a cloud computing fabric controller, the main part of an IaaS system. Individuals and organizations can use Nova to host and manage their own cloud -computing systems. Nova originated as a project out of NASA Ames Research Laboratory. +computing systems. Nova originated as a project out of NASA Ames Research Laboratory. Nova is written with the following design guidelines in mind: @@ -32,7 +32,7 @@ Nova is written with the following design guidelines in mind: * **API Compatibility**: Nova strives to provide API-compatible with popular systems like Amazon EC2 This documentation is generated by the Sphinx toolkit and lives in the source -tree. Additional documentation on Nova and other components of OpenStack can +tree. Additional documentation on Nova and other components of OpenStack can be found on the `OpenStack wiki`_. Also see the :doc:`community` page for other ways to interact with the community. -- cgit From a112d11cc2184fb70d9ed4c0db931d92e02b6c82 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Thu, 20 Jan 2011 16:07:27 -0500 Subject: Use ttx's patch to be explict about paths, as urlmap doesn't work as I expected. --- etc/nova-api.conf | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/etc/nova-api.conf b/etc/nova-api.conf index 4873e465d..f0e749805 100644 --- a/etc/nova-api.conf +++ b/etc/nova-api.conf @@ -11,7 +11,14 @@ use = egg:Paste#urlmap /services/Cloud: ec2cloud /services/Admin: ec2admin /latest: ec2metadata -/20: ec2metadata +/2007-01-19: ec2metadata +/2007-03-01: ec2metadata +/2007-08-29: ec2metadata +/2007-10-10: ec2metadata +/2007-12-15: ec2metadata +/2008-02-01: ec2metadata +/2008-09-01: ec2metadata +/2009-04-04: ec2metadata /1.0: ec2metadata [pipeline:ec2cloud] -- cgit From 6b9ca44c5140fe96395600b858a4566af87795a3 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Fri, 21 Jan 2011 10:08:21 +0100 Subject: No longer chmod 0777 instance directories --- nova/virt/libvirt_conn.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 7005ae814..d8c1bf48a 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -510,7 +510,6 @@ class LibvirtConnection(object): base_dir = os.path.join(FLAGS.instances_path, '_base') if not os.path.exists(base_dir): os.mkdir(base_dir) - os.chmod(base_dir, 0777) base = os.path.join(base_dir, fname) if not os.path.exists(base): fn(target=base, *args, **kwargs) @@ -541,7 +540,6 @@ class LibvirtConnection(object): # ensure directories exist and are writable utils.execute('mkdir -p %s' % basepath(suffix='')) - utils.execute('chmod 0777 %s' % basepath(suffix='')) LOG.info(_('instance %s: Creating image'), inst['name']) f = open(basepath('libvirt.xml'), 'w') -- cgit From b05f4f55f05d9b177ddde03da769cb95c8fbb72e Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Fri, 21 Jan 2011 19:10:31 +0000 Subject: Adding getttext to pluginlib_nova --- plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py index cc0a196af..7fea1136d 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py @@ -19,6 +19,8 @@ # that we need. # +import gettext +gettext.install('nova', unicode=1) import httplib import logging import logging.handlers -- cgit