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>
This commit is contained in:
Stephen Finucane 2021-03-11 15:53:39 +00:00
parent ae1f8f888a
commit 2ccf7727a6
2 changed files with 6 additions and 9 deletions

View File

@ -21,7 +21,6 @@ import io
import json import json
import logging import logging
import os import os
import urllib.parse
from cliff import columns as cliff_columns from cliff import columns as cliff_columns
import iso8601 import iso8601
@ -774,9 +773,8 @@ class BDMAction(parseractions.MultiKeyValueAction):
if getattr(namespace, self.dest, None) is None: if getattr(namespace, self.dest, None) is None:
setattr(namespace, self.dest, []) setattr(namespace, self.dest, [])
if values.startswith('file://'): if os.path.exists(values):
path = urllib.parse.urlparse(values).path with open(values) as fh:
with open(path) as fh:
data = json.load(fh) data = json.load(fh)
# Validate the keys - other validation is left to later # Validate the keys - other validation is left to later
@ -898,10 +896,9 @@ class CreateServer(command.ShowOne):
default=[], default=[],
help=_( help=_(
'Create a block device on the server.\n' 'Create a block device on the server.\n'
'Either a URI-style path (\'file:\\\\{path}\') to a JSON file ' 'Either a path to a JSON file or a CSV-serialized string '
'or a CSV-serialized string describing the block device ' 'describing the block device mapping.\n'
'mapping.\n' 'The following keys are accepted for both:\n'
'The following keys are accepted:\n'
'uuid=<uuid>: UUID of the volume, snapshot or ID ' 'uuid=<uuid>: UUID of the volume, snapshot or ID '
'(required if using source image, snapshot or volume),\n' '(required if using source image, snapshot or volume),\n'
'source_type=<source_type>: source type ' 'source_type=<source_type>: source type '

View File

@ -2197,7 +2197,7 @@ class TestServerCreate(TestServer):
arglist = [ arglist = [
'--image', 'image1', '--image', 'image1',
'--flavor', self.flavor.id, '--flavor', self.flavor.id,
'--block-device', f'file://{fp.name}', '--block-device', fp.name,
self.new_server.name, self.new_server.name,
] ]
verifylist = [ verifylist = [