Skip to content

Commit f0e779e

Browse files
committed
fix: update LG_RESERVATION_ID to LG_RESERVATION
1 parent a5d8bff commit f0e779e

5 files changed

Lines changed: 23 additions & 12 deletions

File tree

doc/man/client.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ LG_PLACE
2525
~~~~~~~~
2626
This variable can be used to specify a place without using the ``-p`` option, the ``-p`` option overrides it.
2727

28-
LG_RESERVATION_ID (previously LG_TOKEN)
29-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28+
LG_RESERVATION (previously LG_TOKEN)
29+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3030
This variable can be used to specify a reservation for the ``wait`` command and
3131
for the ``+`` place expansion.
3232

doc/usage.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,27 @@ can lock that place.
117117
timeout: 2019-08-06 12:59:11.840780
118118
$ labgrid-client -p +SP37P5OQRU console
119119
120+
121+
.. note::
122+
123+
Reservation tokens are now called reservation IDs.
124+
As part of this terminology change, ``LG_TOKEN`` has been renamed to
125+
``LG_RESERVATION``, and ``labgrid-client reserve --shell`` now exports
126+
``LG_RESERVATION``.
127+
Command output now uses ``id`` instead of ``token``.
128+
The legacy ``LG_TOKEN`` variable remains accepted as input for backwards
129+
compatibility, but scripts should migrate to ``LG_RESERVATION``.
130+
120131
When using reservation in a CI job or to save some typing, the ``labgrid-client
121132
reserve`` command supports a ``--shell`` command to print code for evaluating
122133
in the shell.
123-
This sets the ``LG_RESERVATION_ID`` environment variable, which is then automatically
134+
This sets the ``LG_RESERVATION`` environment variable, which is then automatically
124135
used by ``wait`` and expanded via ``-p +``.
125136

126137
.. code-block:: bash
127138
128139
$ eval `labgrid-client reserve --shell board=imx6-foo`
129-
$ echo $LG_RESERVATION_ID
140+
$ echo $LG_RESERVATION
130141
ZDMZJZNLBF
131142
$ labgrid-client wait
132143
owner: rettich/jlu

labgrid/remote/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def _match_places(self, pattern):
443443
if pattern.startswith("+"):
444444
reservation_id = pattern[1:]
445445
if not reservation_id:
446-
reservation_id = os.environ.get("LG_RESERVATION_ID", None)
446+
reservation_id = os.environ.get("LG_RESERVATION", None)
447447
if not reservation_id:
448448
reservation_id = os.environ.get("LG_TOKEN", None) # For backwards compatibility
449449
if not reservation_id:
@@ -1574,7 +1574,7 @@ async def create_reservation(self):
15741574

15751575
res = Reservation.from_pb2(response.reservation)
15761576
if self.args.shell:
1577-
print(f"export LG_RESERVATION_ID={res.id}")
1577+
print(f"export LG_RESERVATION={res.id}")
15781578
else:
15791579
print(f"Reservation '{res.id}':")
15801580
res.show(level=1)
@@ -2259,7 +2259,7 @@ def main():
22592259
state = os.environ.get("STATE", None)
22602260
state = os.environ.get("LG_STATE", state)
22612261
initial_state = os.environ.get("LG_INITIAL_STATE", None)
2262-
reservation_id = os.environ.get("LG_RESERVATION_ID", None)
2262+
reservation_id = os.environ.get("LG_RESERVATION", None)
22632263
if reservation_id is None:
22642264
reservation_id = os.environ.get("LG_TOKEN", None) # For backwards compatibility
22652265

man/labgrid-client.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ Various labgrid\-client commands use the following environment variable:
11271127
.SS LG_PLACE
11281128
.sp
11291129
This variable can be used to specify a place without using the \fB\-p\fP option, the \fB\-p\fP option overrides it.
1130-
.SS LG_RESERVATION_ID (previously LG_TOKEN)
1130+
.SS LG_RESERVATION (previously LG_TOKEN)
11311131
.sp
11321132
This variable can be used to specify a reservation for the \fBwait\fP command and
11331133
for the \fB+\fP place expansion.

tests/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@ def test_reservation(place_acquire, tmpdir):
361361
spawn.expect(pexpect.EOF)
362362
spawn.close()
363363
assert spawn.exitstatus == 0, spawn.before.strip()
364-
m = re.search(rb"^export LG_RESERVATION_ID=(\S+)$", spawn.before.replace(b'\r\n', b'\n'), re.MULTILINE)
364+
m = re.search(rb"^export LG_RESERVATION=(\S+)$", spawn.before.replace(b'\r\n', b'\n'), re.MULTILINE)
365365
assert m is not None, spawn.before.strip()
366366
reservation_id = m.group(1)
367367

368368
env = os.environ.copy()
369-
# Use LG_TOKEN in this test to validate backwards compatibility. Other tests use LG_RESERVATION_ID.
369+
# Use LG_TOKEN in this test to validate backwards compatibility. Other tests use LG_RESERVATION.
370370
env['LG_TOKEN'] = reservation_id.decode('ASCII')
371371

372372
with pexpect.spawn('python -m labgrid.remote.client reservations') as spawn:
@@ -569,14 +569,14 @@ def test_reservation_custom_config(place, exporter, tmpdir):
569569
spawn.expect(pexpect.EOF)
570570
spawn.close()
571571
assert spawn.exitstatus == 0, spawn.before.strip()
572-
m = re.search(rb"^export LG_RESERVATION_ID=(\S+)$", spawn.before.replace(b'\r\n', b'\n'), re.MULTILINE)
572+
m = re.search(rb"^export LG_RESERVATION=(\S+)$", spawn.before.replace(b'\r\n', b'\n'), re.MULTILINE)
573573
s = re.search(rb"^Selected role$", spawn.before.replace(b'\r\n', b'\n'), re.MULTILINE)
574574
assert m is not None, spawn.before.strip()
575575
assert s is None, spawn.before.strip()
576576
reservation_id = m.group(1)
577577

578578
env = os.environ.copy()
579-
env['LG_RESERVATION_ID'] = reservation_id.decode('ASCII')
579+
env['LG_RESERVATION'] = reservation_id.decode('ASCII')
580580

581581
with pexpect.spawn(f'python -m labgrid.remote.client -c {p} -p + lock', env=env) as spawn:
582582
spawn.expect("acquired place test")

0 commit comments

Comments
 (0)