def create_newer(self): """Creates a new Lease which is newer than this Lease. Returns: A new Lease object where self.compare(returned_lease) would return OLDER. """ incr_lease_proto = LeaseProto() incr_lease_proto.CopyFrom(self.lease_proto) incr_lease_proto.sequence[-1] = self.lease_proto.sequence[-1] + 1 return Lease(incr_lease_proto)
def create_sublease(self): """Creates a sublease of this lease. Returns: A new Lease object where self.compare(returned_lease) would return SUB_LEASE. """ sub_lease_proto = LeaseProto() sub_lease_proto.CopyFrom(self.lease_proto) sub_lease_proto.sequence.append(0) return Lease(sub_lease_proto)
def create_sublease(self, client_name=None): """Creates a sublease of this lease. Args: client_name (string): Optional argument to pass a client name to be appended to the new lease's set of clients which have used it. Returns: A new Lease object where self.compare(returned_lease) would return SUB_LEASE. """ sub_lease_proto = LeaseProto() sub_lease_proto.CopyFrom(self.lease_proto) sub_lease_proto.sequence.append(0) if client_name is not None: sub_lease_proto.client_names.append(client_name) return Lease(sub_lease_proto)