diff -Nru ols-vms-1.2.0/debian/bzr-builder.manifest ols-vms-1.2.1/debian/bzr-builder.manifest --- ols-vms-1.2.0/debian/bzr-builder.manifest 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/debian/bzr-builder.manifest 2017-02-13 18:08:35.000000000 +0000 @@ -1,2 +1,2 @@ -# bzr-builder format 0.3 deb-version {debupstream}-0~288 -lp:ols-vms revid:vila+ols@canonical.com-20170202114441-noq7za9x7almze8a +# bzr-builder format 0.3 deb-version {debupstream}-0~292 +lp:ols-vms revid:vila+ols@canonical.com-20170213180532-ukmqq7yzq2buwdo3 diff -Nru ols-vms-1.2.0/debian/changelog ols-vms-1.2.1/debian/changelog --- ols-vms-1.2.0/debian/changelog 2017-02-03 11:47:35.000000000 +0000 +++ ols-vms-1.2.1/debian/changelog 2017-02-13 18:08:35.000000000 +0000 @@ -1,8 +1,20 @@ -ols-vms (1.2.0-0~288~ubuntu14.04.1) trusty; urgency=low +ols-vms (1.2.1-0~292~ubuntu14.04.1) trusty; urgency=low * Auto build. - -- Vincent Ladeuil Fri, 03 Feb 2017 11:47:34 +0000 + -- Vincent Ladeuil Mon, 13 Feb 2017 18:08:35 +0000 + +ols-vms (1.2.1) unstable; urgency=medium + + * Fix a leak where 'exsiting-vms.conf' content wasn't properly saved + when a container was tear down. + + * Add 'logging.format' to allow users to specify the logging format to + be used. + + * Properly report invalid values for 'lxd.nesting'. + + -- Vincent Ladeuil Mon, 13 Feb 2017 17:46:03 +0100 ols-vms (1.2.0) unstable; urgency=medium diff -Nru ols-vms-1.2.0/NEWS.rst ols-vms-1.2.1/NEWS.rst --- ols-vms-1.2.0/NEWS.rst 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/NEWS.rst 2017-02-13 18:08:35.000000000 +0000 @@ -4,11 +4,17 @@ Overview of changes to ols-vms in reverse chronological order. -dev -=== +1.2.1 +===== +* Fix a leak where 'exsiting-vms.conf' content wasn't properly saved when a + container was tear down. +* Add 'logging.format' to allow users to specify the logging format to be + used. +* Properly report invalid values for 'lxd.nesting'. + 1.2.0 ===== diff -Nru ols-vms-1.2.0/olsvms/commands.py ols-vms-1.2.1/olsvms/commands.py --- ols-vms-1.2.0/olsvms/commands.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/commands.py 2017-02-13 18:08:35.000000000 +0000 @@ -223,10 +223,6 @@ def parse_args(self, args): super(VmCommand, self).parse_args(args) self.parse_vm_arg() - log_level = self.vm.conf.get('logging.level') - if log_level is not None: - # Override log level in the root logger - logging.getLogger('').setLevel(log_level) return self.options def parse_vm_arg(self): @@ -254,6 +250,10 @@ except config_errors.OptionMandatoryValueError: raise errors.InvalidVmClass(self.vm_name, kls_name) self.vm = kls(conf) + # Now that we know the vm, we may configure logging + log_level = self.vm.conf.get('logging.level') + log_format = self.vm.conf.get('logging.format') + logging.basicConfig(level=log_level, format=log_format) return @@ -598,16 +598,6 @@ help_string=commands_help)) -def setup_logging(level=None): - if level is None: - level = logging.ERROR - if level == logging.DEBUG: - log_format = '%(asctime)s %(name)s %(levelname)s %(message)s' - else: - log_format = '%(asctime)s %(levelname)s %(message)s' - logging.basicConfig(level=level, format=log_format) - - def run(args=None, out=None, err=None): if args is None: args = sys.argv[1:] diff -Nru ols-vms-1.2.0/olsvms/config.py ols-vms-1.2.1/olsvms/config.py --- ols-vms-1.2.0/olsvms/config.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/config.py 2017-02-13 18:08:35.000000000 +0000 @@ -724,7 +724,7 @@ with id being the correct user (and group) id (i.e. the user running the 'setup' command). ''')) -register(options.Option('lxd.nesting', default=0, +register(options.Option('lxd.nesting', default=0, invalid='error', from_unicode=options.int_from_store, help_string='''\ How many level of nesting containers should be allowed for the vm. @@ -864,13 +864,18 @@ from_unicode=level_from_store, default_from_env=['LOG_LEVEL'], help_string='''\ -Logging level (same as python).''')) +Logging level (same as python: error, warning, info, debug).''')) +register(options.Option('logging.format', + default='%(asctime)s %(levelname)s %(message)s', + help_string='''\ +Logging format (see python doc).''')) ###################################################################### # launchpad options ###################################################################### + def default_lp_login(): lp_login_cmd = ['bzr', 'lp-login'] try: diff -Nru ols-vms-1.2.0/olsvms/logs.py ols-vms-1.2.1/olsvms/logs.py --- ols-vms-1.2.0/olsvms/logs.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/logs.py 2017-02-13 18:08:35.000000000 +0000 @@ -1,6 +1,6 @@ # This file is part of Online Services virtual machine tools. # -# Copyright 2014, 2015, 2016 Canonical Ltd. +# Copyright 2014-2017 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License version 3, as published by the diff -Nru ols-vms-1.2.0/olsvms/ssh.py ols-vms-1.2.1/olsvms/ssh.py --- ols-vms-1.2.0/olsvms/ssh.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/ssh.py 2017-02-13 18:08:35.000000000 +0000 @@ -1,6 +1,6 @@ # This file is part of Online Services virtual machine tools. # -# Copyright 2014, 2015, 2016 Canonical Ltd. +# Copyright 2014-2017 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License version 3, as published by the diff -Nru ols-vms-1.2.0/olsvms/tests/fixtures.py ols-vms-1.2.1/olsvms/tests/fixtures.py --- ols-vms-1.2.0/olsvms/tests/fixtures.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/tests/fixtures.py 2017-02-13 18:08:35.000000000 +0000 @@ -118,7 +118,7 @@ super(_MyStreamHandler, self).emit(record) -def override_logging(test, stream_out, level=logging.INFO, fmt='%(message)s'): +def override_logging(test, stream_out, level=logging.INFO): """Setup a logging handler, restoring the actual handlers after the test. This assumes a logging setup where handlers are added to the root logger diff -Nru ols-vms-1.2.0/olsvms/tests/test_config.py ols-vms-1.2.1/olsvms/tests/test_config.py --- ols-vms-1.2.0/olsvms/tests/test_config.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/tests/test_config.py 2017-02-13 18:08:35.000000000 +0000 @@ -137,6 +137,13 @@ self.assertValue(os.path.join(self.home_dir, 'images'), 'libvirt.images_dir') + def test_lxd_invalid_nesting(self): + self.conf.set('lxd.nesting', 'true') + with self.assertRaises(errors.OptionValueError) as cm: + self.conf.get('lxd.nesting') + self.assertEqual('lxd.nesting: Value "true" is not valid.', + '{}'.format(cm.exception)) + class TestPathOption(unittest.TestCase): diff -Nru ols-vms-1.2.0/olsvms/tests/test_logs.py ols-vms-1.2.1/olsvms/tests/test_logs.py --- ols-vms-1.2.0/olsvms/tests/test_logs.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/tests/test_logs.py 2017-02-13 18:08:35.000000000 +0000 @@ -1,6 +1,6 @@ # This file is part of Online Services virtual machine tools. # -# Copyright 2014, 2015, 2016 Canonical Ltd. +# Copyright 2014-2017 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License version 3, as published by the diff -Nru ols-vms-1.2.0/olsvms/vms/__init__.py ols-vms-1.2.1/olsvms/vms/__init__.py --- ols-vms-1.2.0/olsvms/vms/__init__.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/vms/__init__.py 2017-02-13 18:08:35.000000000 +0000 @@ -108,7 +108,10 @@ except KeyError: # The setup didn't went as far as creating the section pass - self.econf.store.save_changes() + # deleting a section is not supported by save_changes() so save() and + # unload() + self.econf.store.save() + self.econf.store.unload() def hash_value(self, hasher, value): # No point in hashing none values, as soon as a value is set, it diff -Nru ols-vms-1.2.0/olsvms/vms/lxd.py ols-vms-1.2.1/olsvms/vms/lxd.py --- ols-vms-1.2.0/olsvms/vms/lxd.py 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/olsvms/vms/lxd.py 2017-02-13 18:08:35.000000000 +0000 @@ -278,13 +278,13 @@ subprocesses.run(stop_command) def publish(self): - logger.info('Publishing lxd image..') + logger.info('Publishing lxd image...') publish_command = ['lxc', 'publish', self.conf.get('vm.name'), '--alias', self.conf.get('vm.published_as')] subprocesses.run(publish_command) def unpublish(self): - logger.info('Un-publishing lxd image..') + logger.info('Un-publishing lxd image...') unpublish_command = ['lxc', 'image', 'delete', self.conf.get('vm.published_as')] subprocesses.run(unpublish_command) @@ -314,6 +314,9 @@ # the same volume twice (and also find a better naming scheme to # not conflict (olsvmsdiskN needs at least to start above the # existing ones) -- vila 2017-01-12 + + # FIXME: The solution is one vm.backing.conf.get('lxd.user_mounts') + # away -- vila 2017-02-04 raise errors.OlsVmsError( 'Backing vm {} already has mounts'.format( self.conf.get('vm.backing'))) diff -Nru ols-vms-1.2.0/ols-vms ols-vms-1.2.1/ols-vms --- ols-vms-1.2.0/ols-vms 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/ols-vms 2017-02-13 18:08:35.000000000 +0000 @@ -22,5 +22,4 @@ if __name__ == '__main__': - commands.setup_logging() sys.exit(commands.run()) diff -Nru ols-vms-1.2.0/ols-vms2 ols-vms-1.2.1/ols-vms2 --- ols-vms-1.2.0/ols-vms2 2017-02-03 11:47:34.000000000 +0000 +++ ols-vms-1.2.1/ols-vms2 2017-02-13 18:08:35.000000000 +0000 @@ -23,5 +23,4 @@ if __name__ == '__main__': - commands.setup_logging() sys.exit(commands.run())