Follow up "Fix up userdata argument to rebuild"
This patch is a follow-up patch for I9752d849aa0e6cf608db0def3ca89565cff4debc. * Add checking a message of an exception in the unit test * Add 'with' statement when opening a file * Fix descriptions in the release note Change-Id: I2c399490f320a202b41a8f8d36710a36621c4853
This commit is contained in:
parent
bfbec25e27
commit
47dc339ab9
@ -1773,8 +1773,11 @@ class ShellTest(utils.TestCase):
|
|||||||
'no_such_file')
|
'no_such_file')
|
||||||
cmd = ('rebuild sample-server %s --user-data %s'
|
cmd = ('rebuild sample-server %s --user-data %s'
|
||||||
% (FAKE_UUID_1, invalid_file))
|
% (FAKE_UUID_1, invalid_file))
|
||||||
self.assertRaises(exceptions.CommandError, self.run_command, cmd,
|
ex = self.assertRaises(exceptions.CommandError, self.run_command, cmd,
|
||||||
api_version='2.57')
|
api_version='2.57')
|
||||||
|
self.assertIn("Can't open '%(user_data)s': "
|
||||||
|
"[Errno 2] No such file or directory: '%(user_data)s'" %
|
||||||
|
{'user_data': invalid_file}, six.text_type(ex))
|
||||||
|
|
||||||
def test_rebuild_unset_user_data(self):
|
def test_rebuild_unset_user_data(self):
|
||||||
self.run_command('rebuild sample-server %s --user-data-unset' %
|
self.run_command('rebuild sample-server %s --user-data-unset' %
|
||||||
|
@ -398,7 +398,8 @@ def _boot(cs, args):
|
|||||||
for f in args.files:
|
for f in args.files:
|
||||||
try:
|
try:
|
||||||
dst, src = f.split('=', 1)
|
dst, src = f.split('=', 1)
|
||||||
files[dst] = open(src)
|
with open(src) as fo:
|
||||||
|
files[dst] = fo.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
_("Can't open '%(src)s': %(exc)s") %
|
_("Can't open '%(src)s': %(exc)s") %
|
||||||
@ -416,7 +417,8 @@ def _boot(cs, args):
|
|||||||
|
|
||||||
if args.user_data:
|
if args.user_data:
|
||||||
try:
|
try:
|
||||||
userdata = open(args.user_data)
|
with open(args.user_data) as f:
|
||||||
|
userdata = f.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise exceptions.CommandError(_("Can't open '%(user_data)s': "
|
raise exceptions.CommandError(_("Can't open '%(user_data)s': "
|
||||||
"%(exc)s") %
|
"%(exc)s") %
|
||||||
@ -1916,7 +1918,8 @@ def do_rebuild(cs, args):
|
|||||||
"'--user-data'."))
|
"'--user-data'."))
|
||||||
elif args.user_data:
|
elif args.user_data:
|
||||||
try:
|
try:
|
||||||
kwargs['userdata'] = open(args.user_data)
|
with open(args.user_data) as f:
|
||||||
|
kwargs['userdata'] = f.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
_("Can't open '%(user_data)s': %(exc)s") % {
|
_("Can't open '%(user_data)s': %(exc)s") % {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
fixes:
|
fixes:
|
||||||
- |
|
- |
|
||||||
The user data argument to rebuild was passing the filename as is as userdata.
|
The user data argument in the ``nova rebuild`` command was passing
|
||||||
Now this passes the contents of the filename as intended.
|
the filename as userdata. Now this passes the contents of the file
|
||||||
|
as intended.
|
||||||
|
Loading…
Reference in New Issue
Block a user