Skip to content

Commit 2ccf772

Browse files
committed
compute: Remove 'file://' prefix from '--block-device'
There are a couple of other (networking-related) options which accept paths, none of which insist on a URI-style path. Let's just drop this bit of complexity before we release the feature. Change-Id: Ia7f781d82f3f4695b49b55a39abbb6e582cd879c Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
1 parent ae1f8f8 commit 2ccf772

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import json
2222
import logging
2323
import os
24-
import urllib.parse
2524

2625
from cliff import columns as cliff_columns
2726
import iso8601
@@ -774,9 +773,8 @@ def __call__(self, parser, namespace, values, option_string=None):
774773
if getattr(namespace, self.dest, None) is None:
775774
setattr(namespace, self.dest, [])
776775

777-
if values.startswith('file://'):
778-
path = urllib.parse.urlparse(values).path
779-
with open(path) as fh:
776+
if os.path.exists(values):
777+
with open(values) as fh:
780778
data = json.load(fh)
781779

782780
# Validate the keys - other validation is left to later
@@ -898,10 +896,9 @@ def get_parser(self, prog_name):
898896
default=[],
899897
help=_(
900898
'Create a block device on the server.\n'
901-
'Either a URI-style path (\'file:\\\\{path}\') to a JSON file '
902-
'or a CSV-serialized string describing the block device '
903-
'mapping.\n'
904-
'The following keys are accepted:\n'
899+
'Either a path to a JSON file or a CSV-serialized string '
900+
'describing the block device mapping.\n'
901+
'The following keys are accepted for both:\n'
905902
'uuid=<uuid>: UUID of the volume, snapshot or ID '
906903
'(required if using source image, snapshot or volume),\n'
907904
'source_type=<source_type>: source type '

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,7 @@ def test_server_create_with_block_device_from_file(self):
21972197
arglist = [
21982198
'--image', 'image1',
21992199
'--flavor', self.flavor.id,
2200-
'--block-device', f'file://{fp.name}',
2200+
'--block-device', fp.name,
22012201
self.new_server.name,
22022202
]
22032203
verifylist = [

0 commit comments

Comments
 (0)