sync: auto-sync from GURU-5070 at 2026-06-13 20:21:10
Author: Mike Swanson Machine: GURU-5070 Timestamp: 2026-06-13 20:21:10
This commit is contained in:
18
.tmp-xen-token.py
Normal file
18
.tmp-xen-token.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os, paramiko
|
||||
host="192.168.0.104"; user="root"; pw=os.environ["XEN_PW"]
|
||||
c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username=user, password=pw, timeout=20,
|
||||
disabled_algorithms={'pubkeys': ['rsa-sha2-256','rsa-sha2-512']},
|
||||
look_for_keys=False, allow_agent=False)
|
||||
def run(cmd):
|
||||
i,o,e=c.exec_command(cmd,timeout=60); return (o.read().decode(errors="replace")+e.read().decode(errors="replace")).strip()
|
||||
# Generate a temporary XenAPI session ref for the HTTP export (avoids putting root pw in the RMM command log)
|
||||
pyc = (
|
||||
"import XenAPI;"
|
||||
"s=XenAPI.Session('https://localhost');"
|
||||
"s.login_with_password('root', __import__('os').environ['XPW'], '1.0', 'g-migration');"
|
||||
"print(s._session)"
|
||||
)
|
||||
out=run(f"XPW='{pw}' python -c \"{pyc}\"")
|
||||
print("SESSION_REF:", out)
|
||||
c.close()
|
||||
Reference in New Issue
Block a user