-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: script to easily display BMC password
Example run: ``` $ devbox run bmc-kube-password 10.4.13.1 lREDACTEDREDACTEDRED $ ```
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
python/understack-workflows/understack_workflows/main/bmc_display_password.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import base64 | ||
import subprocess | ||
import sys | ||
|
||
from understack_workflows import bmc_password_standard | ||
|
||
|
||
def main(): | ||
if len(sys.argv) != 2: | ||
print("Usage: bmc-kube-password <ip_addr>", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
ip_addr = sys.argv[1] | ||
master_key = ( | ||
subprocess.check_output( | ||
[ | ||
"kubectl", | ||
"get", | ||
"secret", | ||
"-n", | ||
"argo-events", | ||
"bmc-master", | ||
"-o", | ||
"jsonpath={.data.key}", | ||
] | ||
) | ||
.decode("utf-8") | ||
.strip() | ||
) | ||
master_key = base64.b64decode(master_key).decode("utf-8") | ||
if not master_key: | ||
print("Unable to obtain master secret", file=sys.stderr) | ||
sys.exit(2) | ||
|
||
print( | ||
bmc_password_standard.standard_password(ip_addr=ip_addr, master_key=master_key) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |