self.logSource="Client"
self.my_furl = None
self.introducer_client = None
- self.init_secret()
+ self.init_lease_secret()
self.init_storage()
self.init_options()
self.add_service(Uploader())
d.addErrback(log.err)
return self._start_page_observers.when_fired()
- def init_secret(self):
+ def init_lease_secret(self):
def make_secret():
- return idlib.b2a(os.urandom(16)) + "\n"
+ return idlib.b2a(os.urandom(hashutil.CRYPTO_VAL_SIZE)) + "\n"
secret_s = self.get_or_create_private_config("secret", make_secret)
- self._secret = idlib.a2b(secret_s)
+ self._lease_secret = idlib.a2b(secret_s)
def init_storage(self):
storedir = os.path.join(self.basedir, self.STOREDIR)
return False
def get_renewal_secret(self):
- return hashutil.my_renewal_secret_hash(self._secret)
+ return hashutil.my_renewal_secret_hash(self._lease_secret)
def get_cancel_secret(self):
- return hashutil.my_cancel_secret_hash(self._secret)
+ return hashutil.my_cancel_secret_hash(self._lease_secret)
def debug_wait_for_client_connections(self, num_clients):
"""Return a Deferred that fires (with None) when we have connections
def setUp(self):
self.sparent = service.MultiService()
- self._secret = itertools.count()
+ self._lease_secret = itertools.count()
def tearDown(self):
return self.sparent.stopService()
ss = self.create("test_create")
def allocate(self, ss, storage_index, sharenums, size):
- renew_secret = hashutil.tagged_hash("blah", "%d" % self._secret.next())
- cancel_secret = hashutil.tagged_hash("blah", "%d" % self._secret.next())
+ renew_secret = hashutil.tagged_hash("blah", "%d" % self._lease_secret.next())
+ cancel_secret = hashutil.tagged_hash("blah", "%d" % self._lease_secret.next())
return ss.remote_allocate_buckets(storage_index,
renew_secret, cancel_secret,
sharenums, size, Referenceable())
sharenums = range(5)
size = 100
- rs0,cs0 = (hashutil.tagged_hash("blah", "%d" % self._secret.next()),
- hashutil.tagged_hash("blah", "%d" % self._secret.next()))
+ rs0,cs0 = (hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()),
+ hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()))
already,writers = ss.remote_allocate_buckets("si0", rs0, cs0,
sharenums, size, canary)
self.failUnlessEqual(len(already), 0)
self.failUnlessEqual(len(leases), 1)
self.failUnlessEqual(set([l[1] for l in leases]), set([rs0]))
- rs1,cs1 = (hashutil.tagged_hash("blah", "%d" % self._secret.next()),
- hashutil.tagged_hash("blah", "%d" % self._secret.next()))
+ rs1,cs1 = (hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()),
+ hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()))
already,writers = ss.remote_allocate_buckets("si1", rs1, cs1,
sharenums, size, canary)
for wb in writers.values():
wb.remote_close()
# take out a second lease on si1
- rs2,cs2 = (hashutil.tagged_hash("blah", "%d" % self._secret.next()),
- hashutil.tagged_hash("blah", "%d" % self._secret.next()))
+ rs2,cs2 = (hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()),
+ hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()))
already,writers = ss.remote_allocate_buckets("si1", rs2, cs2,
sharenums, size, canary)
self.failUnlessEqual(len(already), 5)
# test overlapping uploads
- rs3,cs3 = (hashutil.tagged_hash("blah", "%d" % self._secret.next()),
- hashutil.tagged_hash("blah", "%d" % self._secret.next()))
- rs4,cs4 = (hashutil.tagged_hash("blah", "%d" % self._secret.next()),
- hashutil.tagged_hash("blah", "%d" % self._secret.next()))
+ rs3,cs3 = (hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()),
+ hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()))
+ rs4,cs4 = (hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()),
+ hashutil.tagged_hash("blah", "%d" % self._lease_secret.next()))
already,writers = ss.remote_allocate_buckets("si3", rs3, cs3,
sharenums, size, canary)
self.failUnlessEqual(len(already), 0)
def setUp(self):
self.sparent = service.MultiService()
- self._secret = itertools.count()
+ self._lease_secret = itertools.count()
def tearDown(self):
return self.sparent.stopService()
def test_allocate(self):
ss = self.create("test_allocate")
- self.allocate(ss, "si1", "we1", self._secret.next(),
+ self.allocate(ss, "si1", "we1", self._lease_secret.next(),
set([0,1,2]), 100)
read = ss.remote_slot_readv