Commit a3794938 authored by Sebastien Gougeaud's avatar Sebastien Gougeaud Committed by Thomas Leibovici
Browse files

cli: add daemon notify when adding a dir (dummy device)



A faulty behavior could happen when formatting directories if the daemon
did not add their corresponding dummy devices. Now, if a directory is
added, the daemon is notified.

Also fix missing layout in test_resource_availability.sh. This cannot be
done in another patch, as the tests need both modifications to succeed.

Change-Id: I8ed551389fb548a6ceb523cb6dce68d4b84ea47b
Signed-off-by: default avatarSebastien Gougeaud <sebastien.gougeaud@cea.fr>
Reviewed-on: https://gerrit.ccc.ocre.cea.fr/gerrit/6788


Reviewed-by: Linter
Tested-by: default avatarJenkins s8open_nr <s8open_nr@ccc.ocre.cea.fr>
Reviewed-by: default avatarQuentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: default avatarThomas Leibovici <thomas.leibovici@cea.fr>
parent 644e18ef
......@@ -908,21 +908,28 @@ class DirOptHandler(MediaOptHandler):
resources = self.params.get('res')
keep_locked = not self.params.get('unlock')
tags = self.params.get('tags', [])
adm = AdminClient()
try:
adm.init(lrs_required=False)
for path in resources:
# Remove any trailing slash
path = path.rstrip('/')
for path in resources:
# Remove any trailing slash
path = path.rstrip('/')
try:
self.client.media.add(self.family, 'POSIX', None, path,
locked=keep_locked, tags=tags)
# Add device unlocked and rely on media locking
self.client.devices.add(self.family, path, locked=False)
except EnvironmentError as err:
self.logger.error("Cannot add directory: %s",
env_error_format(err))
sys.exit(os.EX_DATAERR)
_, serial = self.client.devices.add(self.family, path,
locked=False)
adm.device_add(self.family, serial)
self.logger.debug("Added directory '%s'", path)
self.logger.debug("Added directory '%s'", path)
adm.fini()
except EnvironmentError as err:
self.logger.error("Cannot add directory: %s", env_error_format(err))
sys.exit(os.EX_DATAERR)
self.logger.info("Added %d dir(s) successfully", len(resources))
......
......@@ -160,7 +160,8 @@ function put_tape_raid
# TODO: to uncomment once the admin lock on device is considered
# when selecting one
# $LOG_VALG $phobos drive lock ${DRIVE_ARRAY[0]}
# $LOG_VALG $phobos put /etc/hosts ${id}.2 &&
# PHOBOS_STORE_default_layout=raid1 $LOG_VALG $phobos put \
# /etc/hosts ${id}.2 &&
# error "Should not be able to put objects with 1/2 unlocked devices"
return 0
......@@ -187,7 +188,7 @@ function put_dir_raid
# resources are available
$LOG_VALG $phobos dir unlock ${DIR_ARRAY[0]}
$LOG_VALG $phobos put /etc/hosts $id ||
PHOBOS_STORE_default_layout=raid1 $LOG_VALG $phobos put /etc/hosts $id ||
error "Put with available media should have worked"
return 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment