Nir Soffer has uploaded a new change for review.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
fc-scan: Use utilities from vdsm library.
Replace low level threading code with simpler concurrent.tmap() call and duplicate monotonic_time() with utils.monotonic_time().
Change-Id: Ic48748d6a43d41e034e16cb4f636ebe627881590 Signed-off-by: Nir Soffer nsoffer@redhat.com --- M vdsm/storage/fc-scan 1 file changed, 24 insertions(+), 46 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/38466/1
diff --git a/vdsm/storage/fc-scan b/vdsm/storage/fc-scan index 344345d..c746ea4 100755 --- a/vdsm/storage/fc-scan +++ b/vdsm/storage/fc-scan @@ -38,43 +38,11 @@ import logging import os import sys -import threading + +from vdsm import concurrent +from vdsm import utils
log = logging.getLogger("fc-scan") - - -class Scan(object): - - def __init__(self, host): - self.host = host - self.succeeded = False - self.thread = None - - def start(self): - self.thread = threading.Thread(target=self.run) - self.thread.daemon = True - self.thread.start() - - def wait(self): - self.thread.join() - - def run(self): - try: - path = "/sys/class/scsi_host/%s/scan" % self.host - log.debug("Scanning %s", path) - start = monotonic_time() - fd = os.open(path, os.O_WRONLY) - try: - os.write(fd, "- - -") - finally: - os.close(fd) - self.succeeded = True - elapsed = monotonic_time() - start - log.debug("Scanned %s in %.2f seconds", path, elapsed) - except OSError as e: - log.error("Scanning %s failed: %s", path, e) - except Exception: - log.exception("Scanning %s failed", path)
def main(args): @@ -93,22 +61,32 @@ log.debug("No fc_host found") return 0
- scans = [] - - for host in hosts: - s = Scan(host) - s.start() - scans.append(s) - - for s in scans: - s.wait() + scans = concurrent.tmap(scan_host, hosts)
if not all(s.succeeded for s in scans): return 1
+ return 0
-def monotonic_time(): - return os.times()[4] + +def scan_host(name): + try: + path = "/sys/class/scsi_host/%s/scan" % name + log.debug("Scanning %s", path) + start = utils.monotonic_time() + fd = os.open(path, os.O_WRONLY) + try: + os.write(fd, "- - -") + finally: + os.close(fd) + elapsed = utils.monotonic_time() - start + log.debug("Scanned %s in %.2f seconds", path, elapsed) + except OSError as e: + log.error("Scanning %s failed: %s", path, e) + raise + except Exception: + log.exception("Scanning %s failed", path) + raise
if __name__ == '__main__':
automation@ovirt.org has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Nir Soffer has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 1:
Tested with iscsi Needs testing with fc storage.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 1:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16366/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/16537/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_el_gerrit/15566/ : FAILURE
automation@ovirt.org has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 2:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16702/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/16874/ : SUCCESS
Francesco Romani has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 2:
Seems fine as log as we are allowed to use VDSM library code in here. Are we? (just asking, I don't know the policy here)
Nir Soffer has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 2:
Since this is part of vdsm, it seems wasteful to avoid using vdsm infrastructure.
If we like to make this more general tool separate from vdsm, we will probably rewrite this in C, so sharing code with vdsm will not be an option :-)
Francesco Romani has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 2: Code-Review+1
Agreed, so +1
Allon Mureinik has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 2: Code-Review+1
automation@ovirt.org has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 3:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17002/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 3:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17176/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 3:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17002/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17176/ : SUCCESS
Adam Litke has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 3: Code-Review+1
Fred Rolland has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 3: Code-Review+1
automation@ovirt.org has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 4:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17142/
Nir Soffer has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 4:
This version simplify and improve error handling based on error handling changes in tmap.
- rescan_host handle now only expect errors - try except blocks are minimized to code that is expected to fail
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 4:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17316/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 4:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17142/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17316/ : FAILURE
Yaniv Bronhaim has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 4: Code-Review+1
Jenkins CI RO has abandoned this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Abandoned
Abandoned due to no activity - please restore if still relevant
gerrit-hooks has posted comments on this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Patch Set 4:
* Update tracker: IGNORE, no Bug-Url found
Nir Soffer has restored this change.
Change subject: fc-scan: Use utilities from vdsm library. ......................................................................
Restored
vdsm-patches@lists.fedorahosted.org