Normalize all return messages

Ensure all API return messages are formated the same: no "error", a
final period except when displaying Exception text, and a regular spaced
out format.
This commit is contained in:
2020-02-20 22:38:31 -05:00
parent 31a117e21c
commit 56a9e48163
4 changed files with 167 additions and 167 deletions

View File

@ -175,9 +175,9 @@ def Authenticator(function):
if any(token for token in config['auth_tokens'] if flask.request.headers.get('X-Api-Key') == token.get('token')):
return function(*args, **kwargs)
else:
return {"message":"X-Api-Key Authentication failed"}, 401
return { "message": "X-Api-Key Authentication failed." }, 401
# All authentications failed
return {"message":"X-Api-Key Authentication required"}, 401
return { "message": "X-Api-Key Authentication required." }, 401
return authenticate
@ -405,7 +405,7 @@ class API_Status(Resource):
return api_helper.cluster_status()
@RequestParser([
{ 'name': 'state', 'choices': ('true', 'false'), 'required': True, 'helpmsg': "A valid state must be specified" }
{ 'name': 'state', 'choices': ('true', 'false'), 'required': True, 'helpmsg': "A valid state must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -2172,7 +2172,7 @@ api.add_resource(API_Network_Lease_Element, '/network/<vni>/lease/<mac>')
class API_Network_ACL_Root(Resource):
@RequestParser([
{ 'name': 'limit' },
{ 'name': 'direction', 'choices': ('in', 'out'), 'helpmsg': "A valid direction must be specified" }
{ 'name': 'direction', 'choices': ('in', 'out'), 'helpmsg': "A valid direction must be specified." }
])
@Authenticator
def get(self, vni, reqargs):
@ -2234,9 +2234,9 @@ class API_Network_ACL_Root(Resource):
)
@RequestParser([
{ 'name': 'description', 'required': True, 'helpmsg': "A whitespace-free description must be specified" },
{ 'name': 'rule', 'required': True, 'helpmsg': "A rule must be specified" },
{ 'name': 'direction', 'choices': ('in', 'out'), 'helpmsg': "A valid direction must be specified" },
{ 'name': 'description', 'required': True, 'helpmsg': "A whitespace-free description must be specified." },
{ 'name': 'rule', 'required': True, 'helpmsg': "A rule must be specified." },
{ 'name': 'direction', 'choices': ('in', 'out'), 'helpmsg': "A valid direction must be specified." },
{ 'name': 'order' }
])
@Authenticator
@ -2323,8 +2323,8 @@ class API_Network_ACL_Element(Resource):
)
@RequestParser([
{ 'name': 'rule', 'required': True, 'helpmsg': "A rule must be specified" },
{ 'name': 'direction', 'choices': ('in', 'out'), 'helpmsg': "A valid direction must be specified" },
{ 'name': 'rule', 'required': True, 'helpmsg': "A rule must be specified." },
{ 'name': 'direction', 'choices': ('in', 'out'), 'helpmsg': "A valid direction must be specified." },
{ 'name': 'order' }
])
@Authenticator
@ -2479,8 +2479,8 @@ api.add_resource(API_Storage_Ceph_Utilization, '/storage/ceph/utilization')
# /storage/ceph/option
class API_Storage_Ceph_Option(Resource):
@RequestParser([
{ 'name': 'option', 'required': True, 'helpmsg': "A valid option must be specified" },
{ 'name': 'action', 'required': True, 'choices': ('set', 'unset'), 'helpmsg': "A valid action must be specified" },
{ 'name': 'option', 'required': True, 'helpmsg': "A valid option must be specified." },
{ 'name': 'action', 'required': True, 'choices': ('set', 'unset'), 'helpmsg': "A valid action must be specified." },
])
@Authenticator
def post(self, reqargs):
@ -2618,9 +2618,9 @@ class API_Storage_Ceph_OSD_Root(Resource):
)
@RequestParser([
{ 'name': 'node', 'required': True, 'helpmsg': "A valid node must be specified" },
{ 'name': 'device', 'required': True, 'helpmsg': "A valid device must be specified" },
{ 'name': 'weight', 'required': True, 'helpmsg': "An OSD weight must be specified" },
{ 'name': 'node', 'required': True, 'helpmsg': "A valid node must be specified." },
{ 'name': 'device', 'required': True, 'helpmsg': "A valid device must be specified." },
{ 'name': 'weight', 'required': True, 'helpmsg': "An OSD weight must be specified." },
])
@Authenticator
def post(self, reqargs):
@ -2685,7 +2685,7 @@ class API_Storage_Ceph_OSD_Element(Resource):
)
@RequestParser([
{ 'name': 'yes-i-really-mean-it', 'required': True, 'helpmsg': "Please confirm that yes-i-really-mean-it" }
{ 'name': 'yes-i-really-mean-it', 'required': True, 'helpmsg': "Please confirm that 'yes-i-really-mean-it'." }
])
@Authenticator
def delete(self, osdid, reqargs):
@ -2748,7 +2748,7 @@ class API_Storage_Ceph_OSD_State(Resource):
)
@RequestParser([
{ 'name': 'state', 'choices': ('in', 'out'), 'required': True, 'helpmsg': "A valid state must be specified" },
{ 'name': 'state', 'choices': ('in', 'out'), 'required': True, 'helpmsg': "A valid state must be specified." },
])
@Authenticator
def post(self, osdid, reqargs):
@ -2865,9 +2865,9 @@ class API_Storage_Ceph_Pool_Root(Resource):
)
@RequestParser([
{ 'name': 'pool', 'required': True, 'helpmsg': "A pool name must be specified" },
{ 'name': 'pgs', 'required': True, 'helpmsg': "A placement group count must be specified" },
{ 'name': 'replcfg', 'required': True, 'helpmsg': "A valid replication configuration must be specified" }
{ 'name': 'pool', 'required': True, 'helpmsg': "A pool name must be specified." },
{ 'name': 'pgs', 'required': True, 'helpmsg': "A placement group count must be specified." },
{ 'name': 'replcfg', 'required': True, 'helpmsg': "A valid replication configuration must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -2937,8 +2937,8 @@ class API_Storage_Ceph_Pool_Element(Resource):
)
@RequestParser([
{ 'name': 'pgs', 'required': True, 'helpmsg': "A placement group count must be specified" },
{ 'name': 'replcfg', 'required': True, 'helpmsg': "A valid replication configuration must be specified" }
{ 'name': 'pgs', 'required': True, 'helpmsg': "A placement group count must be specified." },
{ 'name': 'replcfg', 'required': True, 'helpmsg': "A valid replication configuration must be specified." }
])
@Authenticator
def post(self, pool):
@ -2982,7 +2982,7 @@ class API_Storage_Ceph_Pool_Element(Resource):
)
@RequestParser([
{ 'name': 'yes-i-really-mean-it', 'required': True, 'helpmsg': "Please confirm that yes-i-really-mean-it" }
{ 'name': 'yes-i-really-mean-it', 'required': True, 'helpmsg': "Please confirm that 'yes-i-really-mean-it'." }
])
@Authenticator
def delete(self, pool, reqargs):
@ -3123,9 +3123,9 @@ class API_Storage_Ceph_Volume_Root(Resource):
)
@RequestParser([
{ 'name': 'volume', 'required': True, 'helpmsg': "A volume name must be specified" },
{ 'name': 'pool', 'required': True, 'helpmsg': "A valid pool name must be specified" },
{ 'name': 'size', 'required': True, 'helpmsg': "A volume size in bytes (or with k/M/G/T suffix) must be specified" }
{ 'name': 'volume', 'required': True, 'helpmsg': "A volume name must be specified." },
{ 'name': 'pool', 'required': True, 'helpmsg': "A valid pool name must be specified." },
{ 'name': 'size', 'required': True, 'helpmsg': "A volume size in bytes (or with k/M/G/T suffix) must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -3196,7 +3196,7 @@ class API_Storage_Ceph_Volume_Element(Resource):
)
@RequestParser([
{ 'name': 'size', 'required': True, 'helpmsg': "A volume size in bytes (or with k/M/G/T suffix) must be specified" }
{ 'name': 'size', 'required': True, 'helpmsg': "A volume size in bytes (or with k/M/G/T suffix) must be specified." }
])
@Authenticator
def post(self, pool, volume, reqargs):
@ -3319,7 +3319,7 @@ api.add_resource(API_Storage_Ceph_Volume_Element, '/storage/ceph/volume/<pool>/<
# /storage/ceph/volume/<pool>/<volume>/clone
class API_Storage_Ceph_Volume_Element_Clone(Resource):
@RequestParser([
{ 'name': 'new_volume', 'required': True, 'helpmsg': "A new volume name must be specified" }
{ 'name': 'new_volume', 'required': True, 'helpmsg': "A new volume name must be specified." }
])
@Authenticator
def post(self, pool, volume, reqargs):
@ -3361,7 +3361,7 @@ api.add_resource(API_Storage_Ceph_Volume_Element_Clone, '/storage/ceph/volume/<p
# /storage/ceph/volume/<pool>/<volume>/upload
class API_Storage_Ceph_Volume_Element_Upload(Resource):
@RequestParser([
{ 'name': 'image_format', 'required': True, 'helpmsg': "A source image format must be specified" }
{ 'name': 'image_format', 'required': True, 'helpmsg': "A source image format must be specified." }
])
@Authenticator
def post(self, pool, volume, reqargs):
@ -3409,7 +3409,7 @@ class API_Storage_Ceph_Volume_Element_Upload(Resource):
data = parser.parse_args()
image_data = data.get('file', None)
if not image_data:
return {'message':'An image file contents must be specified'}, 400
return { 'message': 'An image file contents must be specified.' }, 400
return api_helper.ceph_volume_upload(
pool,
@ -3478,9 +3478,9 @@ class API_Storage_Ceph_Snapshot_Root(Resource):
)
@RequestParser([
{ 'name': 'snapshot', 'required': True, 'helpmsg': "A snapshot name must be specified" },
{ 'name': 'volume', 'required': True, 'helpmsg': "A volume name must be specified" },
{ 'name': 'pool', 'required': True, 'helpmsg': "A pool name must be specified" }
{ 'name': 'snapshot', 'required': True, 'helpmsg': "A snapshot name must be specified." },
{ 'name': 'volume', 'required': True, 'helpmsg': "A volume name must be specified." },
{ 'name': 'pool', 'required': True, 'helpmsg': "A pool name must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -3598,7 +3598,7 @@ class API_Storage_Ceph_Snapshot_Element(Resource):
)
@RequestParser([
{ 'name': 'new_name', 'required': True, 'helpmsg': "A new name must be specified" }
{ 'name': 'new_name', 'required': True, 'helpmsg': "A new name must be specified." }
])
@Authenticator
def put(self, pool, volume, snapshot, reqargs):
@ -3791,11 +3791,11 @@ class API_Provisioner_Template_System_Root(Resource):
)
@RequestParser([
{ 'name': 'name', 'required': True, 'helpmsg': "A name must be specified" },
{ 'name': 'vcpus', 'required': True, 'helpmsg': "A vcpus value must be specified" },
{ 'name': 'vram', 'required': True, 'helpmsg': "A vram value in MB must be specified" },
{ 'name': 'serial', 'required': True, 'helpmsg': "A serial value must be specified" },
{ 'name': 'vnc', 'required': True, 'helpmsg': "A vnc value must be specified" },
{ 'name': 'name', 'required': True, 'helpmsg': "A name must be specified." },
{ 'name': 'vcpus', 'required': True, 'helpmsg': "A vcpus value must be specified." },
{ 'name': 'vram', 'required': True, 'helpmsg': "A vram value in MB must be specified." },
{ 'name': 'serial', 'required': True, 'helpmsg': "A serial value must be specified." },
{ 'name': 'vnc', 'required': True, 'helpmsg': "A vnc value must be specified." },
{ 'name': 'vnc_bind' },
{ 'name': 'node_limit' },
{ 'name': 'node_selector' },
@ -3930,10 +3930,10 @@ class API_Provisioner_Template_System_Element(Resource):
)
@RequestParser([
{ 'name': 'vcpus', 'required': True, 'helpmsg': "A vcpus value must be specified" },
{ 'name': 'vram', 'required': True, 'helpmsg': "A vram value in MB must be specified" },
{ 'name': 'serial', 'required': True, 'helpmsg': "A serial value must be specified" },
{ 'name': 'vnc', 'required': True, 'helpmsg': "A vnc value must be specified" },
{ 'name': 'vcpus', 'required': True, 'helpmsg': "A vcpus value must be specified." },
{ 'name': 'vram', 'required': True, 'helpmsg': "A vram value in MB must be specified." },
{ 'name': 'serial', 'required': True, 'helpmsg': "A serial value must be specified." },
{ 'name': 'vnc', 'required': True, 'helpmsg': "A vnc value must be specified." },
{ 'name': 'vnc_bind' },
{ 'name': 'node_limit' },
{ 'name': 'node_selector' },
@ -4196,7 +4196,7 @@ class API_Provisioner_Template_Network_Root(Resource):
)
@RequestParser([
{ 'name': 'name', 'required': True, 'helpmsg': "A template name must be specified" },
{ 'name': 'name', 'required': True, 'helpmsg': "A template name must be specified." },
{ 'name': 'mac_template' }
])
@Authenticator
@ -4346,10 +4346,10 @@ class API_Provisioner_Template_Network_Net_Root(Resource):
if templates:
return templates['networks']
else:
return { 'message': 'Template not found' }, 404
return { 'message': 'Template not found.' }, 404
@RequestParser([
{ 'name': 'vni', 'required': True, 'helpmsg': "A valid VNI must be specified" }
{ 'name': 'vni', 'required': True, 'helpmsg': "A valid VNI must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -4536,7 +4536,7 @@ class API_Provisioner_Template_Storage_Root(Resource):
)
@RequestParser([
{ 'name': 'name', 'required': True, 'helpmsg': "A template name must be specified" }
{ 'name': 'name', 'required': True, 'helpmsg': "A template name must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -4672,11 +4672,11 @@ class API_Provisioner_Template_Storage_Disk_Root(Resource):
if templates:
return templates['disks']
else:
return { 'message': 'Template not found' }, 404
return { 'message': 'Template not found.' }, 404
@RequestParser([
{ 'name': 'disk_id', 'required': True, 'helpmsg': "A disk identifier in sdX or vdX format must be specified" },
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified" },
{ 'name': 'disk_id', 'required': True, 'helpmsg': "A disk identifier in sdX or vdX format must be specified." },
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified." },
{ 'name': 'source_volume' },
{ 'name': 'disk_size' },
{ 'name': 'filesystem' },
@ -4780,7 +4780,7 @@ class API_Provisioner_Template_Storage_Disk_Element(Resource):
abort(404)
@RequestParser([
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified" },
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified." },
{ 'name': 'source_volume' },
{ 'name': 'disk_size' },
{ 'name': 'filesystem' },
@ -4919,8 +4919,8 @@ class API_Provisioner_Userdata_Root(Resource):
)
@RequestParser([
{ 'name': 'name', 'required': True, 'helpmsg': "A name must be specified" },
{ 'name': 'data', 'required': True, 'helpmsg': "A userdata document must be specified" }
{ 'name': 'name', 'required': True, 'helpmsg': "A name must be specified." },
{ 'name': 'data', 'required': True, 'helpmsg': "A userdata document must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -4984,7 +4984,7 @@ class API_Provisioner_Userdata_Element(Resource):
)
@RequestParser([
{ 'name': 'data', 'required': True, 'helpmsg': "A userdata document must be specified" }
{ 'name': 'data', 'required': True, 'helpmsg': "A userdata document must be specified." }
])
@Authenticator
def post(self, userdata, reqargs):
@ -5017,7 +5017,7 @@ class API_Provisioner_Userdata_Element(Resource):
)
@RequestParser([
{ 'name': 'data', 'required': True, 'helpmsg': "A userdata document must be specified" }
{ 'name': 'data', 'required': True, 'helpmsg': "A userdata document must be specified." }
])
@Authenticator
def put(self, userdata, reqargs):
@ -5118,8 +5118,8 @@ class API_Provisioner_Script_Root(Resource):
)
@RequestParser([
{ 'name': 'name', 'required': True, 'helpmsg': "A script name must be specified" },
{ 'name': 'data', 'required': True, 'helpmsg': "A script document must be specified" }
{ 'name': 'name', 'required': True, 'helpmsg': "A script name must be specified." },
{ 'name': 'data', 'required': True, 'helpmsg': "A script document must be specified." }
])
@Authenticator
def post(self, reqargs):
@ -5183,7 +5183,7 @@ class API_Provisioner_Script_Element(Resource):
)
@RequestParser([
{ 'name': 'data', 'required': True, 'helpmsg': "A script document must be specified" }
{ 'name': 'data', 'required': True, 'helpmsg': "A script document must be specified." }
])
@Authenticator
def post(self, script):
@ -5216,7 +5216,7 @@ class API_Provisioner_Script_Element(Resource):
)
@RequestParser([
{ 'name': 'data', 'required': True, 'helpmsg': "A script document must be specified" }
{ 'name': 'data', 'required': True, 'helpmsg': "A script document must be specified." }
])
@Authenticator
def put(self, script, reqargs):
@ -5335,9 +5335,9 @@ class API_Provisioner_OVA_Root(Resource):
)
@RequestParser([
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified" },
{ 'name': 'name', 'required': True, 'helpmsg': "A VM name must be specified" },
{ 'name': 'ova_size', 'required': True, 'helpmsg': "An OVA size must be specified" },
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified." },
{ 'name': 'name', 'required': True, 'helpmsg': "A VM name must be specified." },
{ 'name': 'ova_size', 'required': True, 'helpmsg': "An OVA size must be specified." },
])
@Authenticator
def post(self, reqargs):
@ -5383,7 +5383,7 @@ class API_Provisioner_OVA_Root(Resource):
data = parser.parse_args()
ova_data = data.get('file', None)
if not ova_data:
return {'message':'An OVA file contents must be specified'}, 400
return { 'message': 'An OVA file contents must be specified.' }, 400
return api_ova.upload_ova(
ova_data,
@ -5419,8 +5419,8 @@ class API_Provisioner_OVA_Element(Resource):
)
@RequestParser([
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified" },
{ 'name': 'ova_size', 'required': True, 'helpmsg': "An OVA size must be specified" },
{ 'name': 'pool', 'required': True, 'helpmsg': "A storage pool must be specified." },
{ 'name': 'ova_size', 'required': True, 'helpmsg': "An OVA size must be specified." },
])
@Authenticator
def post(self, ova, reqargs):
@ -5461,7 +5461,7 @@ class API_Provisioner_OVA_Element(Resource):
data = parser.parse_args()
ova_data = data.get('file', None)
if not ova_data:
return {'message':'An OVA file contents must be specified'}, 400
return { 'message': 'An OVA file contents must be specified.' }, 400
return api_ova.upload_ova(
ova_data,
@ -5556,8 +5556,8 @@ class API_Provisioner_Profile_Root(Resource):
)
@RequestParser([
{ 'name': 'name', 'required': True, 'helpmsg': "A profile name must be specified" },
{ 'name': 'profile_type', 'required': True, 'helpmsg': "A profile type must be specified" },
{ 'name': 'name', 'required': True, 'helpmsg': "A profile name must be specified." },
{ 'name': 'profile_type', 'required': True, 'helpmsg': "A profile type must be specified." },
{ 'name': 'system_template' },
{ 'name': 'network_template' },
{ 'name': 'storage_template' },
@ -5672,7 +5672,7 @@ class API_Provisioner_Profile_Element(Resource):
)
@RequestParser([
{ 'name': 'profile_type', 'required': True, 'helpmsg': "A profile type must be specified" },
{ 'name': 'profile_type', 'required': True, 'helpmsg': "A profile type must be specified." },
{ 'name': 'system_template' },
{ 'name': 'network_template' },
{ 'name': 'storage_template' },
@ -5851,8 +5851,8 @@ api.add_resource(API_Provisioner_Profile_Element, '/provisioner/profile/<profile
# /provisioner/create
class API_Provisioner_Create_Root(Resource):
@RequestParser([
{ 'name': 'name', 'required': True, 'helpmsg': "A VM name must be specified" },
{ 'name': 'profile', 'required': True, 'helpmsg': "A profile name must be specified" },
{ 'name': 'name', 'required': True, 'helpmsg': "A VM name must be specified." },
{ 'name': 'profile', 'required': True, 'helpmsg': "A profile name must be specified." },
{ 'name': 'define_vm' },
{ 'name': 'start_vm' }
])