Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 5c3125a

Browse files
committed
Add status field to jmp admin get exporter
1 parent 777786e commit 5c3125a

2 files changed

Lines changed: 52 additions & 7 deletions

File tree

  • packages

packages/jumpstarter-cli-admin/jumpstarter_cli_admin/get_test.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ def test_get_clients(_load_kube_config_mock, list_clients_mock: AsyncMock):
301301
kind="Exporter",
302302
metadata=V1ObjectMeta(name="test", namespace="testing", creation_timestamp="2024-01-01T21:00:00Z"),
303303
status=V1Alpha1ExporterStatus(
304-
endpoint="grpc://example.com:443", credential=V1ObjectReference(name="test-credential"), devices=[]
304+
endpoint="grpc://example.com:443",
305+
credential=V1ObjectReference(name="test-credential"),
306+
devices=[],
307+
exporter_status="Available",
305308
),
306309
)
307310

@@ -318,7 +321,9 @@ def test_get_clients(_load_kube_config_mock, list_clients_mock: AsyncMock):
318321
"name": "test-credential"
319322
},
320323
"devices": [],
321-
"endpoint": "grpc://example.com:443"
324+
"endpoint": "grpc://example.com:443",
325+
"exporterStatus": "Available",
326+
"statusMessage": null
322327
}
323328
}
324329
"""
@@ -334,6 +339,8 @@ def test_get_clients(_load_kube_config_mock, list_clients_mock: AsyncMock):
334339
name: test-credential
335340
devices: []
336341
endpoint: grpc://example.com:443
342+
exporterStatus: Available
343+
statusMessage: null
337344
338345
"""
339346

@@ -348,6 +355,7 @@ def test_get_exporter(_load_kube_config_mock, get_exporter_mock: AsyncMock):
348355
result = runner.invoke(get, ["exporter", "test"])
349356
assert result.exit_code == 0
350357
assert "test" in result.output
358+
assert "Available" in result.output
351359
assert "grpc://example.com:443" in result.output
352360
get_exporter_mock.reset_mock()
353361

@@ -396,6 +404,7 @@ def test_get_exporter(_load_kube_config_mock, get_exporter_mock: AsyncMock):
396404
V1Alpha1ExporterDevice(labels={"hardware": "rpi4"}, uuid="82a8ac0d-d7ff-4009-8948-18a3c5c607b1"),
397405
V1Alpha1ExporterDevice(labels={"hardware": "rpi4"}, uuid="f7cd30ac-64a3-42c6-ba31-b25f033b97c1"),
398406
],
407+
exporter_status="Available",
399408
),
400409
)
401410

@@ -425,7 +434,9 @@ def test_get_exporter(_load_kube_config_mock, get_exporter_mock: AsyncMock):
425434
"uuid": "f7cd30ac-64a3-42c6-ba31-b25f033b97c1"
426435
}
427436
],
428-
"endpoint": "grpc://example.com:443"
437+
"endpoint": "grpc://example.com:443",
438+
"exporterStatus": "Available",
439+
"statusMessage": null
429440
}
430441
}
431442
"""
@@ -447,6 +458,8 @@ def test_get_exporter(_load_kube_config_mock, get_exporter_mock: AsyncMock):
447458
hardware: rpi4
448459
uuid: f7cd30ac-64a3-42c6-ba31-b25f033b97c1
449460
endpoint: grpc://example.com:443
461+
exporterStatus: Available
462+
statusMessage: null
450463
451464
"""
452465

@@ -460,6 +473,7 @@ def test_get_exporter_devices(_load_kube_config_mock, get_exporter_mock: AsyncMo
460473
result = runner.invoke(get, ["exporter", "test", "--devices"])
461474
assert result.exit_code == 0
462475
assert "test" in result.output
476+
assert "Available" in result.output
463477
assert "grpc://example.com:443" in result.output
464478
assert "hardware:rpi4" in result.output
465479
assert "82a8ac0d-d7ff-4009-8948-18a3c5c607b1" in result.output
@@ -510,6 +524,7 @@ def test_get_exporter_devices(_load_kube_config_mock, get_exporter_mock: AsyncMo
510524
endpoint="grpc://example.com:443",
511525
credential=V1ObjectReference(name="test-credential"),
512526
devices=[],
527+
exporter_status="Available",
513528
),
514529
),
515530
V1Alpha1Exporter(
@@ -520,6 +535,7 @@ def test_get_exporter_devices(_load_kube_config_mock, get_exporter_mock: AsyncMo
520535
endpoint="grpc://example.com:443",
521536
credential=V1ObjectReference(name="another-credential"),
522537
devices=[],
538+
exporter_status="Available",
523539
),
524540
),
525541
]
@@ -541,7 +557,9 @@ def test_get_exporter_devices(_load_kube_config_mock, get_exporter_mock: AsyncMo
541557
"name": "test-credential"
542558
},
543559
"devices": [],
544-
"endpoint": "grpc://example.com:443"
560+
"endpoint": "grpc://example.com:443",
561+
"exporterStatus": "Available",
562+
"statusMessage": null
545563
}
546564
},
547565
{
@@ -557,7 +575,9 @@ def test_get_exporter_devices(_load_kube_config_mock, get_exporter_mock: AsyncMo
557575
"name": "another-credential"
558576
},
559577
"devices": [],
560-
"endpoint": "grpc://example.com:443"
578+
"endpoint": "grpc://example.com:443",
579+
"exporterStatus": "Available",
580+
"statusMessage": null
561581
}
562582
}
563583
],
@@ -578,6 +598,8 @@ def test_get_exporter_devices(_load_kube_config_mock, get_exporter_mock: AsyncMo
578598
name: test-credential
579599
devices: []
580600
endpoint: grpc://example.com:443
601+
exporterStatus: Available
602+
statusMessage: null
581603
- apiVersion: jumpstarter.dev/v1alpha1
582604
kind: Exporter
583605
metadata:
@@ -589,6 +611,8 @@ def test_get_exporter_devices(_load_kube_config_mock, get_exporter_mock: AsyncMo
589611
name: another-credential
590612
devices: []
591613
endpoint: grpc://example.com:443
614+
exporterStatus: Available
615+
statusMessage: null
592616
kind: ExporterList
593617
594618
"""
@@ -609,6 +633,7 @@ def test_get_exporters(_load_kube_config_mock, list_exporters_mock: AsyncMock):
609633
assert result.exit_code == 0
610634
assert "test" in result.output
611635
assert "another" in result.output
636+
assert "Available" in result.output
612637
list_exporters_mock.reset_mock()
613638

614639
# List exporters JSON output
@@ -655,6 +680,7 @@ def test_get_exporters(_load_kube_config_mock, list_exporters_mock: AsyncMock):
655680
devices=[
656681
V1Alpha1ExporterDevice(labels={"hardware": "rpi4"}, uuid="82a8ac0d-d7ff-4009-8948-18a3c5c607b1")
657682
],
683+
exporter_status="Available",
658684
),
659685
),
660686
V1Alpha1Exporter(
@@ -667,6 +693,7 @@ def test_get_exporters(_load_kube_config_mock, list_exporters_mock: AsyncMock):
667693
devices=[
668694
V1Alpha1ExporterDevice(labels={"hardware": "rpi4"}, uuid="f7cd30ac-64a3-42c6-ba31-b25f033b97c1"),
669695
],
696+
exporter_status="Available",
670697
),
671698
),
672699
]
@@ -695,7 +722,9 @@ def test_get_exporters(_load_kube_config_mock, list_exporters_mock: AsyncMock):
695722
"uuid": "82a8ac0d-d7ff-4009-8948-18a3c5c607b1"
696723
}
697724
],
698-
"endpoint": "grpc://example.com:443"
725+
"endpoint": "grpc://example.com:443",
726+
"exporterStatus": "Available",
727+
"statusMessage": null
699728
}
700729
},
701730
{
@@ -718,7 +747,9 @@ def test_get_exporters(_load_kube_config_mock, list_exporters_mock: AsyncMock):
718747
"uuid": "f7cd30ac-64a3-42c6-ba31-b25f033b97c1"
719748
}
720749
],
721-
"endpoint": "grpc://example.com:443"
750+
"endpoint": "grpc://example.com:443",
751+
"exporterStatus": "Available",
752+
"statusMessage": null
722753
}
723754
}
724755
],
@@ -742,6 +773,8 @@ def test_get_exporters(_load_kube_config_mock, list_exporters_mock: AsyncMock):
742773
hardware: rpi4
743774
uuid: 82a8ac0d-d7ff-4009-8948-18a3c5c607b1
744775
endpoint: grpc://example.com:443
776+
exporterStatus: Available
777+
statusMessage: null
745778
- apiVersion: jumpstarter.dev/v1alpha1
746779
kind: Exporter
747780
metadata:
@@ -756,6 +789,8 @@ def test_get_exporters(_load_kube_config_mock, list_exporters_mock: AsyncMock):
756789
hardware: rpi4
757790
uuid: f7cd30ac-64a3-42c6-ba31-b25f033b97c1
758791
endpoint: grpc://example.com:443
792+
exporterStatus: Available
793+
statusMessage: null
759794
kind: ExporterList
760795
761796
"""
@@ -774,6 +809,7 @@ def test_get_exporters_devices(_load_kube_config_mock, list_exporters_mock: Asyn
774809
assert result.exit_code == 0
775810
assert "test" in result.output
776811
assert "another" in result.output
812+
assert "Available" in result.output
777813
assert "hardware:rpi4" in result.output
778814
assert "82a8ac0d-d7ff-4009-8948-18a3c5c607b1" in result.output
779815
assert "f7cd30ac-64a3-42c6-ba31-b25f033b97c1" in result.output

packages/jumpstarter-kubernetes/jumpstarter_kubernetes/exporters.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class V1Alpha1ExporterStatus(JsonBaseModel):
2626
credential: SerializeV1ObjectReference
2727
devices: list[V1Alpha1ExporterDevice]
2828
endpoint: str
29+
exporter_status: str | None = Field(alias="exporterStatus", default=None)
30+
status_message: str | None = Field(alias="statusMessage", default=None)
2931

3032

3133
class V1Alpha1Exporter(JsonBaseModel):
@@ -55,24 +57,29 @@ def from_dict(dict: dict):
5557
devices=[V1Alpha1ExporterDevice(labels=d["labels"], uuid=d["uuid"]) for d in dict["status"]["devices"]]
5658
if "devices" in dict["status"]
5759
else [],
60+
exporter_status=dict["status"].get("exporterStatus"),
61+
status_message=dict["status"].get("statusMessage"),
5862
),
5963
)
6064

6165
@classmethod
6266
def rich_add_columns(cls, table, devices: bool = False):
6367
if devices:
6468
table.add_column("NAME", no_wrap=True)
69+
table.add_column("STATUS")
6570
table.add_column("ENDPOINT")
6671
table.add_column("AGE")
6772
table.add_column("LABELS")
6873
table.add_column("UUID")
6974
else:
7075
table.add_column("NAME", no_wrap=True)
76+
table.add_column("STATUS")
7177
table.add_column("ENDPOINT")
7278
table.add_column("DEVICES")
7379
table.add_column("AGE")
7480

7581
def rich_add_rows(self, table, devices: bool = False):
82+
status = self.status.exporter_status if self.status else "Unknown"
7683
if devices:
7784
if self.status is not None:
7885
for d in self.status.devices:
@@ -82,6 +89,7 @@ def rich_add_rows(self, table, devices: bool = False):
8289
labels.append(f"{label}:{str(d.labels[label])}")
8390
table.add_row(
8491
self.metadata.name,
92+
status or "Unknown",
8593
self.status.endpoint,
8694
time_since(self.metadata.creation_timestamp),
8795
",".join(labels),
@@ -91,6 +99,7 @@ def rich_add_rows(self, table, devices: bool = False):
9199
else:
92100
table.add_row(
93101
self.metadata.name,
102+
status or "Unknown",
94103
self.status.endpoint,
95104
str(len(self.status.devices) if self.status and self.status.devices else 0),
96105
time_since(self.metadata.creation_timestamp),

0 commit comments

Comments
 (0)