Beispiel #1
0
def renew_lease(renewal_secret, storage_index, server):
    """
    Renew the lease on the shares in one storage index on one server.

    :param renewal_secret: A seed for the renewal secret hash calculation for
        any leases which need to be renewed.

    :param bytes storage_index: The storage index to operate on.

    :param StorageServer server: The storage server to operate on.

    :return Deferred: A Deferred that fires when the lease has been renewed.
    """
    # See allmydata/immutable/checker.py, _get_renewal_secret
    renew_secret = bucket_renewal_secret_hash(
        file_renewal_secret_hash(
            renewal_secret,
            storage_index,
        ),
        server.get_lease_seed(),
    )
    return server.renew_lease(
        storage_index,
        renew_secret,
    )
Beispiel #2
0
def _dump_secrets(storage_index, secret, nodeid, out):
    from allmydata.util import hashutil
    from allmydata.util import base32

    if secret:
        crs = hashutil.my_renewal_secret_hash(secret)
        print(" client renewal secret:",
              str(base32.b2a(crs), "ascii"),
              file=out)
        frs = hashutil.file_renewal_secret_hash(crs, storage_index)
        print(" file renewal secret:", str(base32.b2a(frs), "ascii"), file=out)
        if nodeid:
            renew = hashutil.bucket_renewal_secret_hash(frs, nodeid)
            print(" lease renewal secret:",
                  str(base32.b2a(renew), "ascii"),
                  file=out)
        ccs = hashutil.my_cancel_secret_hash(secret)
        print(" client cancel secret:",
              str(base32.b2a(ccs), "ascii"),
              file=out)
        fcs = hashutil.file_cancel_secret_hash(ccs, storage_index)
        print(" file cancel secret:", str(base32.b2a(fcs), "ascii"), file=out)
        if nodeid:
            cancel = hashutil.bucket_cancel_secret_hash(fcs, nodeid)
            print(" lease cancel secret:",
                  str(base32.b2a(cancel), "ascii"),
                  file=out)
Beispiel #3
0
def _dump_secrets(storage_index, secret, nodeid, out):
    from allmydata.util import hashutil
    from allmydata.util import base32

    if secret:
        crs = hashutil.my_renewal_secret_hash(secret)
        print >>out, " client renewal secret:", base32.b2a(crs)
        frs = hashutil.file_renewal_secret_hash(crs, storage_index)
        print >>out, " file renewal secret:", base32.b2a(frs)
        if nodeid:
            renew = hashutil.bucket_renewal_secret_hash(frs, nodeid)
            print >>out, " lease renewal secret:", base32.b2a(renew)
        ccs = hashutil.my_cancel_secret_hash(secret)
        print >>out, " client cancel secret:", base32.b2a(ccs)
        fcs = hashutil.file_cancel_secret_hash(ccs, storage_index)
        print >>out, " file cancel secret:", base32.b2a(fcs)
        if nodeid:
            cancel = hashutil.bucket_cancel_secret_hash(fcs, nodeid)
            print >>out, " lease cancel secret:", base32.b2a(cancel)
Beispiel #4
0
 def _get_renewal_secret(self, seed):
     return bucket_renewal_secret_hash(self.file_renewal_secret, seed)
Beispiel #5
0
 def rs(self, i, serverid):
     return hashutil.bucket_renewal_secret_hash(str(i), serverid)
Beispiel #6
0
 def get_renewal_secret(self, server):
     crs = self._secret_holder.get_renewal_secret()
     frs = hashutil.file_renewal_secret_hash(crs, self._storage_index)
     lease_seed = server.get_lease_seed()
     assert len(lease_seed) == 20
     return hashutil.bucket_renewal_secret_hash(frs, lease_seed)
Beispiel #7
0
 def _get_renewal_secret(self, seed):
     return bucket_renewal_secret_hash(self.file_renewal_secret, seed)
Beispiel #8
0
 def get_renewal_secret(self, peerid):
     assert len(peerid) == 20
     crs = self._secret_holder.get_renewal_secret()
     frs = hashutil.file_renewal_secret_hash(crs, self._storage_index)
     return hashutil.bucket_renewal_secret_hash(frs, peerid)
 def rs(self, i, serverid):
     return hashutil.bucket_renewal_secret_hash(b"%d" % (i,), serverid)
Beispiel #10
0
 def _get_renewal_secret(self, peerid):
     return bucket_renewal_secret_hash(self.file_renewal_secret, peerid)
Beispiel #11
0
 def get_renewal_secret(self, peerid):
     assert len(peerid) == 20
     crs = self._secret_holder.get_renewal_secret()
     frs = hashutil.file_renewal_secret_hash(crs, self._storage_index)
     return hashutil.bucket_renewal_secret_hash(frs, peerid)
Beispiel #12
0
 def get_renewal_secret(self, server):
     crs = self._secret_holder.get_renewal_secret()
     frs = hashutil.file_renewal_secret_hash(crs, self._storage_index)
     lease_seed = server.get_lease_seed()
     assert len(lease_seed) == 20
     return hashutil.bucket_renewal_secret_hash(frs, lease_seed)
Beispiel #13
0
 def rs(self, i, serverid):
     return hashutil.bucket_renewal_secret_hash(str(i), serverid)