Skip to content

Commit cbaf801

Browse files
committed
feat(k8sworker): combine commands
Signed-off-by: Chris Snow <[email protected]>
1 parent af9f917 commit cbaf801

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ hpecp lock delete-all
7575

7676
Add K8s worker host:
7777
```sh
78-
hpecp k8sworker create-with-ssh-key --ip 10.1.0.10 --ssh-key-file controller_private.key
79-
hpecp k8sworker wait-for-status --id /api/v2/worker/1 --status [storage_pending] --timeout-secs 600
80-
hpecp k8sworker set-storage --id /api/v2/worker/1 --persistent-disks=/dev/nvme1n1 --ephemeral-disks=/dev/nvme2n1
81-
hpecp k8sworker wait-for-status --id /api/v2/worker/1 --status [ready] --timeout-secs 600
78+
hpecp k8sworker create-with-ssh-key \
79+
--ip 10.1.0.10 \
80+
--ssh-key-file controller_private.key \
81+
--persistent-disks /dev/nvme1n1 \
82+
--ephemeral-disks /dev/nvme2n1 \
83+
--wait-for-operation-secs 600
8284
```
8385

8486
K8s versions:

bin/cli.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,14 @@ def __init__(self):
614614

615615
@intercept_exception
616616
def create_with_ssh_key(
617-
self, ip=None, ssh_key=None, ssh_key_file=None, tags=[],
617+
self,
618+
ip=None,
619+
ssh_key=None,
620+
ssh_key_file=None,
621+
tags=[],
622+
ephemeral_disks=None,
623+
persistent_disks=None,
624+
wait_for_operation_secs=0,
618625
):
619626
"""Create a K8s Worker using SSH key authentication.
620627
@@ -630,6 +637,15 @@ def create_with_ssh_key(
630637
The SSH key file path, by default None
631638
tags : list, optional
632639
Tags to use, e.g. "{ "tag1": "foo", "tag2": "bar"}", by default []
640+
ephemeral_disks : str
641+
Comma separated string containing ephemeral disks.
642+
e.g: "/dev/nvme2n1,/dev/nvme2n2"
643+
persistent_disks : str, optional
644+
Comma separated string containing persistent disks, by default
645+
None.
646+
e.g: "/dev/nvme1n1,/dev/nvme1n2"
647+
wait_for_operation_secs: int
648+
wait for operations to complete. 0 = don't wait
633649
"""
634650
if ssh_key is None and ssh_key_file is None:
635651
print(
@@ -652,6 +668,28 @@ def create_with_ssh_key(
652668
worker_id = get_client().k8s_worker.create_with_ssh_key(
653669
ip=ip, ssh_key_data=ssh_key, tags=tags,
654670
)
671+
672+
if wait_for_operation_secs > 0:
673+
self.wait_for_status(
674+
id=worker_id,
675+
status=["storage_pending"],
676+
timeout_secs=wait_for_operation_secs,
677+
)
678+
679+
if ephemeral_disks is not None or persistent_disks is not None:
680+
self.set_storage(
681+
id=worker_id,
682+
ephemeral_disks=ephemeral_disks,
683+
persistent_disks=persistent_disks,
684+
)
685+
686+
if wait_for_operation_secs > 0:
687+
self.wait_for_status(
688+
id=worker_id,
689+
status=["ready"],
690+
timeout_secs=wait_for_operation_secs,
691+
)
692+
655693
print(worker_id)
656694

657695
# TODO: verify with engineering if setup_log is a valid parameter

0 commit comments

Comments
 (0)