예제 #1
0
 def _remove_scsi_symlinks(self, devices_names):
     devices = ['/dev/' + dev for dev in devices_names]
     links = glob.glob('/dev/disk/by-id/scsi-*')
     unlink = [link for link in links
               if os.path.realpath(link) in devices]
     if unlink:
         priv_rootwrap.unlink_root(no_errors=True, *unlink)
예제 #2
0
    def _remove_scsi_symlinks(self, devices_names):
        devices = ['/dev/' + dev for dev in devices_names]
        links = glob.glob('/dev/disk/by-id/scsi-*')
        unlink = []
        for link in links:
            try:
                if os.path.realpath(link) in devices:
                    unlink.append(link)
            except OSError:
                # A race condition in Python's posixpath:realpath just occurred
                # so we can ignore it because the file was just removed between
                # a check if file exists and a call to os.readlink
                continue

        if unlink:
            priv_rootwrap.unlink_root(no_errors=True, *unlink)
예제 #3
0
 def test_unlink_root(self, unlink_mock):
     links = ['/dev/disk/by-id/link1', '/dev/disk/by-id/link2']
     priv_rootwrap.unlink_root(*links, no_errors=True)
     unlink_mock.assert_has_calls([mock.call(links[0]),
                                   mock.call(links[1])])
예제 #4
0
 def _remove_scsi_symlinks(self, devices_names):
     devices = ['/dev/' + dev for dev in devices_names]
     links = glob.glob('/dev/disk/by-id/scsi-*')
     unlink = [link for link in links if os.path.realpath(link) in devices]
     if unlink:
         priv_rootwrap.unlink_root(no_errors=True, *unlink)
예제 #5
0
 def test_unlink_root(self, unlink_mock):
     links = ['/dev/disk/by-id/link1', '/dev/disk/by-id/link2']
     priv_rootwrap.unlink_root(*links, no_errors=True)
     unlink_mock.assert_has_calls([mock.call(links[0]),
                                   mock.call(links[1])])