Qualify tenant-scoped bootstrap rotation and fresh Windows scripting

This commit is contained in:
2026-11-17 16:19:08 +01:00
parent 81fcd9c8f8
commit fbd24b6d75
26 changed files with 877 additions and 118 deletions
+16 -3
View File
@@ -20,6 +20,7 @@ def on_server(options):
from pathlib import Path
import shutil
import subprocess
import uuid
import tempfile
os.umask(0o077)
@@ -49,7 +50,7 @@ def on_server(options):
raise ValueError('sequence already contains different build: ' + name)
inputs = ['--artifacts', str(build), '--build-receipt', str(build / options['receipt'])]
subprocess.run(['python3', '-I', str(tool), 'prepare', *inputs, '--state', str(state), '--gateway', options['gateway'],
'--service-uid','10001','--sequence',str(options['sequence']),'--version',options['version']],check=True)
'--service-uid','10001','--minimum-updater-version',str(options['minimum']),'--sequence',str(options['sequence']),'--version',options['version']],check=True)
if options['label'].startswith('windows'):
import re
import uuid
@@ -91,10 +92,20 @@ def on_server(options):
with tempfile.NamedTemporaryFile(mode='w', dir=state) as auth:
json.dump({'username':env['RMM_DEV_USERNAME'],'password':env['RMM_DEV_PASSWORD']},auth)
auth.flush()
label=options['label']
tenant=str(uuid.UUID(options['tenant']))
pin=(state/'config'/(label+'-bootstrap.json')).with_suffix('.'+tenant+'.json')
if options['rotate']:
selection=['--rotate-bootstrap-from',options['rotate'],'--bootstrap-state',str(state)]
elif pin.is_file():
sha=json.loads(pin.read_bytes())['current']['sha256']
selection=['--bootstrap-worker',str(state/'objects'/tenant/sha)]
else:
selection=['--bootstrap-worker',str(state/'bootstrap-workers'/label)]
subprocess.run(['python3','-I',str(tool),'publish',*inputs,'--tenant',options['tenant'],
'--envelope',str(state/'prepared'/options['label']/str(options['sequence'])/'envelope.json'),
'--origin','https://localhost:18443','--ca','/opt/rust-discovery/devstate/api-pki/ca.pem',
'--dev-login-file',auth.name,'--bootstrap-worker',str(state/'bootstrap-workers'/options['label'])],check=True)
'--dev-login-file',auth.name,*selection],check=True)
def main():
import inspect
@@ -103,6 +114,8 @@ def main():
parser.add_argument('--build-receipt',type=Path,required=True)
parser.add_argument('--sequence',type=int,required=True)
parser.add_argument('--version',required=True)
parser.add_argument('--minimum-updater-version',type=int,default=1)
parser.add_argument('--rotate-bootstrap-from',help='Rotate only this tenant from the given previous worker SHA-256')
parser.add_argument('--gateway',default='https://discovery.ease-technologies.de')
parser.add_argument('--tenant',default='11111111-1111-4111-8111-111111111111')
parser.add_argument('--prepare-only',action='store_true')
@@ -114,7 +127,7 @@ def main():
raise ValueError('build receipt and binary names must differ')
params={'files':{f.name:hashlib.sha256(f.read_bytes()).hexdigest() for f in files},'tool':hashlib.sha256(tool.read_bytes()).hexdigest(),
'receipt':args.build_receipt.name,'sequence':args.sequence,'version':args.version,'tenant':args.tenant,
'gateway':args.gateway,'prepare_only':args.prepare_only,'label':{agent_release.LINUX:'linux',
'minimum':args.minimum_updater_version,'rotate':args.rotate_bootstrap_from,'gateway':args.gateway,'prepare_only':args.prepare_only,'label':{agent_release.LINUX:'linux',
agent_release.WINDOWS:'windows',agent_release.WINDOWS_GNU:'windows-gnu'}[platform]}
subprocess.run([sys.executable,str(ROOT/'tools/dev_stage.py'),'server',*map(str,files),str(tool)],check=True)
command=inspect.getsource(on_server)+'\non_server('+repr(params)+')\n'