Add override args for RequestParser
Properly fixes the issue with OVA upload bodies by allowing the restriction of the 'location' directive when parsing specific request args. Thus the 'form' location can be included by default but removed for those parsers that have a file body.
This commit is contained in:
parent
b169620eee
commit
e6bca5b6a9
|
@ -157,13 +157,16 @@ class RequestParser(object):
|
||||||
parser = reqparse.RequestParser()
|
parser = reqparse.RequestParser()
|
||||||
# Parse and add each argument
|
# Parse and add each argument
|
||||||
for reqarg in self.reqargs:
|
for reqarg in self.reqargs:
|
||||||
|
location = reqarg.get('location', None)
|
||||||
|
if location is None:
|
||||||
|
location = ['args', 'form']
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
reqarg.get('name', None),
|
reqarg.get('name', None),
|
||||||
required=reqarg.get('required', False),
|
required=reqarg.get('required', False),
|
||||||
action=reqarg.get('action', None),
|
action=reqarg.get('action', None),
|
||||||
choices=reqarg.get('choices', ()),
|
choices=reqarg.get('choices', ()),
|
||||||
help=reqarg.get('helptext', None),
|
help=reqarg.get('helptext', None),
|
||||||
location=['args']
|
location=location
|
||||||
)
|
)
|
||||||
reqargs = parser.parse_args()
|
reqargs = parser.parse_args()
|
||||||
kwargs['reqargs'] = reqargs
|
kwargs['reqargs'] = reqargs
|
||||||
|
@ -3803,7 +3806,7 @@ api.add_resource(API_Storage_Ceph_Volume_Element_Clone, '/storage/ceph/volume/<p
|
||||||
# /storage/ceph/volume/<pool>/<volume>/upload
|
# /storage/ceph/volume/<pool>/<volume>/upload
|
||||||
class API_Storage_Ceph_Volume_Element_Upload(Resource):
|
class API_Storage_Ceph_Volume_Element_Upload(Resource):
|
||||||
@RequestParser([
|
@RequestParser([
|
||||||
{'name': 'image_format', 'required': True, 'helpmsg': "A source image format must be specified."}
|
{'name': 'image_format', 'required': True, 'location': ['args'], 'helpmsg': "A source image format must be specified."}
|
||||||
])
|
])
|
||||||
@Authenticator
|
@Authenticator
|
||||||
def post(self, pool, volume, reqargs):
|
def post(self, pool, volume, reqargs):
|
||||||
|
@ -5846,9 +5849,9 @@ class API_Provisioner_OVA_Root(Resource):
|
||||||
)
|
)
|
||||||
|
|
||||||
@RequestParser([
|
@RequestParser([
|
||||||
{'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified."},
|
{'name': 'pool', 'required': True, 'location': ['args'], 'helpmsg': "A storage pool must be specified."},
|
||||||
{'name': 'name', 'required': True, 'helpmsg': "A VM name must be specified."},
|
{'name': 'name', 'required': True, 'location': ['args'], 'helpmsg': "A VM name must be specified."},
|
||||||
{'name': 'ova_size', 'required': True, 'helpmsg': "An OVA size must be specified."},
|
{'name': 'ova_size', 'required': True, 'location': ['args'], 'helpmsg': "An OVA size must be specified."},
|
||||||
])
|
])
|
||||||
@Authenticator
|
@Authenticator
|
||||||
def post(self, reqargs):
|
def post(self, reqargs):
|
||||||
|
@ -5923,8 +5926,8 @@ class API_Provisioner_OVA_Element(Resource):
|
||||||
)
|
)
|
||||||
|
|
||||||
@RequestParser([
|
@RequestParser([
|
||||||
{'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified."},
|
{'name': 'pool', 'required': True, 'location': ['args'], 'helpmsg': "A storage pool must be specified."},
|
||||||
{'name': 'ova_size', 'required': True, 'helpmsg': "An OVA size must be specified."},
|
{'name': 'ova_size', 'required': True, 'location': ['args'], 'helpmsg': "An OVA size must be specified."},
|
||||||
])
|
])
|
||||||
@Authenticator
|
@Authenticator
|
||||||
def post(self, ova, reqargs):
|
def post(self, ova, reqargs):
|
||||||
|
|
Loading…
Reference in New Issue