def _create_drive(self, name, size):
"""
Actually creates a ceph rbd image of a given size.
:param name: string -> drive name
:param size: int -> drive size in GB
:return: int -> return code of 'run'
"""
mb_size = 1024 * int(size)
try:
self.run_on_first_node(
'rbd {0} create {1} --size={2} --image-format=2'.format(
get_ceph_credentials(), name, mb_size
)
)
except NodeCommandError:
# FIXME: we use warning for all possible errors. This is wrong,
# we should check whether retcode == 17 (already exists case) and
# print correct message with appropriate level
current_app.logger.warning(
u"Failed to create CEPH drive '%s', size = %s. "
u"Possibly it's already exists or other error has happened",
name, size)
return 1
return 0
评论列表
文章目录