コード例 #1
0
def find_shares(options):
    """Given a storage index and a list of node directories, emit a list of
    all matching shares to stdout, one per line. For example:

     find-shares.py 44kai1tui348689nrw8fjegc8c ~/testnet/node-*

    gives:

    /home/warner/testnet/node-1/storage/shares/44k/44kai1tui348689nrw8fjegc8c/5
    /home/warner/testnet/node-1/storage/shares/44k/44kai1tui348689nrw8fjegc8c/9
    /home/warner/testnet/node-2/storage/shares/44k/44kai1tui348689nrw8fjegc8c/2
    """
    from allmydata.storage.server import si_a2b, storage_index_to_dir
    from allmydata.util.encodingutil import listdir_unicode, quote_local_unicode_path

    out = options.stdout
    sharedir = storage_index_to_dir(si_a2b(options.si_s.encode("utf-8")))
    for d in options.nodedirs:
        d = os.path.join(d, "storage", "shares", sharedir)
        if os.path.exists(d):
            for shnum in listdir_unicode(d):
                print(quote_local_unicode_path(os.path.join(d, shnum),
                                               quotemarks=False),
                      file=out)

    return 0
コード例 #2
0
ファイル: no_network.py プロジェクト: trel/tahoe-lafs
 def find_uri_shares(self, uri):
     si = tahoe_uri.from_string(uri).get_storage_index()
     prefixdir = storage_index_to_dir(si)
     shares = []
     for i, ss in self.g.servers_by_number.items():
         serverid = ss.my_nodeid
         basedir = os.path.join(ss.sharedir, prefixdir)
         if not os.path.exists(basedir):
             continue
         for f in os.listdir(basedir):
             try:
                 shnum = int(f)
                 shares.append((shnum, serverid, os.path.join(basedir, f)))
             except ValueError:
                 pass
     return sorted(shares)
コード例 #3
0
 def find_uri_shares(self, uri):
     si = tahoe_uri.from_string(uri).get_storage_index()
     prefixdir = storage_index_to_dir(si)
     shares = []
     for i,ss in self.g.servers_by_number.items():
         serverid = ss.my_nodeid
         basedir = os.path.join(ss.sharedir, prefixdir)
         if not os.path.exists(basedir):
             continue
         for f in os.listdir(basedir):
             try:
                 shnum = int(f)
                 shares.append((shnum, serverid, os.path.join(basedir, f)))
             except ValueError:
                 pass
     return sorted(shares)
コード例 #4
0
ファイル: test_checker.py プロジェクト: zhutony/tahoe-lafs
 def copy_share_to_server(self, uri, share_number, server_number):
     ss = self.g.servers_by_number[server_number]
     # Copy share i from the directory associated with the first
     # storage server to the directory associated with this one.
     assert self.g, "I tried to find a grid at self.g, but failed"
     assert self.shares, "I tried to find shares at self.shares, but failed"
     old_share_location = self.shares[share_number][2]
     new_share_location = os.path.join(ss.storedir, "shares")
     si = tahoe_uri.from_string(self.uri).get_storage_index()
     new_share_location = os.path.join(new_share_location,
                                       storage_index_to_dir(si))
     if not os.path.exists(new_share_location):
         os.makedirs(new_share_location)
     new_share_location = os.path.join(new_share_location,
                                       str(share_number))
     if old_share_location != new_share_location:
         shutil.copy(old_share_location, new_share_location)
     shares = self.find_uri_shares(uri)
     # Make sure that the storage server has the share.
     self.failUnless((share_number, ss.my_nodeid,
                      new_share_location) in shares)
コード例 #5
0
ファイル: test_checker.py プロジェクト: BenKoerber/tahoe-lafs
 def copy_share_to_server(self, uri, share_number, server_number):
     ss = self.g.servers_by_number[server_number]
     # Copy share i from the directory associated with the first
     # storage server to the directory associated with this one.
     assert self.g, "I tried to find a grid at self.g, but failed"
     assert self.shares, "I tried to find shares at self.shares, but failed"
     old_share_location = self.shares[share_number][2]
     new_share_location = os.path.join(ss.storedir, "shares")
     si = tahoe_uri.from_string(self.uri).get_storage_index()
     new_share_location = os.path.join(new_share_location,
                                       storage_index_to_dir(si))
     if not os.path.exists(new_share_location):
         os.makedirs(new_share_location)
     new_share_location = os.path.join(new_share_location,
                                       str(share_number))
     if old_share_location != new_share_location:
         shutil.copy(old_share_location, new_share_location)
     shares = self.find_uri_shares(uri)
     # Make sure that the storage server has the share.
     self.failUnless((share_number, ss.my_nodeid, new_share_location)
                     in shares)
コード例 #6
0
ファイル: debug.py プロジェクト: drewp/tahoe-lafs
def find_shares(options):
    """Given a storage index and a list of node directories, emit a list of
    all matching shares to stdout, one per line. For example:

     find-shares.py 44kai1tui348689nrw8fjegc8c ~/testnet/node-*

    gives:

    /home/warner/testnet/node-1/storage/shares/44k/44kai1tui348689nrw8fjegc8c/5
    /home/warner/testnet/node-1/storage/shares/44k/44kai1tui348689nrw8fjegc8c/9
    /home/warner/testnet/node-2/storage/shares/44k/44kai1tui348689nrw8fjegc8c/2
    """
    from allmydata.storage.server import si_a2b, storage_index_to_dir
    from allmydata.util.encodingutil import listdir_unicode

    out = options.stdout
    sharedir = storage_index_to_dir(si_a2b(options.si_s))
    for d in options.nodedirs:
        d = os.path.join(d, "storage/shares", sharedir)
        if os.path.exists(d):
            for shnum in listdir_unicode(d):
                print >>out, os.path.join(d, shnum)

    return 0