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:
parent
31a117e21c
commit
56a9e48163
|
@ -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' }
|
||||
])
|
||||
|
|
|
@ -428,7 +428,7 @@ def vm_define(xml, node, limit, selector, autostart):
|
|||
xml_data = etree.fromstring(xml)
|
||||
new_cfg = etree.tostring(xml_data, pretty_print=True).decode('utf8')
|
||||
except Exception as e:
|
||||
return {'message': 'Error: XML is malformed or incorrect: {}'.format(e)}, 400
|
||||
return { 'message': 'XML is malformed or incorrect: {}'.format(e) }, 400
|
||||
|
||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
||||
retflag, retdata = pvc_vm.define_vm(zk_conn, new_cfg, node, limit, selector, autostart, profile=None)
|
||||
|
@ -510,7 +510,7 @@ def vm_modify(name, restart, xml):
|
|||
xml_data = etree.fromstring(xml)
|
||||
new_cfg = etree.tostring(xml_data, pretty_print=True).decode('utf8')
|
||||
except Exception as e:
|
||||
return {'message': 'Error: XML is malformed or incorrect: {}'.format(e)}, 400
|
||||
return { 'message': 'XML is malformed or incorrect: {}'.format(e) }, 400
|
||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
||||
retflag, retdata = pvc_vm.modify_vm(zk_conn, name, restart, new_cfg)
|
||||
pvc_common.stopZKConnection(zk_conn)
|
||||
|
@ -1334,7 +1334,7 @@ def ceph_volume_upload(pool, volume, data, img_type):
|
|||
# Determine the image conversion options
|
||||
if img_type not in ['raw', 'vmdk', 'qcow2', 'qed', 'vdi', 'vpc']:
|
||||
output = {
|
||||
"message": "ERROR: Image type '{}' is not valid.".format(img_type)
|
||||
"message": "Image type '{}' is not valid.".format(img_type)
|
||||
}
|
||||
retcode = 400
|
||||
return output, retcode
|
||||
|
@ -1346,7 +1346,7 @@ def ceph_volume_upload(pool, volume, data, img_type):
|
|||
# If there's no target, return failure
|
||||
if not retcode or len(retdata) < 1:
|
||||
output = {
|
||||
"message": "ERROR: Target volume '{}' does not exist in pool '{}'.".format(volume, pool)
|
||||
"message": "Target volume '{}' does not exist in pool '{}'.".format(volume, pool)
|
||||
}
|
||||
retcode = 400
|
||||
return output, retcode
|
||||
|
@ -1382,7 +1382,7 @@ def ceph_volume_upload(pool, volume, data, img_type):
|
|||
data.save(dest_blockdev)
|
||||
except:
|
||||
output = {
|
||||
'message': "ERROR: Failed to write image file to volume."
|
||||
'message': "Failed to write image file to volume."
|
||||
}
|
||||
retcode = 400
|
||||
cleanup_maps_and_volumes()
|
||||
|
@ -1440,7 +1440,7 @@ def ceph_volume_upload(pool, volume, data, img_type):
|
|||
data.save(temp_blockdev)
|
||||
except:
|
||||
output = {
|
||||
'message': "ERROR: Failed to write image file to temporary volume."
|
||||
'message': "Failed to write image file to temporary volume."
|
||||
}
|
||||
retcode = 400
|
||||
cleanup_maps_and_volumes()
|
||||
|
@ -1452,7 +1452,7 @@ def ceph_volume_upload(pool, volume, data, img_type):
|
|||
)
|
||||
if retcode:
|
||||
output = {
|
||||
'message': "ERROR: Failed to convert image format from '{}' to 'raw': {}".format(img_type, stderr)
|
||||
'message': "Failed to convert image format from '{}' to 'raw': {}".format(img_type, stderr)
|
||||
}
|
||||
retcode = 400
|
||||
cleanup_maps_and_volumes()
|
||||
|
|
|
@ -111,12 +111,12 @@ def list_ova(limit, is_fuzzy=True):
|
|||
if ova_data:
|
||||
return ova_data, 200
|
||||
else:
|
||||
return {'message': 'No OVAs found'}, 404
|
||||
return { 'message': 'No OVAs found.' }, 404
|
||||
|
||||
def delete_ova(name):
|
||||
ova_data, retcode = list_ova(name, is_fuzzy=False)
|
||||
if retcode != 200:
|
||||
retmsg = { 'message': 'The OVA "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The OVA "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -154,7 +154,7 @@ def delete_ova(name):
|
|||
args = (ova_id,)
|
||||
cur.execute(query, args)
|
||||
|
||||
retmsg = { "message": 'Removed OVA image "{}"'.format(name) }
|
||||
retmsg = { "message": 'Removed OVA image "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to remove OVA "{}": {}'.format(name, e) }
|
||||
|
@ -191,7 +191,7 @@ def upload_ova(ova_data, pool, name, ova_size):
|
|||
pool_free_space_bytes = int(pool_information['stats']['free_bytes'])
|
||||
if ova_size_bytes * 2 >= pool_free_space_bytes:
|
||||
output = {
|
||||
'message': "ERROR: The cluster does not have enough free space ({}) to store the OVA volume ({}).".format(
|
||||
'message': "The cluster does not have enough free space ({}) to store the OVA volume ({}).".format(
|
||||
pvc_ceph.format_bytes_tohuman(pool_free_space_bytes),
|
||||
pvc_ceph.format_bytes_tohuman(ova_size_bytes)
|
||||
)
|
||||
|
@ -230,7 +230,7 @@ def upload_ova(ova_data, pool, name, ova_size):
|
|||
ova_data.save(ova_blockdev)
|
||||
except:
|
||||
output = {
|
||||
'message': "ERROR: Failed to write OVA file to temporary volume."
|
||||
'message': "Failed to write OVA file to temporary volume."
|
||||
}
|
||||
retcode = 400
|
||||
cleanup_ova_maps_and_volumes()
|
||||
|
@ -243,7 +243,7 @@ def upload_ova(ova_data, pool, name, ova_size):
|
|||
members = ova_archive.getmembers()
|
||||
except tarfile.TarError:
|
||||
output = {
|
||||
'message': "ERROR: The uploaded OVA file is not readable."
|
||||
'message': "The uploaded OVA file is not readable."
|
||||
}
|
||||
retcode = 400
|
||||
cleanup_ova_maps_and_volumes()
|
||||
|
@ -328,7 +328,7 @@ def upload_ova(ova_data, pool, name, ova_size):
|
|||
pvc_common.run_os_command('sync')
|
||||
except:
|
||||
output = {
|
||||
'message': "ERROR: Failed to write image file '{}' to temporary volume.".format(disk.get('src'))
|
||||
'message': "Failed to write image file '{}' to temporary volume.".format(disk.get('src'))
|
||||
}
|
||||
retcode = 400
|
||||
cleanup_img_maps()
|
||||
|
@ -405,7 +405,7 @@ def upload_ova(ova_data, pool, name, ova_size):
|
|||
retdata, retcode = provisioner.create_profile(name, 'ova', system_template_name, None, None, userdata=None, script=None, ova=name, arguments=None)
|
||||
|
||||
output = {
|
||||
'message': "Imported OVA image '{}'".format(name)
|
||||
'message': "Imported OVA image '{}'.".format(name)
|
||||
}
|
||||
retcode = 200
|
||||
return output, retcode
|
||||
|
|
|
@ -141,7 +141,7 @@ def list_template_system(limit, is_fuzzy=True):
|
|||
if data:
|
||||
return data, 200
|
||||
else:
|
||||
return {'message': 'No system templates found'}, 404
|
||||
return { 'message': 'No system templates found.' }, 404
|
||||
|
||||
def list_template_network(limit, is_fuzzy=True):
|
||||
"""
|
||||
|
@ -151,7 +151,7 @@ def list_template_network(limit, is_fuzzy=True):
|
|||
if data:
|
||||
return data, 200
|
||||
else:
|
||||
return {'message': 'No network templates found'}, 404
|
||||
return { 'message': 'No network templates found.' }, 404
|
||||
|
||||
def list_template_network_vnis(name):
|
||||
"""
|
||||
|
@ -162,7 +162,7 @@ def list_template_network_vnis(name):
|
|||
if networks:
|
||||
return networks, 200
|
||||
else:
|
||||
return {'message': 'No network template networks found'}, 404
|
||||
return { 'message': 'No network template networks found.' }, 404
|
||||
|
||||
def list_template_storage(limit, is_fuzzy=True):
|
||||
"""
|
||||
|
@ -172,7 +172,7 @@ def list_template_storage(limit, is_fuzzy=True):
|
|||
if data:
|
||||
return data, 200
|
||||
else:
|
||||
return {'message': 'No storage templates found'}, 404
|
||||
return { 'message': 'No storage templates found.' }, 404
|
||||
|
||||
def list_template_storage_disks(name):
|
||||
"""
|
||||
|
@ -183,7 +183,7 @@ def list_template_storage_disks(name):
|
|||
if disks:
|
||||
return disks, 200
|
||||
else:
|
||||
return {'message': 'No storage template disks found'}, 404
|
||||
return { 'message': 'No storage template disks found.' }, 404
|
||||
|
||||
def template_list(limit):
|
||||
system_templates, code = list_template_system(limit)
|
||||
|
@ -203,7 +203,7 @@ def template_list(limit):
|
|||
#
|
||||
def create_template_system(name, vcpu_count, vram_mb, serial=False, vnc=False, vnc_bind=None, node_limit=None, node_selector=None, node_autostart=False, ova=None):
|
||||
if list_template_system(name, is_fuzzy=False)[-1] != 404:
|
||||
retmsg = { 'message': 'The system template "{}" already exists'.format(name) }
|
||||
retmsg = { 'message': 'The system template "{}" already exists.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -213,7 +213,7 @@ def create_template_system(name, vcpu_count, vram_mb, serial=False, vnc=False, v
|
|||
conn, cur = open_database(config)
|
||||
try:
|
||||
cur.execute(query, args)
|
||||
retmsg = { 'message': 'Added new system template "{}"'.format(name) }
|
||||
retmsg = { 'message': 'Added new system template "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create system template "{}": {}'.format(name, e) }
|
||||
|
@ -223,7 +223,7 @@ def create_template_system(name, vcpu_count, vram_mb, serial=False, vnc=False, v
|
|||
|
||||
def create_template_network(name, mac_template=None):
|
||||
if list_template_network(name, is_fuzzy=False)[-1] != 404:
|
||||
retmsg = { 'message': 'The network template "{}" already exists'.format(name) }
|
||||
retmsg = { 'message': 'The network template "{}" already exists.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -232,7 +232,7 @@ def create_template_network(name, mac_template=None):
|
|||
query = "INSERT INTO network_template (name, mac_template) VALUES (%s, %s);"
|
||||
args = (name, mac_template)
|
||||
cur.execute(query, args)
|
||||
retmsg = { 'message': 'Added new network template "{}"'.format(name) }
|
||||
retmsg = { 'message': 'Added new network template "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create network template "{}": {}'.format(name, e) }
|
||||
|
@ -242,7 +242,7 @@ def create_template_network(name, mac_template=None):
|
|||
|
||||
def create_template_network_element(name, vni):
|
||||
if list_template_network(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The network template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The network template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -254,7 +254,7 @@ def create_template_network_element(name, vni):
|
|||
if int(network['vni']) == vni:
|
||||
found_vni = True
|
||||
if found_vni:
|
||||
retmsg = { 'message': 'The VNI "{}" in network template "{}" already exists'.format(vni, name) }
|
||||
retmsg = { 'message': 'The VNI "{}" in network template "{}" already exists.'.format(vni, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -267,17 +267,17 @@ def create_template_network_element(name, vni):
|
|||
query = "INSERT INTO network (network_template, vni) VALUES (%s, %s);"
|
||||
args = (template_id, vni)
|
||||
cur.execute(query, args)
|
||||
retmsg = { 'message': 'Added new network "{}" to network template "{}"'.format(vni, name) }
|
||||
retmsg = { 'message': 'Added new network "{}" to network template "{}".'.format(vni, name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create entry "{}"'.format(vni, e) }
|
||||
retmsg = { 'message': 'Failed to create entry "{}": {}'.format(vni, e) }
|
||||
retcode = 400
|
||||
close_database(conn, cur)
|
||||
return retmsg, retcode
|
||||
|
||||
def create_template_storage(name):
|
||||
if list_template_storage(name, is_fuzzy=False)[-1] != 404:
|
||||
retmsg = { 'message': 'The storage template "{}" already exists'.format(name) }
|
||||
retmsg = { 'message': 'The storage template "{}" already exists.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -286,7 +286,7 @@ def create_template_storage(name):
|
|||
query = "INSERT INTO storage_template (name) VALUES (%s);"
|
||||
args = (name,)
|
||||
cur.execute(query, args)
|
||||
retmsg = { 'message': 'Added new storage template "{}"'.format(name) }
|
||||
retmsg = { 'message': 'Added new storage template "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create entry "{}": {}'.format(name, e) }
|
||||
|
@ -296,7 +296,7 @@ def create_template_storage(name):
|
|||
|
||||
def create_template_storage_element(name, disk_id, pool, source_volume=None, disk_size_gb=None, filesystem=None, filesystem_args=[], mountpoint=None):
|
||||
if list_template_storage(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The storage template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The storage template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -308,7 +308,7 @@ def create_template_storage_element(name, disk_id, pool, source_volume=None, dis
|
|||
if disk['disk_id'] == disk_id:
|
||||
found_disk = True
|
||||
if found_disk:
|
||||
retmsg = { 'message': 'The disk "{}" in storage template "{}" already exists'.format(disk_id, name) }
|
||||
retmsg = { 'message': 'The disk "{}" in storage template "{}" already exists.'.format(disk_id, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -335,10 +335,10 @@ def create_template_storage_element(name, disk_id, pool, source_volume=None, dis
|
|||
fsargs = ''
|
||||
args = (template_id, pool, disk_id, source_volume, disk_size_gb, mountpoint, filesystem, fsargs)
|
||||
cur.execute(query, args)
|
||||
retmsg = { 'message': 'Added new disk "{}" to storage template "{}"'.format(disk_id, name) }
|
||||
retmsg = { 'message': 'Added new disk "{}" to storage template "{}".'.format(disk_id, name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create entry "{}"'.format(disk_id, e) }
|
||||
retmsg = { 'message': 'Failed to create entry "{}": {}'.format(disk_id, e) }
|
||||
retcode = 400
|
||||
close_database(conn, cur)
|
||||
return retmsg, retcode
|
||||
|
@ -348,7 +348,7 @@ def create_template_storage_element(name, disk_id, pool, source_volume=None, dis
|
|||
#
|
||||
def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc=None, vnc_bind=None, node_limit=None, node_selector=None, node_autostart=None):
|
||||
if list_profile(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The system template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The system template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -358,7 +358,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
|||
try:
|
||||
vcpu_count = int(vcpu_count)
|
||||
except:
|
||||
retmsg = { 'message': 'The vcpus value must be an integer' }
|
||||
retmsg = { 'message': 'The vcpus value must be an integer.' }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'vcpu_count', 'data': vcpu_count})
|
||||
|
@ -367,7 +367,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
|||
try:
|
||||
vram_mb = int(vram_mb)
|
||||
except:
|
||||
retmsg = { 'message': 'The vram value must be an integer' }
|
||||
retmsg = { 'message': 'The vram value must be an integer.' }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'vram_mb', 'data': vram_mb})
|
||||
|
@ -376,7 +376,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
|||
try:
|
||||
serial = bool(strtobool(serial))
|
||||
except:
|
||||
retmsg = { 'message': 'The serial value must be a boolean' }
|
||||
retmsg = { 'message': 'The serial value must be a boolean.' }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'serial', 'data': serial})
|
||||
|
@ -385,7 +385,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
|||
try:
|
||||
vnc = bool(strtobool(vnc))
|
||||
except:
|
||||
retmsg = { 'message': 'The vnc value must be a boolean' }
|
||||
retmsg = { 'message': 'The vnc value must be a boolean.' }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'vnc', 'data': vnc})
|
||||
|
@ -403,7 +403,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
|||
try:
|
||||
node_autostart = bool(strtobool(node_autostart))
|
||||
except:
|
||||
retmsg = { 'message': 'The node_autostart value must be a boolean' }
|
||||
retmsg = { 'message': 'The node_autostart value must be a boolean.' }
|
||||
retcode = 400
|
||||
fields.append({'field': 'node_autostart', 'data': node_autostart})
|
||||
|
||||
|
@ -413,7 +413,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
|||
query = "UPDATE system_template SET {} = %s WHERE name = %s;".format(field.get('field'))
|
||||
args = (field.get('data'), name)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Modified system template "{}"'.format(name) }
|
||||
retmsg = { "message": 'Modified system template "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to modify entry "{}": {}'.format(name, e) }
|
||||
|
@ -426,7 +426,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
|||
#
|
||||
def delete_template_system(name):
|
||||
if list_template_system(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The system template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The system template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -435,7 +435,7 @@ def delete_template_system(name):
|
|||
query = "DELETE FROM system_template WHERE name = %s;"
|
||||
args = (name,)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed system template "{}"'.format(name) }
|
||||
retmsg = { "message": 'Removed system template "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
|
@ -445,7 +445,7 @@ def delete_template_system(name):
|
|||
|
||||
def delete_template_network(name):
|
||||
if list_template_network(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The network template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The network template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -461,7 +461,7 @@ def delete_template_network(name):
|
|||
query = "DELETE FROM network_template WHERE name = %s;"
|
||||
args = (name,)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed network template "{}"'.format(name) }
|
||||
retmsg = { "message": 'Removed network template "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
|
@ -471,7 +471,7 @@ def delete_template_network(name):
|
|||
|
||||
def delete_template_network_element(name, vni):
|
||||
if list_template_network(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The network template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The network template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -481,7 +481,7 @@ def delete_template_network_element(name, vni):
|
|||
if network['vni'] == int(vni):
|
||||
found_vni = True
|
||||
if not found_vni:
|
||||
retmsg = { 'message': 'The VNI "{}" in network template "{}" does not exist'.format(vni, name) }
|
||||
retmsg = { 'message': 'The VNI "{}" in network template "{}" does not exist.'.format(vni, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -494,7 +494,7 @@ def delete_template_network_element(name, vni):
|
|||
query = "DELETE FROM network WHERE network_template = %s and vni = %s;"
|
||||
args = (template_id, vni)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed network "{}" from network template "{}"'.format(vni, name) }
|
||||
retmsg = { "message": 'Removed network "{}" from network template "{}".'.format(vni, name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
|
@ -504,7 +504,7 @@ def delete_template_network_element(name, vni):
|
|||
|
||||
def delete_template_storage(name):
|
||||
if list_template_storage(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The storage template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The storage template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -520,7 +520,7 @@ def delete_template_storage(name):
|
|||
query = "DELETE FROM storage_template WHERE name = %s;"
|
||||
args = (name,)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed storage template "{}"'.format(name) }
|
||||
retmsg = { "message": 'Removed storage template "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
|
@ -530,7 +530,7 @@ def delete_template_storage(name):
|
|||
|
||||
def delete_template_storage_element(name, disk_id):
|
||||
if list_template_storage(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The storage template "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The storage template "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -540,7 +540,7 @@ def delete_template_storage_element(name, disk_id):
|
|||
if disk['disk_id'] == disk_id:
|
||||
found_disk = True
|
||||
if not found_disk:
|
||||
retmsg = { 'message': 'The disk "{}" in storage template "{}" does not exist'.format(disk_id, name) }
|
||||
retmsg = { 'message': 'The disk "{}" in storage template "{}" does not exist.'.format(disk_id, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -553,7 +553,7 @@ def delete_template_storage_element(name, disk_id):
|
|||
query = "DELETE FROM storage WHERE storage_template = %s and disk_id = %s;"
|
||||
args = (template_id, disk_id)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed disk "{}" from storage template "{}"'.format(disk_id, name) }
|
||||
retmsg = { "message": 'Removed disk "{}" from storage template "{}".'.format(disk_id, name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
|
@ -590,11 +590,11 @@ def list_userdata(limit, is_fuzzy=True):
|
|||
if data:
|
||||
return data, 200
|
||||
else:
|
||||
return {'message': 'No userdata documents found'}, 404
|
||||
return { 'message': 'No userdata documents found.' }, 404
|
||||
|
||||
def create_userdata(name, userdata):
|
||||
if list_userdata(name, is_fuzzy=False)[-1] != 404:
|
||||
retmsg = { 'message': 'The userdata document "{}" already exists'.format(name) }
|
||||
retmsg = { 'message': 'The userdata document "{}" already exists.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -603,7 +603,7 @@ def create_userdata(name, userdata):
|
|||
query = "INSERT INTO userdata (name, userdata) VALUES (%s, %s);"
|
||||
args = (name, userdata)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Created userdata document "{}"'.format(name) }
|
||||
retmsg = { "message": 'Created userdata document "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create entry "{}": {}'.format(name, e) }
|
||||
|
@ -613,7 +613,7 @@ def create_userdata(name, userdata):
|
|||
|
||||
def update_userdata(name, userdata):
|
||||
if list_userdata(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The userdata "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The userdata "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -625,7 +625,7 @@ def update_userdata(name, userdata):
|
|||
query = "UPDATE userdata SET userdata = %s WHERE id = %s;"
|
||||
args = (userdata, tid)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Updated userdata document "{}"'.format(name) }
|
||||
retmsg = { "message": 'Updated userdata document "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to update entry "{}": {}'.format(name, e) }
|
||||
|
@ -635,7 +635,7 @@ def update_userdata(name, userdata):
|
|||
|
||||
def delete_userdata(name):
|
||||
if list_userdata(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The userdata "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The userdata "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -644,10 +644,10 @@ def delete_userdata(name):
|
|||
query = "DELETE FROM userdata WHERE name = %s;"
|
||||
args = (name,)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed userdata document "{}"'.format(name) }
|
||||
retmsg = { "message": 'Removed userdata document "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}"'.format(name), 'error': str(e) }
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
retcode = 400
|
||||
close_database(conn, cur)
|
||||
return retmsg, retcode
|
||||
|
@ -681,11 +681,11 @@ def list_script(limit, is_fuzzy=True):
|
|||
if data:
|
||||
return data, 200
|
||||
else:
|
||||
return {'message': 'No scripts found'}, 404
|
||||
return { 'message': 'No scripts found.' }, 404
|
||||
|
||||
def create_script(name, script):
|
||||
if list_script(name, is_fuzzy=False)[-1] != 404:
|
||||
retmsg = { 'message': 'The script "{}" already exists'.format(name) }
|
||||
retmsg = { 'message': 'The script "{}" already exists.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -694,7 +694,7 @@ def create_script(name, script):
|
|||
query = "INSERT INTO script (name, script) VALUES (%s, %s);"
|
||||
args = (name, script)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Created provisioning script "{}"'.format(name) }
|
||||
retmsg = { "message": 'Created provisioning script "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create entry "{}": {}'.format(name, e) }
|
||||
|
@ -704,7 +704,7 @@ def create_script(name, script):
|
|||
|
||||
def update_script(name, script):
|
||||
if list_script(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The script "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The script "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -716,7 +716,7 @@ def update_script(name, script):
|
|||
query = "UPDATE script SET script = %s WHERE id = %s;"
|
||||
args = (script, tid)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Updated provisioning script "{}"'.format(name) }
|
||||
retmsg = { "message": 'Updated provisioning script "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to update entry "{}": {}'.format(name, e) }
|
||||
|
@ -726,7 +726,7 @@ def update_script(name, script):
|
|||
|
||||
def delete_script(name):
|
||||
if list_script(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The script "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The script "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -735,10 +735,10 @@ def delete_script(name):
|
|||
query = "DELETE FROM script WHERE name = %s;"
|
||||
args = (name,)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed provisioning script "{}"'.format(name) }
|
||||
retmsg = { "message": 'Removed provisioning script "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}"'.format(name), 'error': str(e) }
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
retcode = 400
|
||||
close_database(conn, cur)
|
||||
return retmsg, retcode
|
||||
|
@ -792,16 +792,16 @@ def list_profile(limit, is_fuzzy=True):
|
|||
if data:
|
||||
return data, 200
|
||||
else:
|
||||
return {'message': 'No profiles found'}, 404
|
||||
return { 'message': 'No profiles found.' }, 404
|
||||
|
||||
def create_profile(name, profile_type, system_template, network_template, storage_template, userdata=None, script=None, ova=None, arguments=None):
|
||||
if list_profile(name, is_fuzzy=False)[-1] != 404:
|
||||
retmsg = { 'message': 'The profile "{}" already exists'.format(name) }
|
||||
retmsg = { 'message': 'The profile "{}" already exists.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
if profile_type not in ['provisioner', 'ova']:
|
||||
retmsg = { 'message': 'A valid profile type (provisioner, ova) must be specified' }
|
||||
retmsg = { 'message': 'A valid profile type (provisioner, ova) must be specified.' }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -811,7 +811,7 @@ def create_profile(name, profile_type, system_template, network_template, storag
|
|||
if template['name'] == system_template:
|
||||
system_template_id = template['id']
|
||||
if not system_template_id:
|
||||
retmsg = { 'message': 'The system template "{}" for profile "{}" does not exist'.format(system_template, name) }
|
||||
retmsg = { 'message': 'The system template "{}" for profile "{}" does not exist.'.format(system_template, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -821,7 +821,7 @@ def create_profile(name, profile_type, system_template, network_template, storag
|
|||
if template['name'] == network_template:
|
||||
network_template_id = template['id']
|
||||
if not network_template_id and profile_type != 'ova':
|
||||
retmsg = { 'message': 'The network template "{}" for profile "{}" does not exist'.format(network_template, name) }
|
||||
retmsg = { 'message': 'The network template "{}" for profile "{}" does not exist.'.format(network_template, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -831,7 +831,7 @@ def create_profile(name, profile_type, system_template, network_template, storag
|
|||
if template['name'] == storage_template:
|
||||
storage_template_id = template['id']
|
||||
if not storage_template_id and profile_type != 'ova':
|
||||
retmsg = { 'message': 'The storage template "{}" for profile "{}" does not exist'.format(storage_template, name) }
|
||||
retmsg = { 'message': 'The storage template "{}" for profile "{}" does not exist.'.format(storage_template, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -863,7 +863,7 @@ def create_profile(name, profile_type, system_template, network_template, storag
|
|||
query = "INSERT INTO profile (name, profile_type, system_template, network_template, storage_template, userdata, script, ova, arguments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s);"
|
||||
args = (name, profile_type, system_template_id, network_template_id, storage_template_id, userdata_id, script_id, ova_id, arguments_formatted)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Created VM profile "{}"'.format(name) }
|
||||
retmsg = { "message": 'Created VM profile "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to create entry "{}": {}'.format(name, e) }
|
||||
|
@ -873,7 +873,7 @@ def create_profile(name, profile_type, system_template, network_template, storag
|
|||
|
||||
def modify_profile(name, profile_type, system_template, network_template, storage_template, userdata, script, ova, arguments=None):
|
||||
if list_profile(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The profile "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The profile "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -881,7 +881,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
|
||||
if profile_type is not None:
|
||||
if profile_type not in ['provisioner', 'ova']:
|
||||
retmsg = { 'message': 'A valid profile type (provisioner, ova) must be specified' }
|
||||
retmsg = { 'message': 'A valid profile type (provisioner, ova) must be specified.' }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'type', 'data': profile_type})
|
||||
|
@ -893,7 +893,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
if template['name'] == system_template:
|
||||
system_template_id = template['id']
|
||||
if not system_template_id:
|
||||
retmsg = { 'message': 'The system template "{}" for profile "{}" does not exist'.format(system_template, name) }
|
||||
retmsg = { 'message': 'The system template "{}" for profile "{}" does not exist.'.format(system_template, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'system_template', 'data': system_template_id})
|
||||
|
@ -905,7 +905,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
if template['name'] == network_template:
|
||||
network_template_id = template['id']
|
||||
if not network_template_id:
|
||||
retmsg = { 'message': 'The network template "{}" for profile "{}" does not exist'.format(network_template, name) }
|
||||
retmsg = { 'message': 'The network template "{}" for profile "{}" does not exist.'.format(network_template, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'network_template', 'data': network_template_id})
|
||||
|
@ -917,7 +917,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
if template['name'] == storage_template:
|
||||
storage_template_id = template['id']
|
||||
if not storage_template_id:
|
||||
retmsg = { 'message': 'The storage template "{}" for profile "{}" does not exist'.format(storage_template, name) }
|
||||
retmsg = { 'message': 'The storage template "{}" for profile "{}" does not exist.'.format(storage_template, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'storage_template', 'data': storage_template_id})
|
||||
|
@ -929,7 +929,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
if template['name'] == userdata:
|
||||
userdata_id = template['id']
|
||||
if not userdata_id:
|
||||
retmsg = { 'message': 'The userdata template "{}" for profile "{}" does not exist'.format(userdata, name) }
|
||||
retmsg = { 'message': 'The userdata template "{}" for profile "{}" does not exist.'.format(userdata, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'userdata', 'data': userdata_id})
|
||||
|
@ -941,7 +941,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
if scr['name'] == script:
|
||||
script_id = scr['id']
|
||||
if not script_id:
|
||||
retmsg = { 'message': 'The script "{}" for profile "{}" does not exist'.format(script, name) }
|
||||
retmsg = { 'message': 'The script "{}" for profile "{}" does not exist.'.format(script, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'script', 'data': script_id})
|
||||
|
@ -953,7 +953,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
if ov['name'] == ova:
|
||||
ova_id = ov['id']
|
||||
if not ova_id:
|
||||
retmsg = { 'message': 'The OVA "{}" for profile "{}" does not exist'.format(ova, name) }
|
||||
retmsg = { 'message': 'The OVA "{}" for profile "{}" does not exist.'.format(ova, name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
fields.append({'field': 'ova', 'data': ova_id})
|
||||
|
@ -971,7 +971,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
query = "UPDATE profile SET {}=%s WHERE name=%s;".format(field.get('field'))
|
||||
args = (field.get('data'), name)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Modified VM profile "{}"'.format(name) }
|
||||
retmsg = { "message": 'Modified VM profile "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to modify entry "{}": {}'.format(name, e) }
|
||||
|
@ -981,7 +981,7 @@ def modify_profile(name, profile_type, system_template, network_template, storag
|
|||
|
||||
def delete_profile(name):
|
||||
if list_profile(name, is_fuzzy=False)[-1] != 200:
|
||||
retmsg = { 'message': 'The profile "{}" does not exist'.format(name) }
|
||||
retmsg = { 'message': 'The profile "{}" does not exist.'.format(name) }
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
|
@ -990,7 +990,7 @@ def delete_profile(name):
|
|||
query = "DELETE FROM profile WHERE name = %s;"
|
||||
args = (name,)
|
||||
cur.execute(query, args)
|
||||
retmsg = { "message": 'Removed VM profile "{}"'.format(name) }
|
||||
retmsg = { "message": 'Removed VM profile "{}".'.format(name) }
|
||||
retcode = 200
|
||||
except Exception as e:
|
||||
retmsg = { 'message': 'Failed to delete entry "{}": {}'.format(name, e) }
|
||||
|
@ -1127,7 +1127,7 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
|
|||
|
||||
# Verify that a VM with this name does not already exist
|
||||
if pvc_vm.searchClusterByName(zk_conn, vm_name):
|
||||
raise ClusterError("A VM with the name '{}' already exists in the cluster".format(vm_name))
|
||||
raise ClusterError("A VM with the name '{}' already exists in the cluster.".format(vm_name))
|
||||
|
||||
# Verify that at least one host has enough free RAM to run the VM
|
||||
_discard, nodes = pvc_node.get_list(zk_conn, None)
|
||||
|
@ -1146,7 +1146,7 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
|
|||
target_node = node['name']
|
||||
# Raise if no node was found
|
||||
if not target_node:
|
||||
raise ClusterError("No ready cluster node contains at least {}+512 MB of free RAM".format(vm_data['system_details']['vram_mb']))
|
||||
raise ClusterError("No ready cluster node contains at least {}+512 MB of free RAM.".format(vm_data['system_details']['vram_mb']))
|
||||
|
||||
print('Selecting target node "{}" with "{}" MB free RAM'.format(target_node, last_free))
|
||||
|
||||
|
@ -1155,7 +1155,7 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
|
|||
for network in vm_data['networks']:
|
||||
vni = str(network['vni'])
|
||||
if not vni in cluster_networks:
|
||||
raise ClusterError('The network VNI "{}" is not present on the cluster'.format(vni))
|
||||
raise ClusterError('The network VNI "{}" is not present on the cluster.'.format(vni))
|
||||
|
||||
print("All configured networks for VM are valid")
|
||||
|
||||
|
@ -1167,12 +1167,12 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
|
|||
volume_data, status = pvc_ceph.getVolumeInformation(zk_conn, volume['pool'], volume['source_volume'])
|
||||
pools[volume['pool']] = volume_data['disk_size_gb']
|
||||
if not status:
|
||||
raise ClusterError('The source volume {}/{} could not be found'.format(volume['pool'], volume['source_volume']))
|
||||
raise ClusterError('The source volume {}/{} could not be found.'.format(volume['pool'], volume['source_volume']))
|
||||
else:
|
||||
volume_data, status = pvc_ceph.getVolumeInformation(zk_conn, volume['pool'], volume['source_volume'])
|
||||
pools[volume['pool']] += volume_data['disk_size_gb']
|
||||
if not status:
|
||||
raise ClusterError('The source volume {}/{} could not be found'.format(volume['pool'], volume['source_volume']))
|
||||
raise ClusterError('The source volume {}/{} could not be found.'.format(volume['pool'], volume['source_volume']))
|
||||
else:
|
||||
if not volume['pool'] in pools:
|
||||
pools[volume['pool']] = volume['disk_size_gb']
|
||||
|
@ -1182,12 +1182,12 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
|
|||
for pool in pools:
|
||||
pool_information = pvc_ceph.getPoolInformation(zk_conn, pool)
|
||||
if not pool_information:
|
||||
raise ClusterError('Pool "{}" is not present on the cluster'.format(pool))
|
||||
raise ClusterError('Pool "{}" is not present on the cluster.'.format(pool))
|
||||
pool_free_space_gb = int(pool_information['stats']['free_bytes'] / 1024 / 1024 / 1024)
|
||||
pool_vm_usage_gb = int(pools[pool])
|
||||
|
||||
if pool_vm_usage_gb >= pool_free_space_gb:
|
||||
raise ClusterError('Pool "{}" has only {} GB free and VM requires {} GB'.format(pool, pool_free_space_gb, pool_vm_usage_gb))
|
||||
raise ClusterError('Pool "{}" has only {} GB free and VM requires {} GB.'.format(pool, pool_free_space_gb, pool_vm_usage_gb))
|
||||
|
||||
print("There is enough space on cluster to store VM volumes")
|
||||
|
||||
|
@ -1236,7 +1236,7 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
|
|||
|
||||
# Verify that the install() function is valid
|
||||
if not "install" in dir(installer_script):
|
||||
raise ProvisioningError("Specified script does not contain an install() function")
|
||||
raise ProvisioningError("Specified script does not contain an install() function.")
|
||||
|
||||
print("Provisioning script imported successfully")
|
||||
|
||||
|
@ -1388,12 +1388,12 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
|
|||
success, message = pvc_ceph.clone_volume(zk_conn, volume['pool'], "{}_{}".format(vm_name, volume['disk_id']), volume['source_volume'])
|
||||
print(message)
|
||||
if not success:
|
||||
raise ClusterError('Failed to clone volume "{}" to "{}"'.format(volume['source_volume'], volume['disk_id']))
|
||||
raise ClusterError('Failed to clone volume "{}" to "{}".'.format(volume['source_volume'], volume['disk_id']))
|
||||
else:
|
||||
success, message = pvc_ceph.add_volume(zk_conn, volume['pool'], "{}_{}".format(vm_name, volume['disk_id']), "{}G".format(volume['disk_size_gb']))
|
||||
print(message)
|
||||
if not success:
|
||||
raise ClusterError('Failed to create volume "{}"'.format(volume['disk_id']))
|
||||
raise ClusterError('Failed to create volume "{}".'.format(volume['disk_id']))
|
||||
|
||||
# Phase 7 - disk mapping
|
||||
# * Map each volume to the local host in order
|
||||
|
|
Loading…
Reference in New Issue